Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- app.py +15 -0
- requirements.txt +2 -3
app.py
CHANGED
|
@@ -20,6 +20,20 @@ except Exception:
|
|
| 20 |
|
| 21 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
def _env_bool(name: str, default: bool) -> bool:
|
| 24 |
val = os.environ.get(name)
|
| 25 |
if val is None:
|
|
@@ -51,6 +65,7 @@ def get_hf_token():
|
|
| 51 |
return token
|
| 52 |
|
| 53 |
HF_TOKEN = get_hf_token()
|
|
|
|
| 54 |
|
| 55 |
# 设备和计算类型配置
|
| 56 |
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 20 |
|
| 21 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 22 |
|
| 23 |
+
def _configure_torch_load_compat():
|
| 24 |
+
"""
|
| 25 |
+
PyTorch >=2.6 changed torch.load default `weights_only=True`, which can break
|
| 26 |
+
some third-party checkpoints (e.g. pyannote VAD models used by whisperx).
|
| 27 |
+
We only allowlist OmegaConf config objects required by those checkpoints.
|
| 28 |
+
"""
|
| 29 |
+
try:
|
| 30 |
+
import torch.serialization
|
| 31 |
+
from omegaconf import DictConfig, ListConfig
|
| 32 |
+
torch.serialization.add_safe_globals([DictConfig, ListConfig])
|
| 33 |
+
logging.info("已配置 torch.load 安全全局白名单 (omegaconf DictConfig/ListConfig)。")
|
| 34 |
+
except Exception as e:
|
| 35 |
+
logging.warning(f"torch.load 兼容性配置跳过: {e}")
|
| 36 |
+
|
| 37 |
def _env_bool(name: str, default: bool) -> bool:
|
| 38 |
val = os.environ.get(name)
|
| 39 |
if val is None:
|
|
|
|
| 65 |
return token
|
| 66 |
|
| 67 |
HF_TOKEN = get_hf_token()
|
| 68 |
+
_configure_torch_load_compat()
|
| 69 |
|
| 70 |
# 设备和计算类型配置
|
| 71 |
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
requirements.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 2 |
-
torch
|
| 3 |
-
torchaudio
|
| 4 |
|
| 5 |
ffmpeg-python>=0.2.0
|
| 6 |
flask>=3.1.2
|
|
@@ -8,4 +8,3 @@ openai>=2.7.2
|
|
| 8 |
pydub>=0.25.1
|
| 9 |
waitress>=3.0.2
|
| 10 |
whisperx>=3.7.4
|
| 11 |
-
|
|
|
|
| 1 |
--extra-index-url https://download.pytorch.org/whl/cpu
|
| 2 |
+
torch==2.5.1+cpu
|
| 3 |
+
torchaudio==2.5.1+cpu
|
| 4 |
|
| 5 |
ffmpeg-python>=0.2.0
|
| 6 |
flask>=3.1.2
|
|
|
|
| 8 |
pydub>=0.25.1
|
| 9 |
waitress>=3.0.2
|
| 10 |
whisperx>=3.7.4
|
|
|