Skip to content

Commit 2da042f

Browse files
zhresholdJerryzcntmwangcaschongruoUbuntu
authored
Merge branch estimator into master (#1492)
* [WIP] Fit api with sacred config (#1331) * config using sacred * update * update base * allow attribute access, add warning to config modification (#1348) * Faster R-CNN estimator (#1338) * move rcnn forward backward task to model zoo * revert #1249 * fix * fix * docstring * fix style * add docs * faster rcnn estimator * refactor * move dataset to init * lint * merge * disable sacred config for now * logger fix * fix fit * update full centernet example (#1349) * Autogluon Integration (#1355) * move rcnn forward backward task to model zoo * revert #1249 * fix * fix * docstring * fix style * add docs * faster rcnn estimator * refactor * move dataset to init * lint * merge * disable sacred config for now * logger fix * fix fit * autogluon integration * fix small bug. training working * lint * sacred config for faster rcnn (#1358) * move rcnn forward backward task to model zoo * revert #1249 * fix * fix * docstring * fix style * add docs * faster rcnn estimator * refactor * move dataset to init * lint * merge * disable sacred config for now * logger fix * fix fit * autogluon integration * fix small bug. training working * lint * sacred config for faster rcnn * Finish centernet fit estimator (#1359) * add voc detection pipeline * update * fix errors * Add docs for Faster R-CNN config (#1361) * move rcnn forward backward task to model zoo * revert #1249 * fix * fix * docstring * fix style * add docs * faster rcnn estimator * refactor * move dataset to init * lint * merge * disable sacred config for now * logger fix * fix fit * autogluon integration * fix small bug. training working * lint * sacred config for faster rcnn * add config docs * Estimator rcnn (#1366) * move rcnn forward backward task to model zoo * revert #1249 * fix * fix * docstring * fix style * add docs * faster rcnn estimator * refactor * move dataset to init * lint * merge * disable sacred config for now * logger fix * fix fit * autogluon integration * fix small bug. training working * lint * sacred config for faster rcnn * add config docs * move all logging into base estimator logdir * raise key error when config is not found in freezed config (#1367) * auto object detection refactor (#1371) * auto object detection refactor * change logdir and common config * centernet config change * autogluon * fix auto object detection task * add mask_rcnn estimator (#1398) * fix typo (#1378) Co-authored-by: Ubuntu <ubuntu@ip-172-31-0-100.us-west-2.compute.internal> * add ssd estimator (#1394) * add ssd estimator * modify ssd estimator * provide options to customize network structure * minor changes * minor changes * add auto detection using ssd * add auto detection using ssd * add custom model for ssd * minor changes * add tiny dataset for testing; fix errors in training auto detector * [WIP] Add estimator(yolo) (#1380) * yolo * yolo * add yolo * [chore] update name, add fit script Co-authored-by: Ubuntu <ubuntu@ip-172-31-0-100.us-west-2.compute.internal> * auto register args (#1419) * Auto detector (#1425) * auto detector * auto detector * auto detector * auto detector * auto detector * auto detector Co-authored-by: Joshua Z. Zhang <cheungchih@gmail.com> * update auto detection (#1436) * auto detector * auto detector * auto detector * auto detector * auto detector * auto detector * update auto detection * add a framework for automatic suggestion of hyperparameter search space * 1) change auto_resume default to False; 2) change input config to estimator is a pure dict * [fix] bugs for test_auto_detection (#1438) Co-authored-by: Ubuntu <ubuntu@ip-172-31-31-97.us-west-2.compute.internal> * add cls (#1381) * update auto suggest (#1443) * update auto suggest * update auto suggest * fix yolo errors (#1445) * remove dependencies on AutoGluon non-core functions (#1452) * remove dependency to autogluon non-core functions * fix errors on importing estimators * [Lint] fix pylint for estimator branch (#1451) * fix pylint * update mxnet build * remove py2 * remove py2.yml * fix jenkinsfile * fix post_nms in rcnn * fix * fix doc build * fix lint con't * add sacred * no tutorial yet * estimator prototype for save/load (#1458) * prototype for save/load * add type check * handle ctx * fix * collect * fix classmethod self * fix * pickle only init args * cast to numpy to avoid ctypes * fix get data * base estimator * [WIP] Add detailed logging information for auto estimator (#1470) * add detailed logging information for auto estimator * fix lint error * [WIP] Estimator data (#1471) * dataframe for object detection * fix pack and unpack for bboxes * update * refactor fit * fix * update pickle behavior * update * fix __all__ * Dataset as class property not module * fix centernet, add image classification dataset * fix * fix * fix logger not inited before init_network * reuse weights from known classes * add predict * fix index * format returned prediction * fix id to int * improve predict with pd.dataframe * add numpy * reset index * clean up * update image classification dataset * dataset improvements * valid url checker * setup.py improve * fix * fix import utils * add display to object detection * fix * change fit functions * add coco import * fix lint * fix lint * fix lint * fix * Estimator con't improvements (#1484) * allow ssd/faster-rcnn to take in train/val dataset * update * fix * update ssd * fix ctx * fix ctx * fix self.datasets * fix self.epoch * remove async_net * fix predict * debug predict * fix predict scores * filter out invalid predictions * fix faster_rcnn * fix * fix * fix deepcopy * fix fpn anchor generator * fix ctx * fix frcnn predict * fix * fix skipping logic * fix yolo3 * fix import * fix rename yoloestimator * fix import * fix yolo3 train * fix * fix * fix * fix * fix * fix * fix * fix ctx * fix trainer * fix num_class < 5 for topk * fix unpickable batch_fn * fix print * add predict * fix cls predict * fix cls predict * fix cls predict * fix cls predict * improve auto fit * improve auto fit * fix * fix * fix * fix * fix * debug * fix * fix * fix * fix * fix * fix * fix reporter pickle * change epochs to smaller * update image cls search space * fix * fix * fix * fix * fix * fix * fix * replace sacred with autocfg * fix * fix tuple type * fix * fix * fix * clean up * remove sacred * fix import * fix import * add types * fix * fix * defaults for object detection * fix * fix * update image classification * change lr * update * Fix pylint * Fix pylint * fit summary * pprint summary * fix * update * fix single trial * fix sample_config * fix sample_config * fix sample_config * fix lint * fix lint * adjust batch size * fix * stacktrace * fix * fix traceback * fix traceback * fix train evaluation * default networks * default networks * improves * fix * fix lint Co-authored-by: tmwangcas <tmwang428@outlook.com> * update script to master * add unittests for auto * update conda * pin autogluon * fix test * fix * fix ssd/yolo * fix * update defaults * fix kv_store being overwriten * fix rcnn batch size Co-authored-by: Jerry Zhang <zhangz6@cs.washington.edu> Co-authored-by: Tianming Wang <tmwang428@outlook.com> Co-authored-by: Chongruo Wu <chongruo@gmail.com> Co-authored-by: Ubuntu <ubuntu@ip-172-31-0-100.us-west-2.compute.internal> Co-authored-by: Ubuntu <ubuntu@ip-172-31-31-97.us-west-2.compute.internal>
1 parent 60d82b3 commit 2da042f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+7335
-219
lines changed

Jenkinsfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,35 @@ stage("Unit Test") {
8585
}
8686
}
8787
}
88+
},
89+
'Auto': {
90+
node('linux-gpu') {
91+
ws('workspace/gluon-cv-py3-auto') {
92+
timeout(time: max_time, unit: 'MINUTES') {
93+
checkout scm
94+
VISIBLE_GPU=env.EXECUTOR_NUMBER.toInteger() % 8
95+
sh """#!/bin/bash
96+
conda env remove -n gluon-cv-py3-auto_test -y
97+
set -ex
98+
# remove and create new env instead
99+
conda env create -n gluon-cv-py3-auto_test -f tests/py3_auto.yml
100+
conda env update -n gluon-cv-py3-auto_test -f tests/py3_auto.yml --prune
101+
conda activate gluon-cv-py3-auto_test
102+
conda list
103+
export CUDA_VISIBLE_DEVICES=${VISIBLE_GPU}
104+
export KMP_DUPLICATE_LIB_OK=TRUE
105+
make clean
106+
# from https://stackoverflow.com/questions/19548957/can-i-force-pip-to-reinstall-the-current-version
107+
pip install --upgrade --force-reinstall --no-deps .
108+
env
109+
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64
110+
export MPLBACKEND=Agg
111+
export MXNET_CUDNN_AUTOTUNE_DEFAULT=0
112+
nosetests --with-timer --timer-ok 60 --timer-warning 120 -x --with-coverage --cover-package gluoncv -v tests/auto
113+
"""
114+
}
115+
}
116+
}
88117
}
89118
}
90119

docs/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ dependencies:
2323
- decord
2424
- cython
2525
- pycocotools
26+
- autocfg

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
'build/examples_distributed',
8888
'build/examples_deployment',],
8989

90-
'filename_pattern': '.py',
90+
'filename_pattern': '.pydisabled',
9191
'ignore_pattern': 'im2rec.py',
9292
'expected_failing_examples': [],
9393

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""01. HPO with Faster R-CNN end-to-end on PASCAL VOC
2+
=====================================================
3+
4+
This tutorial goes through the basic steps of using AutoGluon to tune hyper-parameters for a
5+
Faster-RCNN [Ren15]_ object detection model provided by GluonCV.
6+
"""
7+
8+
##########################################################
9+
# Dataset
10+
# -------
11+
#
12+
# Please first go through this :ref:`sphx_glr_build_examples_datasets_pascal_voc.py` tutorial to setup Pascal
13+
# VOC dataset on your disk.
14+
# Then, we are ready to load training and validation images.
15+
16+
import autogluon as ag
17+
18+
from gluoncv.auto.estimators.faster_rcnn import FasterRCNNEstimator
19+
from gluoncv.auto.tasks.object_detection import ObjectDetection
20+
21+
# Define search space
22+
time_limits = 60 * 60 # 1hr
23+
search_args = {'dataset': 'voc', 'split_ratio': 0.8, 'num_trials': 30,
24+
'epochs': ag.Categorical(30, 40, 50, 60), 'num_workers': 16,
25+
'net': ag.Categorical('resnest101', 'resnest50'), 'meta_arch': 'faster_rcnn',
26+
'search_strategy': 'random', 'search_options': {},
27+
'lr': ag.Categorical(0.005, 0.002, 2e-4, 5e-4), 'transfer': False,
28+
'data_shape': (640, 800), 'nthreads_per_trial': 12, 'verbose': False,
29+
'ngpus_per_trial': 4, 'batch_size': 4, 'hybridize': True,
30+
'lr_decay_epoch': ag.Categorical([24, 28], [35], [50, 55], [40], [45], [55],
31+
[30, 35], [20]),
32+
'warmup_iters': ag.Int(5, 500), 'resume': False, 'checkpoint': 'checkpoint/exp1.ag',
33+
'visualizer': 'none', 'start_epoch': 0, 'lr_mode': 'step', 'lr_decay': 0.1,
34+
'lr_decay_period': 0, 'warmup_lr': 0.0, 'warmup_epochs': 2, 'warmup_factor': 1. / 3.,
35+
'momentum': 0.9, 'log_interval': 100, 'save_prefix': '', 'save_interval': 10,
36+
'val_interval': 1, 'num_samples': -1, 'no_random_shape': False, 'no_wd': False,
37+
'mixup': False, 'no_mixup_epochs': 20, 'reuse_pred_weights': True, 'horovod': False,
38+
'grace_period': None, 'auto_search': True, 'seed': 223,
39+
'wd': ag.Categorical(1e-4, 5e-4, 2.5e-4), 'syncbn': ag.Bool(), 'label_smooth': False,
40+
'time_limits': time_limits, 'dist_ip_addrs': []}
41+
42+
# Construct a object detection task based on the config.
43+
task = ObjectDetection(search_args, FasterRCNNEstimator)
44+
45+
# Automatically fit a model.
46+
estimator = task.fit()
47+
48+
# Evaluate the final model on test set.
49+
test_map = estimator.evaluate()
50+
print("mAP on test dataset: {}".format(test_map[-1][-1]))
51+
print(test_map)
52+
53+
# Save our final model.
54+
estimator.save('final_model.model')
55+
56+
##########################################################
57+
# References
58+
# ----------
59+
#
60+
# .. [Girshick14] Ross Girshick and Jeff Donahue and Trevor Darrell and Jitendra Malik. Rich Feature Hierarchies for Accurate Object Detection and Semantic Segmentation. CVPR 2014.
61+
# .. [Girshick15] Ross Girshick. Fast {R-CNN}. ICCV 2015.
62+
# .. [Ren15] Shaoqing Ren and Kaiming He and Ross Girshick and Jian Sun. Faster {R-CNN}: Towards Real-Time Object Detection with Region Proposal Networks. NIPS 2015.
63+
# .. [He16] Kaiming He and Xiangyu Zhang and Shaoqing Ren and Jian Sun. Deep Residual Learning for Image Recognition. CVPR 2016.
64+
# .. [Lin17] Tsung-Yi Lin and Piotr Dollár and Ross Girshick and Kaiming He and Bharath Hariharan and Serge Belongie. Feature Pyramid Networks for Object Detection. CVPR 2017.

docs/tutorials/detection/finetune_detection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,4 @@ def get_dataloader(net, train_dataset, data_shape, batch_size, num_workers):
170170
# adapting a training blocks in the following examples:
171171
#
172172
# :download:`Download train_faster_rcnn.py<../../../scripts/detection/faster_rcnn/train_faster_rcnn.py>`
173-
# :download:`Download train_yolo3.py<../../../scripts/detection/yolo/train_yolo3.py>`
173+
# :download:`Download train_yolo.py<../../../scripts/detection/yolo/train_yolo.py>`

docs/tutorials/detection/train_yolo_v3.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
You can skip the rest of this tutorial and start training your YOLOv3 model
1313
right away by downloading this script:
1414
15-
:download:`Download train_yolo3.py<../../../scripts/detection/yolo/train_yolo3.py>`
15+
:download:`Download train_yolo.py<../../../scripts/detection/yolo/train_yolo.py>`
1616
Random shape training requires more GPU memory but generates better results. You can turn it off by setting `--no-random-shape`.
1717
1818
Example usage:
@@ -21,19 +21,19 @@
2121
2222
.. code-block:: bash
2323
24-
python train_yolo3.py --gpus 0
24+
python train_yolo.py --gpus 0
2525
2626
Train a darknet53 model on GPU 0,1,2,3 with synchronize BatchNorm:
2727
2828
.. code-block:: bash
2929
30-
python train_yolo3.py --gpus 0,1,2,3 --network darknet53 --syncbn
30+
python train_yolo.py --gpus 0,1,2,3 --network darknet53 --syncbn
3131
3232
Check the supported arguments:
3333
3434
.. code-block:: bash
3535
36-
python train_yolo3.py --help
36+
python train_yolo.py --help
3737
3838
3939
.. hint::
@@ -234,7 +234,7 @@
234234
#
235235
# .. hint::
236236
#
237-
# Please checkout the full :download:`training script <../../../scripts/detection/yolo/train_yolo3.py>` for complete implementation.
237+
# Please checkout the full :download:`training script <../../../scripts/detection/yolo/train_yolo.py>` for complete implementation.
238238

239239

240240
##########################################################

docs/tutorials/pose/cam_demo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
detector.reset_class(classes=['person'], reuse_weights={'person':'person'})
5353
detector.hybridize()
5454
55-
Next for the estimator, we choose ``simple_pose_resnet18_v1b`` for it is light-weighted.
55+
Next for the estimators, we choose ``simple_pose_resnet18_v1b`` for it is light-weighted.
5656
5757
The default ``simple_pose_resnet18_v1b`` model was trained with input size 256x192.
5858
We also provide an optional ``simple_pose_resnet18_v1b`` model trained with input size 128x96.
@@ -61,8 +61,8 @@
6161
6262
.. code-block:: python
6363
64-
estimator = get_model('simple_pose_resnet18_v1b', pretrained='ccd24037', ctx=ctx)
65-
estimator.hybridize()
64+
estimators = get_model('simple_pose_resnet18_v1b', pretrained='ccd24037', ctx=ctx)
65+
estimators.hybridize()
6666
6767
With OpenCV, we can easily retrieve frames from the webcam.
6868
@@ -107,7 +107,7 @@
107107
pose_input, upscale_bbox = detector_to_simple_pose(frame, class_IDs, scores, bounding_boxs,
108108
output_shape=(128, 96), ctx=ctx)
109109
if len(upscale_bbox) > 0:
110-
predicted_heatmap = estimator(pose_input)
110+
predicted_heatmap = estimators(pose_input)
111111
pred_coords, confidence = heatmap_to_coord(predicted_heatmap, upscale_bbox)
112112
113113
img = cv_plot_keypoints(frame, pred_coords, confidence, class_IDs, bounding_boxs, scores,

gluoncv/auto/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"""GluonCV auto"""
2+
from .estimators import *

gluoncv/auto/data/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"""Data Pipelines"""
2+
from .auto_data import url_data, URLs, is_url

gluoncv/auto/data/auto_data.py

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
"""Auto data preparation."""
2+
import os
3+
import re
4+
from pathlib import Path
5+
import yaml
6+
from ...utils.download import download
7+
from ...utils.filesystem import unzip, untar, PathTree
8+
9+
def url_data(url, path=None, overwrite=False, overwrite_folder=False, sha1_hash=None, root=None, disp_depth=1):
10+
"""Download an given URL
11+
12+
Parameters
13+
----------
14+
url : str
15+
URL to download
16+
path : str, optional
17+
Destination path to store downloaded file. By default stores to the
18+
~/.gluoncv directory with same name as in url.
19+
You can also change the default behavior by editing ~/.gluoncv/config.yaml.
20+
overwrite : bool, optional
21+
Whether to overwrite destination file if already exists.
22+
overwrite_folder : bool, optional
23+
Whether to extract file to destination folder if already exists. You may use this option if you suspect
24+
the destination is corrupted or some files are missing.
25+
sha1_hash : str, optional
26+
Expected sha1 hash in hexadecimal digits. Will ignore existing file when hash is specified
27+
but doesn't match.
28+
root : str, optional
29+
Destination root dir to store extracted files. By default it's default in ~/.gluoncv directory.
30+
disp_depth : int, optional
31+
If set > 0, will print out the tree structure of extracted dataset folder with maximum `disp_depth`.
32+
33+
Returns
34+
-------
35+
str or tuple of str
36+
The file path of the downloaded file.
37+
"""
38+
fname = Path(path or URLs.path(url, c_key='archive'))
39+
fname.parent.mkdir(parents=True, exist_ok=True)
40+
fname = download(url, path=str(fname.resolve()), overwrite=overwrite, sha1_hash=sha1_hash)
41+
extract_root = URLs.path(url, c_key='data')
42+
extract_root = extract_root.parent.joinpath(extract_root.stem)
43+
extract_root.mkdir(parents=True, exist_ok=True)
44+
if fname.endswith('.zip'):
45+
folder = unzip(fname, root=root if root else extract_root, strict=overwrite_folder)
46+
elif fname.endswith('gz'):
47+
folder = untar(fname, root=root if root else extract_root, strict=overwrite_folder)
48+
else:
49+
raise ValueError('Unknown url data with file: {}'.format(fname))
50+
51+
if disp_depth > 0:
52+
path_tree = PathTree(folder, disp_depth)
53+
print(path_tree)
54+
55+
return Path(folder)
56+
57+
58+
class Config:
59+
"Setup config at `~/.gluoncv` unless it exists already."
60+
config_path = Path(os.getenv('MXNET_HOME', '~/.gluoncv')).expanduser()
61+
config_file = config_path/'config.yml'
62+
63+
def __init__(self):
64+
self.config_path.mkdir(parents=True, exist_ok=True)
65+
if not self.config_file.exists():
66+
self.create_config()
67+
self.d = self.load_config()
68+
69+
def __getitem__(self, k):
70+
k = k.lower()
71+
if k not in self.d:
72+
k = k + '_path'
73+
return Path(self.d[k])
74+
75+
def __getattr__(self, k):
76+
if k == 'd':
77+
raise AttributeError
78+
return self[k]
79+
80+
def __setitem__(self, k, v):
81+
self.d[k] = str(v)
82+
def __contains__(self, k):
83+
return k in self.d
84+
85+
def load_config(self):
86+
"load and return config if version equals 2 in existing, else create new config."
87+
with open(self.config_file, 'r') as f:
88+
config = yaml.safe_load(f)
89+
if 'version' in config and config['version'] == 2:
90+
return config
91+
elif 'version' in config:
92+
self.create_config(config)
93+
else:
94+
self.create_config()
95+
return self.load_config()
96+
97+
def create_config(self, cfg=None):
98+
"create new config with default paths and set `version` to 2."
99+
config = {'data_path': str(self.config_path/'datasets'),
100+
'archive_path': str(self.config_path/'archive'),
101+
'storage_path': '/tmp',
102+
'model_path': str(self.config_path/'models'),
103+
'version': 2}
104+
if cfg is not None:
105+
cfg['version'] = 2
106+
config = merge(config, cfg)
107+
self.save_file(config)
108+
109+
def save(self):
110+
self.save_file(self.d)
111+
112+
def save_file(self, config):
113+
"save config file at default config location `~/.gluoncv/config.yml`."
114+
with self.config_file.open('w') as f:
115+
yaml.dump(config, f, default_flow_style=False)
116+
117+
118+
# pylint: disable=bad-whitespace
119+
class URLs():
120+
"Global constants for dataset and model URLs."
121+
LOCAL_PATH = Path.cwd()
122+
MDL = 'http://files.fast.ai/models/'
123+
S3 = 'https://s3.amazonaws.com/fast-ai-'
124+
URL = f'{S3}sample/'
125+
126+
S3_IMAGE = f'{S3}imageclas/'
127+
S3_IMAGELOC = f'{S3}imagelocal/'
128+
S3_COCO = f'{S3}coco/'
129+
130+
# main datasets
131+
ADULT_SAMPLE = f'{URL}adult_sample.tgz'
132+
BIWI_SAMPLE = f'{URL}biwi_sample.tgz'
133+
CIFAR = f'{URL}cifar10.tgz'
134+
COCO_SAMPLE = f'{S3_COCO}coco_sample.tgz'
135+
COCO_TINY = f'{S3_COCO}coco_tiny.tgz'
136+
HUMAN_NUMBERS = f'{URL}human_numbers.tgz'
137+
# IMDB = f'{S3_NLP}imdb.tgz'
138+
IMDB_SAMPLE = f'{URL}imdb_sample.tgz'
139+
ML_SAMPLE = f'{URL}movie_lens_sample.tgz'
140+
ML_100k = 'http://files.grouplens.org/datasets/movielens/ml-100k.zip'
141+
MNIST_SAMPLE = f'{URL}mnist_sample.tgz'
142+
MNIST_TINY = f'{URL}mnist_tiny.tgz'
143+
MNIST_VAR_SIZE_TINY = f'{S3_IMAGE}mnist_var_size_tiny.tgz'
144+
PLANET_SAMPLE = f'{URL}planet_sample.tgz'
145+
PLANET_TINY = f'{URL}planet_tiny.tgz'
146+
IMAGENETTE = f'{S3_IMAGE}imagenette2.tgz'
147+
IMAGENETTE_160 = f'{S3_IMAGE}imagenette2-160.tgz'
148+
IMAGENETTE_320 = f'{S3_IMAGE}imagenette2-320.tgz'
149+
IMAGEWOOF = f'{S3_IMAGE}imagewoof2.tgz'
150+
IMAGEWOOF_160 = f'{S3_IMAGE}imagewoof2-160.tgz'
151+
IMAGEWOOF_320 = f'{S3_IMAGE}imagewoof2-320.tgz'
152+
IMAGEWANG = f'{S3_IMAGE}imagewang.tgz'
153+
IMAGEWANG_160 = f'{S3_IMAGE}imagewang-160.tgz'
154+
IMAGEWANG_320 = f'{S3_IMAGE}imagewang-320.tgz'
155+
156+
# kaggle competitions download dogs-vs-cats -p {DOGS.absolute()}
157+
DOGS = f'{URL}dogscats.tgz'
158+
159+
# image classification datasets
160+
CALTECH_101 = f'{S3_IMAGE}caltech_101.tgz'
161+
CARS = f'{S3_IMAGE}stanford-cars.tgz'
162+
CIFAR_100 = f'{S3_IMAGE}cifar100.tgz'
163+
CUB_200_2011 = f'{S3_IMAGE}CUB_200_2011.tgz'
164+
FLOWERS = f'{S3_IMAGE}oxford-102-flowers.tgz'
165+
FOOD = f'{S3_IMAGE}food-101.tgz'
166+
MNIST = f'{S3_IMAGE}mnist_png.tgz'
167+
PETS = f'{S3_IMAGE}oxford-iiit-pet.tgz'
168+
169+
# Image localization datasets
170+
BIWI_HEAD_POSE = f"{S3_IMAGELOC}biwi_head_pose.tgz"
171+
CAMVID = f'{S3_IMAGELOC}camvid.tgz'
172+
CAMVID_TINY = f'{URL}camvid_tiny.tgz'
173+
LSUN_BEDROOMS = f'{S3_IMAGE}bedroom.tgz'
174+
PASCAL_2007 = f'{S3_IMAGELOC}pascal_2007.tgz'
175+
PASCAL_2012 = f'{S3_IMAGELOC}pascal_2012.tgz'
176+
177+
# Medical Imaging datasets
178+
#SKIN_LESION = f'{S3_IMAGELOC}skin_lesion.tgz'
179+
SIIM_SMALL = f'{S3_IMAGELOC}siim_small.tgz'
180+
181+
@staticmethod
182+
def path(url='.', c_key='archive'):
183+
"Return local path where to download based on `c_key`"
184+
fname = url.split('/')[-1]
185+
local_path = URLs.LOCAL_PATH / ('models' if c_key == 'models' else 'datasets')/fname
186+
if local_path.exists():
187+
return local_path
188+
return Config()[c_key]/fname
189+
190+
_URL_REGEX = re.compile(
191+
r'^(?:http|ftp)s?://' # http:// or https://
192+
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
193+
r'localhost|' #localhost...
194+
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
195+
r'(?::\d+)?' # optional port
196+
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
197+
198+
def is_url(url_like):
199+
if not isinstance(url_like, str):
200+
return False
201+
return re.match(_URL_REGEX, url_like) is not None

0 commit comments

Comments
 (0)