8uydz commited on
Commit
3945011
·
1 Parent(s): 25f174a

create app

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf', 'multi_classifycation']
2
+
3
+ from fastai.vision.all import *
4
+ import gradio as gr
5
+ import timm
6
+
7
+ #load model
8
+ learn = load_learner('convnext_tiny_for_paddy_disease.pkl')
9
+
10
+ categories = learn.dls.vocab
11
+
12
+ def tensor2labels(img):
13
+ pred = learn.predict(img)
14
+ predict = torch.where(pred[1].sigmoid()>0.4)[0]
15
+ return categories[predict]
16
+
17
+
18
+ gr.components
19
+
20
+ image = gr.inputs.Image(shape=(192, 192))
21
+ label = gr.outputs.Label()
22
+ examples = []
23
+
24
+ intf = gr.Interface(fn=tensor2labels, inputs=image, outputs=label, examples=examples)
25
+ intf.launch()