jumashafara commited on
Commit
dd61043
·
1 Parent(s): 3478e90

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import timm
2
+ import wandb
3
+ import gradio as gr
4
+ from pathlib import Path
5
+ from fastai.vision.all import load_learner
6
+
7
+ wandb.login(key='4d2ff70f59f0bfc0397e9fea4300819244bf3fce')
8
+ wandb.init(
9
+ name='pepper_fastai_gradio',
10
+ project='plant_disease_detection',
11
+ entity='jumashafara',
12
+ )
13
+
14
+ categories = ['bacterial_spot', 'healthy']
15
+
16
+ learner = load_learner(Path('pepper_fastai_model.pkl'))
17
+
18
+ def classify(img):
19
+ category, index, probs = learner.predict(img)
20
+ return (dict(zip(categories, map(float, probs))))
21
+
22
+ image = gr.inputs.Image(shape=(224))
23
+ label = gr.outputs.Label()
24
+ example = []
25
+
26
+ interface = gr.Interface(fn=classify,
27
+ inputs='image',
28
+ outputs='label',
29
+ example=example)
30
+
31
+ interface.launch()