File size: 1,032 Bytes
b013f99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from fastai.vision.all import load_learner
import gradio as gr 

chicken_breeds = [
 'Austra White',
 'Black Sex Link',
 'Blue Laced Red Wyandotte',
 'Bresse',
 'Cherry Egger',
 'Cochin',
 'Cornish Cross',
 'Cream Legbar',
 'Easter Egger',
 'Frizzle',
 'Iowa Blue',
 'Jersey Giant',
 'Nankin',
 'New Hampshire',
 'Orpingtons',
 'Polish',
 'Shamo',
 'Silkie',
 'Silver Laced Wyandotte',
 'Turken (Naked Neck)'
]

version = 2
model_path = f"chicken_breed_recognizer-v{version}.pkl"
model = load_learner(model_path)

def recognize_image(image):
    pred, idx, probs = model.predict(image)
    return dict(zip(cap_labels, map(float, probs)))

image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()

examples = [
  'test_images/test_00.jpg',
  'test_images/cornish_cross_test_01.jpg'
  'test_images/frizzle_test_03.jpg',
  'test_images/polish_test_05.jpg',
  'test_images/blue_laced_red_wyandotte_09.jpg'
]

iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
iface.launch(inline=False)