Spaces:
Runtime error
Runtime error
Update model/backbones/mobilenetv2.py
Browse files
model/backbones/mobilenetv2.py
CHANGED
|
@@ -1,20 +1,12 @@
|
|
| 1 |
import torch.nn as nn
|
| 2 |
-
from torchvision.models import mobilenet_v2
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
| 7 |
class MobileNetV2Backbone(nn.Module):
|
| 8 |
def __init__(self):
|
| 9 |
-
super().__init__()
|
| 10 |
-
|
| 11 |
-
self.model =
|
| 12 |
-
self.enc_channels = [24, 32, 96, 160, 320] # фиксированные выходы энкодера
|
| 13 |
|
| 14 |
def forward(self, x):
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
x = layer(x)
|
| 18 |
-
if idx in {2, 4, 7, 13}:
|
| 19 |
-
features.append(x)
|
| 20 |
-
return features
|
|
|
|
| 1 |
import torch.nn as nn
|
| 2 |
+
from torchvision.models import mobilenet_v2, MobileNet_V2_Weights
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
class MobileNetV2Backbone(nn.Module):
|
| 5 |
def __init__(self):
|
| 6 |
+
super(MobileNetV2Backbone, self).__init__()
|
| 7 |
+
# Используем актуальный способ загрузки предобученной модели
|
| 8 |
+
self.model = mobilenet_v2(weights=MobileNet_V2_Weights.DEFAULT).features
|
|
|
|
| 9 |
|
| 10 |
def forward(self, x):
|
| 11 |
+
return self.model(x)
|
| 12 |
+
|
|
|
|
|
|
|
|
|
|
|
|