Spaces:
Sleeping
Sleeping
Delete model.py
Browse files
model.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
import torch.nn as nn
|
| 2 |
-
from torchvision import models
|
| 3 |
-
|
| 4 |
-
class FoodIngredientClassifier(nn.Module):
|
| 5 |
-
def __init__(self, num_classes):
|
| 6 |
-
super().__init__()
|
| 7 |
-
|
| 8 |
-
self.backbone = models.vit_b_16(
|
| 9 |
-
weights=models.ViT_B_16_Weights.DEFAULT
|
| 10 |
-
)
|
| 11 |
-
|
| 12 |
-
num_features = self.backbone.heads.head.in_features
|
| 13 |
-
|
| 14 |
-
self.backbone.heads = nn.Sequential(
|
| 15 |
-
nn.Dropout(0.5),
|
| 16 |
-
nn.Linear(num_features, 1024),
|
| 17 |
-
nn.BatchNorm1d(1024),
|
| 18 |
-
nn.ReLU(),
|
| 19 |
-
nn.Dropout(0.4),
|
| 20 |
-
nn.Linear(1024, 512),
|
| 21 |
-
nn.BatchNorm1d(512),
|
| 22 |
-
nn.ReLU(),
|
| 23 |
-
nn.Dropout(0.3),
|
| 24 |
-
nn.Linear(512, num_classes)
|
| 25 |
-
)
|
| 26 |
-
|
| 27 |
-
def forward(self, x):
|
| 28 |
-
return self.backbone(x)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|