Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,21 @@
|
|
| 1 |
-
from fastai.
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
| 7 |
pred, pred_idx, probs = learn.predict(img)
|
| 8 |
return f"Prediction: {pred} ({probs[pred_idx]*100:.2f}%)"
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
# Load the exported fastai learner
|
| 5 |
+
learn = load_learner("clean_model.pkl")
|
| 6 |
|
| 7 |
+
# Prediction function
|
| 8 |
+
def classify_image(img):
|
| 9 |
pred, pred_idx, probs = learn.predict(img)
|
| 10 |
return f"Prediction: {pred} ({probs[pred_idx]*100:.2f}%)"
|
| 11 |
|
| 12 |
+
# Gradio interface
|
| 13 |
+
interface = gr.Interface(
|
| 14 |
+
fn=classify_image,
|
| 15 |
+
inputs=gr.Image(type='pil'),
|
| 16 |
+
outputs=gr.Text(),
|
| 17 |
+
title="Cat vs Dog Classifier",
|
| 18 |
+
description="Upload an image of a cat or dog to classify."
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
interface.launch()
|