Thenujan commited on
Commit
dd27fa4
·
1 Parent(s): a2d67f9

Changed model

Browse files
app.py CHANGED
@@ -23,7 +23,7 @@ model = create_custom_model()
23
  # Load saved weights
24
  model.load_state_dict(
25
  torch.load(
26
- f="./cnn-custom-model-version-3.pt",
27
  map_location=torch.device("cpu"), # load to CPU
28
  )
29
  )
 
23
  # Load saved weights
24
  model.load_state_dict(
25
  torch.load(
26
+ f="./cnn-custom-model-version-5.pt",
27
  map_location=torch.device("cpu"), # load to CPU
28
  )
29
  )
cnn-custom-model-version-4.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:520294eec0d142912af0081c04a2c96046cc0f3dae5c986813a018593be15264
3
+ size 43115
cnn-custom-model-version-5.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c6ed267c84de62f7ee86a28bf3816fb5bf70327314d3197f780e4d44a1bf3355
3
+ size 43115
model.py CHANGED
@@ -5,6 +5,44 @@ import torchvision.models as models
5
  from torch import nn
6
 
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  class ConvModel(nn.Module):
9
  def __init__(self, input_shape, output_shape, hidden_units):
10
  super().__init__()
@@ -23,27 +61,51 @@ class ConvModel(nn.Module):
23
  padding = 1),
24
  nn.ReLU(),
25
  nn.MaxPool2d(kernel_size = 2,
26
- stride = 2))
 
 
27
 
28
  self.block_2 = nn.Sequential(
29
  nn.Conv2d(hidden_units, hidden_units, 3, padding = 1),
30
  nn.ReLU(),
31
  nn.Conv2d(hidden_units, hidden_units, 3, padding = 1),
32
  nn.ReLU(),
33
- nn.MaxPool2d(2))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  self.classifier = nn.Sequential(
36
  nn.Flatten(),
37
- nn.Linear(in_features = 40960, out_features = output_shape))
38
 
39
 
40
  def forward(self, x):
41
  x = self.block_1(x)
42
  x = self.block_2(x)
 
 
 
43
  x = self.classifier(x)
44
  return x
45
 
46
-
47
  def create_custom_model(seed:int=42):
48
  """Creates an EfficientNetB2 feature extractor model and transforms.
49
 
 
5
  from torch import nn
6
 
7
 
8
+ # class ConvModel(nn.Module):
9
+ # def __init__(self, input_shape, output_shape, hidden_units):
10
+ # super().__init__()
11
+
12
+ # self.block_1 = nn.Sequential(
13
+ # nn.Conv2d(in_channels = input_shape,
14
+ # out_channels = hidden_units,
15
+ # kernel_size = 3,
16
+ # stride = 1,
17
+ # padding = 1),
18
+ # nn.ReLU(),
19
+ # nn.Conv2d(in_channels = hidden_units,
20
+ # out_channels = hidden_units,
21
+ # kernel_size = 3,
22
+ # stride = 1,
23
+ # padding = 1),
24
+ # nn.ReLU(),
25
+ # nn.MaxPool2d(kernel_size = 2,
26
+ # stride = 2))
27
+
28
+ # self.block_2 = nn.Sequential(
29
+ # nn.Conv2d(hidden_units, hidden_units, 3, padding = 1),
30
+ # nn.ReLU(),
31
+ # nn.Conv2d(hidden_units, hidden_units, 3, padding = 1),
32
+ # nn.ReLU(),
33
+ # nn.MaxPool2d(2))
34
+
35
+ # self.classifier = nn.Sequential(
36
+ # nn.Flatten(),
37
+ # nn.Linear(in_features = 40960, out_features = output_shape))
38
+
39
+
40
+ # def forward(self, x):
41
+ # x = self.block_1(x)
42
+ # x = self.block_2(x)
43
+ # x = self.classifier(x)
44
+ # return x
45
+
46
  class ConvModel(nn.Module):
47
  def __init__(self, input_shape, output_shape, hidden_units):
48
  super().__init__()
 
61
  padding = 1),
62
  nn.ReLU(),
63
  nn.MaxPool2d(kernel_size = 2,
64
+ stride = 2),
65
+ # nn.BatchNorm2d()
66
+ )
67
 
68
  self.block_2 = nn.Sequential(
69
  nn.Conv2d(hidden_units, hidden_units, 3, padding = 1),
70
  nn.ReLU(),
71
  nn.Conv2d(hidden_units, hidden_units, 3, padding = 1),
72
  nn.ReLU(),
73
+ nn.MaxPool2d(2),
74
+ # nn.BatchNorm2d()
75
+ )
76
+
77
+ self.block_3 = nn.Sequential(
78
+ nn.Conv2d(hidden_units, hidden_units, 3, padding = 1),
79
+ nn.ReLU(),
80
+ nn.Conv2d(hidden_units, hidden_units, 3, padding = 1),
81
+ nn.ReLU(),
82
+ nn.MaxPool2d(2),
83
+ # nn.BatchNorm2d()
84
+ )
85
+
86
+ self.block_4 = nn.Sequential(
87
+ nn.Conv2d(hidden_units, hidden_units, 3, padding = 1),
88
+ nn.ReLU(),
89
+ nn.Conv2d(hidden_units, hidden_units, 3, padding = 1),
90
+ nn.ReLU(),
91
+ nn.MaxPool2d(2),
92
+ # nn.BatchNorm2d()
93
+ )
94
 
95
  self.classifier = nn.Sequential(
96
  nn.Flatten(),
97
+ nn.Linear(in_features = 5120, out_features = output_shape))
98
 
99
 
100
  def forward(self, x):
101
  x = self.block_1(x)
102
  x = self.block_2(x)
103
+ x = self.block_3(x)
104
+ x = self.block_4(x)
105
+ # print(x.shape)
106
  x = self.classifier(x)
107
  return x
108
 
 
109
  def create_custom_model(seed:int=42):
110
  """Creates an EfficientNetB2 feature extractor model and transforms.
111