Mason Grimshaw commited on
Commit
fe18fa2
·
1 Parent(s): a3749ba

Initial commit for LAICC Gradio App

Browse files
Files changed (3) hide show
  1. app.py +27 -0
  2. model.pkl +3 -0
  3. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['path_to_pkl_model', 'learn', 'categories', 'image', 'label', 'intf', 'classify_image']
5
+
6
+ # %% ../app.ipynb 3
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+ path_to_pkl_model = '/workspace/models/'
10
+
11
+ # %% ../app.ipynb 6
12
+ learn = load_learner(path_to_pkl_model)
13
+
14
+ # %% ../app.ipynb 9
15
+ categories = learn.dls.vocab # learn.dls.vocab provides the categories from our trained model
16
+
17
+ def classify_image(img):
18
+ img = PILImage.create(img).resize((192, 192))
19
+ pred,idx,probs = learn.predict(img)
20
+ return dict(zip(categories, map(float,probs)))
21
+
22
+ # %% ../app.ipynb 12
23
+ image = gr.Image()
24
+ label = gr.Label()
25
+
26
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label)
27
+ intf.launch(inline=False)
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:320601c00d7e8b75f425f0d56ce3bf172aa0060df84af9149729b5b1bf198952
3
+ size 49467174
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fastai