Atlasbot commited on
Commit
cabe44f
·
1 Parent(s): aea4870

initial app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+
5
+ learn = load_learner('export.pkl')
6
+ labels = learn.dls.vocab
7
+ def predict(img):
8
+ img = img.resize((512, 512))
9
+ img = PILImage.create(img)
10
+ pred,pred_idx,probs = learn.predict(img)
11
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
12
+
13
+ title = "Camel or a Llama ?"
14
+ examples = ['/content/Llama_or_not/Llama/123e64ba-45e6-4f8b-b055-8762d6a9a347.jpg']
15
+ interpretation='default'
16
+ enable_queue=True
17
+
18
+ gr.Interface(
19
+ fn=predict,
20
+ inputs=gr.Image(type="pil"),
21
+ outputs=gr.Label(num_top_classes=3),
22
+ title=title,
23
+ examples=examples,
24
+ ).launch(share=True)