Spaces:
Sleeping
Sleeping
| import torch.nn as nn | |
| class EmotionCNN(nn.Module): | |
| def __init__(self, num_classes=7): | |
| super(EmotionCNN, self).__init__() | |
| self.conv_layers = nn.Sequential( | |
| nn.Conv2d(1, 32, kernel_size=3, padding=1), | |
| nn.ReLU(), nn.MaxPool2d(2), | |
| nn.Conv2d(32, 64, kernel_size=3, padding=1), | |
| nn.ReLU(), nn.MaxPool2d(2), | |
| nn.Conv2d(64, 128, kernel_size=3, padding=1), | |
| nn.ReLU(), nn.MaxPool2d(2) | |
| ) | |
| self.fc_layers = nn.Sequential( | |
| nn.Flatten(), | |
| nn.Linear(128 * 6 * 6, 256), | |
| nn.ReLU(), | |
| nn.Dropout(0.5), | |
| nn.Linear(256, num_classes) # Now dynamic! | |
| ) | |
| def forward(self, x): | |
| x = self.conv_layers(x) | |
| x = self.fc_layers(x) | |
| return x | |