File size: 1,707 Bytes
585152a
b46c470
 
585152a
7613528
585152a
d51ae79
b46c470
 
 
 
 
3926786
b46c470
 
3926786
 
b46c470
 
 
 
 
 
3926786
b46c470
 
 
 
 
 
4669188
b46c470
 
715e479
 
 
 
 
 
 
 
fd246ce
 
b46c470
 
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
import gradio as gr
from fastai.vision.all import *
from fastcore.all import *

learn = load_learner("model_cow (1).pkl")

categories = ('Angus', 'Brown Swiss', 'Charolais', 'Hereford', 'Holstein', 'Jersey', 'Limousin', 'Simmental')

def classify_img(img):
    pred,idx,probs = learn.predict(img)
    return dict(zip(categories, map(float,probs)))

with gr.Blocks(title = " what kind of cow ") as demo:
    with gr.Row():
        gr.Markdown("""
                     ###  what kind of cow ? 
                     #### click on the photos and then click "PREDİCT" button.
                     """)
    with gr.Row():
        image = gr.inputs.Image(shape=(192,192))   
    with gr.Row():
        output = gr.outputs.Label()      
    with gr.Row():
        image_button = gr.Button("PREDİCT")
        image_button.click(classify_img, inputs=image, outputs=output)
    
    with gr.Row():
        with gr.Column():
            gr.Examples(inputs=image,examples=["1.jpg"],label="angus")
        with gr.Column():
            gr.Examples(inputs=image,examples=["2.jpg"],label="brown swiss")
        with gr.Column():
            gr.Examples(inputs=image,examples=["3.jpg"],label="simmental")
        with gr.Column():
            gr.Examples(inputs=image,examples=["7.jpg"],label="jersey")
        with gr.Column():
            gr.Examples(inputs=image,examples=["5.jpg"],label="Angus")
        with gr.Column():
            gr.Examples(inputs=image,examples=["6.jpg"],label="brown swiss")
        with gr.Column():
            gr.Examples(inputs=image,examples=["4.jpg"],label="simmental")
        with gr.Column():
            gr.Examples(inputs=image,examples=["8.jpg"],label="angus")
    
demo.launch()