Add app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import pathlib
|
| 4 |
+
learn = load_learner('model.pkl')
|
| 5 |
+
categories = ('Empty','Healthy', 'Wilted')
|
| 6 |
+
|
| 7 |
+
def classify_img(img):
|
| 8 |
+
pred, idx, probs = learn.predict(img)
|
| 9 |
+
return dict(zip(categories, map(float,probs)))
|
| 10 |
+
|
| 11 |
+
image = gr.Image(shape=(192,192))
|
| 12 |
+
label = gr.Label()
|
| 13 |
+
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples= ['healthy_hydro_kale.jpg', 'wilted_plant.jpg', 'empty_trays.jpg'])
|
| 14 |
+
intf.launch(inline=False)
|