-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ac2fd30
Showing
54 changed files
with
3,260 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# User defined | ||
data/* | ||
!data/demo/ | ||
model/* | ||
!model/README.md | ||
cache/* | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
*.d | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*~ | ||
|
||
*.pyc | ||
.Rhistory | ||
*log | ||
Debug | ||
*suo | ||
tracker | ||
|
||
# vim | ||
*.swp | ||
*.swo | ||
*.swn | ||
.vimrc | ||
.ycm_extra_conf.py | ||
.ycm_extra_conf.pyc | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# IPython Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
venv/ | ||
ENV/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
|
||
# Rope project settings | ||
.ropeproject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "mxnet"] | ||
path = mxnet | ||
url = https://github.com/zhreshold/mxnet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016 Joshua Z. Zhang | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# YOLO-v2: Real-Time Object Detection | ||
|
||
|
||
|
||
### Disclaimer |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import os | ||
from utils import DotDict, namedtuple_with_defaults, zip_namedtuple, config_as_dict | ||
|
||
RandCropper = namedtuple_with_defaults('RandCropper', | ||
'min_crop_scales, max_crop_scales, \ | ||
min_crop_aspect_ratios, max_crop_aspect_ratios, \ | ||
min_crop_overlaps, max_crop_overlaps, \ | ||
min_crop_sample_coverages, max_crop_sample_coverages, \ | ||
min_crop_object_coverages, max_crop_object_coverages, \ | ||
max_crop_trials', | ||
[0.0, 1.0, | ||
0.5, 2.0, | ||
0.0, 1.0, | ||
0.0, 1.0, | ||
0.0, 1.0, | ||
25]) | ||
|
||
RandPadder = namedtuple_with_defaults('RandPadder', | ||
'rand_pad_prob, max_pad_scale, fill_value', | ||
[0.0, 1.0, 127]) | ||
|
||
ColorJitter = namedtuple_with_defaults('ColorJitter', | ||
'random_hue_prob, max_random_hue, \ | ||
random_saturation_prob, max_random_saturation, \ | ||
random_illumination_prob, max_random_illumination, \ | ||
random_contrast_prob, max_random_contrast', | ||
[0.0, 18, | ||
0.0, 32, | ||
0.0, 32, | ||
0.0, 0.5]) | ||
|
||
|
||
cfg = DotDict() | ||
cfg.ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) | ||
|
||
# training configs | ||
cfg.train = DotDict() | ||
# random cropping samplers | ||
cfg.train.rand_crop_samplers = [ | ||
RandCropper(min_crop_scales=0.3, min_crop_overlaps=0.1), | ||
RandCropper(min_crop_scales=0.3, min_crop_overlaps=0.3), | ||
RandCropper(min_crop_scales=0.3, min_crop_overlaps=0.5), | ||
RandCropper(min_crop_scales=0.3, min_crop_overlaps=0.7), | ||
RandCropper(min_crop_scales=0.3, min_crop_overlaps=0.9),] | ||
cfg.train.crop_emit_mode = 'center' | ||
# cfg.train.emit_overlap_thresh = 0.4 | ||
# random padding | ||
cfg.train.rand_pad = RandPadder(rand_pad_prob=0.5, max_pad_scale=4.0) | ||
# random color jitter | ||
cfg.train.color_jitter = ColorJitter(random_hue_prob=0.5, random_saturation_prob=0.5, | ||
random_illumination_prob=0.5, random_contrast_prob=0.5) | ||
cfg.train.inter_method = 10 # random interpolation | ||
cfg.train.rand_mirror_prob = 0.5 | ||
cfg.train.shuffle = True | ||
cfg.train.seed = 233 | ||
cfg.train.preprocess_threads = 6 | ||
cfg.train = config_as_dict(cfg.train) # convert to normal dict | ||
|
||
# validation | ||
cfg.valid = DotDict() | ||
cfg.valid.rand_crop_samplers = [] | ||
cfg.valid.rand_pad = RandPadder() | ||
cfg.valid.color_jitter = ColorJitter() | ||
cfg.valid.rand_mirror_prob = 0 | ||
cfg.valid.shuffle = False | ||
cfg.valid.seed = 0 | ||
cfg.valid = config_as_dict(cfg.valid) # convert to normal dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import collections | ||
|
||
class DotDict(dict): | ||
""" | ||
Simple class for dot access elements in dict, support nested initialization | ||
Example: | ||
d = DotDict({'child': 'dotdict'}, name='dotdict', index=1, contents=['a', 'b']) | ||
# add new key | ||
d.new_key = '!' # or d['new_key'] = '!' | ||
# update values | ||
d.new_key = '!!!' | ||
# delete keys | ||
del d.new_key | ||
""" | ||
def __init__(self, *args, **kwargs): | ||
super(DotDict, self).__init__(*args, **kwargs) | ||
for arg in args: | ||
if isinstance(arg, dict): | ||
for k, v in arg.items(): | ||
self[k] = v | ||
|
||
if kwargs: | ||
for k, v in kwargs.items(): | ||
self[k] = v | ||
|
||
def __getattr__(self, attr): | ||
return self.get(attr) | ||
|
||
def __setattr__(self, key, value): | ||
self.__setitem__(key, value) | ||
|
||
def __setitem__(self, key, value): | ||
super(DotDict, self).__setitem__(key, value) | ||
self.__dict__.update({key: value}) | ||
|
||
def __delattr__(self, item): | ||
self.__delitem__(item) | ||
|
||
def __delitem__(self, key): | ||
super(DotDict, self).__delitem__(key) | ||
del self.__dict__[key] | ||
|
||
|
||
def namedtuple_with_defaults(typename, field_names, default_values=()): | ||
""" create a namedtuple with default values """ | ||
T = collections.namedtuple(typename, field_names) | ||
T.__new__.__defaults__ = (None, ) * len(T._fields) | ||
if isinstance(default_values, collections.Mapping): | ||
prototype = T(**default_values) | ||
else: | ||
prototype = T(*default_values) | ||
T.__new__.__defaults__ = tuple(prototype) | ||
return T | ||
|
||
def merge_dict(a, b): | ||
""" merge dict a, b, with b overriding keys in a """ | ||
c = a.copy() | ||
c.update(b) | ||
return c | ||
|
||
def zip_namedtuple(nt_list): | ||
""" accept list of namedtuple, return a dict of zipped fields """ | ||
if not nt_list: | ||
return dict() | ||
if not isinstance(nt_list, list): | ||
nt_list = [nt_list] | ||
for nt in nt_list: | ||
assert type(nt) == type(nt_list[0]) | ||
ret = {k : [v] for k, v in nt_list[0]._asdict().items()} | ||
for nt in nt_list[1:]: | ||
for k, v in nt._asdict().items(): | ||
ret[k].append(v) | ||
return ret | ||
|
||
def config_as_dict(cfg): | ||
""" convert raw configuration to unified dictionary """ | ||
ret = cfg.__dict__.copy() | ||
# random cropping params | ||
del ret['rand_crop_samplers'] | ||
assert isinstance(cfg.rand_crop_samplers, list) | ||
ret = merge_dict(ret, zip_namedtuple(cfg.rand_crop_samplers)) | ||
num_crop_sampler = len(cfg.rand_crop_samplers) | ||
ret['num_crop_sampler'] = num_crop_sampler # must specify the # | ||
ret['rand_crop_prob'] = 1.0 / (num_crop_sampler + 1) * num_crop_sampler | ||
# random padding params | ||
del ret['rand_pad'] | ||
ret = merge_dict(ret, cfg.rand_pad._asdict()) | ||
# color jitter | ||
del ret['color_jitter'] | ||
ret = merge_dict(ret, cfg.color_jitter._asdict()) | ||
return ret |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Oops, something went wrong.