Improve ZeroGPU compatibility

#2
by hysts HF Staff - opened

Hi @haodongli , I noticed a couple of things that could be improved for ZeroGPU, so I'm opening this PR.

  • Eager model loading: Moved checkpoint download and load_model() to module level. On ZeroGPU, models loaded at startup are automatically managed (moved between CPU/GPU) by the backend, so there's no need to spend GPU quota time on initialization.
  • Frame limit: Added a cap of 300 frames to avoid loading arbitrarily long videos into memory, which could cause OOM or ZeroGPU quota timeout. The limit and duration=90 are tentative. Feel free to adjust if you have better numbers in mind.
  • read_video_limited(): A small wrapper around the same cv2 logic in read_video(), just with an early stop at MAX_FRAMES so it doesn't load the entire video upfront.
hysts changed pull request status to open

Hi @hysts ,

Thank you very much for your assistance! I've merged your modification.

Best,
Haodong

haodongli changed pull request status to merged

image

Hi @hysts ,

It works very well, thanks again!

Best,
Haodong

Sign up or log in to comment