Skip to content

Commit

Permalink
Merge pull request #157 from thearyadev/151-add-new-model
Browse files Browse the repository at this point in the history
151 add new model
  • Loading branch information
thearyadev authored Feb 16, 2024
2 parents 693c1c1 + 9f62305 commit 9898abe
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 1 deletion.
2 changes: 1 addition & 1 deletion classifier/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def main() -> int:
shutil.copy(Path("./classifier/model.py"), model_dir / "frozen_model.py")

with open(model_dir / "detail", "w+") as file:
file.writelines(info_file)
file.write("\n".join(info_file))

with open(model_dir / "__init__.py", "w+") as file:
file.write("from .frozen_model import transformer, NNModel as FrozenNeuralNetworkModel")
Expand Down
1 change: 1 addition & 0 deletions models/thearyadev-initial-15-02-2024/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .frozen_model import transformer, NNModel as FrozenNeuralNetworkModel
40 changes: 40 additions & 0 deletions models/thearyadev-initial-15-02-2024/classes
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
0
1
10
11
12
13
14
15
16
17
18
19
2
20
21
22
23
24
25
26
27
28
29
3
30
31
32
33
34
35
36
37
38
39
4
40
6
7
8
9
12 changes: 12 additions & 0 deletions models/thearyadev-initial-15-02-2024/detail
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Model Name: thearyadev-initial-15-02-2024
Class Size: 250
Epoch 1: Validation Loss: 0.0213, Accuracy: 1.00
Epoch 2: Validation Loss: 0.0083, Accuracy: 1.00
Epoch 3: Validation Loss: 0.0045, Accuracy: 1.00
Epoch 4: Validation Loss: 0.0027, Accuracy: 1.00
Epoch 5: Validation Loss: 0.0019, Accuracy: 1.00
Epoch 6: Validation Loss: 0.0013, Accuracy: 1.00
Epoch 7: Validation Loss: 0.0010, Accuracy: 1.00
Epoch 8: Validation Loss: 0.0007, Accuracy: 1.00
Epoch 9: Validation Loss: 0.0006, Accuracy: 1.00
Epoch 10: Validation Loss: 0.0005, Accuracy: 1.00
28 changes: 28 additions & 0 deletions models/thearyadev-initial-15-02-2024/frozen_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""this module is written with the help of chatgpt"""
import torchvision.transforms as transforms # type: ignore
import torch.nn as nn
import torch.nn.functional as F

transformer = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])

class NNModel(nn.Module):
def __init__(self, num_classes: int) -> None:
super(NNModel, self).__init__()
self.conv1 = nn.Conv2d(3, 6, 5)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(6, 16, 5)
self.fc1 = nn.Linear(16 * 8 * 22, 120)
self.fc2 = nn.Linear(120, 84)
self.fc3 = nn.Linear(84, num_classes)

def forward(self, x):
x = self.pool(F.relu(self.conv1(x)))
x = self.pool(F.relu(self.conv2(x)))
x = x.view(-1, 16 * 8 * 22)
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
Binary file added models/thearyadev-initial-15-02-2024/model.pth
Binary file not shown.

0 comments on commit 9898abe

Please sign in to comment.