From 90f936cf4f815b230f7da7cf4576845cf565d271 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 29 Sep 2026 11:31:06 +0000 Subject: [PATCH] =?UTF-8?q?qwen-tts=20:=20chargement=20des=20mod=C3=A8les?= =?UTF-8?q?=20hors=20ligne?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit transformers interroge l'API Hugging Face au chargement quand le modèle est désigné par son nom de dépôt (détection des tokenizers Mistral), ce qui plantait le démarrage avec HF_HUB_OFFLINE=1 (conteneur en boucle sur Unraid). Le modèle est désormais chargé depuis son dossier local dans le cache. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Upu97wMmsRkBoj6iVM4rH6 --- qwen-tts/main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/qwen-tts/main.py b/qwen-tts/main.py index d86c6bd..dd33f05 100644 --- a/qwen-tts/main.py +++ b/qwen-tts/main.py @@ -65,11 +65,23 @@ def _load(name: str): from qwen_tts import Qwen3TTSModel started = time.monotonic() - _models[name] = Qwen3TTSModel.from_pretrained(name, device_map=DEVICE, dtype=DTYPE) + _models[name] = Qwen3TTSModel.from_pretrained(_local_path(name), device_map=DEVICE, dtype=DTYPE) log.info("Modèle %s chargé sur %s en %.1f s", name, _device_label(), time.monotonic() - started) return _models[name] +def _local_path(name: str) -> str: + """Dossier du modèle téléchargé au build. Avec un nom de dépôt, transformers + interroge l'API Hugging Face au chargement (détection des tokenizers Mistral), + ce qui échoue en mode hors ligne ; avec un chemin local, non.""" + from huggingface_hub import snapshot_download + + try: + return snapshot_download(name, local_files_only=True) + except Exception: # noqa: BLE001 — absent du cache : téléchargement normal + return name + + def _device_label() -> str: if DEVICE.startswith("cuda"): return f"{torch.cuda.get_device_name(torch.device(DEVICE))} ({DEVICE}, {DTYPE})"