Doubiiu / DynamiCrafter

[ECCV 2024] DynamiCrafter: Animating Open-domain Images with Video Diffusion Priors
Apache License 2.0
2.2k stars 172 forks source link

Generated video is hole black #2

Closed howardgriffin closed 7 months ago

howardgriffin commented 7 months ago

Hi,When I used run the gradio_app, I got the hole black video out. What's wrong?

Doubiiu commented 7 months ago

Hi, is there any error message printed in the standard output console?

howardgriffin commented 7 months ago

There was no error log. BTW, when I run the scripts/run.sh, everything was fine.

Doubiiu commented 7 months ago

Also can you run the demo using the command line? Not sure if there is any environment setup issue.

howardgriffin commented 7 months ago

Here is my console log when used gradio_app: Global seed set to 111 start: girl talking and blinking 2023-12-05 11:52:47 /usr/local/lib/python3.10/dist-packages/torchvision/transforms/functional.py:1603: UserWarning: The default value of the antialias parameter of all the resizing transforms (Resize(), RandomResizedCrop(), etc.) will change from None to True in v0.17, in order to be consistent across the PIL and Tensor backends. To suppress this warning, directly pass antialias=True (recommended, future default), antialias=None (current default, which means False for Tensors and True for PIL), or antialias=False (only works on Tensors - PIL will still use antialiasing). This also applies if you are using the inference transforms from the models weights: update the call to weights.transforms(antialias=True). warnings.warn( Saved in girl_talking_and_blinking. Time used: 46.71 seconds

Doubiiu commented 7 months ago

I just tested the local gradio demo without any problem. Not sure the error is related to this torchvision.transforms warning and it is so weird. May be need to print the input tensor and output tensor from the network. I guess there may be some issues during saving? Since the model won't predict all black results. Sorry for the inconvenience caused.

howardgriffin commented 7 months ago

Really strange. When I debugged the code by using gradio_app, I found that the output video tensor was a normal value, but when I saved the video with torchvision, it turned black. (However, the script method saves the video normally.) Finnally,I rewrote the way I saved the video to make sure the code was running properly.

Doubiiu commented 7 months ago

Glad to here that you have solved it. Would you mind sharing the modified code of saving videos (should be the function save_videos in the scripts/gradio/i2v_test.py)? It may help someone else in the future, thanks very much!

howardgriffin commented 7 months ago

I just replace this line with the following 3 lines: torchvision.io.write_video(savepath, grid, fps=fps, video_codec='h264', options={'crf': '10'}) import imageio
grid_list = [i.squeeze().numpy() for i in list(torch.split(grid,1))] imageio.mimsave(savepath, grid_list, fps=fps)

Doubiiu commented 7 months ago

Well-noted. Thanks a lot!