"ImportError: Package `num2words` is required to run SmolVLM processor" getting this issue wwhile importing SmolVLM2 from AutoProcessor

#18
by aryachakraborty - opened

I have installed the transformer using the following command "pip install git+https://github.com/huggingface/[email protected]".
and using the following code to import the model ,

Screenshot 2025-03-16 125521.png

processor = AutoProcessor.from_pretrained(model_path)
model = AutoModelForImageTextToText.from_pretrained(
    model_path,
    torch_dtype=torch.bfloat16,
    _attn_implementation="flash_attention_2"
).to("cuda")```

it's showing the error mentioned in the title. Explicitly I have installed the 'num2words' package using pip, still same error is showing. 

is there a particular version I need to install ? (PS: I have restarted the runtime multiple times, that didn't work.

I modify the "lib/python3.12/site-packages/transformers/models/smolvlm/processing_smolvlm.py" file.
The line 48 show this:

image.png

These conditional isn't executing as true... so import "from num2words import num2words" before this line and it will work.

image.png
I'm also facing the issue. Any idea how to move ahead?

Hugging Face Smol Models Research org

When running in colab, be sure to restart your runtime after installing packages. That should fix your issue.

I have multiple times and its giving the same error :(

I have multiple times and its giving the same error :(

@Daaku-C5 can you please try the solution that @Jaocs provided, even though I haven't tried but it seems a reasonable solution.

@Xenova 's solution for restarting the Colab session after pip install worked for me.

Can the package be updated to avoid requiring a runtime restart? I want to use this for educational purposes, and the workaround is forcing me to move on to alternatives, as the last thing I want learners to have to do is troubleshoot a basic example. If not, no worries, we will move on.

Sign up or log in to comment