Commit
·
160cb15
1
Parent(s):
3d8ee2c
updated the model
Browse files
app.py
CHANGED
@@ -9,19 +9,8 @@ import random
|
|
9 |
|
10 |
device = torch.device('cpu')
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
os.environ['PYTHONHASHSEED'] = str(seed)
|
15 |
-
np.random.seed(seed)
|
16 |
-
torch.manual_seed(seed)
|
17 |
-
torch.cuda.manual_seed(seed)
|
18 |
-
torch.backends.cudnn.deterministic = True
|
19 |
-
torch.backends.cudnn.benchmark = True
|
20 |
-
|
21 |
-
seed_everything(seed=42)
|
22 |
-
|
23 |
-
|
24 |
-
labels = {0: 'bacterial_leaf_blight',
|
25 |
1: 'bacterial_leaf_streak',
|
26 |
2: 'bacterial_panicle_blight',
|
27 |
3: 'blast',
|
@@ -30,7 +19,8 @@ labels = {0: 'bacterial_leaf_blight',
|
|
30 |
6: 'downy_mildew',
|
31 |
7: 'hispa',
|
32 |
8: 'normal',
|
33 |
-
9: 'tungro'
|
|
|
34 |
|
35 |
def inference_fn(model, image=None):
|
36 |
model.eval()
|
@@ -41,8 +31,7 @@ def inference_fn(model, image=None):
|
|
41 |
return out
|
42 |
|
43 |
|
44 |
-
def predict(image
|
45 |
-
#image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
46 |
mean = (0.485, 0.456, 0.406)
|
47 |
std = (0.229, 0.224, 0.225)
|
48 |
|
@@ -71,4 +60,4 @@ def predict(image = None) :
|
|
71 |
gr.Interface(fn=predict,
|
72 |
inputs=gr.inputs.Image(),
|
73 |
outputs=gr.outputs.Label(num_top_classes=10),
|
74 |
-
examples=["200005.jpg", "200006.jpg"]).launch()
|
|
|
9 |
|
10 |
device = torch.device('cpu')
|
11 |
|
12 |
+
labels = {
|
13 |
+
0: 'bacterial_leaf_blight',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
1: 'bacterial_leaf_streak',
|
15 |
2: 'bacterial_panicle_blight',
|
16 |
3: 'blast',
|
|
|
19 |
6: 'downy_mildew',
|
20 |
7: 'hispa',
|
21 |
8: 'normal',
|
22 |
+
9: 'tungro'
|
23 |
+
}
|
24 |
|
25 |
def inference_fn(model, image=None):
|
26 |
model.eval()
|
|
|
31 |
return out
|
32 |
|
33 |
|
34 |
+
def predict(image=None) -> dict:
|
|
|
35 |
mean = (0.485, 0.456, 0.406)
|
36 |
std = (0.229, 0.224, 0.225)
|
37 |
|
|
|
60 |
gr.Interface(fn=predict,
|
61 |
inputs=gr.inputs.Image(),
|
62 |
outputs=gr.outputs.Label(num_top_classes=10),
|
63 |
+
examples=["200005.jpg", "200006.jpg"], interpretation='default', capture_session=True).launch(share=True)
|