chaopro commited on
Commit
a40c3d6
·
verified ·
1 Parent(s): 2ddbf04

Update config.py

Browse files
Files changed (1) hide show
  1. config.py +8 -31
config.py CHANGED
@@ -1,38 +1,15 @@
1
  import os
2
- import platform
3
- import stat
4
  import urllib.request
5
 
6
  BASE_DIR = os.path.dirname(os.path.abspath(__file__))
7
-
8
- def ensure_model(path, filename, url):
9
- os.makedirs(path, exist_ok=True)
10
- full_path = os.path.join(path, filename)
11
- if not os.path.exists(full_path):
12
- print(f"🔄 正在下载模型:{filename}")
13
- urllib.request.urlretrieve(url, full_path)
14
-
15
- # 模型路径定义
16
  LAMA_MODEL_PATH = os.path.join(BASE_DIR, 'models', 'big-lama')
17
- STTN_MODEL_PATH = os.path.join(BASE_DIR, 'models', 'sttn')
18
- VIDEO_INPAINT_MODEL_PATH = os.path.join(BASE_DIR, 'models', 'video')
19
- DET_MODEL_PATH = os.path.join(BASE_DIR, 'models', 'V4', 'ch_det')
20
-
21
- # 模型下载链接(请替换为你自己的 Hugging Face Hub 链接)
22
- ensure_model(LAMA_MODEL_PATH, 'big-lama.pt', 'https://huggingface.co/your-username/your-repo/resolve/main/big-lama.pt')
23
- ensure_model(STTN_MODEL_PATH, 'infer_model.pth', 'https://huggingface.co/your-username/your-repo/resolve/main/infer_model.pth')
24
- ensure_model(VIDEO_INPAINT_MODEL_PATH, 'ProPainter.pth', 'https://huggingface.co/your-username/your-repo/resolve/main/ProPainter.pth')
25
- ensure_model(DET_MODEL_PATH, 'inference.pdiparams', 'https://huggingface.co/your-username/your-repo/resolve/main/inference.pdiparams')
26
 
27
- # ffmpeg 路径处理
28
- sys_str = platform.system()
29
- ffmpeg_bin = {
30
- "Windows": os.path.join('win_x64', 'ffmpeg.exe'),
31
- "Linux": os.path.join('linux_x64', 'ffmpeg'),
32
- "Darwin": os.path.join('macos', 'ffmpeg')
33
- }.get(sys_str, os.path.join('linux_x64', 'ffmpeg'))
34
 
35
- FFMPEG_PATH = os.path.join(BASE_DIR, 'ffmpeg', ffmpeg_bin)
36
- ffmpeg_dir = os.path.dirname(FFMPEG_PATH)
37
- os.makedirs(ffmpeg_dir, exist_ok=True)
38
- os.chmod(FFMPEG_PATH, stat.S_IRWXU + stat.S_IRWXG + stat.S_IRWXO)
 
 
 
1
  import os
 
 
2
  import urllib.request
3
 
4
  BASE_DIR = os.path.dirname(os.path.abspath(__file__))
 
 
 
 
 
 
 
 
 
5
  LAMA_MODEL_PATH = os.path.join(BASE_DIR, 'models', 'big-lama')
6
+ MODEL_FILE = os.path.join(LAMA_MODEL_PATH, 'big-lama.pt')
 
 
 
 
 
 
 
 
7
 
8
+ os.makedirs(LAMA_MODEL_PATH, exist_ok=True)
 
 
 
 
 
 
9
 
10
+ if not os.path.exists(MODEL_FILE):
11
+ print("🔄 正在下载 big-lama 模型...")
12
+ urllib.request.urlretrieve(
13
+ "https://huggingface.co/prodev/vsr-models/resolve/main/big-lama.pt",
14
+ MODEL_FILE
15
+ )