hysts HF staff commited on
Commit
965498b
1 Parent(s): adfea12
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -3,12 +3,14 @@
3
  from __future__ import annotations
4
 
5
  import os
 
6
  import random
7
  import shlex
8
  import subprocess
9
 
10
  import gradio as gr
11
  import torch
 
12
 
13
  if os.getenv('SYSTEM') == 'spaces':
14
  subprocess.run(shlex.split('pip uninstall -y modelscope'))
@@ -20,11 +22,18 @@ if os.getenv('SYSTEM') == 'spaces':
20
  from modelscope.outputs import OutputKeys
21
  from modelscope.pipelines import pipeline
22
 
 
 
 
 
 
 
 
23
  DESCRIPTION = '# [ModelScope Text to Video Synthesis](https://modelscope.cn/models/damo/text-to-video-synthesis/summary)'
24
  if (SPACE_ID := os.getenv('SPACE_ID')) is not None:
25
  DESCRIPTION += f'\n<p>For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. <a href="https://huggingface.co/spaces/{SPACE_ID}?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>'
26
 
27
- pipe = pipeline('text-to-video-synthesis', 'damo/text-to-video-synthesis')
28
 
29
 
30
  def generate(prompt: str, seed: int) -> str:
 
3
  from __future__ import annotations
4
 
5
  import os
6
+ import pathlib
7
  import random
8
  import shlex
9
  import subprocess
10
 
11
  import gradio as gr
12
  import torch
13
+ from huggingface_hub import snapshot_download
14
 
15
  if os.getenv('SYSTEM') == 'spaces':
16
  subprocess.run(shlex.split('pip uninstall -y modelscope'))
 
22
  from modelscope.outputs import OutputKeys
23
  from modelscope.pipelines import pipeline
24
 
25
+ model_dir = pathlib.Path('weights')
26
+ if not model_dir.exists():
27
+ model_dir.mkdir()
28
+ snapshot_download('hysts/modelscope-damo-text-to-video-synthesis',
29
+ repo_type='model',
30
+ local_dir=model_dir)
31
+
32
  DESCRIPTION = '# [ModelScope Text to Video Synthesis](https://modelscope.cn/models/damo/text-to-video-synthesis/summary)'
33
  if (SPACE_ID := os.getenv('SPACE_ID')) is not None:
34
  DESCRIPTION += f'\n<p>For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. <a href="https://huggingface.co/spaces/{SPACE_ID}?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>'
35
 
36
+ pipe = pipeline('text-to-video-synthesis', model_dir.as_posix())
37
 
38
 
39
  def generate(prompt: str, seed: int) -> str: