Fix startup crash: ImportError (diffusers-export-api-drift)

#14
by kavyabhand - opened

Hi! This Space currently fails to start on Hugging Face with:

ImportError: cannot import name 'cached_download' from 'huggingface_hub' (/home/user/.pyenv/versions/3.10.15/lib/python3.10/site-packages/huggingface_hub/__init__.py)

Cause. The decisive runtime error is ValueError: too many values to unpack (expected 3) at h, w, c = video_frames[0].shape in diffusers.utils.export_utils.export_to_video. pipe(...).frames is batched as (batch, frames, H, W, C), so video_frames[0] is 4D; the first batch must be selected before export. The build also fails on the unused av<10.0.0 dependency, which tries to compile against missing libav headers.

Change. README.md, requirements.txt, video_diffusion/damo/damo_text2_video.py. requirements.txt is a lockfile resolved as of 2024-03-15 (Python 3.10), so the app runs on the library versions it was written for. python_version is pinned in the README to the interpreter we tested with. Nothing else is touched.

Tested. We rebuilt the Space with this patch the way Spaces builds it (README front-matter, requirements.txt, then the SDK), on an NVIDIA A10G (same GPU as a10g-small). The app started, and calling its /generate_video_2 endpoint returned:

1 output file(s) (mp4), non-empty

The diagnosis and patch were written by Beam (Reflection AI's open model) as part of Space Doctor, a Build with Beam challenge project that repairs broken Spaces and only proposes fixes that pass this check. We read the diff before opening this PR. Feel free to close it if you'd rather fix it another way.

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment