This article introduces the steps to publish a YOLOv11x model trained on the Japanese Classical Kuzushiji Dataset on Hugging Face and create a demo with Gradio Spaces.
Overview
- Model: YOLOv11x (for kuzushiji character detection)
- Dataset: Japanese Classical Kuzushiji Dataset
- Publication: Hugging Face Models + Spaces
1. Register the Model on Hugging Face Models
1.1 Install huggingface_hub
1.2 Login
Or from Python:
You can obtain a token from https://huggingface.co/settings/tokens (Write permission required).
1.3 Upload the Model
1.4 Create a Model Card (README.md)
Create a README.md with usage instructions and license information and upload it.
2. Publish a Demo on Hugging Face Spaces
2.1 Spaces Configuration (README.md)
Key points:
- Specifying
sdk: gradiopre-installs Gradio sdk_versioncan be used to pin the version- No need to add gradio to requirements.txt
2.2 requirements.txt
2.3 Load the Model in app.py
Use hf_hub_download to load the model from Hugging Face Hub.
2.4 Notes on Gradio 5.x
In Gradio 5.x, SSR (Server-Side Rendering) is enabled by default as an experimental feature. This can cause the following error:
To work around this issue, specify ssr_mode=False in launch().
3. Benefits of This Architecture
| Item | Benefit |
|---|---|
| Model management | Models and Spaces can be separated |
| Repository size | No need to include large model files in Spaces |
| Reusability | Other users can easily use the model |
| Version management | Spaces code doesn’t need to change when the model is updated |
4. Published Resources
- Model: https://huggingface.co/nakamura196/yolov11x-codh-char
- Spaces: https://huggingface.co/spaces/nakamura196/yolov11x-codh-char