File size: 673 Bytes
1c8dc00
830c435
1c8dc00
830c435
1c8dc00
 
830c435
1c8dc00
 
 
 
 
830c435
9f43ed3
 
 
 
 
 
 
 
 
 
 
1c8dc00
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import gradio as gr
from PIL import Image
from model import predict

def classify_image(img: Image.Image):
    label, confidence, probs = predict(img)

    return (
        label,
        round(confidence, 3),
        {k: round(v, 3) for k, v in probs.items()}
    )

demo = gr.Interface(
    fn=classify_image,
    inputs=gr.Image(type="pil", label="Upload an image"),
    outputs=[
        gr.Label(label="Predicted Class"),
        gr.Number(label="Confidence"),
        gr.JSON(label="All Probabilities")
    ],
    title="Animal Image Classifier",
    description="Upload an image and the model will predict the animal."
)

if __name__ == "__main__":
    demo.launch()