diff --git a/doc/MODEL_ZOO.md b/doc/MODEL_ZOO.md new file mode 100644 index 000000000..0baa62106 --- /dev/null +++ b/doc/MODEL_ZOO.md @@ -0,0 +1,2 @@ +## MODEL ZOO +Coming Soon... \ No newline at end of file diff --git a/mmskeleton/utils/checkpoint.py b/mmskeleton/utils/checkpoint.py index d131ce848..94c63524a 100644 --- a/mmskeleton/utils/checkpoint.py +++ b/mmskeleton/utils/checkpoint.py @@ -1,24 +1,23 @@ from mmcv.runner import load_checkpoint as mmcv_load_checkpoint from mmcv.runner.checkpoint import load_url_dist +import urllib mmskeleton_model_urls = { 'st_gcn/kinetics-skeleton': "https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmskeleton/models/st-gcn/st_gcn.kinetics-6fa43f73.pth", 'st_gcn/ntu-xsub': "https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmskeleton/models/st-gcn/st_gcn.ntu-xsub-300b57d4.pth", 'st_gcn/ntu-xview': "https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmskeleton/models/st-gcn/st_gcn.ntu-xview-9ba67746.pth", 'mmdet/htc_dconv_c3-c5_mstrain_400_1400_x101_64x4d_fpn_20e': 'https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmskeleton/models/mmdet/htc_dconv_c3-c5_mstrain_400_1400_x101_64x4d_fpn_20e_20190408-0e50669c.pth', - 'pose_estimation/pose_hrnet_w32_256x192': 'https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmskeleton/models/pose_estimation/pose_hrnet_w32_256x192-76ea353b.pth', + 'pose_estimation/pose_hrnet_w32_256x192': 'https://1open-mmlab.s3.ap-northeast-2.amazonaws.com/mmskeleton/models/pose_estimation/pose_hrnet_w32_256x192-76ea353b.pth', 'mmdet/cascade_rcnn_r50_fpn_20e': 'https://s3.ap-northeast-2.amazonaws.com/open-mmlab/mmdetection/models/cascade_rcnn_r50_fpn_20e_20181123-db483a09.pth', } # yapf: disable def load_checkpoint(model, filename, *args, **kwargs): - if filename.startswith('mmskeleton://'): - model_name = filename[13:] - model_url = (mmskeleton_model_urls[model_name]) - checkpoint = mmcv_load_checkpoint(model, model_url, *args, **kwargs) - return checkpoint - else: + try: + filename = get_mmskeleton_url(filename) return mmcv_load_checkpoint(model, filename, *args, **kwargs) + except (urllib.error.HTTPError, urllib.error.URLError) as e: + raise Exception(url_error_message.format(filename)) from e def get_mmskeleton_url(filename): @@ -30,7 +29,18 @@ def get_mmskeleton_url(filename): def cache_checkpoint(filename): - if filename.startswith('mmskeleton://'): + try: + filename = get_mmskeleton_url(filename) load_url_dist(get_mmskeleton_url(filename)) - elif filename.startswith(('http://', 'https://')): - load_url_dist(filename) \ No newline at end of file + except (urllib.error.HTTPError, urllib.error.URLError) as e: + raise Exception(url_error_message.format(filename)) from e + + +url_error_message = """ + +================================================== +MMSkeleton fail to load checkpoint from url: + {} +Please check your network connection. Or manually download checkpoints according to the instructor: + https://github.com/open-mmlab/mmskeleton/blob/master/doc/MODEL_ZOO.md +""" \ No newline at end of file diff --git a/setup.py b/setup.py index 381dbbb88..ce849681f 100644 --- a/setup.py +++ b/setup.py @@ -78,7 +78,9 @@ def write_version_py(): MMSKELETON_HOME = os.path.dirname(os.path.realpath(__file__)) with open(version_file, 'w') as f: - f.write(content.format(time.asctime(), VERSION, SHORT_VERSION, MMSKELETON_HOME)) + f.write( + content.format(time.asctime(), VERSION, SHORT_VERSION, + MMSKELETON_HOME)) def get_version():