Spaces:
Sleeping
Sleeping
create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import load_learner
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
chicken_breeds = [
|
5 |
+
'Austra White',
|
6 |
+
'Black Sex Link',
|
7 |
+
'Blue Laced Red Wyandotte',
|
8 |
+
'Bresse',
|
9 |
+
'Cherry Egger',
|
10 |
+
'Cochin',
|
11 |
+
'Cornish Cross',
|
12 |
+
'Cream Legbar',
|
13 |
+
'Easter Egger',
|
14 |
+
'Frizzle',
|
15 |
+
'Iowa Blue',
|
16 |
+
'Jersey Giant',
|
17 |
+
'Nankin',
|
18 |
+
'New Hampshire',
|
19 |
+
'Orpingtons',
|
20 |
+
'Polish',
|
21 |
+
'Shamo',
|
22 |
+
'Silkie',
|
23 |
+
'Silver Laced Wyandotte',
|
24 |
+
'Turken (Naked Neck)'
|
25 |
+
]
|
26 |
+
|
27 |
+
version = 2
|
28 |
+
model_path = f"chicken_breed_recognizer-v{version}.pkl"
|
29 |
+
model = load_learner(model_path)
|
30 |
+
|
31 |
+
def recognize_image(image):
|
32 |
+
pred, idx, probs = model.predict(image)
|
33 |
+
return dict(zip(cap_labels, map(float, probs)))
|
34 |
+
|
35 |
+
image = gr.inputs.Image(shape=(192, 192))
|
36 |
+
label = gr.outputs.Label()
|
37 |
+
|
38 |
+
examples = [
|
39 |
+
'test_images/test_00.jpg',
|
40 |
+
'test_images/cornish_cross_test_01.jpg'
|
41 |
+
'test_images/frizzle_test_03.jpg',
|
42 |
+
'test_images/polish_test_05.jpg',
|
43 |
+
'test_images/blue_laced_red_wyandotte_09.jpg'
|
44 |
+
]
|
45 |
+
|
46 |
+
iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
|
47 |
+
iface.launch(inline=False)
|