idan-haimovich commited on
Commit
90d3ef2
1 Parent(s): 399c26f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
2
+
3
+ from fastai.vision.all import *
4
+ import gradio as gr
5
+
6
+ learn = load_learner('export.pkl')
7
+ #export.pkl is the name of the neural network file, change accordingly
8
+
9
+ categories = ('cuts_and_wounds', 'fracture', 'rash', 'splinter')
10
+ def classify_image(img):
11
+ pred, idx, probs = learn.predict(img)
12
+ return dict(zip(categories, map(float, probs)))
13
+
14
+ image=gr.Image(height = 192, width = 192)
15
+ label = gr.Label()
16
+ examples = ['Cuts_for_nn.jpeg', 'Fracture_examp.jpeg', 'Rash.jpeg', 'Splinter_examp.jpeg']
17
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
18
+ intf.launch(inline=False)