Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Benchmark related bugs #1236

Merged
merged 2 commits into from
Oct 11, 2022
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
6 changes: 6 additions & 0 deletions .dev_scripts/download_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def download(args):

http_prefix_long = 'https://openmmlab-share.oss-cn-hangzhou.aliyuncs.com/mmediting/' # noqa
http_prefix_short = 'https://download.openmmlab.com/mmediting/'
http_prefix_gen = 'https://download.openmmlab.com/mmgen/'

# load model list
if args.model_list:
Expand Down Expand Up @@ -112,6 +113,11 @@ def download(args):
model_name = model_weight_url[len(http_prefix_long):]
elif model_weight_url.startswith(http_prefix_short):
model_name = model_weight_url[len(http_prefix_short):]
elif model_weight_url.startswith(http_prefix_gen):
model_name = model_weight_url[len(http_prefix_gen):]
elif model_weight_url == '':
print(f'{model_info.Name} weight is missing')
return None
else:
raise ValueError(f'Unknown url prefix. \'{model_weight_url}\'')

Expand Down
6 changes: 6 additions & 0 deletions .dev_scripts/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,18 @@ def create_test_job_batch(commands, model_info, args, port, script_name):

http_prefix_short = 'https://download.openmmlab.com/mmediting/'
http_prefix_long = 'https://openmmlab-share.oss-cn-hangzhou.aliyuncs.com/mmediting/' # noqa
http_prefix_gen = 'https://download.openmmlab.com/mmgen/'
model_weight_url = model_info.weights

if model_weight_url.startswith(http_prefix_long):
model_name = model_weight_url[len(http_prefix_long):]
elif model_weight_url.startswith(http_prefix_short):
model_name = model_weight_url[len(http_prefix_short):]
elif model_weight_url.startswith(http_prefix_gen):
model_name = model_weight_url[len(http_prefix_gen):]
elif model_weight_url == '':
print(f'{fname} weight is missing')
return None
else:
raise ValueError(f'Unknown url prefix. \'{model_weight_url}\'')

Expand Down
9 changes: 7 additions & 2 deletions .dev_scripts/train_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,19 @@ def create_train_job_batch(commands, model_info, args, port, script_name):
config = Path(config)
assert config.exists(), f'{fname}: {config} not found.'

# get n gpus
try:
n_gpus = int(model_info.metadata.data['GPUs'].split()[0])
except Exception:
if 'official' in model_info.config:
return None
else:
n_gpus = 1
pattern = r'\d+xb\d+'
parse_res = re.search(pattern, config.name)
if not parse_res:
# defaults to use 1 gpu
n_gpus = 1
else:
n_gpus = int(parse_res.group().split('x')[0])

if args.gpus_per_job is not None:
n_gpus = min(args.gpus_per_job, n_gpus)
Expand Down
3 changes: 2 additions & 1 deletion tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import mmengine
from mmengine.config import Config, DictAction
from mmengine.hooks import Hook
from mmengine.runner import Runner

from mmedit.utils import print_colored_log, register_all_modules
Expand Down Expand Up @@ -73,7 +74,7 @@ def main():

if args.out:

class SaveMetricHook(mmengine.Hook):
class SaveMetricHook(Hook):

def after_test_epoch(self, _, metrics=None):
if metrics is not None:
Expand Down