Spaces:
Runtime error
Runtime error
Commit ·
3130661
1
Parent(s): 0d13471
fix examples attempt 3
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ plt = platform.system()
|
|
| 8 |
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
|
| 9 |
|
| 10 |
learn = load_learner('model.pkl')
|
| 11 |
-
examples = [
|
| 12 |
|
| 13 |
labels = learn.dls.vocab
|
| 14 |
def predict(img):
|
|
@@ -19,11 +19,10 @@ def predict(img):
|
|
| 19 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 20 |
|
| 21 |
title = "Northern EU Mushroom Classifier"
|
| 22 |
-
description = "<
|
| 23 |
-
article="<
|
| 24 |
interpretation='default'
|
| 25 |
enable_queue=True
|
| 26 |
inputs = gr.Image(shape=(224, 224))
|
| 27 |
-
examples = gr.Examples(examples=examples, inputs=inputs)
|
| 28 |
|
| 29 |
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)
|
|
|
|
| 8 |
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
|
| 9 |
|
| 10 |
learn = load_learner('model.pkl')
|
| 11 |
+
examples = [PILImage.create(str(x)) for x in get_image_files('images')]
|
| 12 |
|
| 13 |
labels = learn.dls.vocab
|
| 14 |
def predict(img):
|
|
|
|
| 19 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 20 |
|
| 21 |
title = "Northern EU Mushroom Classifier"
|
| 22 |
+
description = "<p style='text-align: center, font-size:14px'>A North EU mushroom image classifier trained on a kaggle dataset with fastai. The dataset consist of 9 different folders that contains from 300 to 1500 selected images of mushrooms genuses.</p>"
|
| 23 |
+
article="<p style='text-align: center, font-size:14px'><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)
|