File size: 577 Bytes
00b5287 ce2d510 ebf4b1f 00b5287 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from fastai.vision.all import *
import gradio as gr
import pathlib
learn = load_learner('sunfish_vs_perch.pkl')
def predict(img):
pred_class, pred_idx, outputs = learn.predict(img)
return {learn.dls.vocab[i]: float(outputs[i]) for i in range(len(outputs))}
demo = gr.Interface(
fn=predict,
inputs=gr.Image(type="pil"),
outputs=gr.Label(num_top_classes=2),
title="Sunfish vs Perch Classifier",
description="Classify fish as Sunfish (Lepomis) or Perch (Perca) using fastai and ResNet18",
examples=["sunfish.jpg", "perch.jpeg"]
)
demo.launch()
|