rakgesh commited on
Commit
dce4ee2
1 Parent(s): f841f84

Upload 2 files

Browse files
Files changed (2) hide show
  1. CNN.py +108 -0
  2. plant_disease_model_1_latest.pt +3 -0
CNN.py ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import torch.nn as nn
3
+
4
+ class CNN(nn.Module):
5
+ def __init__(self, K):
6
+ super(CNN, self).__init__()
7
+ self.conv_layers = nn.Sequential(
8
+ # conv1
9
+ nn.Conv2d(in_channels=3, out_channels=32,
10
+ kernel_size=3, padding=1),
11
+ nn.ReLU(),
12
+ nn.BatchNorm2d(32),
13
+ nn.Conv2d(in_channels=32, out_channels=32,
14
+ kernel_size=3, padding=1),
15
+ nn.ReLU(),
16
+ nn.BatchNorm2d(32),
17
+ nn.MaxPool2d(2),
18
+ # conv2
19
+ nn.Conv2d(in_channels=32, out_channels=64,
20
+ kernel_size=3, padding=1),
21
+ nn.ReLU(),
22
+ nn.BatchNorm2d(64),
23
+ nn.Conv2d(in_channels=64, out_channels=64,
24
+ kernel_size=3, padding=1),
25
+ nn.ReLU(),
26
+ nn.BatchNorm2d(64),
27
+ nn.MaxPool2d(2),
28
+ # conv3
29
+ nn.Conv2d(in_channels=64, out_channels=128,
30
+ kernel_size=3, padding=1),
31
+ nn.ReLU(),
32
+ nn.BatchNorm2d(128),
33
+ nn.Conv2d(in_channels=128, out_channels=128,
34
+ kernel_size=3, padding=1),
35
+ nn.ReLU(),
36
+ nn.BatchNorm2d(128),
37
+ nn.MaxPool2d(2),
38
+ # conv4
39
+ nn.Conv2d(in_channels=128, out_channels=256,
40
+ kernel_size=3, padding=1),
41
+ nn.ReLU(),
42
+ nn.BatchNorm2d(256),
43
+ nn.Conv2d(in_channels=256, out_channels=256,
44
+ kernel_size=3, padding=1),
45
+ nn.ReLU(),
46
+ nn.BatchNorm2d(256),
47
+ nn.MaxPool2d(2),
48
+ )
49
+
50
+ self.dense_layers = nn.Sequential(
51
+ nn.Dropout(0.4),
52
+ nn.Linear(50176, 1024),
53
+ nn.ReLU(),
54
+ nn.Dropout(0.4),
55
+ nn.Linear(1024, K),
56
+ )
57
+
58
+ def forward(self, X):
59
+ out = self.conv_layers(X)
60
+
61
+ # Flatten
62
+ out = out.view(-1, 50176)
63
+
64
+ # Fully connected
65
+ out = self.dense_layers(out)
66
+
67
+ return out
68
+
69
+
70
+ idx_to_classes = {0: 'Apple___Apple_scab',
71
+ 1: 'Apple___Black_rot',
72
+ 2: 'Apple___Cedar_apple_rust',
73
+ 3: 'Apple___healthy',
74
+ 4: 'Background_without_leaves',
75
+ 5: 'Blueberry___healthy',
76
+ 6: 'Cherry___Powdery_mildew',
77
+ 7: 'Cherry___healthy',
78
+ 8: 'Corn___Cercospora_leaf_spot Gray_leaf_spot',
79
+ 9: 'Corn___Common_rust',
80
+ 10: 'Corn___Northern_Leaf_Blight',
81
+ 11: 'Corn___healthy',
82
+ 12: 'Grape___Black_rot',
83
+ 13: 'Grape___Esca_(Black_Measles)',
84
+ 14: 'Grape___Leaf_blight_(Isariopsis_Leaf_Spot)',
85
+ 15: 'Grape___healthy',
86
+ 16: 'Orange___Haunglongbing_(Citrus_greening)',
87
+ 17: 'Peach___Bacterial_spot',
88
+ 18: 'Peach___healthy',
89
+ 19: 'Pepper,_bell___Bacterial_spot',
90
+ 20: 'Pepper,_bell___healthy',
91
+ 21: 'Potato___Early_blight',
92
+ 22: 'Potato___Late_blight',
93
+ 23: 'Potato___healthy',
94
+ 24: 'Raspberry___healthy',
95
+ 25: 'Soybean___healthy',
96
+ 26: 'Squash___Powdery_mildew',
97
+ 27: 'Strawberry___Leaf_scorch',
98
+ 28: 'Strawberry___healthy',
99
+ 29: 'Tomato___Bacterial_spot',
100
+ 30: 'Tomato___Early_blight',
101
+ 31: 'Tomato___Late_blight',
102
+ 32: 'Tomato___Leaf_Mold',
103
+ 33: 'Tomato___Septoria_leaf_spot',
104
+ 34: 'Tomato___Spider_mites Two-spotted_spider_mite',
105
+ 35: 'Tomato___Target_Spot',
106
+ 36: 'Tomato___Tomato_Yellow_Leaf_Curl_Virus',
107
+ 37: 'Tomato___Tomato_mosaic_virus',
108
+ 38: 'Tomato___healthy'}
plant_disease_model_1_latest.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1a60ecd77e31d64dc726e1cca0ea43d0cbec0cf2088bb403f44f0e2720c23bb1
3
+ size 210409423