__init__.py 1.55 KB
Newer Older
1 2 3
"""Store for onnx examples and common models."""
from __future__ import absolute_import as _abs
import os
4
import logging
5 6
from .super_resolution import get_super_resolution

7 8 9 10 11 12 13 14 15 16 17
def _download(url, filename, overwrite=False):
    if os.path.isfile(filename) and not overwrite:
        logging.debug('File %s existed, skip.', filename)
        return
    logging.debug('Downloading from url %s to %s', url, filename)
    try:
        import urllib.request
        urllib.request.urlretrieve(url, filename)
    except:
        import urllib
        urllib.urlretrieve(url, filename)
18 19 20 21 22

def _as_abs_path(fname):
    cur_dir = os.path.abspath(os.path.dirname(__file__))
    return os.path.join(cur_dir, fname)

23 24 25 26

URLS = {
    'super_resolution.onnx': 'https://gist.github.com/zhreshold/bcda4716699ac97ea44f791c24310193/raw/93672b029103648953c4e5ad3ac3aadf346a4cdc/super_resolution_0.2.onnx',
    'squeezenet1_1.onnx': 'https://gist.github.com/zhreshold/bcda4716699ac97ea44f791c24310193/raw/93672b029103648953c4e5ad3ac3aadf346a4cdc/squeezenet1_1_0.2.onnx',
Joshua Z. Zhang committed
27 28
    'lenet.onnx': 'https://gist.github.com/zhreshold/bcda4716699ac97ea44f791c24310193/raw/93672b029103648953c4e5ad3ac3aadf346a4cdc/lenet_0.2.onnx',
    'resnet18_1_0.onnx': 'https://gist.github.com/zhreshold/bcda4716699ac97ea44f791c24310193/raw/b385b1b242dc89a35dd808235b885ed8a19aedc1/resnet18_1.0.onnx'}
29 30 31 32 33 34 35 36 37 38

# download and add paths
for k, v  in URLS.items():
    name = k.split('.')[0]
    path = _as_abs_path(k)
    _download(v, path, False)
    locals()[name] = path

# symbol for graph comparison
super_resolution_sym = get_super_resolution()