Add dynamic num2words cache override to build_stage1_model

This commit is contained in:
Sarvesh 2026-06-09 16:15:31 +05:30
parent 4e42b8a1d8
commit 17f31415d4

View file

@ -183,7 +183,16 @@
" kl_weight: float = 0.0\n",
" generation_max_new_tokens: int = 128\n",
"\n",
"print(\"Video2LoRA imported architectures and utility functions successfully.\")"
"print(\"Video2LoRA imported architectures and utility functions successfully.\")",
"\n",
"# Force-refresh Hugging Face transformers dependency cache for num2words if installed mid-session\n",
"import importlib.util\n",
"if importlib.util.find_spec(\"num2words\") is not None:\n",
" try:\n",
" import transformers.utils.import_utils\n",
" transformers.utils.import_utils._num2words_available = True\n",
" except Exception:\n",
" pass\n"
]
},
{
@ -432,6 +441,15 @@
"\n",
"# 1. Initialize SmolVLM2 base model, processor, and tokenizer\n",
"print(\"Loading SmolVLM2 model (2.2B-Instruct)...\")\n",
"# Force-refresh Hugging Face transformers dependency cache for num2words if installed mid-session\n",
"import importlib.util\n",
"if importlib.util.find_spec(\"num2words\") is not None:\n",
" try:\n",
" import transformers.utils.import_utils\n",
" transformers.utils.import_utils._num2words_available = True\n",
" except Exception:\n",
" pass\n",
"\n",
"model, raw_model, processor, tokenizer = build_stage1_model(train_args, device=device)\n",
"\n",
"# 2. Load the hypernetwork weights\n",