Spaces:
Running on Zero

little612pea commited on
Commit
2f4a0d8
·
verified ·
1 Parent(s): 555db94

Connect the video upload demo to the private four-layer inference runtime

Browse files
Files changed (2) hide show
  1. app.py +2 -5
  2. requirements.txt +1 -1
app.py CHANGED
@@ -23,7 +23,7 @@ def read_clip(path):
23
  raise gr.Error("Choose a video first.")
24
  frames = []
25
  try:
26
- with av.open(path, options={"protocol_whitelist": "file"}) as video:
27
  stream = video.streams.video[0]
28
  if stream.width * stream.height > 4096 * 2160:
29
  raise gr.Error("Use a video at 4K resolution or smaller.")
@@ -95,10 +95,7 @@ def recover(video, progress=gr.Progress()):
95
  ids = np.clip((layer-lo) / max(hi-lo,1e-8)*255,0,255).astype(np.uint8)
96
  path = Path(tmp)/f"L{k}.mp4"
97
  write_video(lut[ids], path)
98
- # Gradio copies the result into its managed output cache on return.
99
- with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as saved:
100
- saved.write(path.read_bytes())
101
- outputs.append(saved.name)
102
  return tuple(outputs)
103
 
104
 
 
23
  raise gr.Error("Choose a video first.")
24
  frames = []
25
  try:
26
+ with av.open(path, options={"protocol_whitelist": "file", "format_whitelist": "mov,matroska,webm,avi"}) as video:
27
  stream = video.streams.video[0]
28
  if stream.width * stream.height > 4096 * 2160:
29
  raise gr.Error("Use a video at 4K resolution or smaller.")
 
95
  ids = np.clip((layer-lo) / max(hi-lo,1e-8)*255,0,255).astype(np.uint8)
96
  path = Path(tmp)/f"L{k}.mp4"
97
  write_video(lut[ids], path)
98
+ outputs.append(gr.processing_utils.save_file_to_cache(str(path), cache_dir=demo.GRADIO_CACHE))
 
 
 
99
  return tuple(outputs)
100
 
101
 
requirements.txt CHANGED
@@ -2,6 +2,6 @@ spaces
2
  torch==2.8.0
3
  diffusers==0.33.1
4
  einops
5
- av==14.4.0
6
  matplotlib
7
  huggingface_hub>=0.34,<1
 
2
  torch==2.8.0
3
  diffusers==0.33.1
4
  einops
5
+ av==16.0.1
6
  matplotlib
7
  huggingface_hub>=0.34,<1