|
|
import gradio as gr |
|
|
|
|
|
from fastai.vision.all import * |
|
|
|
|
|
|
|
|
learn = load_learner('3label.pkl') |
|
|
|
|
|
|
|
|
|
|
|
labels = learn.dls.vocab |
|
|
|
|
|
def classify_image(img): |
|
|
pred,idx,probs = learn.predict(img) |
|
|
|
|
|
return {labels[i]: float(probs[i]) for i in range(len(labels))} |
|
|
|
|
|
|
|
|
image = gr.inputs.Image(shape=(224, 224)) |
|
|
label = gr.outputs.Label() |
|
|
examples = ['fake_1.jpg','fake_2.jpg','tank_6.jfif','tank_7.jfif','tank_0.jfif', 'tank_1.jpg', 'tank_2.jfif', 'tank_3.jfif', 'tank_4.jfif', 'photo_1.jfif', 'photo_2.jfif', 'photo_3.jfif', 'photo_4.jfif', 'photo_5.jfif', 'photo_6.jfif'] |
|
|
|
|
|
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) |
|
|
intf.launch(inline=False) |