File size: 843 Bytes
0963123 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
import numpy as np
from huggingface_hub import from_pretrained_keras
model = from_pretrained_keras("mouaff25/tyre_quality_classifier")
labels = ["defective", "good"]
def classify_image(inp: np.ndarray):
inp = inp.reshape((-1, 224, 224, 3))
prediction = model.predict(inp).flatten()
confidences = {
"defective": 1 - float(prediction[0]),
"good": float(prediction[0])
}
return confidences
demo = gr.Interface(fn=classify_image,
inputs=gr.Image(shape=(224, 224)),
outputs=gr.Label(num_top_classes=2),
examples=["./examples/defective.jpg", "./examples/good.jpg"],
title="Tyre Quality Classifier",
description="This model can distinguish between good and defective tyres. Upload an image of a tyre to see the model in action!")
demo.launch() |