Skip to content

Add mobilenet_v5 stub implementation to fix "Unknown Model" error#39211

Open
VXXXO wants to merge 4 commits intohuggingface:mainfrom
VXXXO:fix-mobilenetv5-unknown-model
Open

Add mobilenet_v5 stub implementation to fix "Unknown Model" error#39211
VXXXO wants to merge 4 commits intohuggingface:mainfrom
VXXXO:fix-mobilenetv5-unknown-model

Conversation

@VXXXO
Copy link
Copy Markdown

@VXXXO VXXXO commented Jul 3, 2025

What does this PR do?

This PR addresses issue #39208: "Unknown Model (mobilenetv5_300m_enc) when loading Gemma 3n".

Problem

When loading Gemma 3n models, the default vision architecture is set to "mobilenetv5_300m_enc", but this architecture was not implemented in Transformers, causing an "Unknown Model" error that prevents users from using Gemma 3n.

Solution

  • Added minimal mobilenet_v5 implementation with proper structure:
    • MobileNetV5Config - configuration class with standard parameters
    • MobileNetV5Model - stub model implementation (inherits from PreTrainedModel)
    • MobileNetV5ImageProcessor - stub image processor
  • Registered mobilenet_v5 in all auto classes (AutoConfig, AutoModel, AutoImageProcessor)
  • Used lazy loading to avoid circular dependencies
  • Added proper docstrings and warnings about stub nature

Benefits

  • Eliminates "Unknown Model" error when loading Gemma 3n
  • Provides foundation for future full implementation of mobilenet_v5
  • Maintains backward compatibility
  • Follows Transformers architecture standards

Testing

  • Verified that AutoConfig.for_model('mobilenet_v5') works
  • Verified that AutoModel.from_config works for mobilenet_v5
  • Verified that Gemma3nVisionConfig with architecture='mobilenetv5_300m_enc' works
  • All components compile without syntax errors

Note: This is a stub implementation that prevents crashes. Full implementation of mobilenet_v5 architecture is left for future contributions.

Fixes #39208

VXXXO added 4 commits July 3, 2025 23:37
…odel

- Rename PretrainedFSMTModel to PreTrainedFSMTModel to match naming convention
- Update all usages and exports accordingly
- Fixes issue huggingface#39202
- Add minimal mobilenet_v5 model implementation with config, model, and image processor
- Register mobilenet_v5 in auto classes (AutoConfig, AutoModel, AutoImageProcessor)
- Fixes issue huggingface#39208: 'Unknown Model (mobilenetv5_300m_enc)' when loading Gemma 3n
- Provides stub implementation that prevents crashes and allows future expansion
- Includes proper docstrings and warnings about stub nature
- All components are properly integrated with Transformers architecture
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 3, 2025

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, fsmt

@ArthurZucker
Copy link
Copy Markdown
Collaborator

cc @qubvel !

@qubvel
Copy link
Copy Markdown
Contributor

qubvel commented Jul 7, 2025

Hey @VXXXO, thanks for your contribution, but we just need a check for the timm version for gemma3n, it would be much simpler. I mean transformers need timm >= 1.0.16 to instantiate gemma3n with mobilenetv5 vision encoder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unknown Model (mobilenetv5_300m_enc) when loading Gemma 3n

3 participants