Upload 3 files
Browse files- app.py +19 -0
- requirements.txt +8 -0
- sunfish_vs_perch.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import pathlib
|
| 4 |
+
|
| 5 |
+
learn = load_learner('sunfish_vs_perch.pkl')
|
| 6 |
+
|
| 7 |
+
def predict(img):
|
| 8 |
+
pred_class, pred_idx, outputs = learn.predict(img)
|
| 9 |
+
return {learn.dls.vocab[i]: float(outputs[i]) for i in range(len(outputs))}
|
| 10 |
+
|
| 11 |
+
demo = gr.Interface(
|
| 12 |
+
fn=predict,
|
| 13 |
+
inputs=gr.Image(type="pil"),
|
| 14 |
+
outputs=gr.Label(num_top_classes=2),
|
| 15 |
+
title="Sunfish vs Perch Classifier",
|
| 16 |
+
description="Classify fish as Sunfish (Lepomis) or Perch (Perca) using fastai and ResNet18"
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai==2.7.19
|
| 2 |
+
torch==2.6.0
|
| 3 |
+
torchvision==0.21.0
|
| 4 |
+
numpy==1.26.4
|
| 5 |
+
gradio
|
| 6 |
+
pandas==2.2.2
|
| 7 |
+
duckduckgo-search
|
| 8 |
+
requests
|
sunfish_vs_perch.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5e19dddaa1212ee613ab2714b0f8b45da3617df6dbc9dd0dc354c53bd20a239d
|
| 3 |
+
size 46963683
|