u0feff commited on
Commit
fb2b3c7
·
1 Parent(s): f5e5139

Use install bash script instead of python subprocesses

Browse files
Files changed (2) hide show
  1. app.py +1 -12
  2. install.sh +29 -1
app.py CHANGED
@@ -30,18 +30,7 @@ from moviepy.editor import *
30
  from transformers import WhisperModel
31
 
32
  if os.getenv('SYSTEM') == 'spaces':
33
- os.environ['HOME'] = '/home/user/app'
34
-
35
- subprocess.call('pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118'.split())
36
-
37
- subprocess.call('mim install mmengine'.split())
38
- subprocess.call('mim install mmcv==2.0.1'.split())
39
- subprocess.call('mim install mmdet==3.1.0'.split())
40
- subprocess.call('mim install mmpose==1.1.0'.split())
41
-
42
- subprocess.call('ls ~/.cache/huggingface/hub/'.split())
43
- subprocess.call('ls ~/.cache/huggingface/hub/TMElyralab'.split())
44
- subprocess.call('ls ~/.cache/huggingface/hub/TMElyralab/MuseTalk'.split())
45
 
46
  ProjectDir = os.path.abspath(os.path.dirname(__file__))
47
  CheckpointsDir = os.path.join(ProjectDir, "models")
 
30
  from transformers import WhisperModel
31
 
32
  if os.getenv('SYSTEM') == 'spaces':
33
+ subprocess.run(["bash", "install.sh"])
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  ProjectDir = os.path.abspath(os.path.dirname(__file__))
36
  CheckpointsDir = os.path.join(ProjectDir, "models")
install.sh CHANGED
@@ -1,3 +1,31 @@
1
  #!/bin/bash
2
 
3
- #./download_weights.sh
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  #!/bin/bash
2
 
3
+ # Since we use preloaded, cached versions of models, we must link them for further use
4
+ mkdir ~/app/models/musetalkV15
5
+ ln -s ~/.cache/huggingface/hub/models--TMElyralab--MuseTalk/snapshots/*/musetalkV15/* ~/app/models/musetalkV15/
6
+
7
+ mkdir ~/app/models/musetalk
8
+ ln -s ~/.cache/huggingface/hub/models--TMElyralab--MuseTalk/snapshots/*/musetalk/* ~/app/models/musetalk/
9
+
10
+ mkdir ~/app/models/dwpose
11
+ ln -s ~/.cache/huggingface/hub/models--yzd-v--DWPose/snapshots/*/* ~/app/models/dwpose/
12
+
13
+ mkdir ~/app/models/sd-vae
14
+ ln -s ~/.cache/huggingface/hub/models--stabilityai--sd-vae-ft-mse/snapshots/*/* ~/app/models/sd-vae/
15
+
16
+ mkdir ~/app/models/syncnet
17
+ ln -s ~/.cache/huggingface/hub/models--ByteDance--LatentSync/snapshots/*/* ~/app/models/syncnet/
18
+
19
+ mkdir ~/app/models/whisper
20
+ ln -s ~/.cache/huggingface/hub/models--openai--whisper-tiny/snapshots/*/* ~/app/models/whisper/
21
+
22
+ # Hugging face only allows to install torch atleast version 2.1.0, so we reinstalling it at runtime
23
+ pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
24
+
25
+ # Mim uses ~/.cache/mim by default for cache, but hugging face only allows to use /home/user/app, so we use little hack
26
+ export HOME=/home/user/app
27
+
28
+ mim install mmengine
29
+ mim install mmcv==2.0.1
30
+ mim install mmdet==3.1.0
31
+ mim install mmpose==1.1.0