Skip to content

Update export to video to support new tensor_to_vid function in video pipelines #6715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

DN6
Copy link
Collaborator

@DN6 DN6 commented Jan 26, 2024

What does this PR do?

Recently merged #6626 which uses a new tensor_to_vid function to output video frames. Frames in the np format are scaled to 0-1, which is causing an issue with export_to_video since it expects numpy arrays scaled between 0-255.

This PR:

  1. Adds a check to export_to_video to see if a numpy array has been passed in and scales it to 0-255 before writing to video.

Fixes # (issue)
#6681

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@DN6 DN6 requested a review from sayakpaul January 26, 2024 05:06
@@ -125,7 +125,10 @@ def export_to_video(
if output_video_path is None:
output_video_path = tempfile.NamedTemporaryFile(suffix=".mp4").name

if isinstance(video_frames[0], PIL.Image.Image):
if isinstance(video_frames[0], np.ndarray):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use the numpy_to_pil() method from processor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would need to pass in the processor instance into export_to_video though?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes. I am okay as is then.

@DN6 DN6 merged commit 8e94663 into main Jan 30, 2024
dg845 pushed a commit to dg845/diffusers that referenced this pull request Feb 2, 2024
@yiyixuxu yiyixuxu mentioned this pull request Feb 18, 2024
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants