Python torchvision.models.resnet34() Examples
The following are 30
code examples of torchvision.models.resnet34().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
torchvision.models
, or try the search function
.
Example #1
Source File: resnet_encoder.py From packnet-sfm with MIT License | 8 votes |
def __init__(self, num_layers, pretrained, num_input_images=1): super(ResnetEncoder, self).__init__() self.num_ch_enc = np.array([64, 64, 128, 256, 512]) resnets = {18: models.resnet18, 34: models.resnet34, 50: models.resnet50, 101: models.resnet101, 152: models.resnet152} if num_layers not in resnets: raise ValueError("{} is not a valid number of resnet layers".format(num_layers)) if num_input_images > 1: self.encoder = resnet_multiimage_input(num_layers, pretrained, num_input_images) else: self.encoder = resnets[num_layers](pretrained) if num_layers > 34: self.num_ch_enc[1:] *= 4
Example #2
Source File: pretrained_networks.py From PerceptualSimilarity with BSD 2-Clause "Simplified" License | 6 votes |
def __init__(self, requires_grad=False, pretrained=True, num=18): super(resnet, self).__init__() if(num==18): self.net = tv.resnet18(pretrained=pretrained) elif(num==34): self.net = tv.resnet34(pretrained=pretrained) elif(num==50): self.net = tv.resnet50(pretrained=pretrained) elif(num==101): self.net = tv.resnet101(pretrained=pretrained) elif(num==152): self.net = tv.resnet152(pretrained=pretrained) self.N_slices = 5 self.conv1 = self.net.conv1 self.bn1 = self.net.bn1 self.relu = self.net.relu self.maxpool = self.net.maxpool self.layer1 = self.net.layer1 self.layer2 = self.net.layer2 self.layer3 = self.net.layer3 self.layer4 = self.net.layer4
Example #3
Source File: pretrained_networks.py From TecoGAN with Apache License 2.0 | 6 votes |
def __init__(self, requires_grad=False, pretrained=True, num=18): super(resnet, self).__init__() if(num==18): self.net = models.resnet18(pretrained=pretrained) elif(num==34): self.net = models.resnet34(pretrained=pretrained) elif(num==50): self.net = models.resnet50(pretrained=pretrained) elif(num==101): self.net = models.resnet101(pretrained=pretrained) elif(num==152): self.net = models.resnet152(pretrained=pretrained) self.N_slices = 5 self.conv1 = self.net.conv1 self.bn1 = self.net.bn1 self.relu = self.net.relu self.maxpool = self.net.maxpool self.layer1 = self.net.layer1 self.layer2 = self.net.layer2 self.layer3 = self.net.layer3 self.layer4 = self.net.layer4
Example #4
Source File: resnet.py From deeplabv3plus-pytorch with MIT License | 6 votes |
def __init__(self, layers, atrous, pretrained=True): super(ResNet, self).__init__() self.inner_layer = [] if layers == 18: self.backbone = models.resnet18(pretrained=pretrained) elif layers == 34: self.backbone = models.resnet34(pretrained=pretrained) elif layers == 50: self.backbone = models.resnet50(pretrained=pretrained) elif layers == 101: self.backbone = models.resnet101(pretrained=pretrained) elif layers == 152: self.backbone = models.resnet152(pretrained=pretrained) else: raise ValueError('resnet.py: network layers is no support yet') def hook_func(module, input, output): self.inner_layer.append(output) self.backbone.layer1.register_forward_hook(hook_func) self.backbone.layer2.register_forward_hook(hook_func) self.backbone.layer3.register_forward_hook(hook_func) self.backbone.layer4.register_forward_hook(hook_func)
Example #5
Source File: frontend.py From pase with MIT License | 6 votes |
def __init__(self, sinc_out, hidden_dim, sinc_kernel=251, sinc_stride=1, conv_stride=5, kernel_size=21, pretrained=True,name="Resnet50"): super().__init__(name=name) self.sinc = SincConv_fast(1, sinc_out, sinc_kernel, sample_rate=16000, padding='SAME', stride=sinc_stride, pad_mode='reflect' ) self.conv1 = nn.Sequential(nn.Conv2d(1, 64, kernel_size=kernel_size, stride=conv_stride, padding= kernel_size // 2, bias=False), nn.BatchNorm2d(64), nn.ReLU(64)) resnet = models.resnet34(pretrained=pretrained) self.resnet = nn.Sequential(resnet.layer1, resnet.layer2, resnet.layer3, resnet.layer4 ) self.conv2 = nn.Sequential(nn.Conv2d(512, 256, kernel_size=[2, 1], stride=1, bias=False)) self.emb_dim = hidden_dim
Example #6
Source File: resnet_encoder.py From SC-SfMLearner-Release with GNU General Public License v3.0 | 6 votes |
def __init__(self, num_layers, pretrained, num_input_images=1): super(ResnetEncoder, self).__init__() self.num_ch_enc = np.array([64, 64, 128, 256, 512]) resnets = {18: models.resnet18, 34: models.resnet34, 50: models.resnet50, 101: models.resnet101, 152: models.resnet152} if num_layers not in resnets: raise ValueError("{} is not a valid number of resnet layers".format(num_layers)) if num_input_images > 1: self.encoder = resnet_multiimage_input(num_layers, pretrained, num_input_images) else: self.encoder = resnets[num_layers](pretrained) if num_layers > 34: self.num_ch_enc[1:] *= 4
Example #7
Source File: imgnet.py From 3DOD_thesis with MIT License | 6 votes |
def __init__(self, model_id, project_dir): super(ImgNet, self).__init__() self.model_id = model_id self.project_dir = project_dir self.create_model_dirs() resnet34 = models.resnet34() # load pretrained model: resnet34.load_state_dict(torch.load("/root/3DOD_thesis/pretrained_models/resnet/resnet34-333f7ec4.pth")) # remove fully connected layer: self.resnet34 = nn.Sequential(*list(resnet34.children())[:-2]) self.avg_pool = nn.AvgPool2d(kernel_size=7) self.fc1 = nn.Linear(512, 256) self.fc2 = nn.Linear(256, 128) self.fc3 = nn.Linear(128, 2*8 + 3 + 1)
Example #8
Source File: resnet.py From deeplabv3 with MIT License | 6 votes |
def __init__(self, num_layers): super(ResNet_BasicBlock_OS16, self).__init__() if num_layers == 18: resnet = models.resnet18() # load pretrained model: resnet.load_state_dict(torch.load("/root/deeplabv3/pretrained_models/resnet/resnet18-5c106cde.pth")) # remove fully connected layer, avg pool and layer5: self.resnet = nn.Sequential(*list(resnet.children())[:-3]) num_blocks = 2 print ("pretrained resnet, 18") elif num_layers == 34: resnet = models.resnet34() # load pretrained model: resnet.load_state_dict(torch.load("/root/deeplabv3/pretrained_models/resnet/resnet34-333f7ec4.pth")) # remove fully connected layer, avg pool and layer5: self.resnet = nn.Sequential(*list(resnet.children())[:-3]) num_blocks = 3 print ("pretrained resnet, 34") else: raise Exception("num_layers must be in {18, 34}!") self.layer5 = make_layer(BasicBlock, in_channels=256, channels=512, num_blocks=num_blocks, stride=1, dilation=2)
Example #9
Source File: pretrained_networks.py From SMIT with MIT License | 6 votes |
def __init__(self, requires_grad=False, pretrained=True, num=18): super(resnet, self).__init__() if (num == 18): self.net = models.resnet18(pretrained=pretrained) elif (num == 34): self.net = models.resnet34(pretrained=pretrained) elif (num == 50): self.net = models.resnet50(pretrained=pretrained) elif (num == 101): self.net = models.resnet101(pretrained=pretrained) elif (num == 152): self.net = models.resnet152(pretrained=pretrained) self.N_slices = 5 self.conv1 = self.net.conv1 self.bn1 = self.net.bn1 self.relu = self.net.relu self.maxpool = self.net.maxpool self.layer1 = self.net.layer1 self.layer2 = self.net.layer2 self.layer3 = self.net.layer3 self.layer4 = self.net.layer4
Example #10
Source File: resnet.py From LaSO with BSD 3-Clause "New" or "Revised" License | 6 votes |
def resnet34_ids_pre(num_attributes, ids_embedding_size, **kwargs): """Constructs a ResNet-34 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet """ model = zoo.resnet34(pretrained=True) for param in model.parameters(): param.requires_grad = False # Remove the last fully-connected layer # Parameters of newly constructed modules have requires_grad=True by default model = nn.Sequential(*list(model.children())[:-1]) classifier_attr = ResNetClassifier(BasicBlock, num_classes=num_attributes, **kwargs) classifier_ids = ResNetClassifier(BasicBlock, num_classes=ids_embedding_size, **kwargs) return model, classifier_attr, classifier_ids
Example #11
Source File: resnet_encoder.py From DF-VO with MIT License | 6 votes |
def __init__(self, num_layers, pretrained, num_input_images=1): super(ResnetEncoder, self).__init__() self.num_ch_enc = np.array([64, 64, 128, 256, 512]) resnets = {18: models.resnet18, 34: models.resnet34, 50: models.resnet50, 101: models.resnet101, 152: models.resnet152} if num_layers not in resnets: raise ValueError("{} is not a valid number of resnet layers".format(num_layers)) if num_input_images > 1: self.encoder = resnet_multiimage_input(num_layers, pretrained, num_input_images) else: self.encoder = resnets[num_layers](pretrained) if num_layers > 34: self.num_ch_enc[1:] *= 4
Example #12
Source File: models.py From nni with MIT License | 5 votes |
def create_resnet(layers): if layers == 34: return resnet34(pretrained=True), 512 elif layers == 50: return resnet50(pretrained=True), 2048 elif layers == 101: return resnet101(pretrained=True), 2048 elif layers == 152: return resnet152(pretrained=True), 2048 else: raise NotImplementedError('only 34, 50, 101, 152 version of Resnet are implemented')
Example #13
Source File: resnet.py From MCD_DA with MIT License | 5 votes |
def __init__(self, downblock, upblock, num_layers, n_classes): super(ResNet, self).__init__() self.in_channels = 64 resnet = models.resnet34(pretrained=True) self.conv1 = resnet.conv1 self.bn1 = resnet.bn1 self.relu = resnet.relu self.maxpool = resnet.maxpool self.dlayer1 = resnet.layer1 self.dlayer2 = resnet.layer2 self.dlayer3 = resnet.layer3 self.dlayer4 = resnet.layer4 self.uplayer1 = self._make_up_block(upblock, 512, 1, stride=2) self.uplayer2 = self._make_up_block(upblock, 256, num_layers[2], stride=2) self.uplayer3 = self._make_up_block(upblock, 128, num_layers[1], stride=2) self.uplayer4 = self._make_up_block(upblock, 64, 2, stride=2) upsample = nn.Sequential( nn.ConvTranspose2d(self.in_channels, # 256 64, kernel_size=1, stride=2, bias=False, output_padding=1), nn.BatchNorm2d(64), ) self.uplayer_top = DeconvBottleneck(self.in_channels, 64, 1, 2, upsample) self.conv1_1 = nn.ConvTranspose2d(64, n_classes, kernel_size=1, stride=1, bias=False)
Example #14
Source File: model_occ.py From Silhouette-Guided-3D with MIT License | 5 votes |
def initialize_encoder(model_name, num_classes, use_pretrained=True): # Initialize these variables which will be set in this if statement. Each of these # variables is model specific. model_ft = None if model_name == "resnet18": """ Resnet18 """ #model_ft = models.resnet18(pretrained=use_pretrained) model_ft = resnet.resnet18(pretrained=use_pretrained, num_classes=1000) #set_parameter_requires_grad(model_ft) num_ftrs = model_ft.fc.in_features model_ft.fc = nn.Linear(num_ftrs, num_classes) elif model_name == "resnet34": """ Resnet34 """ #model_ft = models.resnet34(pretrained=use_pretrained) model_ft = resnet.resnet34(pretrained=use_pretrained, num_classes=1000) #set_parameter_requires_grad(model_ft) num_ftrs = model_ft.fc.in_features model_ft.fc = nn.Linear(num_ftrs, num_classes) elif model_name == "resnet50": """ Resnet50 """ #model_ft = models.resnet50(pretrained=use_pretrained) model_ft = resnet.resnet50(pretrained=use_pretrained, num_classes=1000) #set_parameter_requires_grad(model_ft) num_ftrs = model_ft.fc.in_features model_ft.fc = nn.Linear(num_ftrs, num_classes) else: print("Invalid model name, exiting...") exit() return model_ft # full model
Example #15
Source File: pyt_common.py From advex-uar with Apache License 2.0 | 5 votes |
def get_imagenet_model(resnet_size, nb_classes): size_to_model = { 18: models.resnet18, 34: models.resnet34, 50: models.resnet50, 101: models.resnet101, 152: models.resnet152 } return size_to_model[resnet_size](num_classes=nb_classes)
Example #16
Source File: model.py From Beyond-Binary-Supervision-CVPR19 with MIT License | 5 votes |
def __init__(self,embedding_size, pretrained=True, is_norm=False): super(PoseModel_Resnet34, self).__init__() self.model = resnet34(pretrained) self.is_norm = is_norm self.embedding_size = embedding_size self.num_ftrs = self.model.fc.in_features self.model.fc = nn.Linear(self.num_ftrs, self.embedding_size) self.not_training = [self.model.conv1] self._initialize_weights()
Example #17
Source File: linknet.py From kaggle_carvana_segmentation with MIT License | 5 votes |
def __init__(self, num_classes, num_channels=3): super().__init__() assert num_channels == 3, "num channels not used now. to use changle first conv layer to support num channels other then 3" filters = [64, 128, 256, 512] resnet = models.resnet34(pretrained=True) self.firstconv = resnet.conv1 self.firstbn = resnet.bn1 self.firstrelu = resnet.relu self.firstmaxpool = resnet.maxpool self.encoder1 = resnet.layer1 self.encoder2 = resnet.layer2 self.encoder3 = resnet.layer3 self.encoder4 = resnet.layer4 # Decoder self.decoder4 = DecoderBlock(filters[3], filters[2]) self.decoder3 = DecoderBlock(filters[2], filters[1]) self.decoder2 = DecoderBlock(filters[1], filters[0]) self.decoder1 = DecoderBlock(filters[0], filters[0]) # Final Classifier self.finaldeconv1 = nn.ConvTranspose2d(filters[0], 32, 3, stride=2) self.finalrelu1 = nonlinearity(inplace=True) self.finalconv2 = nn.Conv2d(32, 32, 3) self.finalrelu2 = nonlinearity(inplace=True) self.finalconv3 = nn.Conv2d(32, num_classes, 2, padding=1) # noinspection PyCallingNonCallable
Example #18
Source File: torchvision_models.py From models-comparison.pytorch with BSD 3-Clause "New" or "Revised" License | 5 votes |
def resnet34(num_classes=1000, pretrained='imagenet'): """Constructs a ResNet-34 model. """ model = models.resnet34(pretrained=False) if pretrained is not None: settings = pretrained_settings['resnet34'][pretrained] model = load_pretrained(model, num_classes, settings) model = modify_resnets(model) return model
Example #19
Source File: gcn152.py From segmentation-networks-benchmark with MIT License | 5 votes |
def __init__(self, num_classes, input_size, pretrained=True): super(GCN34, self).__init__() self.input_size = input_size self.num_classes = num_classes resnet = models.resnet34(pretrained) self.layer0 = nn.Sequential(resnet.conv1, resnet.bn1, resnet.relu) self.layer1 = nn.Sequential(resnet.maxpool, resnet.layer1) self.layer2 = resnet.layer2 self.layer3 = resnet.layer3 self.layer4 = resnet.layer4 self.gcm1 = _GlobalConvModule(512, num_classes, (7, 7)) self.gcm2 = _GlobalConvModule(256, num_classes, (7, 7)) self.gcm3 = _GlobalConvModule(128, num_classes, (7, 7)) self.gcm4 = _GlobalConvModule(64, num_classes, (7, 7)) self.brm1 = _BoundaryRefineModule(num_classes) self.brm2 = _BoundaryRefineModule(num_classes) self.brm3 = _BoundaryRefineModule(num_classes) self.brm4 = _BoundaryRefineModule(num_classes) self.brm5 = _BoundaryRefineModule(num_classes) self.brm6 = _BoundaryRefineModule(num_classes) self.brm7 = _BoundaryRefineModule(num_classes) self.brm8 = _BoundaryRefineModule(num_classes) self.brm9 = _BoundaryRefineModule(num_classes) initialize_weights(self.gcm1, self.gcm2, self.gcm3, self.gcm4, self.brm1, self.brm2, self.brm3, self.brm4, self.brm5, self.brm6, self.brm7, self.brm8, self.brm9)
Example #20
Source File: linknet.py From segmentation-networks-benchmark with MIT License | 5 votes |
def __init__(self, num_classes=1, num_channels=3, pretrained=True): super().__init__() assert num_channels == 3 self.num_classes = num_classes filters = [64, 128, 256, 512] resnet = models.resnet34(pretrained=pretrained) self.firstconv = resnet.conv1 self.firstbn = resnet.bn1 self.firstrelu = resnet.relu self.firstmaxpool = resnet.maxpool self.encoder1 = resnet.layer1 self.encoder2 = resnet.layer2 self.encoder3 = resnet.layer3 self.encoder4 = resnet.layer4 # Decoder self.decoder4 = DecoderBlockLinkNet(filters[3], filters[2]) self.decoder3 = DecoderBlockLinkNet(filters[2], filters[1]) self.decoder2 = DecoderBlockLinkNet(filters[1], filters[0]) self.decoder1 = DecoderBlockLinkNet(filters[0], filters[0]) # Final Classifier self.finaldrop1 = nn.Dropout2d(p=0.5) self.finaldeconv1 = nn.ConvTranspose2d(filters[0], 32, 3, stride=2) self.finalrelu1 = nn.LeakyReLU(inplace=True) self.finalconv2 = nn.Conv2d(32, 32, 3) self.finalrelu2 = nn.LeakyReLU(inplace=True) self.finalconv3 = nn.Conv2d(32, num_classes, 2, padding=1) # noinspection PyCallingNonCallable
Example #21
Source File: utils_test.py From pytorch-dp with Apache License 2.0 | 5 votes |
def test_run_resnet34(self): imgSize = (3, 224, 224) # should throw because privacy engine does not work with batch norm # remove the next two lines when we support batch norm with self.assertRaises(Exception): self.runOneBatch(models.resnet34(), imgSize) self.runOneBatch( utils.convert_batchnorm_modules(models.resnet34()), imgSize)
Example #22
Source File: conv.py From occupancy_networks with MIT License | 5 votes |
def __init__(self, c_dim, normalize=True, use_linear=True): super().__init__() self.normalize = normalize self.use_linear = use_linear self.features = models.resnet34(pretrained=True) self.features.fc = nn.Sequential() if use_linear: self.fc = nn.Linear(512, c_dim) elif c_dim == 512: self.fc = nn.Sequential() else: raise ValueError('c_dim must be 512 if use_linear is False')
Example #23
Source File: archs.py From pytorch-adacos with MIT License | 5 votes |
def __init__(self, args): super().__init__() if args.backbone == 'resnet18': self.backbone = models.resnet18(pretrained=True) last_channels = 512 elif args.backbone == 'resnet34': self.backbone = models.resnet34(pretrained=True) last_channels = 512 elif args.backbone == 'resnet50': self.backbone = models.resnet50(pretrained=True) last_channels = 2048 elif args.backbone == 'resnet101': self.backbone = models.resnet101(pretrained=True) last_channels = 2048 elif args.backbone == 'resnet152': self.backbone = models.resnet152(pretrained=True) last_channels = 2048 self.features = nn.Sequential( self.backbone.conv1, self.backbone.bn1, self.backbone.relu, self.backbone.layer1, self.backbone.layer2, self.backbone.layer3, self.backbone.layer4) self.bn1 = nn.BatchNorm2d(last_channels) self.dropout = nn.Dropout2d(0.5) self.fc = nn.Linear(8*8*last_channels, args.num_features) self.bn2 = nn.BatchNorm1d(args.num_features)
Example #24
Source File: encoder.py From pytorch-segmentation with MIT License | 5 votes |
def resnet(name, pretrained=False): def get_channels(layer): block = layer[-1] if isinstance(block, models.resnet.BasicBlock): return block.conv2.out_channels elif isinstance(block, models.resnet.Bottleneck): return block.conv3.out_channels raise RuntimeError("unknown resnet block: {}".format(block)) if name == 'resnet18': resnet = models.resnet18(pretrained=pretrained) elif name == 'resnet34': resnet = models.resnet34(pretrained=pretrained) elif name == 'resnet50': resnet = models.resnet50(pretrained=pretrained) elif name == 'resnet101': resnet = models.resnet101(pretrained=pretrained) elif name == 'resnet152': resnet = models.resnet152(pretrained=pretrained) else: return NotImplemented layer0 = nn.Sequential(resnet.conv1, resnet.bn1, resnet.relu, resnet.maxpool) layer0.out_channels = resnet.bn1.num_features resnet.layer1.out_channels = get_channels(resnet.layer1) resnet.layer2.out_channels = get_channels(resnet.layer2) resnet.layer3.out_channels = get_channels(resnet.layer3) resnet.layer4.out_channels = get_channels(resnet.layer4) return [layer0, resnet.layer1, resnet.layer2, resnet.layer3, resnet.layer4]
Example #25
Source File: resnet_qc.py From AD-DL with MIT License | 5 votes |
def resnet_qc_34(pretrained=False, **kwargs): """Constructs a ResNet-34 model. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet """ model = ResNetQC(BasicBlock, [3, 4, 6, 3], **kwargs) if pretrained: # load basic Resnet model model_ft = models.resnet34(pretrained=True) model.load_from_std(model_ft) return model
Example #26
Source File: model.py From kaggle-airbus-ship-detection-challenge with Apache License 2.0 | 5 votes |
def __init__(self): super().__init__() resnet34 = models.resnet34(pretrained=True) self.resnet34_main = nn.Sequential( resnet34.conv1, resnet34.bn1, resnet34.relu, resnet34.maxpool, resnet34.layer1, resnet34.layer2, resnet34.layer3 ) self.conv_ex1 = resnet34.layer4 self.conv_ex2 = nn.Sequential(nn.Conv2d(512, 256, kernel_size=1, padding=0, stride=1), nn.ReLU(inplace=True), nn.Conv2d(256, 512, kernel_size=3, padding=1, stride=2), nn.ReLU(inplace=True) ) self.conv_ex3 = nn.Sequential(nn.Conv2d(512, 128, kernel_size=1, padding=0, stride=1), nn.ReLU(inplace=True), nn.Conv2d(128, 256, kernel_size=3, padding=1, stride=2), nn.ReLU(inplace=True) ) self.ex0_intermediate = nn.Conv2d(256, 24, kernel_size=3, padding=1, stride=1) self.ex1_intermediate = nn.Conv2d(512, 24, kernel_size=3, padding=1, stride=1) self.ex2_intermediate = nn.Conv2d(512, 24, kernel_size=3, padding=1, stride=1) self.ex3_intermediate = nn.Conv2d(256, 24, kernel_size=3, padding=1, stride=1)
Example #27
Source File: backbone.py From transferlearning with MIT License | 5 votes |
def __init__(self): super(ResNet34Fc, self).__init__() model_resnet34 = models.resnet34(pretrained=True) self.conv1 = model_resnet34.conv1 self.bn1 = model_resnet34.bn1 self.relu = model_resnet34.relu self.maxpool = model_resnet34.maxpool self.layer1 = model_resnet34.layer1 self.layer2 = model_resnet34.layer2 self.layer3 = model_resnet34.layer3 self.layer4 = model_resnet34.layer4 self.avgpool = model_resnet34.avgpool
Example #28
Source File: backbone.py From transferlearning with MIT License | 5 votes |
def __init__(self): super(ResNet34Fc, self).__init__() model_resnet34 = models.resnet34(pretrained=True) self.conv1 = model_resnet34.conv1 self.bn1 = model_resnet34.bn1 self.relu = model_resnet34.relu self.maxpool = model_resnet34.maxpool self.layer1 = model_resnet34.layer1 self.layer2 = model_resnet34.layer2 self.layer3 = model_resnet34.layer3 self.layer4 = model_resnet34.layer4 self.avgpool = model_resnet34.avgpool self.__in_features = model_resnet34.fc.in_features
Example #29
Source File: torchvision_models.py From pretorched-x with MIT License | 5 votes |
def resnet34(num_classes=1000, pretrained='imagenet'): """Constructs a ResNet-34 model. """ model = models.resnet34(pretrained=False, num_classes=num_classes) if pretrained is not None: settings = pretrained_settings['resnet34'][pretrained] model = load_pretrained(model, num_classes, settings) model = modify_resnets(model) return model
Example #30
Source File: models_classy_model_test.py From ClassyVision with MIT License | 5 votes |
def test_train_step(self): # test that the model can be run in a train step model = models.resnet34(pretrained=False) classy_model = ClassyModel.from_model(model) config = get_fast_test_task_config() task = build_task(config) task.set_model(classy_model) trainer = LocalTrainer() trainer.train(task)