mirror of
https://github.com/SakanaAI/doc-to-lora.git
synced 2026-07-23 17:01:04 +02:00
Inject num2words module directly into sys.modules to bypass Hugging Face cache
This commit is contained in:
parent
17f31415d4
commit
5a000a7c27
1 changed files with 18 additions and 3 deletions
21
demo.ipynb
21
demo.ipynb
|
|
@ -183,14 +183,21 @@
|
|||
" 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",
|
||||
"\n",
|
||||
"# Force-refresh Hugging Face transformers dependency cache for num2words if installed mid-session\n",
|
||||
"# Force-refresh Hugging Face dependency cache for num2words if installed mid-session\n",
|
||||
"import sys\n",
|
||||
"import importlib.util\n",
|
||||
"if importlib.util.find_spec(\"num2words\") is not None:\n",
|
||||
" try:\n",
|
||||
" import num2words\n",
|
||||
" import transformers.utils.import_utils\n",
|
||||
" transformers.utils.import_utils._num2words_available = True\n",
|
||||
" for mod_name in list(sys.modules.keys()):\n",
|
||||
" if \"processing_smolvlm\" in mod_name or \"smolvlm\" in mod_name:\n",
|
||||
" mod = sys.modules[mod_name]\n",
|
||||
" if hasattr(mod, \"num2words\") and getattr(mod, \"num2words\") is None:\n",
|
||||
" setattr(mod, \"num2words\", num2words)\n",
|
||||
" except Exception:\n",
|
||||
" pass\n"
|
||||
]
|
||||
|
|
@ -441,12 +448,20 @@
|
|||
"\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",
|
||||
"\n",
|
||||
"# Force-refresh Hugging Face dependency cache for num2words if installed mid-session\n",
|
||||
"import sys\n",
|
||||
"import importlib.util\n",
|
||||
"if importlib.util.find_spec(\"num2words\") is not None:\n",
|
||||
" try:\n",
|
||||
" import num2words\n",
|
||||
" import transformers.utils.import_utils\n",
|
||||
" transformers.utils.import_utils._num2words_available = True\n",
|
||||
" for mod_name in list(sys.modules.keys()):\n",
|
||||
" if \"processing_smolvlm\" in mod_name or \"smolvlm\" in mod_name:\n",
|
||||
" mod = sys.modules[mod_name]\n",
|
||||
" if hasattr(mod, \"num2words\") and getattr(mod, \"num2words\") is None:\n",
|
||||
" setattr(mod, \"num2words\", num2words)\n",
|
||||
" except Exception:\n",
|
||||
" pass\n",
|
||||
"\n",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue