Skip to content

Instantly share code, notes, and snippets.

@chimanaco
Last active April 20, 2020 06:04
Show Gist options
  • Save chimanaco/c6766f8db950c77ff78c5830e655b8f6 to your computer and use it in GitHub Desktop.
Save chimanaco/c6766f8db950c77ff78c5830e655b8f6 to your computer and use it in GitHub Desktop.
def main_pipeline(data, style_transform_path, width, height):
    output = data

    if torch.no_grad():
        # Get webcam input
        img = data

        # Free-up unneeded cuda memory
        torch.cuda.empty_cache()
        
        # Generate image
        content_tensor = utils.itot(img).to(device)
        generated_tensor = net(content_tensor)
        generated_image = utils.ttoi(generated_tensor.detach())
        if (PRESERVE_COLOR):
            generated_image = utils.transfer_color(img, generated_image)

        generated_image = generated_image/255

        # Show webcam
        cv2.imshow('Demo webcam', generated_image)
        output = generated_image

    return output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment