Fabrice-TIERCELIN commited on
Commit
0c79af5
·
verified ·
1 Parent(s): 292f168

This PR fixes the space

Browse files

This PR correctly downloads the model and adds more GPU allocation. It still can process only small videos.

Click on _Merge_ to add this feature.

Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -2,16 +2,19 @@ import spaces
2
  import os
3
  import gradio as gr
4
  from video_super_resolution.scripts.inference_sr import STAR_sr
 
 
 
5
 
6
  # Example video and prompt pairs
7
  examples = [
8
- ["examples/023_klingai_reedit.mp4", "The video shows a panda strumming a guitar on a rock by a tranquil lake at sunset. With its black-and-white fur, the panda sits against a backdrop of mountains and a vibrant sky painted in orange and pink hues. The serene scene highlights relaxation and whimsy, with the panda, guitar, and lake harmoniously positioned. The natural landscape's depth and perspective enhance the focus on the panda's peaceful interaction with the guitar.", 4, 24, 250],
9
- ["examples/017_klingai_reedit.mp4", "The video depicts a majestic lion with eagle-like wings standing on a grassy hill against rolling green hills and a clear sky. The lion’s golden mane contrasts with the warm hues of the scene, and its intense gaze draws focus. The detailed, fully spread wings add a fantastical element. A 'PremiumBeat' watermark appears in the lower right, hinting at the image's source. The style blends realism with fantasy, showcasing the lion's mythical nature.", 4, 24, 250],
10
- ["examples/016_video.mp4", "The video is a black-and-white silent film featuring two men in wheelchairs on a pier. The foreground man, in a suit and hat, holds a sign reading 'HELP CRIPPLE.' The background shows a building and a boat, with early 20th-century clothing and image quality suggesting a narrative of disability and assistance.", 4, 24, 300],
11
  ]
12
 
13
  # Define a GPU-decorated function for enhancement
14
- @spaces.GPU()
15
  def enhance_with_gpu(input_video, input_text, upscale, max_chunk_len, chunk_size):
16
  """在每次调用时创建新的 STAR_sr 实例,确保参数正确传递"""
17
  star = STAR_sr(
@@ -49,7 +52,7 @@ def star_demo(result_dir="./tmp/"):
49
 
50
  gr.Examples(
51
  examples=examples,
52
- inputs=[input_video, input_text],
53
  outputs=[output_video],
54
  fn=enhance_with_gpu, # Use the GPU-decorated function
55
  cache_examples=False,
 
2
  import os
3
  import gradio as gr
4
  from video_super_resolution.scripts.inference_sr import STAR_sr
5
+ from huggingface_hub import hf_hub_download
6
+
7
+ hf_hub_download(repo_id="SherryX/STAR", filename="I2VGen-XL-based/heavy_deg.pt", local_dir="pretrained_weight")
8
 
9
  # Example video and prompt pairs
10
  examples = [
11
+ ["Examples/023_klingai_reedit.mp4", "The video shows a panda strumming a guitar on a rock by a tranquil lake at sunset. With its black-and-white fur, the panda sits against a backdrop of mountains and a vibrant sky painted in orange and pink hues. The serene scene highlights relaxation and whimsy, with the panda, guitar, and lake harmoniously positioned. The natural landscape's depth and perspective enhance the focus on the panda's peaceful interaction with the guitar.", 2, 24, 250],
12
+ ["Examples/017_klingai_reedit.mp4", "The video depicts a majestic lion with eagle-like wings standing on a grassy hill against rolling green hills and a clear sky. The lion’s golden mane contrasts with the warm hues of the scene, and its intense gaze draws focus. The detailed, fully spread wings add a fantastical element. A 'PremiumBeat' watermark appears in the lower right, hinting at the image's source. The style blends realism with fantasy, showcasing the lion's mythical nature.", 4, 24, 250],
13
+ ["Examples/016_video.mp4", "The video is a black-and-white silent film featuring two men in wheelchairs on a pier. The foreground man, in a suit and hat, holds a sign reading 'HELP CRIPPLE.' The background shows a building and a boat, with early 20th-century clothing and image quality suggesting a narrative of disability and assistance.", 4, 24, 300],
14
  ]
15
 
16
  # Define a GPU-decorated function for enhancement
17
+ @spaces.GPU(duration=180)
18
  def enhance_with_gpu(input_video, input_text, upscale, max_chunk_len, chunk_size):
19
  """在每次调用时创建新的 STAR_sr 实例,确保参数正确传递"""
20
  star = STAR_sr(
 
52
 
53
  gr.Examples(
54
  examples=examples,
55
+ inputs=[input_video, input_text, upscale, max_chunk_len, chunk_size],
56
  outputs=[output_video],
57
  fn=enhance_with_gpu, # Use the GPU-decorated function
58
  cache_examples=False,