n-e-w commited on
Commit
b7decb5
1 Parent(s): 1475e24

ADD app.py and pickled model

Browse files
Files changed (2) hide show
  1. app.py +19 -0
  2. export.pkl +3 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+
5
+ learn = load_learner('export.pkl')
6
+
7
+ labels = learn.dls.vocab
8
+ def predict(img):
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 = "Glock 9mm Classifier for Meatheads"
14
+ description = "Model to Predict Glock 9mm Model Type from Images. Based on Resnet 152 using fast.ai."
15
+ article="<p style='text-align: center'><a href='https://us.glock.com/en/pistols' target='_blank'>Glock Product Page</a></p>"
16
+ examples = ['glock17.jpg','glock19.jpg','glock26.jpg']
17
+ interpretation='default'
18
+ enable_queue=True
19
+ gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch(share=True)
export.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d8024f23ab15a5b3733e84998e48dcb0207a66ea7a658407b0f4dacfb009d8f
3
+ size 242084507