MasleK commited on
Commit
c951ada
·
1 Parent(s): 8983eae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -1,13 +1,15 @@
1
  import gradio as gr
2
- from fastai.vision.all import *
3
 
 
4
 
5
- learn = load_learner('sss_export.pkl')
6
-
7
- def predict(img):
8
- img = PILImage.create(img)
9
- pred,pred_idx,probs = learn.predict(img)
10
- return {labels[i]: float(probs[i]) for i in range(len(labels))}
11
-
12
- gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)
13
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ pipeline = pipeline(task="image-classification", model="MasleK/snails_snakes_slugs")
5
 
6
+ def predict(image):
7
+ predictions = pipeline(image)
8
+ return {p["label"]: p["score"] for p in predictions}
 
 
 
 
 
9
 
10
+ gr.Interface(
11
+ predict,
12
+ inputs=gr.inputs.Image(label="candidate", type="filepath"),
13
+ outputs=gr.outputs.Label(num_top_classes=3),
14
+ title="Snail? Snake? Slug?",
15
+ ).launch()