Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from fastai.vision.all import * | |
| from fastcore.all import * | |
| learn = load_learner("model_cow.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() |