jonathanagustin commited on
Commit
42b7a6d
1 Parent(s): 76e4b2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -1,11 +1,22 @@
1
  import gradio as gr
2
  from modelscope.pipelines import pipeline
3
  from modelscope.outputs import OutputKeys
 
 
4
 
5
- p = pipeline('text-to-video-synthesis', 'damo/text-to-video-synthesis')
 
 
 
 
 
 
 
6
 
7
- def generate_video(text_input):
8
- output_video_path = p({'text': text_input})[OutputKeys.OUTPUT_VIDEO]
 
 
9
  return output_video_path
10
 
11
  iface = gr.Interface(
 
1
  import gradio as gr
2
  from modelscope.pipelines import pipeline
3
  from modelscope.outputs import OutputKeys
4
+ from huggingface_hub import snapshot_download, HfApi
5
+ import pathlib
6
 
7
+ HUB_TOKEN = os.getenv("HUB_TOKEN")
8
+ api = HfApi()
9
+ api.set_access_token(HUB_TOKEN)
10
+ model_dir = pathlib.Path('weights')
11
+ snapshot_download('damo-vilab/modelscope-damo-text-to-video-synthesis',
12
+ repo_type='model',
13
+ local_dir=model_dir,
14
+ use_auth_token=True)
15
 
16
+ pipe = pipeline('text-to-video-synthesis', model_dir.as_posix())
17
+
18
+ def generate_video(prompt):
19
+ output_video_path = pipe({'text': prompt})[OutputKeys.OUTPUT_VIDEO]
20
  return output_video_path
21
 
22
  iface = gr.Interface(