Spaces:
Running
Running
A newer version of the Gradio SDK is available:
6.1.0
metadata
title: Keras Image Classifier
emoji: 🖼️
colorFrom: indigo
colorTo: blue
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
Image Classifier — Keras/TensorFlow (Hugging Face Space)
A dead-simple image classification app you can deploy in minutes.
How it works
- If
model.h5exists in the repository root, the app loads your custom Keras model.- Optionally add
labels.txt(one class name per line) to show readable labels. - Input is resized to 224×224. Adjust
TARGET_SIZEinapp.pyif your model expects a different size.
- Optionally add
- If no
model.h5is found, it falls back to MobileNetV2 (ImageNet).
Run locally
pip install -r requirements.txt
python app.py
Then open the local URL printed by Gradio.
Deploy to Hugging Face Spaces
- Create a new Space → Gradio (Python).
- Upload these files:
app.py,requirements.txt,README.md. - (Optional) Upload your
model.h5andlabels.txtto use your own model. - The Space will build and auto-start.
Using your notebook's model
If your notebook trained a model, export it:
model.save("model.h5")
# Optional labels file (one per line)
with open("labels.txt", "w") as f:
f.write("\n".join(class_names))
Commit both files to the Space.