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

1. Register the Model on Hugging Face Models

1.1 Install huggingface_hub

pipinstallhuggingface_hub

1.2 Login

huggingface-clilogin

Or from Python:

flroogminh(u)ggingface_hubimportlogin

You can obtain a token from https://huggingface.co/settings/tokens (Write permission required).

1.3 Upload the Model

far#c#arperpoipeimoa.=_tupprrhiepaaeeuHd_lttppgfrohhoogA=ea____ippdoiitni"o_rndyg(y(f__=pf)orifrreaueliee=crpelpp"e-o(eoom_u_o=_ohsib"iduedjbdebr,=e,ln"s"iarbtmmee.pepspo/ottry_."totp,lytHop"fve,A1=p1"ixm,-ocdcoerdleh"a-,tcehe_axrrie"spto_ok=True)

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)

teccssapimooddpitollkkpnljoo:__neirrvfe::FTgeidrorrl:Y👁o:aseOmdi:fL:gioaOronalvpe:ps1iepe1nn5.xk.p4yC9h.a1racter

Key points:

  • Specifying sdk: gradio pre-installs Gradio
  • sdk_version can be used to pin the version
  • No need to add gradio to requirements.txt

2.2 requirements.txt

uPlitlrlaolwytics

2.3 Load the Model in app.py

Use hf_hub_download to load the model from Hugging Face Hub.

ff#m#m#rrrooeooHddsmmueeuglrflluhg_eitluippl=stgnaoerggt_nY=aihiaOlnFdmLmyga==eOotfc"=(diaehn"meccfabolse_ked._hasepihumtlrmubu._epb_rppdodatairio1"tctmw9htpn6)(Yol"OryiLtaomOdlah(ogfve_1.h1juxpb-g_c"do,odwhcn-olcnohfaa=dr0".,25,iou=0.45)

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:

IndexError:functionhasnobackendmethod.

To work around this issue, specify ssr_mode=False in launch().

demo.launch(share=False,ssr_mode=False)

3. Benefits of This Architecture

ItemBenefit
Model managementModels and Spaces can be separated
Repository sizeNo need to include large model files in Spaces
ReusabilityOther users can easily use the model
Version managementSpaces code doesn’t need to change when the model is updated

4. Published Resources

References