alvinichi commited on
Commit
3cb17a3
·
1 Parent(s): e9c078a
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -1,22 +1,30 @@
1
- import gradio as gr
2
  import os
3
- import numpy as np
4
- import torch
5
- import imageio
6
  import subprocess
7
- from skimage.transform import resize
8
- from skimage import img_as_ubyte
 
 
 
9
 
10
  # Clone repo nếu chưa có
11
- if not os.path.exists('first-order-model'):
12
  subprocess.call(['git', 'clone', 'https://github.com/AliaksandrSiarohin/first-order-model.git'])
13
  os.rename('first-order-model', 'first_order_model')
14
 
15
  # Thêm đường dẫn vào PYTHONPATH
16
- import sys
17
  sys.path.append('first_order_model')
18
 
19
- # Import các module cần thiết từ repo
 
 
 
 
 
 
 
 
20
  from first_order_model.demo import load_checkpoints
21
  from first_order_model.animate import normalize_kp
22
 
 
 
1
  import os
2
+ import sys
 
 
3
  import subprocess
4
+
5
+ # Đảm bảo cài đặt các thư viện cần thiết trước khi import
6
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "scikit-learn"])
7
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "scikit-image==0.19.3"])
8
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "face-alignment==1.3.5"])
9
 
10
  # Clone repo nếu chưa có
11
+ if not os.path.exists('first_order_model'):
12
  subprocess.call(['git', 'clone', 'https://github.com/AliaksandrSiarohin/first-order-model.git'])
13
  os.rename('first-order-model', 'first_order_model')
14
 
15
  # Thêm đường dẫn vào PYTHONPATH
16
+ sys.path.append('.')
17
  sys.path.append('first_order_model')
18
 
19
+ # Bây giờ import các module cần thiết
20
+ import gradio as gr
21
+ import numpy as np
22
+ import torch
23
+ import imageio
24
+ from skimage.transform import resize
25
+ from skimage import img_as_ubyte
26
+
27
+ # Import các module từ first_order_model
28
  from first_order_model.demo import load_checkpoints
29
  from first_order_model.animate import normalize_kp
30