lxylxy123321 1 неделя назад
Родитель
Сommit
4ebad59c81
2 измененных файлов с 3 добавлено и 9 удалено
  1. 1 7
      backend/app/services/model_service.py
  2. 2 2
      backend/requirements.txt

+ 1 - 7
backend/app/services/model_service.py

@@ -43,15 +43,9 @@ async def download_model(model_id: str, use_modelscope: bool = False) -> dict[st
     """从 HF 或 ModelScope 下载模型到本地缓存。"""
     try:
         if use_modelscope:
-            import asyncio
             from modelscope import snapshot_download as ms_download
 
-            download_dir = str(settings.models_dir / model_id.replace("/", "_"))
-
-            # 在线程池中同步执行,避免与 asyncio 事件循环冲突
-            local_path = await asyncio.to_thread(
-                ms_download, model_id, cache_dir=download_dir
-            )
+            local_path = ms_download(model_id, cache_dir=str(settings.models_dir))
         else:
             from huggingface_hub import snapshot_download
 

+ 2 - 2
backend/requirements.txt

@@ -18,7 +18,7 @@ pillow>=10.4.0
 pandas>=2.2.0
 pyarrow>=17.0.0
 addict>=2.4.0
-modelscope
+modelscope>=1.15.0,<1.18.0
 datasets
 huggingface_hub
-aiohttp>=3.9.0
+aiohttp>=3.9.0,<3.11.0