montoti05 commited on
Commit
be7f921
·
verified ·
1 Parent(s): f968612

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.learner import load_learner
3
+ from fastai.vision.core import PILImage
4
+
5
+
6
+ from huggingface_hub import hf_hub_download
7
+
8
+
9
+ learner = load_learner(hf_hub_download("montoti05/isitabird","model.pkl"))
10
+
11
+ def classify_image(image):
12
+ img = PILImage.create(image)
13
+ pred_class, pred_idx, outputs = learner.predict(img)
14
+ return(f"Predicted class: {pred_class}")
15
+
16
+
17
+ gr.Interface(fn=classify_image,
18
+ inputs=gr.Image(width=224, height=224),
19
+ outputs="textbox").launch()