Skip to content

Commit

Permalink
Remove duplicates (paperswithcode/sotabench-api#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Randl committed May 4, 2020
1 parent c4a80ee commit 669afd4
Showing 1 changed file with 0 additions and 373 deletions.
373 changes: 0 additions & 373 deletions sotabench.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,77 +23,6 @@

# parsing args
args = parser.parse_args()
# TResNet-M
model_path = './tresnet_m.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
[transforms.Resize(int(args.input_size / args.val_zoom_factor)),
transforms.CenterCrop(args.input_size)])
val_tfms.transforms.append(transforms.ToTensor())

print('Benchmarking TResNet-M')

# Run the benchmark
ImageNet.benchmark(
model=model,
paper_model_name='TResNet-M',
paper_arxiv_id='2003.13630',
input_transform=val_tfms,
batch_size=432,
num_workers=args.num_workers,
num_gpu=1,
pin_memory=True,
paper_results={'Top 1 Accuracy': 0.807, 'Top 5 Accuracy': 0.948},
model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# TResNet-M-288
model_path = './tresnet_m.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
[transforms.Resize(int(288 / args.val_zoom_factor)),
transforms.CenterCrop(288)])
val_tfms.transforms.append(transforms.ToTensor())

print('Benchmarking TResNet-M-288')

# Run the benchmark
ImageNet.benchmark(
model=model,
paper_model_name='TResNet-M (input=288)',
paper_arxiv_id='2003.13630',
input_transform=val_tfms,
batch_size=352,
num_workers=args.num_workers,
num_gpu=1,
pin_memory=True,
paper_results={'Top 1 Accuracy': 0.807, 'Top 5 Accuracy': 0.948},
model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# MTResNet 224-Mean-Max-vazoom

Expand Down Expand Up @@ -133,305 +62,3 @@
del model
gc.collect()
torch.cuda.empty_cache()

# MTResNet 288-Mean-Max

val_bs = args.batch_size
val_tfms = transforms.Compose(
[transforms.Resize(288),
transforms.CenterCrop(288)])
val_tfms.transforms.append(transforms.ToTensor())

model_path = './tresnet_m.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)

model = TestTimePoolHead(model)

model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()
print('Benchmarking TResNet-M (288-Mean-Max)')

# Run the benchmark
ImageNet.benchmark(
model=model,
paper_model_name='TResNet-M (288-Mean-Max)',
paper_arxiv_id='2003.13630',
input_transform=val_tfms,
batch_size=432,
num_workers=args.num_workers,
num_gpu=1,
pin_memory=True,
paper_results={'Top 1 Accuracy': 0.807, 'Top 5 Accuracy': 0.948},
model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# TResNet-L
args.model_name = 'tresnet_l'
model_path = './tresnet_l.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
[transforms.Resize(int(args.input_size / args.val_zoom_factor)),
transforms.CenterCrop(args.input_size)])
val_tfms.transforms.append(transforms.ToTensor())

print('Benchmarking TResNet-L')

# Run the benchmark
ImageNet.benchmark(
model=model,
paper_model_name='TResNet-L',
paper_arxiv_id='2003.13630',
input_transform=val_tfms,
batch_size=250,
num_workers=args.num_workers,
num_gpu=1,
pin_memory=True,
paper_results={'Top 1 Accuracy': 0.814, 'Top 5 Accuracy': 0.956},
model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# LTResNet 288-Mean-Max

val_bs = args.batch_size
val_tfms = transforms.Compose(
[transforms.Resize(288),
transforms.CenterCrop(288)])
val_tfms.transforms.append(transforms.ToTensor())

model_path = './tresnet_l.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)

model = TestTimePoolHead(model)

model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()
print('Benchmarking TResNet-L (288-Mean-Max)')

# Run the benchmark
ImageNet.benchmark(
model=model,
paper_model_name='TResNet-L (288-Mean-Max)',
paper_arxiv_id='2003.13630',
input_transform=val_tfms,
batch_size=250,
num_workers=args.num_workers,
num_gpu=1,
pin_memory=True,
paper_results={'Top 1 Accuracy': 0.814, 'Top 5 Accuracy': 0.956},
model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# TResNet-XL
args.model_name = 'tresnet_xl'
model_path = './tresnet_xl.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
[transforms.Resize(int(args.input_size / args.val_zoom_factor)),
transforms.CenterCrop(args.input_size)])
val_tfms.transforms.append(transforms.ToTensor())

print('Benchmarking TResNet-XL')

# Run the benchmark
ImageNet.benchmark(
model=model,
paper_model_name='TResNet-XL',
paper_arxiv_id='2003.13630',
input_transform=val_tfms,
batch_size=250,
num_workers=args.num_workers,
num_gpu=1,
pin_memory=True,
paper_results={'Top 1 Accuracy': 0.820, 'Top 5 Accuracy': 0.959},
model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# XLTResNet 288-Mean-Max

val_bs = args.batch_size
val_tfms = transforms.Compose(
[transforms.Resize(288),
transforms.CenterCrop(288)])
val_tfms.transforms.append(transforms.ToTensor())

model_path = './tresnet_xl.pth'
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)

model = TestTimePoolHead(model)

model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()
print('Benchmarking TResNet-XL (288-Mean-Max)')

# Run the benchmark
ImageNet.benchmark(
model=model,
paper_model_name='TResNet-XL (288-Mean-Max)',
paper_arxiv_id='2003.13630',
input_transform=val_tfms,
batch_size=212,
num_workers=args.num_workers,
num_gpu=1,
pin_memory=True,
paper_results={'Top 1 Accuracy': 0.820, 'Top 5 Accuracy': 0.959},
model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# TResNet-M-448
args.model_name = 'tresnet_m'
model_path = './tresnet_m_448.pth'
args.input_size = 448
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
[transforms.Resize((args.input_size, args.input_size))])
val_tfms.transforms.append(transforms.ToTensor())

print('Benchmarking TResNet-M 448')

# Run the benchmark
ImageNet.benchmark(
model=model,
paper_model_name='TResNet-M (input=448)',
paper_arxiv_id='2003.13630',
input_transform=val_tfms,
batch_size=125,
num_workers=args.num_workers,
num_gpu=1,
pin_memory=True,
paper_results={'Top 1 Accuracy': 0.832},
model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# TResNet-L-448
args.model_name = 'tresnet_l'
model_path = './tresnet_l_448.pth'
args.input_size = 448
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
[transforms.Resize((args.input_size, args.input_size))])
val_tfms.transforms.append(transforms.ToTensor())

print('Benchmarking TResNet-L 448')

# Run the benchmark
ImageNet.benchmark(
model=model,
paper_model_name='TResNet-L (input=448)',
paper_arxiv_id='2003.13630',
input_transform=val_tfms,
batch_size=64,
num_workers=args.num_workers,
num_gpu=1,
pin_memory=True,
paper_results={'Top 1 Accuracy': 0.838},
model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

# TResNet-XL-448
args.model_name = 'tresnet_xl'
model_path = './tresnet_xl_448.pth'
args.input_size = 448
model = create_model(args)
state = torch.load(model_path, map_location='cpu')['model']
model.load_state_dict(state, strict=True)
model = InplacABN_to_ABN(model)
model = fuse_bn_recursively(model)
model = model.cuda()
model.eval()

val_bs = args.batch_size
val_tfms = transforms.Compose(
[transforms.Resize((args.input_size, args.input_size))])
val_tfms.transforms.append(transforms.ToTensor())

print('Benchmarking TResNet-XL 448')

# Run the benchmark
ImageNet.benchmark(
model=model,
paper_model_name='TResNet-XL (input=448)',
paper_arxiv_id='2003.13630',
input_transform=val_tfms,
batch_size=32,
num_workers=args.num_workers,
num_gpu=1,
pin_memory=True,
paper_results={'Top 1 Accuracy': 0.843},
model_description="Official weights from the author's of the paper."
)

del model
gc.collect()
torch.cuda.empty_cache()

0 comments on commit 669afd4

Please sign in to comment.