AIOmarRehan commited on
Commit
390c589
·
verified ·
1 Parent(s): 830c435

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+ from model import predict
4
+
5
+ def classify_image(img: Image.Image):
6
+ label, confidence, probs = predict(img)
7
+
8
+ return (
9
+ label,
10
+ round(confidence, 3),
11
+ {k: round(v, 3) for k, v in probs.items()}
12
+ )
13
+
14
+ demo = gr.Interface(
15
+ fn=classify_image,
16
+ inputs=gr.Image(type="pil", label="Upload an image"),
17
+ outputs=[
18
+ gr.Label(label="Predicted Class"),
19
+ gr.Number(label="Confidence"),
20
+ gr.JSON(label="All Probabilities")
21
+ ],
22
+ title="Animal Image Classifier",
23
+ description="Upload an image and the model will predict the animal."
24
+ )
25
+
26
+ if __name__ == "__main__":
27
+ demo.launch()