Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion references/classification/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def main(args):
sampler=test_sampler, num_workers=args.workers, pin_memory=True)

print("Creating model")
model = torchvision.models.__dict__[args.model]()
model = torchvision.models.__dict__[args.model](pretrained=args.pretrained)
model.to(device)
if args.distributed and args.sync_bn:
model = torch.nn.SyncBatchNorm.convert_sync_batchnorm(model)
Expand Down Expand Up @@ -242,6 +242,12 @@ def parse_args():
help="Only test the model",
action="store_true",
)
parser.add_argument(
"--pretrained",
dest="pretrained",
help="Use pre-trained models from the modelzoo",
action="store_true",
)

# distributed training parameters
parser.add_argument('--world-size', default=1, type=int,
Expand Down
9 changes: 8 additions & 1 deletion references/detection/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def main(args):
collate_fn=utils.collate_fn)

print("Creating model")
model = torchvision.models.detection.__dict__[args.model](num_classes=num_classes)
model = torchvision.models.detection.__dict__[args.model](num_classes=num_classes,
pretrained=args.pretrained)
model.to(device)

model_without_ddp = model
Expand Down Expand Up @@ -156,6 +157,12 @@ def main(args):
help="Only test the model",
action="store_true",
)
parser.add_argument(
"--pretrained",
dest="pretrained",
help="Use pre-trained models from the modelzoo",
action="store_true",
)

# distributed training parameters
parser.add_argument('--world-size', default=1, type=int,
Expand Down
10 changes: 9 additions & 1 deletion references/segmentation/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ def main(args):
sampler=test_sampler, num_workers=args.workers,
collate_fn=utils.collate_fn)

model = torchvision.models.segmentation.__dict__[args.model](num_classes=num_classes, aux_loss=args.aux_loss)
model = torchvision.models.segmentation.__dict__[args.model](num_classes=num_classes,
aux_loss=args.aux_loss,
pretrained=args.pretrained)
model.to(device)
if args.distributed:
model = torch.nn.SyncBatchNorm.convert_sync_batchnorm(model)
Expand Down Expand Up @@ -205,6 +207,12 @@ def parse_args():
help="Only test the model",
action="store_true",
)
parser.add_argument(
"--pretrained",
dest="pretrained",
help="Use pre-trained models from the modelzoo",
action="store_true",
)
# distributed training parameters
parser.add_argument('--world-size', default=1, type=int,
help='number of distributed processes')
Expand Down