ModuleNotFoundError: No module named 'transformers_modules.vikhyatk'
My code is this
from transformers import AutoModelForCausalLM, AutoTokenizer
from PIL import Image
model = AutoModelForCausalLM.from_pretrained(
"vikhyatk/moondream2",
revision="2025-03-27",
trust_remote_code=True,
device_map={"": "cuda"}
)
image = Image.open('')
print("Short caption:")
print(model.caption(image, length="short")["caption"])
print("\nNormal caption:")
for t in model.caption(image, length="normal", stream=True)["caption"]:
print(t, end="", flush=True)
print(model.caption(image, length="normal"))
print("\nVisual query: 'How many people are in the image?'")
print(model.query(image, "How many people are in the image?")["answer"])
print("\nObject detection: 'face'")
objects = model.detect(image, "face")["objects"]
print(f"Found {len(objects)} face(s)")
print("\nPointing: 'person'")
points = model.point(image, "person")["points"]
print(f"Found {len(points)} person(s)")
And this is the error
Traceback (most recent call last):
File "C:\Users\Mr\Desktop\WarrantyIT_Python_Backend\test_moondream_trans.py", line 4, in
model = AutoModelForCausalLM.from_pretrained(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mr\Desktop\WarrantyIT_Python_Backend.venv\Lib\site-packages\transformers\models\auto\auto_factory.py", line 531, in from_pretrained
config, kwargs = AutoConfig.from_pretrained(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mr\Desktop\WarrantyIT_Python_Backend.venv\Lib\site-packages\transformers\models\auto\configuration_auto.py", line 1105, in from_pretrained
config_class = get_class_from_dynamic_module(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mr\Desktop\WarrantyIT_Python_Backend.venv\Lib\site-packages\transformers\dynamic_module_utils.py", line 553, in get_class_from_dynamic_module
return get_class_in_module(class_name, final_module, force_reload=force_download)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Mr\Desktop\WarrantyIT_Python_Backend.venv\Lib\site-packages\transformers\dynamic_module_utils.py", line 250, in get_class_in_module
module_spec.loader.exec_module(module)
File "", line 994, in exec_module
File "", line 488, in _call_with_frames_removed
File "C:\Users\Mr.cache\huggingface\modules\transformers_modules\vikhyatk\moondream2\8ef2caddfdead307fe7f3a4ed596baca7eab8a2f\hf_moondream.py", line 3, in
from .config import MoondreamConfig
ModuleNotFoundError: No module named 'transformers_modules.vikhyatk'