Spaces:
Sleeping
Sleeping
Commit
•
630ff4d
1
Parent(s):
b4732cc
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
from fastai.vision.all import *
|
2 |
import gradio as gr
|
|
|
|
|
3 |
|
4 |
-
# Load the trained model
|
5 |
learn = load_learner('ripeorrotten_apple.pkl')
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
#
|
16 |
-
|
17 |
-
|
|
|
18 |
|
19 |
-
|
20 |
-
intf.launch()
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
|
|
|
5 |
learn = load_learner('ripeorrotten_apple.pkl')
|
6 |
|
7 |
+
labels = learn.dls.vocab
|
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 = "Ripe or Rotten Apple Classifier"
|
14 |
+
description = "A apple quality control classifier (AQCC) 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(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
|
|