Spaces:
Sleeping
Sleeping
samschimek
commited on
Commit
•
25adf6e
1
Parent(s):
69d0a9d
Update app.py
Browse fileschanged inputs to components
app.py
CHANGED
@@ -2,33 +2,25 @@ import gradio as gr
|
|
2 |
from fastai.vision.all import *
|
3 |
import skimage
|
4 |
|
5 |
-
# Load the trained model
|
6 |
learn = load_learner('ripeorrotten_apple.pkl')
|
7 |
|
8 |
-
|
9 |
-
labels = ['ripe', 'rotten']
|
10 |
-
|
11 |
-
# Define the prediction function
|
12 |
def predict(img):
|
13 |
img = PILImage.create(img)
|
14 |
-
pred,
|
15 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
16 |
|
17 |
-
# Customize the Gradio interface
|
18 |
title = "Apple Ripeness Classifier"
|
19 |
description = "Is your apple ripe or rotten? Use this AQCC (apple quality control classifier) trained on web images with fastai."
|
20 |
-
article
|
21 |
-
|
22 |
-
# Example images (ensure these are valid paths or URLs)
|
23 |
examples = ['apple-fruit-ripe.jpg']
|
24 |
-
interpretation
|
25 |
-
enable_queue
|
26 |
|
27 |
-
# Create and launch the Gradio interface
|
28 |
gr.Interface(
|
29 |
fn=predict,
|
30 |
-
inputs=gr.
|
31 |
-
outputs=gr.
|
32 |
title=title,
|
33 |
description=description,
|
34 |
article=article,
|
|
|
2 |
from fastai.vision.all import *
|
3 |
import skimage
|
4 |
|
|
|
5 |
learn = load_learner('ripeorrotten_apple.pkl')
|
6 |
|
7 |
+
labels = ('ripe', 'rotten')
|
|
|
|
|
|
|
8 |
def predict(img):
|
9 |
img = PILImage.create(img)
|
10 |
+
pred,pred_idx,probs = learn.predict(img)
|
11 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
12 |
|
|
|
13 |
title = "Apple Ripeness Classifier"
|
14 |
description = "Is your apple ripe or rotten? Use this AQCC (apple quality control classifier) trained on web images with fastai."
|
15 |
+
article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
|
|
|
|
16 |
examples = ['apple-fruit-ripe.jpg']
|
17 |
+
interpretation='default'
|
18 |
+
enable_queue=True
|
19 |
|
|
|
20 |
gr.Interface(
|
21 |
fn=predict,
|
22 |
+
inputs=gr.components.Image(shape=(512, 512)),
|
23 |
+
outputs=gr.components.Label(num_top_classes=3),
|
24 |
title=title,
|
25 |
description=description,
|
26 |
article=article,
|