Files
video-subtitle-remover/backend/tools/model_config.py
Jason 7cf4e882cd 初步支持 macOS (Apple Silicon)
升级至PP-OCRv5
Tested with Python 3.13
感谢用户 "期望" 提供的macOS设备用于开发测试
2025-05-22 13:02:28 +08:00

22 lines
1.2 KiB
Python

import os
from backend.config import config, BASE_DIR
from backend.tools.common_tools import merge_big_file_if_not_exists
from backend.tools.constant import SubtitleDetectMode
class ModelConfig:
def __init__(self):
self.LAMA_MODEL_DIR = os.path.join(BASE_DIR, 'models', 'big-lama')
self.STTN_AUTO_MODEL_PATH = os.path.join(BASE_DIR, 'models', 'sttn-auto', 'infer_model.pth')
self.STTN_DET_MODEL_PATH = os.path.join(BASE_DIR, 'models', 'sttn-det', 'sttn.pth')
self.PROPAINTER_MODEL_DIR = os.path.join(BASE_DIR,'models', 'propainter')
if config.subtitleDetectMode.value == SubtitleDetectMode.Fast:
self.DET_MODEL_DIR = os.path.join(BASE_DIR,'models', 'V5', 'ch_det_fast')
elif config.subtitleDetectMode.value == SubtitleDetectMode.Accurate:
self.DET_MODEL_DIR = os.path.join(BASE_DIR, 'models', 'V5', 'ch_det')
else:
raise ValueError(f"Invalid subtitle detect mode: {config.subtitleDetectMode.value}")
merge_big_file_if_not_exists(self.LAMA_MODEL_DIR, 'bit-lama.pt')
merge_big_file_if_not_exists(self.PROPAINTER_MODEL_DIR, 'ProPainter.pth')
merge_big_file_if_not_exists(self.DET_MODEL_DIR, 'inference.onnx')