Spaces:
Runtime error
Runtime error
Commit ·
f157f75
1
Parent(s): 07f6228
fix examples attempt 1
Browse files
app.py
CHANGED
|
@@ -2,12 +2,13 @@ from fastai.vision.all import *
|
|
| 2 |
import gradio as gr
|
| 3 |
import skimage
|
| 4 |
import pathlib
|
|
|
|
| 5 |
|
| 6 |
plt = platform.system()
|
| 7 |
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
|
| 8 |
|
| 9 |
learn = load_learner('model.pkl')
|
| 10 |
-
examples =
|
| 11 |
|
| 12 |
labels = learn.dls.vocab
|
| 13 |
def predict(img):
|
|
@@ -22,5 +23,6 @@ description = "<h4 style='text-align: center'>A North EU mushroom image classifi
|
|
| 22 |
article="<h4 style='text-align: center'><a href='https://www.kaggle.com/datasets/maysee/mushrooms-classification-common-genuss-images' target='_blank'>Data Source</a></h4>"
|
| 23 |
interpretation='default'
|
| 24 |
enable_queue=True
|
|
|
|
| 25 |
|
| 26 |
-
gr.Interface(fn=predict, inputs=
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import skimage
|
| 4 |
import pathlib
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
plt = platform.system()
|
| 8 |
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
|
| 9 |
|
| 10 |
learn = load_learner('model.pkl')
|
| 11 |
+
examples = [os.path.join(os.path.dirname(__file__), str(x)) for x in get_image_files('./images')]
|
| 12 |
|
| 13 |
labels = learn.dls.vocab
|
| 14 |
def predict(img):
|
|
|
|
| 23 |
article="<h4 style='text-align: center'><a href='https://www.kaggle.com/datasets/maysee/mushrooms-classification-common-genuss-images' target='_blank'>Data Source</a></h4>"
|
| 24 |
interpretation='default'
|
| 25 |
enable_queue=True
|
| 26 |
+
inputs = gr.Image(shape=(224, 224))
|
| 27 |
|
| 28 |
+
gr.Interface(fn=predict, inputs=inputs, outputs=gr.Label(num_top_classes=3), title=title, description=description, article=article, interpretation=interpretation, examples=examples).launch(share=True, enable_queue=enable_queue)
|