File size: 551 Bytes
17c19eb
 
 
 
 
05a179b
17c19eb
 
 
 
 
 
 
1d4cd9f
17c19eb
 
 
 
 
 
1d4cd9f
 
 
 
17c19eb
 
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
import gradio as gr
from fastai.vision.all import *

learn = load_learner("resnet18.pkl")

categories = ("Healthy", "Peacock Spot")


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


labels = gr.Label()
examples = [
    "examples/healthy.jpg",
    "examples/healthy2.jpg",
    "examples/peacock_spot.jpeg",
]
demo = gr.Interface(
    classify_health,
    inputs=gr.Image(height=224, width=224),
    outputs=labels,
    examples=examples,
)
demo.launch(inline=False)