Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
from fastai.vision.all import *
|
3 |
import skimage
|
4 |
-
|
5 |
|
6 |
learn = load_learner('model.pkl')
|
7 |
-
#from huggingface_hub import from_pretrained_fastai
|
8 |
-
#learn = from_pretrained_fastai("devdatanalytics/commonbean")
|
9 |
|
10 |
labels = learn.dls.vocab
|
|
|
11 |
def predict(img):
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
15 |
|
16 |
-
#
|
17 |
-
#description = "An app for Common beans diseases Classisfication"
|
18 |
-
#article="<p style='text-align: center'>The app identifies and classifies common beans diseases: Anthracnose and Bean rust.</p>"
|
19 |
-
# Create the Gradio interface
|
20 |
-
interface = gr.Interface(
|
21 |
-
fn=predict,
|
22 |
-
inputs=gr.Image(),
|
23 |
-
outputs=gr.Label(num_top_classes=3)
|
24 |
-
)
|
25 |
|
26 |
-
#
|
27 |
-
|
28 |
|
29 |
-
# Launch the interface
|
30 |
-
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from fastai.vision.all import *
|
3 |
import skimage
|
4 |
+
from fastai.vision.all import PILImage
|
5 |
|
6 |
learn = load_learner('model.pkl')
|
|
|
|
|
7 |
|
8 |
labels = learn.dls.vocab
|
9 |
+
|
10 |
def predict(img):
|
11 |
+
img = PILImage.create(img)
|
12 |
+
img = img.resize((512, 512))
|
13 |
+
pred,pred_idx,probs = learn.predict(img)
|
14 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
15 |
|
16 |
+
#examples = ['image.jpg']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
#gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
|
19 |
+
gr.Interface(fn=predict,inputs=gr.Image(),outputs=gr.Label(num_top_classes=3)).launch().share=True
|
20 |
|
|
|
|