<p><spanstyle="border-bottom: solid 1px grey;">Generated by Cython 0.29</span></p>
<p><spanstyle="border-bottom: solid 1px grey;">Generated by Cython 0.29</span></p>
<p>
<p>
<spanstyle="background-color: #FFFF00">Yellow lines</span> hint at Python interaction.<br/>
<spanstyle="background-color: #FFFF00">Yellow lines</span> hint at Python interaction.<br/>
Click on a line that starts with a "<code>+</code>" to see the C code that Cython generated for it.
Click on a line that starts with a "<code>+</code>" to see the C code that Cython generated for it.
</p>
</p>
<p>Raw output: <ahref="lcn.c">lcn.c</a></p>
<p>Raw output: <ahref="lcn.c">lcn.c</a></p>
<divclass="cython"><preclass="cython line score-16"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">01</span>: <spanclass="k">import</span><spanclass="nn">numpy</span><spanclass="k">as</span><spanclass="nn">np</span></pre>
</pre><preclass="cython line score-0"> <spanclass="">02</span>: <spanclass="k">cimport</span><spanclass="nn">cython</span></pre>
</pre>
<preclass="cython line score-0"> <spanclass="">03</span>: </pre>
<preclass="cython line score-0"> <spanclass="">02</span>: <spanclass="k">cimport</span><spanclass="nn">cython</span></pre>
<preclass="cython line score-0"> <spanclass="">04</span>: <spanclass="c"># use c square root function</span></pre>
<preclass="cython line score-0"> <spanclass="">03</span>: </pre>
<preclass="cython line score-0"> <spanclass="">05</span>: <spanclass="k">cdef</span><spanclass="kr">extern</span><spanclass="k">from</span><spanclass="s">"math.h"</span><spanclass="p">:</span></pre>
<preclass="cython line score-0"> <spanclass="">04</span>: <spanclass="c"># use c square root function</span></pre>
<preclass="cython line score-0"> <spanclass="">06</span>: <spanclass="nb">float</span><spanclass="n">sqrt</span><spanclass="p">(</span><spanclass="nb">float</span><spanclass="n">x</span><spanclass="p">)</span></pre>
<preclass="cython line score-0"> <spanclass="">05</span>: <spanclass="k">cdef</span><span
<preclass="cython line score-0"> <spanclass="">07</span>: </pre>
<preclass="cython line score-0"> <spanclass="">08</span>: <spanclass="nd">@cython</span><spanclass="o">.</span><spanclass="n">boundscheck</span><spanclass="p">(</span><spanclass="bp">False</span><spanclass="p">)</span></pre>
class="p">:</span></pre>
<preclass="cython line score-0"> <spanclass="">09</span>: <spanclass="nd">@cython</span><spanclass="o">.</span><spanclass="n">wraparound</span><spanclass="p">(</span><spanclass="bp">False</span><spanclass="p">)</span></pre>
<preclass="cython line score-0"> <spanclass="">06</span>: <spanclass="nb">float</span><spanclass="n">sqrt</span><span
<preclass="cython line score-0"> <spanclass="">10</span>: <spanclass="nd">@cython</span><spanclass="o">.</span><spanclass="n">cdivision</span><spanclass="p">(</span><spanclass="bp">True</span><spanclass="p">)</span></pre>
<preclass="cython line score-0"> <spanclass="">14</span>: <spanclass="c"># - kernel size (actually this is the radius, kernel is 2*k+1)</span></pre>
<preclass="cython line score-0"> <spanclass="">15</span>: <spanclass="c"># - small constant epsilon that is used to avoid division by zero</span></pre>
<preclass="cython line score-0"> <spanclass="">09</span>: <spanclass="nd">@cython</span><span
<preclass="cython line score-67"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">16</span>: <spanclass="k">def</span><spanclass="nf">normalize</span><spanclass="p">(</span><spanclass="nb">float</span><spanclass="p">[:,</span><spanclass="p">:]</span><spanclass="n">img</span><spanclass="p">,</span><spanclass="nb">int</span><spanclass="n">kernel_size</span><spanclass="o">=</span><spanclass="mf">4</span><spanclass="p">,</span><spanclass="nb">float</span><spanclass="n">epsilon</span><spanclass="o">=</span><spanclass="mf">0.01</span><spanclass="p">):</span></pre>
<preclass="cython line score-0"> <spanclass="">11</span>: </pre>
<preclass="cython line score-0"> <spanclass="">12</span>: <spanclass="c"># 3 parameters:</span></pre>
<preclass="cython line score-0"> <spanclass="">13</span>: <spanclass="c"># - float image</span></pre>
<preclass="cython line score-0"> <spanclass="">14</span>: <spanclass="c"># - kernel size (actually this is the radius, kernel is 2*k+1)</span></pre>
<preclass="cython line score-0"> <spanclass="">15</span>: <spanclass="c"># - small constant epsilon that is used to avoid division by zero</span></pre>
</pre><preclass="cython line score-0"> <spanclass="">17</span>: </pre>
class='error_goto'> if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 16, __pyx_L1_error)</span>
<preclass="cython line score-0"> <spanclass="">18</span>: <spanclass="c"># image dimensions</span></pre>
</pre>
<preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">19</span>: <spanclass="k">cdef</span><spanclass="kt">Py_ssize_t</span><spanclass="nf">M</span><spanclass="o">=</span><spanclass="n">img</span><spanclass="o">.</span><spanclass="n">shape</span><spanclass="p">[</span><spanclass="mf">0</span><spanclass="p">]</span></pre>
<preclass="cython line score-0"> <spanclass="">17</span>: </pre>
<preclass="cython line score-0"> <spanclass="">18</span>: <spanclass="c"># image dimensions</span></pre>
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">20</span>: <spanclass="k">cdef</span><spanclass="kt">Py_ssize_t</span><spanclass="nf">N</span><spanclass="o">=</span><spanclass="n">img</span><spanclass="o">.</span><spanclass="n">shape</span><spanclass="p">[</span><spanclass="mf">1</span><spanclass="p">]</span></pre>
<preclass="cython line score-46"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">23</span>: <spanclass="n">img_lcn</span><spanclass="o">=</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">zeros</span><spanclass="p">((</span><spanclass="n">M</span><spanclass="p">,</span><spanclass="n">N</span><spanclass="p">),</span><spanclass="n">dtype</span><spanclass="o">=</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">float32</span><spanclass="p">)</span></pre>
</pre><preclass="cython line score-46"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">24</span>: <spanclass="n">img_std</span><spanclass="o">=</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">zeros</span><spanclass="p">((</span><spanclass="n">M</span><spanclass="p">,</span><spanclass="n">N</span><spanclass="p">),</span><spanclass="n">dtype</span><spanclass="o">=</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">float32</span><spanclass="p">)</span></pre>
</pre>
<preclass='cython code score-46 '><spanclass='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_t_5, __pyx_n_s_np);<spanclass='error_goto'> if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 24, __pyx_L1_error)</span>
</pre><preclass="cython line score-2"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">25</span>: <spanclass="k">cdef</span><spanclass="kt">float</span>[<spanclass="p">:,</span><spanclass="p">:]</span><spanclass="n">img_lcn_view</span><spanclass="o">=</span><spanclass="n">img_lcn</span></pre>
class='error_goto'> if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 25, __pyx_L1_error)</span>
__pyx_v_img_lcn_view = __pyx_t_6;
__pyx_v_img_lcn_view = __pyx_t_6;
__pyx_t_6.memview = NULL;
__pyx_t_6.memview = NULL;
__pyx_t_6.data = NULL;
__pyx_t_6.data = NULL;
</pre><preclass="cython line score-2"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">26</span>: <spanclass="k">cdef</span><spanclass="kt">float</span>[<spanclass="p">:,</span><spanclass="p">:]</span><spanclass="n">img_std_view</span><spanclass="o">=</span><spanclass="n">img_std</span></pre>
class='error_goto'> if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 26, __pyx_L1_error)</span>
__pyx_v_img_std_view = __pyx_t_6;
__pyx_v_img_std_view = __pyx_t_6;
__pyx_t_6.memview = NULL;
__pyx_t_6.memview = NULL;
__pyx_t_6.data = NULL;
__pyx_t_6.data = NULL;
</pre><preclass="cython line score-0"> <spanclass="">27</span>: </pre>
</pre>
<preclass="cython line score-0"> <spanclass="">28</span>: <spanclass="c"># temporary c variables</span></pre>
<preclass="cython line score-0"> <spanclass="">27</span>: </pre>
<preclass="cython line score-0"> <spanclass="">29</span>: <spanclass="k">cdef</span><spanclass="kt">float</span><spanclass="nf">tmp</span><spanclass="p">,</span><spanclass="nf">mean</span><spanclass="p">,</span><spanclass="nf">stddev</span></pre>
<preclass="cython line score-0"> <spanclass="">28</span>: <spanclass="c"># temporary c variables</span></pre>
<preclass="cython line score-0"> <spanclass="">30</span>: <spanclass="k">cdef</span><spanclass="kt">Py_ssize_t</span><spanclass="nf">m</span><spanclass="p">,</span><spanclass="nf">n</span><spanclass="p">,</span><spanclass="nf">i</span><spanclass="p">,</span><spanclass="nf">j</span></pre>
<preclass="cython line score-0"> <spanclass="">29</span>: <spanclass="k">cdef</span><spanclass="kt">float</span><span
<preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">31</span>: <spanclass="k">cdef</span><spanclass="kt">Py_ssize_t</span><spanclass="nf">ks</span><spanclass="o">=</span><spanclass="n">kernel_size</span></pre>
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">32</span>: <spanclass="k">cdef</span><spanclass="kt">float</span><spanclass="nf">eps</span><spanclass="o">=</span><spanclass="n">epsilon</span></pre>
<preclass="cython line score-0"> <spanclass="">30</span>: <spanclass="k">cdef</span><spanclass="kt">Py_ssize_t</span><span
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">33</span>: <spanclass="k">cdef</span><spanclass="kt">float</span><spanclass="nf">num</span><spanclass="o">=</span><spanclass="p">(</span><spanclass="n">ks</span><spanclass="o">*</span><spanclass="mf">2</span><spanclass="o">+</span><spanclass="mf">1</span><spanclass="p">)</span><spanclass="o">**</span><spanclass="mf">2</span></pre>
<preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">36</span>: <spanclass="k">for</span><spanclass="n">m</span><spanclass="ow">in</span><spanclass="nb">range</span><spanclass="p">(</span><spanclass="n">ks</span><spanclass="p">,</span><spanclass="n">M</span><spanclass="o">-</span><spanclass="n">ks</span><spanclass="p">):</span></pre>
for (__pyx_t_9 = __pyx_v_ks; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
for (__pyx_t_9 = __pyx_v_ks; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
__pyx_v_m = __pyx_t_9;
__pyx_v_m = __pyx_t_9;
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">37</span>: <spanclass="k">for</span><spanclass="n">n</span><spanclass="ow">in</span><spanclass="nb">range</span><spanclass="p">(</span><spanclass="n">ks</span><spanclass="p">,</span><spanclass="n">N</span><spanclass="o">-</span><spanclass="n">ks</span><spanclass="p">):</span></pre>
for (__pyx_t_12 = __pyx_v_ks; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
for (__pyx_t_12 = __pyx_v_ks; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
__pyx_v_n = __pyx_t_12;
__pyx_v_n = __pyx_t_12;
</pre><preclass="cython line score-0"> <spanclass="">38</span>: </pre>
</pre>
<preclass="cython line score-0"> <spanclass="">39</span>: <spanclass="c"># calculate mean</span></pre>
<preclass="cython line score-0"> <spanclass="">38</span>: </pre>
<preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">40</span>: <spanclass="n">mean</span><spanclass="o">=</span><spanclass="mf">0</span><spanclass="p">;</span></pre>
<preclass="cython line score-0"> <spanclass="">39</span>: <spanclass="c"># calculate mean</span></pre>
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">41</span>: <spanclass="k">for</span><spanclass="n">i</span><spanclass="ow">in</span><spanclass="nb">range</span><spanclass="p">(</span><spanclass="o">-</span><spanclass="n">ks</span><spanclass="p">,</span><spanclass="n">ks</span><spanclass="o">+</span><spanclass="mf">1</span><spanclass="p">):</span></pre>
for (__pyx_t_15 = (-__pyx_v_ks); __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
for (__pyx_t_15 = (-__pyx_v_ks); __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
__pyx_v_i = __pyx_t_15;
__pyx_v_i = __pyx_t_15;
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">42</span>: <spanclass="k">for</span><spanclass="n">j</span><spanclass="ow">in</span><spanclass="nb">range</span><spanclass="p">(</span><spanclass="o">-</span><spanclass="n">ks</span><spanclass="p">,</span><spanclass="n">ks</span><spanclass="o">+</span><spanclass="mf">1</span><spanclass="p">):</span></pre>
for (__pyx_t_18 = (-__pyx_v_ks); __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
for (__pyx_t_18 = (-__pyx_v_ks); __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
__pyx_v_j = __pyx_t_18;
__pyx_v_j = __pyx_t_18;
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">43</span>: <spanclass="n">mean</span><spanclass="o">+=</span><spanclass="n">img</span><spanclass="p">[</span><spanclass="n">m</span><spanclass="o">+</span><spanclass="n">i</span><spanclass="p">,</span><spanclass="n">n</span><spanclass="o">+</span><spanclass="n">j</span><spanclass="p">]</span></pre>
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">44</span>: <spanclass="n">mean</span><spanclass="o">=</span><spanclass="n">mean</span><spanclass="o">/</span><spanclass="n">num</span></pre>
<preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">47</span>: <spanclass="n">stddev</span><spanclass="o">=</span><spanclass="mf">0</span><spanclass="p">;</span></pre>
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">48</span>: <spanclass="k">for</span><spanclass="n">i</span><spanclass="ow">in</span><spanclass="nb">range</span><spanclass="p">(</span><spanclass="o">-</span><spanclass="n">ks</span><spanclass="p">,</span><spanclass="n">ks</span><spanclass="o">+</span><spanclass="mf">1</span><spanclass="p">):</span></pre>
for (__pyx_t_15 = (-__pyx_v_ks); __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
for (__pyx_t_15 = (-__pyx_v_ks); __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
__pyx_v_i = __pyx_t_15;
__pyx_v_i = __pyx_t_15;
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">49</span>: <spanclass="k">for</span><spanclass="n">j</span><spanclass="ow">in</span><spanclass="nb">range</span><spanclass="p">(</span><spanclass="o">-</span><spanclass="n">ks</span><spanclass="p">,</span><spanclass="n">ks</span><spanclass="o">+</span><spanclass="mf">1</span><spanclass="p">):</span></pre>
for (__pyx_t_18 = (-__pyx_v_ks); __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
for (__pyx_t_18 = (-__pyx_v_ks); __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
__pyx_v_j = __pyx_t_18;
__pyx_v_j = __pyx_t_18;
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">50</span>: <spanclass="n">stddev</span><spanclass="o">=</span><spanclass="n">stddev</span><spanclass="o">+</span><spanclass="p">(</span><spanclass="n">img</span><spanclass="p">[</span><spanclass="n">m</span><spanclass="o">+</span><spanclass="n">i</span><spanclass="p">,</span><spanclass="n">n</span><spanclass="o">+</span><spanclass="n">j</span><spanclass="p">]</span><spanclass="o">-</span><spanclass="n">mean</span><spanclass="p">)</span><spanclass="o">*</span><spanclass="p">(</span><spanclass="n">img</span><spanclass="p">[</span><spanclass="n">m</span><spanclass="o">+</span><spanclass="n">i</span><spanclass="p">,</span><spanclass="n">n</span><spanclass="o">+</span><spanclass="n">j</span><spanclass="p">]</span><spanclass="o">-</span><spanclass="n">mean</span><spanclass="p">)</span></pre>
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">51</span>: <spanclass="n">stddev</span><spanclass="o">=</span><spanclass="n">sqrt</span><spanclass="p">(</span><spanclass="n">stddev</span><spanclass="o">/</span><spanclass="n">num</span><spanclass="p">)</span></pre>
<preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">54</span>: <spanclass="n">img_lcn_view</span><spanclass="p">[</span><spanclass="n">m</span><spanclass="p">,</span><spanclass="n">n</span><spanclass="p">]</span><spanclass="o">=</span><spanclass="p">(</span><spanclass="n">img</span><spanclass="p">[</span><spanclass="n">m</span><spanclass="p">,</span><spanclass="n">n</span><spanclass="p">]</span><spanclass="o">-</span><spanclass="n">mean</span><spanclass="p">)</span><spanclass="o">/</span><spanclass="p">(</span><spanclass="n">stddev</span><spanclass="o">+</span><spanclass="n">eps</span><spanclass="p">)</span></pre>
</pre><preclass="cython line score-0"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">55</span>: <spanclass="n">img_std_view</span><spanclass="p">[</span><spanclass="n">m</span><spanclass="p">,</span><spanclass="n">n</span><spanclass="p">]</span><spanclass="o">=</span><spanclass="n">stddev</span></pre>
</pre><preclass="cython line score-0"> <spanclass="">56</span>: </pre>
</pre>
<preclass="cython line score-0"> <spanclass="">57</span>: <spanclass="c"># return both</span></pre>
<preclass="cython line score-0"> <spanclass="">56</span>: </pre>
<preclass="cython line score-10"onclick="(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)">+<spanclass="">58</span>: <spanclass="k">return</span><spanclass="n">img_lcn</span><spanclass="p">,</span><spanclass="n">img_std</span></pre>
<preclass="cython line score-0"> <spanclass="">57</span>: <spanclass="c"># return both</span></pre>
ax=plt.subplot(3,3,7);plt.imshow(im[0],vmin=im.min(),vmax=im.max(),cmap='gray');plt.xticks([]);plt.yticks([]);ax.set_title(f'F0 IR input {im[0].mean():.5f}/{im[0].std():.5f}')
# plot normalized IR inputs
ifes.shape[0]>=2:
ax=plt.subplot(3,3,7);
ax=plt.subplot(3,3,8);plt.imshow(im[1],vmin=im.min(),vmax=im.max(),cmap='gray');plt.xticks([]);plt.yticks([]);ax.set_title(f'F1 IR input {im[1].mean():.5f}/{im[1].std():.5f}')
@ -24,40 +26,45 @@ If you find this code useful for your research, please cite
}
}
```
```
## Dependencies
## Dependencies
The network training/evaluation code is based on `Pytorch`.
The network training/evaluation code is based on `Pytorch`.
```
```
PyTorch>=1.1
PyTorch>=1.1
Cuda>=10.0
Cuda>=10.0
```
```
Updated on 07.06.2021: The code is now compatible with the latest Pytorch version (1.8).
Updated on 07.06.2021: The code is now compatible with the latest Pytorch version (1.8).
The other python packages can be installed with `anaconda`:
The other python packages can be installed with `anaconda`:
```
```
conda install --file requirements.txt
conda install --file requirements.txt
```
```
### Structured Light Renderer
### Structured Light Renderer
To train and evaluate our method in a controlled setting, we implemented an structured light renderer.
It can be used to render a virtual scene (arbitrary triangle mesh) with the structured light pattern projected from a customizable projector location.
To train and evaluate our method in a controlled setting, we implemented an structured light renderer. It can be used to
To build it, first make sure the correct `CUDA_LIBRARY_PATH` is set in `config.json`.
render a virtual scene (arbitrary triangle mesh) with the structured light pattern projected from a customizable
Afterwards, the renderer can be build by running `make` within the `renderer` directory.
projector location. To build it, first make sure the correct `CUDA_LIBRARY_PATH` is set in `config.json`. Afterwards,
the renderer can be build by running `make` within the `renderer` directory.
### PyTorch Extensions
### PyTorch Extensions
The network training/evaluation code is based on `PyTorch`.
We implemented some custom layers that need to be built in the `torchext` directory.
The network training/evaluation code is based on `PyTorch`. We implemented some custom layers that need to be built in
Simply change into this directory and run
the `torchext` directory. Simply change into this directory and run
```
```
python setup.py build_ext --inplace
python setup.py build_ext --inplace
```
```
### Baseline HyperDepth
### Baseline HyperDepth
As baseline we partially re-implemented the random forest based method [HyperDepth](http://openaccess.thecvf.com/content_cvpr_2016/papers/Fanello_HyperDepth_Learning_Depth_CVPR_2016_paper.pdf).
The code resided in the `hyperdepth` directory and is implemented in `C++11` with a Python wrapper written in `Cython`.
As baseline we partially re-implemented the random forest based
To create synthetic data and save it locally, download [ShapeNet V2](https://www.shapenet.org/) and correct `SHAPENET_ROOT` in `config.json`. Then the data can be generated and saved to `DATA_ROOT` in `config.json` by running
To create synthetic data and save it locally, download [ShapeNet V2](https://www.shapenet.org/) and
correct `SHAPENET_ROOT` in `config.json`. Then the data can be generated and saved to `DATA_ROOT` in `config.json` by
running
```
```
./create_syn_data.sh
./create_syn_data.sh
```
```
If you are only interested in evaluating our pre-trained model, [here (3.7G)](https://s3.eu-central-1.amazonaws.com/avg-projects/connecting_the_dots/val_data.zip) is a validation set that contains a small amount of images.
If you are only interested in evaluating our pre-trained
model, [here (3.7G)](https://s3.eu-central-1.amazonaws.com/avg-projects/connecting_the_dots/val_data.zip) is a
validation set that contains a small amount of images.
### Training Network
### Training Network
As a first stage, it is recommended to train the disparity decoder and edge decoder without the geometric loss. To train the network on synthetic data for the first stage run
As a first stage, it is recommended to train the disparity decoder and edge decoder without the geometric loss. To train
the network on synthetic data for the first stage run
```
```
python train_val.py
python train_val.py
```
```
After the model is pretrained without the geometric loss, the full model can be trained from the initialized weights by running
After the model is pretrained without the geometric loss, the full model can be trained from the initialized weights by
running
```
```
python train_val.py --loss phge
python train_val.py --loss phge
```
```
### Evaluating Network
### Evaluating Network
To evaluate a specific checkpoint, e.g. the 50th epoch, one can run
To evaluate a specific checkpoint, e.g. the 50th epoch, one can run
```
```
python train_val.py --cmd retest --epoch 50
python train_val.py --cmd retest --epoch 50
```
```
### Evaluating a Pre-trained Model
### Evaluating a Pre-trained Model
We provide a model pre-trained using the photometric loss. Once you have prepared the synthetic dataset and changed `DATA_ROOT` in `config.json`, the pre-trained model can be evaluated on the validation set by running:
We provide a model pre-trained using the photometric loss. Once you have prepared the synthetic dataset and
changed `DATA_ROOT` in `config.json`, the pre-trained model can be evaluated on the validation set by running: