Update config.py
Browse files
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 |
-
|
| 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 |
-
|
| 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 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
| 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 |
+
)
|