Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,12 @@
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
# Load the Fastai model
|
| 5 |
learn = load_learner('resnet50_30_categories.pkl')
|
| 6 |
|
| 7 |
-
# Prediction function
|
| 8 |
def classify_image(img):
|
| 9 |
pred, idx, probs = learn.predict(img)
|
| 10 |
return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))}
|
| 11 |
|
| 12 |
-
# Gradio Interface
|
| 13 |
iface = gr.Interface(
|
| 14 |
fn=classify_image,
|
| 15 |
inputs=gr.Image(type="pil"),
|
|
@@ -18,6 +15,5 @@ iface = gr.Interface(
|
|
| 18 |
description="Upload an image of a flower and the model will predict its category."
|
| 19 |
)
|
| 20 |
|
| 21 |
-
# Launch the app
|
| 22 |
if __name__ == "__main__":
|
| 23 |
iface.launch()
|
|
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
|
|
|
| 4 |
learn = load_learner('resnet50_30_categories.pkl')
|
| 5 |
|
|
|
|
| 6 |
def classify_image(img):
|
| 7 |
pred, idx, probs = learn.predict(img)
|
| 8 |
return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))}
|
| 9 |
|
|
|
|
| 10 |
iface = gr.Interface(
|
| 11 |
fn=classify_image,
|
| 12 |
inputs=gr.Image(type="pil"),
|
|
|
|
| 15 |
description="Upload an image of a flower and the model will predict its category."
|
| 16 |
)
|
| 17 |
|
|
|
|
| 18 |
if __name__ == "__main__":
|
| 19 |
iface.launch()
|