Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
YangLiu9208 committed Jun 7, 2023
1 parent c54fee5 commit 33c95d9
Show file tree
Hide file tree
Showing 470 changed files with 236,430 additions and 0 deletions.
Binary file removed model.rar
Binary file not shown.
Empty file added model/__init__.py
Empty file.
Binary file added model/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added model/__pycache__/embedding.cpython-37.pyc
Binary file not shown.
1,014 changes: 1,014 additions & 0 deletions model/backbone/TRN.py

Large diffs are not rendered by default.

1,001 changes: 1,001 additions & 0 deletions model/backbone/TRN_resnet18.py

Large diffs are not rendered by default.

998 changes: 998 additions & 0 deletions model/backbone/TRN_resnet50.py

Large diffs are not rendered by default.

687 changes: 687 additions & 0 deletions model/backbone/TSN.py

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions model/backbone/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from .inception.google import GoogleNet
from .inception.v1bn import InceptionV1BN
from .resnet import ResNet50, ResNet18, Semantic_ResNet18, Semantic_ResNet50
from .vggnet import VggNet16
from .vggnet import SeVggNet16
from .vggnet import SeFusionVGG16
from .vggnet import SeFusionVGG16_MMAct
from .vggnet import SeFusionVGG16_Berkeley
from .vggnet import SemanticFusionVGG16
from .vggnet import SemanticFusionVGG16_MMAct
from .vggnet import SemanticFusionVGG16_Berkeley
from .TSN import TSN
from .TRN import TRN
from .TRN_resnet18 import TRN_resnet18
from .TRN_resnet50 import TRN_resnet50
Binary file added model/backbone/__pycache__/TRN.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added model/backbone/__pycache__/TSM.cpython-37.pyc
Binary file not shown.
Binary file added model/backbone/__pycache__/TSN.cpython-37.pyc
Binary file not shown.
Binary file added model/backbone/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file added model/backbone/__pycache__/resnet.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file added model/backbone/__pycache__/vggnet.cpython-37.pyc
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
106 changes: 106 additions & 0 deletions model/backbone/resnet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import torchvision
import torch.nn as nn

__all__ = ['ResNet18', 'ResNet50','Semantic_ResNet18','Semantic_ResNet50']


class ResNet18(nn.Module):
#output_size = 512

def __init__(self,n_classes):
super(ResNet18, self).__init__()
pretrained = torchvision.models.resnet18(pretrained=True)

for module_name in ['conv1', 'bn1', 'relu', 'maxpool', 'layer1', 'layer2', 'layer3', 'layer4', 'avgpool']:
self.add_module(module_name, getattr(pretrained, module_name))
self.fc = nn.Linear(512, n_classes)
def forward(self, x, get_ha=False):
x = self.maxpool(self.relu(self.bn1(self.conv1(x))))
b1 = self.layer1(x)
b2 = self.layer2(b1)
b3 = self.layer3(b2)
b4 = self.layer4(b3)
pool = self.avgpool(b4)
pool = pool.view(pool.size(0), -1)
out = self.fc(pool)
if get_ha:
return b1, b2, b3, b4, pool, out

return out


class ResNet50(nn.Module):
#output_size = 2048

def __init__(self, n_classes):
super(ResNet50, self).__init__()
pretrained = torchvision.models.resnet50(pretrained=True)

for module_name in ['conv1', 'bn1', 'relu', 'maxpool', 'layer1', 'layer2', 'layer3', 'layer4', 'avgpool']:
self.add_module(module_name, getattr(pretrained, module_name))
self.fc = nn.Linear(2048, n_classes)
def forward(self, x, get_ha=False):
x = self.maxpool(self.relu(self.bn1(self.conv1(x))))
b1 = self.layer1(x)
b2 = self.layer2(b1)
b3 = self.layer3(b2)
b4 = self.layer4(b3)
pool = self.avgpool(b4)
pool = pool.view(pool.size(0), -1)
out = self.fc(pool)
if get_ha:
return b1, b2, b3, b4, pool, out

return out

class Semantic_ResNet18(nn.Module):
#output_size = 512

def __init__(self,n_classes):
super(Semantic_ResNet18, self).__init__()
pretrained = torchvision.models.resnet18(pretrained=True)

for module_name in ['conv1', 'bn1', 'relu', 'maxpool', 'layer1', 'layer2', 'layer3', 'layer4', 'avgpool']:
self.add_module(module_name, getattr(pretrained, module_name))
self.fc1 = nn.Linear(512, 300)
self.fc2 = nn.Linear(300, n_classes)
def forward(self, x, get_ha=False):
x = self.maxpool(self.relu(self.bn1(self.conv1(x))))
b1 = self.layer1(x)
b2 = self.layer2(b1)
b3 = self.layer3(b2)
b4 = self.layer4(b3)
pool = self.avgpool(b4)
pool = pool.view(pool.size(0), -1)
semantic = self.fc1(pool)
out = self.fc2(semantic)
if get_ha:
return b1, b2, b3, b4, semantic, out

return out

class Semantic_ResNet50(nn.Module):
#output_size = 2048

def __init__(self,n_classes):
super(Semantic_ResNet50, self).__init__()
pretrained = torchvision.models.resnet50(pretrained=True)

for module_name in ['conv1', 'bn1', 'relu', 'maxpool', 'layer1', 'layer2', 'layer3', 'layer4', 'avgpool']:
self.add_module(module_name, getattr(pretrained, module_name))
self.fc1 = nn.Linear(2048, 300)
self.fc2 = nn.Linear(300, n_classes)
def forward(self, x, get_ha=False):
x = self.maxpool(self.relu(self.bn1(self.conv1(x))))
b1 = self.layer1(x)
b2 = self.layer2(b1)
b3 = self.layer3(b2)
b4 = self.layer4(b3)
pool = self.avgpool(b4)
pool = pool.view(pool.size(0), -1)
semantic = self.fc1(pool)
out = self.fc2(semantic)
if get_ha:
return b1, b2, b3, b4, semantic, out

return out
Loading

0 comments on commit 33c95d9

Please sign in to comment.