Spaces:
Paused
Paused
Dean
commited on
Commit
•
3c0c5aa
1
Parent(s):
9cd8f4a
Finished data import and processing setup, bug in training step
Browse files- .dvc/.gitignore +3 -0
- .dvc/config +4 -0
- .dvc/plots/confusion.json +30 -0
- .dvc/plots/default.json +29 -0
- .dvc/plots/scatter.json +27 -0
- .dvc/plots/smooth.json +39 -0
- .dvcignore +3 -0
- Makefile +1 -1
- dvc.lock +13 -0
- dvc.yaml +10 -0
- requirements.txt +148 -1
- src/code/make_dataset.py +94 -1
- src/code/training.py +37 -0
- src/data/.gitignore +1 -0
- src/data/raw/.gitignore +2 -0
- src/data/raw/nyu_depth_v2_labeled.mat.dvc +8 -0
- src/data/raw/splits.mat.dvc +8 -0
.dvc/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
/config.local
|
2 |
+
/tmp
|
3 |
+
/cache
|
.dvc/config
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[core]
|
2 |
+
analytics = false
|
3 |
+
['remote "dvc-remote"']
|
4 |
+
url = s3://dagshub-savta-depth
|
.dvc/plots/confusion.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
|
3 |
+
"data": {
|
4 |
+
"values": "<DVC_METRIC_DATA>"
|
5 |
+
},
|
6 |
+
"title": "<DVC_METRIC_TITLE>",
|
7 |
+
"mark": "rect",
|
8 |
+
"encoding": {
|
9 |
+
"x": {
|
10 |
+
"field": "<DVC_METRIC_X>",
|
11 |
+
"type": "nominal",
|
12 |
+
"sort": "ascending",
|
13 |
+
"title": "<DVC_METRIC_X_LABEL>"
|
14 |
+
},
|
15 |
+
"y": {
|
16 |
+
"field": "<DVC_METRIC_Y>",
|
17 |
+
"type": "nominal",
|
18 |
+
"sort": "ascending",
|
19 |
+
"title": "<DVC_METRIC_Y_LABEL>"
|
20 |
+
},
|
21 |
+
"color": {
|
22 |
+
"aggregate": "count",
|
23 |
+
"type": "quantitative"
|
24 |
+
},
|
25 |
+
"facet": {
|
26 |
+
"field": "rev",
|
27 |
+
"type": "nominal"
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
.dvc/plots/default.json
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
|
3 |
+
"data": {
|
4 |
+
"values": "<DVC_METRIC_DATA>"
|
5 |
+
},
|
6 |
+
"title": "<DVC_METRIC_TITLE>",
|
7 |
+
"mark": {
|
8 |
+
"type": "line"
|
9 |
+
},
|
10 |
+
"encoding": {
|
11 |
+
"x": {
|
12 |
+
"field": "<DVC_METRIC_X>",
|
13 |
+
"type": "quantitative",
|
14 |
+
"title": "<DVC_METRIC_X_LABEL>"
|
15 |
+
},
|
16 |
+
"y": {
|
17 |
+
"field": "<DVC_METRIC_Y>",
|
18 |
+
"type": "quantitative",
|
19 |
+
"title": "<DVC_METRIC_Y_LABEL>",
|
20 |
+
"scale": {
|
21 |
+
"zero": false
|
22 |
+
}
|
23 |
+
},
|
24 |
+
"color": {
|
25 |
+
"field": "rev",
|
26 |
+
"type": "nominal"
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
.dvc/plots/scatter.json
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
|
3 |
+
"data": {
|
4 |
+
"values": "<DVC_METRIC_DATA>"
|
5 |
+
},
|
6 |
+
"title": "<DVC_METRIC_TITLE>",
|
7 |
+
"mark": "point",
|
8 |
+
"encoding": {
|
9 |
+
"x": {
|
10 |
+
"field": "<DVC_METRIC_X>",
|
11 |
+
"type": "quantitative",
|
12 |
+
"title": "<DVC_METRIC_X_LABEL>"
|
13 |
+
},
|
14 |
+
"y": {
|
15 |
+
"field": "<DVC_METRIC_Y>",
|
16 |
+
"type": "quantitative",
|
17 |
+
"title": "<DVC_METRIC_Y_LABEL>",
|
18 |
+
"scale": {
|
19 |
+
"zero": false
|
20 |
+
}
|
21 |
+
},
|
22 |
+
"color": {
|
23 |
+
"field": "rev",
|
24 |
+
"type": "nominal"
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
.dvc/plots/smooth.json
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
|
3 |
+
"data": {
|
4 |
+
"values": "<DVC_METRIC_DATA>"
|
5 |
+
},
|
6 |
+
"title": "<DVC_METRIC_TITLE>",
|
7 |
+
"mark": {
|
8 |
+
"type": "line"
|
9 |
+
},
|
10 |
+
"encoding": {
|
11 |
+
"x": {
|
12 |
+
"field": "<DVC_METRIC_X>",
|
13 |
+
"type": "quantitative",
|
14 |
+
"title": "<DVC_METRIC_X_LABEL>"
|
15 |
+
},
|
16 |
+
"y": {
|
17 |
+
"field": "<DVC_METRIC_Y>",
|
18 |
+
"type": "quantitative",
|
19 |
+
"title": "<DVC_METRIC_Y_LABEL>",
|
20 |
+
"scale": {
|
21 |
+
"zero": false
|
22 |
+
}
|
23 |
+
},
|
24 |
+
"color": {
|
25 |
+
"field": "rev",
|
26 |
+
"type": "nominal"
|
27 |
+
}
|
28 |
+
},
|
29 |
+
"transform": [
|
30 |
+
{
|
31 |
+
"loess": "<DVC_METRIC_Y>",
|
32 |
+
"on": "<DVC_METRIC_X>",
|
33 |
+
"groupby": [
|
34 |
+
"rev"
|
35 |
+
],
|
36 |
+
"bandwidth": 0.3
|
37 |
+
}
|
38 |
+
]
|
39 |
+
}
|
.dvcignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# Add patterns of files dvc should ignore, which could improve
|
2 |
+
# the performance. Learn more at
|
3 |
+
# https://dvc.org/doc/user-guide/dvcignore
|
Makefile
CHANGED
@@ -19,7 +19,7 @@ endif
|
|
19 |
env:
|
20 |
ifeq (True,$(HAS_CONDA))
|
21 |
@echo ">>> Detected conda, creating conda environment."
|
22 |
-
conda create --name $(PROJECT_NAME) python=3
|
23 |
@echo ">>> New conda env created. Activate with:\nconda activate $(PROJECT_NAME)"
|
24 |
else
|
25 |
@echo ">>> No conda detected, creating venv environment."
|
|
|
19 |
env:
|
20 |
ifeq (True,$(HAS_CONDA))
|
21 |
@echo ">>> Detected conda, creating conda environment."
|
22 |
+
conda create --name $(PROJECT_NAME) python=3.7.6
|
23 |
@echo ">>> New conda env created. Activate with:\nconda activate $(PROJECT_NAME)"
|
24 |
else
|
25 |
@echo ">>> No conda detected, creating venv environment."
|
dvc.lock
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
process_data:
|
2 |
+
cmd: python3 src/code/make_dataset.py src/data/raw/nyu_depth_v2_labeled.mat src/data/raw/splits.mat
|
3 |
+
src/data/processed
|
4 |
+
deps:
|
5 |
+
- path: src/code/make_dataset.py
|
6 |
+
md5: b15a09b30657f303d62215ceb73c6f4f
|
7 |
+
- path: src/data/raw/nyu_depth_v2_labeled.mat
|
8 |
+
md5: 520609c519fba3ba5ac58c8fefcc3530
|
9 |
+
- path: src/data/raw/splits.mat
|
10 |
+
md5: 08e3c3aea27130ac7c01ffd739a4535f
|
11 |
+
outs:
|
12 |
+
- path: src/data/processed/
|
13 |
+
md5: 78d932b016048d527f9e73e1781127cd.dir
|
dvc.yaml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
stages:
|
2 |
+
process_data:
|
3 |
+
cmd: python3 src/code/make_dataset.py src/data/raw/nyu_depth_v2_labeled.mat src/data/raw/splits.mat
|
4 |
+
src/data/processed
|
5 |
+
deps:
|
6 |
+
- src/code/make_dataset.py
|
7 |
+
- src/data/raw/nyu_depth_v2_labeled.mat
|
8 |
+
- src/data/raw/splits.mat
|
9 |
+
outs:
|
10 |
+
- src/data/processed/
|
requirements.txt
CHANGED
@@ -1 +1,148 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file may be used to create an environment using:
|
2 |
+
# $ conda create --name <env> --file <this file>
|
3 |
+
# platform: linux-64
|
4 |
+
_libgcc_mutex=0.1=main
|
5 |
+
appdirs=1.4.4=pypi_0
|
6 |
+
atpublic=2.0=pypi_0
|
7 |
+
attrs=19.3.0=py_0
|
8 |
+
backcall=0.2.0=pypi_0
|
9 |
+
beautifulsoup4=4.9.1=py37_0
|
10 |
+
blas=1.0=mkl
|
11 |
+
bottleneck=1.3.2=py37heb32a55_1
|
12 |
+
brotlipy=0.7.0=py37h7b6447c_1000
|
13 |
+
ca-certificates=2020.6.24=0
|
14 |
+
catalogue=1.0.0=py37_1
|
15 |
+
certifi=2020.6.20=py37_0
|
16 |
+
cffi=1.14.0=py37h2e261b9_0
|
17 |
+
chardet=3.0.4=py37_1003
|
18 |
+
colorama=0.4.3=pypi_0
|
19 |
+
commonmark=0.9.1=pypi_0
|
20 |
+
configobj=5.0.6=pypi_0
|
21 |
+
cryptography=2.9.2=py37h1ba5d50_0
|
22 |
+
cudatoolkit=10.2.89=hfd86e86_1
|
23 |
+
cycler=0.10.0=py37_0
|
24 |
+
cymem=2.0.3=py37he6710b0_0
|
25 |
+
cython-blis=0.4.1=py37h7b6447c_1
|
26 |
+
dataclasses=0.7=py37_0
|
27 |
+
decorator=4.4.2=pypi_0
|
28 |
+
dictdiffer=0.8.1=pypi_0
|
29 |
+
distro=1.5.0=pypi_0
|
30 |
+
dpath=2.0.1=pypi_0
|
31 |
+
dvc=1.6.0=pypi_0
|
32 |
+
fastai=1.0.61=1
|
33 |
+
fastcore=1.0.0=pyh39e3cac_0
|
34 |
+
fastprogress=1.0.0=pyh39e3cac_0
|
35 |
+
flatten-json=0.1.7=pypi_0
|
36 |
+
flufl-lock=3.2=pypi_0
|
37 |
+
freetype=2.10.2=h5ab3b9f_0
|
38 |
+
funcy=1.14=pypi_0
|
39 |
+
future=0.18.2=pypi_0
|
40 |
+
gitdb=4.0.5=pypi_0
|
41 |
+
gitpython=3.1.7=pypi_0
|
42 |
+
grandalf=0.6=pypi_0
|
43 |
+
h5py=2.10.0=pypi_0
|
44 |
+
idna=2.10=py_0
|
45 |
+
importlib-metadata=1.7.0=py37_0
|
46 |
+
importlib_metadata=1.7.0=0
|
47 |
+
intel-openmp=2020.1=217
|
48 |
+
ipython=7.17.0=pypi_0
|
49 |
+
ipython-genutils=0.2.0=pypi_0
|
50 |
+
jedi=0.17.2=pypi_0
|
51 |
+
joblib=0.16.0=py_0
|
52 |
+
jpeg=9b=h024ee3a_2
|
53 |
+
jsonpath-ng=1.5.1=pypi_0
|
54 |
+
jsonschema=3.0.2=py37_0
|
55 |
+
kiwisolver=1.2.0=py37hfd86e86_0
|
56 |
+
lcms2=2.11=h396b838_0
|
57 |
+
ld_impl_linux-64=2.33.1=h53a641e_7
|
58 |
+
libedit=3.1.20191231=h14c3975_1
|
59 |
+
libffi=3.2.1=hd88cf55_4
|
60 |
+
libgcc-ng=9.1.0=hdf63c60_0
|
61 |
+
libgfortran-ng=7.3.0=hdf63c60_0
|
62 |
+
libpng=1.6.37=hbc83047_0
|
63 |
+
libstdcxx-ng=9.1.0=hdf63c60_0
|
64 |
+
libtiff=4.1.0=h2733197_1
|
65 |
+
lz4-c=1.9.2=he6710b0_1
|
66 |
+
matplotlib=3.3.1=1
|
67 |
+
matplotlib-base=3.3.1=py37h817c723_0
|
68 |
+
mkl=2020.1=217
|
69 |
+
mkl-service=2.3.0=py37he904b0f_0
|
70 |
+
mkl_fft=1.1.0=py37h23d657b_0
|
71 |
+
mkl_random=1.1.1=py37h0573a6f_0
|
72 |
+
murmurhash=1.0.2=py37he6710b0_0
|
73 |
+
nanotime=0.5.2=pypi_0
|
74 |
+
ncurses=6.2=he6710b0_1
|
75 |
+
networkx=2.4=pypi_0
|
76 |
+
ninja=1.10.0=py37hfd86e86_0
|
77 |
+
numexpr=2.7.1=py37h423224d_0
|
78 |
+
numpy=1.19.1=py37hbc911f0_0
|
79 |
+
numpy-base=1.19.1=py37hfa32c7d_0
|
80 |
+
nvidia-ml-py3=7.352.0=py_0
|
81 |
+
olefile=0.46=py37_0
|
82 |
+
opencv-python=4.4.0.42=pypi_0
|
83 |
+
openssl=1.1.1g=h7b6447c_0
|
84 |
+
packaging=20.4=py_0
|
85 |
+
pandas=1.1.0=py37he6710b0_0
|
86 |
+
parso=0.7.1=pypi_0
|
87 |
+
pathspec=0.8.0=pypi_0
|
88 |
+
pexpect=4.8.0=pypi_0
|
89 |
+
pickleshare=0.7.5=pypi_0
|
90 |
+
pillow=7.2.0=py37hb39fc2d_0
|
91 |
+
pip=20.2.2=py37_0
|
92 |
+
plac=0.9.6=py37_1
|
93 |
+
ply=3.11=pypi_0
|
94 |
+
preshed=3.0.2=py37he6710b0_1
|
95 |
+
prompt-toolkit=3.0.6=pypi_0
|
96 |
+
ptyprocess=0.6.0=pypi_0
|
97 |
+
pyasn1=0.4.8=pypi_0
|
98 |
+
pycparser=2.20=py_2
|
99 |
+
pydot=1.4.1=pypi_0
|
100 |
+
pygments=2.6.1=pypi_0
|
101 |
+
pygtrie=2.3.2=pypi_0
|
102 |
+
pyopenssl=19.1.0=py_1
|
103 |
+
pyparsing=2.4.7=py_0
|
104 |
+
pyrsistent=0.16.0=py37h7b6447c_0
|
105 |
+
pysocks=1.7.1=py37_1
|
106 |
+
python=3.7.6=cpython_h8356626_6
|
107 |
+
python-dateutil=2.8.1=py_0
|
108 |
+
python_abi=3.7=1_cp37m
|
109 |
+
pytorch=1.6.0=py3.7_cuda10.2.89_cudnn7.6.5_0
|
110 |
+
pytz=2020.1=py_0
|
111 |
+
pyyaml=5.3.1=py37h7b6447c_1
|
112 |
+
readline=8.0=h7b6447c_0
|
113 |
+
requests=2.24.0=py_0
|
114 |
+
rich=5.2.1=pypi_0
|
115 |
+
ruamel-yaml=0.16.10=pypi_0
|
116 |
+
ruamel-yaml-clib=0.2.0=pypi_0
|
117 |
+
scikit-learn=0.23.1=py37h423224d_0
|
118 |
+
scipy=1.5.2=py37h0b6359f_0
|
119 |
+
setuptools=49.6.0=py37_0
|
120 |
+
shortuuid=1.0.1=pypi_0
|
121 |
+
shtab=1.3.1=pypi_0
|
122 |
+
six=1.15.0=py_0
|
123 |
+
smmap=3.0.4=pypi_0
|
124 |
+
soupsieve=2.0.1=py_0
|
125 |
+
spacy=2.3.1=py37hfd86e86_0
|
126 |
+
sqlite=3.33.0=h62c20be_0
|
127 |
+
srsly=1.0.2=py37he6710b0_0
|
128 |
+
tabulate=0.8.7=pypi_0
|
129 |
+
thinc=7.4.1=py37hfd86e86_0
|
130 |
+
threadpoolctl=2.1.0=pyh5ca1d4c_0
|
131 |
+
tk=8.6.10=hbc83047_0
|
132 |
+
toml=0.10.1=pypi_0
|
133 |
+
torchvision=0.7.0=py37_cu102
|
134 |
+
tornado=6.0.4=py37h7b6447c_1
|
135 |
+
tqdm=4.48.2=py_0
|
136 |
+
traitlets=4.3.3=pypi_0
|
137 |
+
typing-extensions=3.7.4.2=pypi_0
|
138 |
+
urllib3=1.25.10=py_0
|
139 |
+
voluptuous=0.11.7=pypi_0
|
140 |
+
wasabi=0.7.1=py_0
|
141 |
+
wcwidth=0.2.5=pypi_0
|
142 |
+
wheel=0.34.2=py37_0
|
143 |
+
xz=5.2.5=h7b6447c_0
|
144 |
+
yaml=0.2.5=h7b6447c_0
|
145 |
+
zc-lockfile=2.0=pypi_0
|
146 |
+
zipp=3.1.0=py_0
|
147 |
+
zlib=1.2.11=h7b6447c_3
|
148 |
+
zstd=1.4.5=h9ceee32_0
|
src/code/make_dataset.py
CHANGED
@@ -1 +1,94 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
#######################################################################################
|
4 |
+
# The MIT License
|
5 |
+
|
6 |
+
# Copyright (c) 2014 Hannes Schulz, University of Bonn <schulz@ais.uni-bonn.de>
|
7 |
+
# Copyright (c) 2013 Benedikt Waldvogel, University of Bonn <mail@bwaldvogel.de>
|
8 |
+
# Copyright (c) 2008-2009 Sebastian Nowozin <nowozin@gmail.com>
|
9 |
+
|
10 |
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
11 |
+
# of this software and associated documentation files (the "Software"), to deal
|
12 |
+
# in the Software without restriction, including without limitation the rights
|
13 |
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14 |
+
# copies of the Software, and to permit persons to whom the Software is
|
15 |
+
# furnished to do so, subject to the following conditions:
|
16 |
+
#
|
17 |
+
# The above copyright notice and this permission notice shall be included in all
|
18 |
+
# copies or substantial portions of the Software.
|
19 |
+
#
|
20 |
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
21 |
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
22 |
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23 |
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
24 |
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25 |
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
26 |
+
# SOFTWARE.
|
27 |
+
#######################################################################################
|
28 |
+
#
|
29 |
+
# Helper script to convert the NYU Depth v2 dataset Matlab file into a set of
|
30 |
+
# PNG and JPEG images.
|
31 |
+
#
|
32 |
+
# See https://github.com/deeplearningais/curfil/wiki/Training-and-Prediction-with-the-NYU-Depth-v2-Dataset
|
33 |
+
|
34 |
+
from __future__ import print_function
|
35 |
+
|
36 |
+
import h5py
|
37 |
+
import numpy as np
|
38 |
+
import os
|
39 |
+
import scipy.io
|
40 |
+
import sys
|
41 |
+
import cv2
|
42 |
+
|
43 |
+
|
44 |
+
def convert_image(i, scene, depth, image, folder):
|
45 |
+
img_depth = depth * 1000.0
|
46 |
+
img_depth_uint16 = img_depth.astype(np.uint16)
|
47 |
+
cv2.imwrite("%s/%05d_depth.png" % (folder, i), img_depth_uint16)
|
48 |
+
|
49 |
+
image = image[:, :, ::-1]
|
50 |
+
image_black_boundary = np.zeros((480, 640, 3), dtype=np.uint8)
|
51 |
+
image_black_boundary[7:474, 7:632, :] = image[7:474, 7:632, :]
|
52 |
+
cv2.imwrite("%s/%05d.jpg" % (folder, i), image_black_boundary)
|
53 |
+
|
54 |
+
|
55 |
+
if __name__ == "__main__":
|
56 |
+
|
57 |
+
if len(sys.argv) < 4:
|
58 |
+
print("usage: %s <h5_file> <train_test_split> <out_folder>" % sys.argv[0], file=sys.stderr)
|
59 |
+
sys.exit(0)
|
60 |
+
|
61 |
+
h5_file = h5py.File(sys.argv[1], "r")
|
62 |
+
# h5py is not able to open that file. but scipy is
|
63 |
+
train_test = scipy.io.loadmat(sys.argv[2])
|
64 |
+
out_folder = sys.argv[3]
|
65 |
+
|
66 |
+
test_images = set([int(x) for x in train_test["testNdxs"]])
|
67 |
+
train_images = set([int(x) for x in train_test["trainNdxs"]])
|
68 |
+
print("%d training images" % len(train_images))
|
69 |
+
print("%d test images" % len(test_images))
|
70 |
+
|
71 |
+
depth = h5_file['depths']
|
72 |
+
|
73 |
+
print("reading", sys.argv[1])
|
74 |
+
|
75 |
+
images = h5_file['images']
|
76 |
+
scenes = [u''.join(chr(c) for c in h5_file[obj_ref]) for obj_ref in h5_file['sceneTypes'][0]]
|
77 |
+
|
78 |
+
print("processing images")
|
79 |
+
for i, image in enumerate(images):
|
80 |
+
print("image", i + 1, "/", len(images))
|
81 |
+
|
82 |
+
idx = int(i) + 1
|
83 |
+
if idx in train_images:
|
84 |
+
train_test = "train"
|
85 |
+
else:
|
86 |
+
assert idx in test_images, "index %d neither found in training set nor in test set" % idx
|
87 |
+
train_test = "test"
|
88 |
+
|
89 |
+
folder = "%s/%s/%s" % (out_folder, train_test, scenes[i])
|
90 |
+
if not os.path.exists(folder):
|
91 |
+
os.makedirs(folder)
|
92 |
+
convert_image(i, scenes[i], depth[i, :, :].T, image.T, folder)
|
93 |
+
|
94 |
+
print("Finished")
|
src/code/training.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import sys
|
3 |
+
from fastai.vision import unet_learner, ImageImageList, models, Path, root_mean_squared_error
|
4 |
+
|
5 |
+
|
6 |
+
def get_y_fn(x):
|
7 |
+
y = str(x.absolute()).replace('.jpg', '_depth.png')
|
8 |
+
y = Path(y)
|
9 |
+
|
10 |
+
return y
|
11 |
+
|
12 |
+
|
13 |
+
def create_databunch(data_path):
|
14 |
+
data = (ImageImageList.from_folder(data_path)
|
15 |
+
.filter_by_func(lambda fname: fname.suffix == '.jpg')
|
16 |
+
.split_by_folder(train='train', valid='test')
|
17 |
+
.label_from_func(get_y_fn).databunch()).normalize()
|
18 |
+
return data
|
19 |
+
|
20 |
+
|
21 |
+
def train(data):
|
22 |
+
learner = unet_learner(data, models.resnet34, metrics=root_mean_squared_error, wd=1e-2, loss_func=torch.nn.SmoothL1Loss())
|
23 |
+
learner.fit_one_cycle(1, 1e-3)
|
24 |
+
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
if len(sys.argv) < 3:
|
28 |
+
print("usage: %s <data_path> <out_folder>" % sys.argv[0], file=sys.stderr)
|
29 |
+
sys.exit(0)
|
30 |
+
|
31 |
+
data = create_databunch(sys.argv[1])
|
32 |
+
data.batch_size = 1
|
33 |
+
data.num_workers = 0
|
34 |
+
learner = train(data)
|
35 |
+
|
36 |
+
learner.save(sys.argv[2])
|
37 |
+
learner.show_results()
|
src/data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
/processed
|
src/data/raw/.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
/nyu_depth_v2_labeled.mat
|
2 |
+
/splits.mat
|
src/data/raw/nyu_depth_v2_labeled.mat.dvc
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
md5: d27a0ba6c898f981797a3388c26c2d0f
|
2 |
+
frozen: true
|
3 |
+
deps:
|
4 |
+
- etag: '"b125b2b1-5aa5b95864fc7"'
|
5 |
+
path: http://horatio.cs.nyu.edu/mit/silberman/nyu_depth_v2/nyu_depth_v2_labeled.mat
|
6 |
+
outs:
|
7 |
+
- md5: 520609c519fba3ba5ac58c8fefcc3530
|
8 |
+
path: nyu_depth_v2_labeled.mat
|
src/data/raw/splits.mat.dvc
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
md5: 26011289311c18b92781de66654223a4
|
2 |
+
frozen: true
|
3 |
+
deps:
|
4 |
+
- etag: '"a42-4cb6a5fad2fc0"'
|
5 |
+
path: http://horatio.cs.nyu.edu/mit/silberman/indoor_seg_sup/splits.mat
|
6 |
+
outs:
|
7 |
+
- md5: 08e3c3aea27130ac7c01ffd739a4535f
|
8 |
+
path: splits.mat
|