Spaces:
Running
on
Zero
Running
on
Zero
Delete vgg16.py
Browse files
vgg16.py
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
import torch.nn as nn
|
2 |
-
import torchvision.models as models
|
3 |
-
|
4 |
-
class VGG_16(nn.Module):
|
5 |
-
def __init__(self):
|
6 |
-
super(VGG_16, self).__init__()
|
7 |
-
self.model = models.vgg16(weights='DEFAULT').features[:30]
|
8 |
-
|
9 |
-
for i, _ in enumerate(self.model):
|
10 |
-
if i in [4, 9, 16, 23]:
|
11 |
-
self.model[i] = nn.AvgPool2d(kernel_size=2, stride=2, padding=0)
|
12 |
-
|
13 |
-
def forward(self, x):
|
14 |
-
features = []
|
15 |
-
|
16 |
-
for i, layer in enumerate(self.model):
|
17 |
-
x = layer(x)
|
18 |
-
if i in [0, 5, 10, 17, 24]:
|
19 |
-
features.append(x)
|
20 |
-
return features
|
21 |
-
|
22 |
-
|
23 |
-
if __name__ == '__main__':
|
24 |
-
model = VGG_16()
|
25 |
-
print(model)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|