Ma Zerun 6cedce234e
[Refactor] Update dev scripts to be compatible with selfsup tasks. (#1412)
* [Refactor] Update dev scripts to be compatible with selfsup tasks.

* Fix some missing fields in config files.

* Set maximum number of gpus for local training.

* Update README files

* Update according to comments.
2023-03-20 14:30:57 +08:00

31 lines
942 B
Python

from pathlib import Path
HTTP_PREFIX = 'https://download.openmmlab.com/'
MMCLS_ROOT = Path(__file__).absolute().parents[2]
METRICS_MAP = {
'Top 1 Accuracy': 'accuracy/top1',
'Top 5 Accuracy': 'accuracy/top5',
'Recall@1': 'retrieval/Recall@1',
}
def substitute_weights(download_link, root):
if 's3://' in root:
from mmengine.fileio.backends import PetrelBackend
from petrel_client.common.exception import AccessDeniedError
file_backend = PetrelBackend()
checkpoint = file_backend.join_path(root,
download_link[len(HTTP_PREFIX):])
try:
exists = file_backend.exists(checkpoint)
except AccessDeniedError:
exists = False
else:
checkpoint = Path(root) / download_link[len(HTTP_PREFIX):]
exists = checkpoint.exists()
if exists:
return str(checkpoint)
else:
return None