ArpitaShenoy commited on
Commit
4ec90e7
1 Parent(s): fe58098

initial commit

Browse files
Files changed (3) hide show
  1. app.py +27 -0
  2. multi_label_owl.pkl +3 -0
  3. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = ['get_y','learn', 'classify_images', 'image', 'label',
2
+ 'intf']
3
+
4
+ import fastai
5
+ from fastai.vision.all import*
6
+ import gradio as gr
7
+
8
+ def get_y(o):
9
+ return [o.parent.name]
10
+
11
+ learn = load_learner('multi_label_owl.pkl')
12
+
13
+ # categories = ('barn', 'barred', 'snowy')
14
+
15
+ def classify_images(img):
16
+ pred,idx,probs = learn.predict(img)
17
+ idxs = torch.where(probs>0.95)
18
+ if len(idxs[0])==0:
19
+ return 'None'
20
+ else:
21
+ return learn.dls.vocab[idxs][0]
22
+
23
+ image = gr.inputs.Image(shape=(192,192))
24
+ label = gr.outputs.Label()
25
+
26
+ intf = gr.Interface(fn=classify_images, inputs=image, outputs=label)
27
+ intf.launch(inline=False)
multi_label_owl.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e1b18198170698e8c3ee965a90b5db101d88bc160bab441d9c81f49547619d69
3
+ size 87478053
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai == 2.7.9
2
+ gradio