Skip to content

Unknown Model (mobilenetv5_300m_enc) when loading Gemma 3n #39208

@HenryNdubuaku

Description

@HenryNdubuaku

System Info

- `transformers` version: 4.53.0
- Platform: Linux-6.1.141+-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 0.33.2
- Safetensors version: 0.5.1
- Accelerate version: 1.2.1
- Accelerate config:    not found
- DeepSpeed version: not installed
- PyTorch version (accelerator?): 2.5.1+cu121 (NA)
- Tensorflow version (GPU?): 2.17.1 (False)
- Flax version (CPU?/GPU?/TPU?): 0.10.2 (cpu)
- Jax version: 0.4.33
- JaxLib version: 0.4.33
- Using distributed or parallel set-up in script?: <fill in>

Does Gemma 3n require special setups? That is not sustainable.

Who can help?

I upgraded to the latest transformers to try Gemma 3n and it would seem there is not implementation of mobilenetv5_300m when i try to run the model as described on the official huggingface page.

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
[<ipython-input-2-ac178faa1642>](https://localhost:8080/#) in <cell line: 8>()
      6 model_id = "google/gemma-3n-e4b-it"
      7 
----> 8 model = Gemma3nForConditionalGeneration.from_pretrained(model_id, device_map="auto", torch_dtype=torch.bfloat16,).eval()
      9 
     10 processor = AutoProcessor.from_pretrained(model_id)

8 frames
[/usr/local/lib/python3.10/dist-packages/timm/models/_factory.py](https://localhost:8080/#) in create_model(model_name, pretrained, pretrained_cfg, pretrained_cfg_overlay, checkpoint_path, scriptable, exportable, no_jit, **kwargs)
    111 
    112     if not is_model(model_name):
--> 113         raise RuntimeError('Unknown model (%s)' % model_name)
    114 
    115     create_fn = model_entrypoint(model_name)

RuntimeError: Unknown model (mobilenetv5_300m_enc)

Does Gemma 3n require special setups? That is not sustainable.

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

The example code on the model card

from transformers import AutoProcessor, Gemma3nForConditionalGeneration
from PIL import Image
import requests
import torch

model_id = "google/gemma-3n-e4b-it"

model = Gemma3nForConditionalGeneration.from_pretrained(model_id, device_map="auto", torch_dtype=torch.bfloat16,).eval()

processor = AutoProcessor.from_pretrained(model_id)

messages = [
    {
        "role": "system",
        "content": [{"type": "text", "text": "You are a helpful assistant."}]
    },
    {
        "role": "user",
        "content": [
            {"type": "image", "image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg"},
            {"type": "text", "text": "Describe this image in detail."}
        ]
    }
]

inputs = processor.apply_chat_template(
    messages,
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    return_tensors="pt",
).to(model.device)

input_len = inputs["input_ids"].shape[-1]

with torch.inference_mode():
    generation = model.generate(**inputs, max_new_tokens=100, do_sample=False)
    generation = generation[0][input_len:]

decoded = processor.decode(generation, skip_special_tokens=True)
print(decoded)

Expected behavior

This is the basic example on the model card.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions