kausmos commited on
Commit
6017fdf
β€’
1 Parent(s): 694e43c

✌🏻 add model script and saved weights

Browse files
models/__pycache__/model.cpython-38.pyc ADDED
Binary file (1.47 kB). View file
 
models/labels.txt ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ alif
2
+ alif mad aa
3
+ ayn
4
+ baa
5
+ bari yaa
6
+ cheey
7
+ choti yaa
8
+ daal
9
+ dhaal
10
+ faa
11
+ gaaf
12
+ ghain
13
+ haa1
14
+ haa2
15
+ haa3
16
+ hamza
17
+ jeem
18
+ kaaf
19
+ khaa
20
+ laam
21
+ meem
22
+ noon
23
+ noonghunna
models/model.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Import PyTorch
2
+ import torch
3
+ from torch import nn
4
+
5
+
6
+ # Import matplotlib for visualization
7
+ import matplotlib.pyplot as plt
8
+
9
+ torch.manual_seed(42)
10
+
11
+ class TinyVGG(nn.Module):
12
+ """
13
+ Model architecture copying TinyVGG from:
14
+ https://poloclub.github.io/cnn-explainer/
15
+ """
16
+ def __init__(self, input_shape: int, hidden_units: int, output_shape: int) -> None:
17
+ super().__init__()
18
+ self.conv_block_1 = nn.Sequential(
19
+ nn.Conv2d(in_channels=input_shape,
20
+ out_channels=hidden_units,
21
+ kernel_size=3, # how big is the square that's going over the image?
22
+ stride=1, # default
23
+ padding=1), # options = "valid" (no padding) or "same" (output has same shape as input) or int for specific number
24
+ nn.ReLU(),
25
+ nn.Conv2d(in_channels=hidden_units,
26
+ out_channels=hidden_units,
27
+ kernel_size=3,
28
+ stride=1,
29
+ padding=1),
30
+ nn.ReLU(),
31
+ nn.MaxPool2d(kernel_size=2,
32
+ stride=2) # default stride value is same as kernel_size
33
+ )
34
+ self.conv_block_2 = nn.Sequential(
35
+ nn.Conv2d(hidden_units, hidden_units, kernel_size=3, padding=1),
36
+ nn.ReLU(),
37
+ nn.Conv2d(hidden_units, hidden_units, kernel_size=3, padding=1),
38
+ nn.ReLU(),
39
+ nn.MaxPool2d(2)
40
+ )
41
+ self.classifier = nn.Sequential(
42
+ nn.Flatten(),
43
+ # Where did this in_features shape come from?
44
+ # It's because each layer of our network compresses and changes the shape of our inputs data.
45
+ nn.Linear(in_features=hidden_units*16*16,
46
+ out_features=output_shape)
47
+ )
48
+
49
+ def forward(self, x: torch.Tensor):
50
+ x = self.conv_block_1(x)
51
+ # print(x.shape)
52
+ x = self.conv_block_2(x)
53
+ # print(x.shape)
54
+ x = self.classifier(x)
55
+ # print(x.shape)
56
+ return x
57
+ # return self.classifier(self.conv_block_2(self.conv_block_1(x))) # <- leverage the benefits of operator fusion
58
+
models/saved/01_pytorch_workflow_model_0.pth ADDED
Binary file (251 kB). View file