Aravinth-Megnath commited on
Commit
372c8a8
·
1 Parent(s): b58cf80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../canals_classification.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'labels', 'demo', 'predict']
5
+
6
+ # %% ../canals_classification.ipynb 1
7
+ import gradio as gr
8
+ from fastai.vision.all import *
9
+ # %% ../canals_classification.ipynb 2
10
+ learn = load_learner("canals.pkl")
11
+
12
+ # %% ../canals_classification.ipynb 6
13
+ labels = learn.dls.vocab
14
+ def predict(img):
15
+ img = PILImage.create(img)
16
+ pred,pred_idx,probs = learn.predict(img)
17
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
18
+
19
+ # %% ../canals_classification.ipynb 8
20
+ demo = gr.Interface(fn=predict, inputs="image", outputs="label")
21
+ demo.launch()