Anis Taluqdar commited on
Commit
888902c
·
1 Parent(s): 65be8c6

app created

Browse files
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from fastai.vision.all import *
3
+ import gradio as gr
4
+
5
+ # import pathlib
6
+ # temp = pathlib.PosixPath
7
+ # pathlib.PosixPath = pathlib.WindowsPath
8
+
9
+ model = load_learner('models/cap-recognizer-v1.pkl')
10
+
11
+ #!export
12
+ cap_labels = model.dls.vocab
13
+ def recognize_image(image):
14
+ pred, idx, probs = model.predict(image)
15
+ return dict(zip(cap_labels, map(float, probs)))
16
+
17
+
18
+
19
+ examples = [
20
+ 'test_images/CowboyHat.jpg',
21
+ 'test_images/beanie cap.jpg',
22
+ 'test_images/taqiyah cap.jpg',
23
+ 'test_images/boater hat.jpg'
24
+ ]
25
+
26
+ iface = gr.Interface(fn=recognize_image, inputs="image", outputs="label", examples=examples)
27
+ iface.launch(inline=False)
models/cap-recognizer-v1.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa427650523fa0f609b2f3f371194d78c1db78d4abeac9f93c6e151543d2073f
3
+ size 87657634
requirements.txt ADDED
Binary file (3.4 kB). View file
 
test_images/CowboyHat.jpg ADDED
test_images/beanie cap.jpg ADDED
test_images/boater hat.jpg ADDED
test_images/taqiyah cap.jpg ADDED