Stability-AI / generative-models

Generative Models by Stability AI
MIT License
23.17k stars 2.56k forks source link

Fix SVD image input #321

Open TianxingWu opened 3 months ago

TianxingWu commented 3 months ago

Found a bug of SVD after the SV3D update:

If the input is a RGB image for SVD, The variable 'input_image' will not be assigned and raises:

UnboundLocalError: local variable 'input_image' referenced before assignment

Using copy() rather than direct assignment, or the following error will raise since the file is closed by the 'with' context manager:

TypeError: int() argument must be a string, a bytes-like object or a real number, not 'PngImageFile'
TianxingWu commented 3 months ago

Another suggestion is to use torchivision.io.write_video() rather than imageio.mimwrite() to save the video. The current output cannot take fps into account and is not compatible with many video players. For example:

from torchvision.io import write_video
...
write_video(video_path, vid, fps=fps_id + 1)