Skip to content

Commit

Permalink
model zoo
Browse files Browse the repository at this point in the history
  • Loading branch information
yysijie committed Oct 8, 2019
1 parent dc3dcba commit d2604dd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
2 changes: 2 additions & 0 deletions doc/MODEL_ZOO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## MODEL ZOO
Coming Soon...
30 changes: 20 additions & 10 deletions mmskeleton/utils/checkpoint.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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)
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
"""
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit d2604dd

Please sign in to comment.