Abuzaid01 commited on
Commit
6ec32d7
·
verified ·
1 Parent(s): a732887

Upload model.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. model.py +24 -0
model.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ from torchvision import models
4
+
5
+ class ASLResNet(nn.Module):
6
+ def __init__(self, num_classes):
7
+ super(ASLResNet, self).__init__()
8
+
9
+ # Load pre-trained ResNet-50
10
+ self.model = models.resnet50(pretrained=True)
11
+
12
+ # Replace classifier head
13
+ num_features = self.model.fc.in_features
14
+ self.model.fc = nn.Sequential(
15
+ nn.Dropout(0.3),
16
+ nn.Linear(num_features, 512),
17
+ nn.BatchNorm1d(512),
18
+ nn.ReLU(),
19
+ nn.Dropout(0.2),
20
+ nn.Linear(512, num_classes)
21
+ )
22
+
23
+ def forward(self, x):
24
+ return self.model(x)