Tony Neel commited on
Commit
7718487
·
1 Parent(s): 9813e4e

working version

Browse files
Files changed (3) hide show
  1. .mambarc +3 -0
  2. README.md +1 -2
  3. app.py +22 -0
.mambarc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ channels:
2
+ - conda-forge
3
+ always_yes: false
README.md CHANGED
@@ -1,4 +1,3 @@
1
  ---
2
  license: apache-2.0
3
- pipeline_tag: image-classification
4
- ---
 
1
  ---
2
  license: apache-2.0
3
+ ---
 
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import logging
4
+
5
+
6
+ def is_cat(x): return x[0].isupper()
7
+
8
+ learn = load_learner('model.pkl')
9
+ labels = learn.dls.vocab
10
+ def predict(img):
11
+ img = PILImage.create(img)
12
+ pred,pred_idx,probs = learn.predict(img)
13
+ logging.info(pred, probs)
14
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
15
+
16
+ demo = gr.Interface(
17
+ fn=predict,
18
+ inputs=gr.Image(),
19
+ outputs=gr.Label(num_top_classes=3)
20
+ )
21
+
22
+ demo.launch()