marix1120
commited on
Commit
•
56edf09
1
Parent(s):
6f275d2
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""app
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1tB5UaeH3SiFcvNJelcs0apxr4mFEHmtA
|
8 |
+
"""
|
9 |
+
|
10 |
+
learn = load_learner('model.pkl')
|
11 |
+
|
12 |
+
labels = learn.dls.vocab
|
13 |
+
def predict(img):
|
14 |
+
img = PILImage.create(img)
|
15 |
+
pred,pred_idx,probs = learn.predict(img)
|
16 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
17 |
+
|
18 |
+
import gradio as gr
|
19 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)
|