Deploy your model on Hugging Face
A 20-minute guide · no web-development experience needed
You have trained a segmentation model. Now give it a web page: a visitor uploads an image and gets the same image back with the predicted defect masks drawn on top.
Prepare the files · Publish on Hugging Face · I have a .pth file
Hugging Face account under 30 days old? Follow page 4 · Deploy free with Streamlit Community Cloud. It provides a hosted image-to-overlay demo on CPU using GitHub, with no Hugging Face account needed.

Why this is the simplest route
| Choice | Why |
|---|---|
| Hugging Face Spaces | Free hosting for small apps, with a public link you can share. |
| Gradio | One gr.Interface(...) call builds the whole upload-and-show page. No HTML, no server code. |
| ZeroGPU (free) | Free accounts run Gradio apps on a shared GPU that is lent to your function only while it runs. One 128 × 800 image needs a second or two. |
What the app does

Steps 2 to 4 are the same three things you already do at validation time: prepare the image, run the model, threshold the probabilities. The only new part is painting the result.
What you need before you start
- A trained model's weights file (
weights.pt) and the Python class that builds the same architecture. - The preprocessing used in training (resize, normalisation).
- Your chosen threshold.
- A free account on huggingface.co with a verified email. ZeroGPU hosting needs an account older than 30 days.
You do not need the competition data. Never upload it. The Space needs only code and weights.
The route
- Prepare five small files and test them on your own computer. Have a
.pthfile instead ofweights.pt? See page 3. - Create a Space and upload them. Hugging Face builds and runs the app for you.
- Open your link, drop in an image, and check the overlay.
One rule runs through everything: the app must prepare an image exactly the way training did. Most deployment bugs are a preprocessing mismatch, not a coding error.