Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker setup + commit Monodepth2 #2

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
730e2ca
Initial commit
mdfirman May 2, 2019
a166168
Fix broken link
mdfirman May 2, 2019
8c69788
Removed GPU specification in odometry experiments
mdfirman May 2, 2019
8ec01fb
Changed from Dropbox to Google Cloud hosting to fix bandwidth problems
mdfirman May 7, 2019
647a147
Replace deprecated scipy.misc.imresize with skimage.transform.resize
mdfirman May 9, 2019
683bdf8
Using try/except instead of 'if' to fix augmentation runtime error
mdfirman May 13, 2019
e2e38c8
Added non-pretrained models
mdfirman May 20, 2019
9f61553
Fixed block type for resnet50
mrharicot May 20, 2019
902e1fc
Fixing typo
mdfirman May 22, 2019
bcfc0d9
Now compatible with tensorboardX 1.7, and fixed predictive mask logging
mdfirman May 29, 2019
b38ea1e
Added links to odometry models
mdfirman May 31, 2019
c2f19cf
Fixing logging for small batch sizes
mdfirman Jun 3, 2019
727bd86
Fixed bug in model to load in ipynb
mdfirman Jun 3, 2019
88ba4a8
Saving colormapped image using pil rather than plt, in attempt to fix…
mdfirman Jun 11, 2019
4bcd519
jpg -> jpeg (might be more pillow compatible)
mdfirman Jun 11, 2019
e3ff726
Improved README odometry training instructions
mdfirman Jun 18, 2019
8636f75
Added resnet50 models to README
mdfirman Jun 18, 2019
3bdb683
Merge branch 'master' of https://github.com/nianticlabs/monodepth2
mdfirman Jun 18, 2019
7b8bee3
Update layers.py
daniyar-niantic Aug 19, 2019
8b43f5d
Changed bibtex to ICCV 19
mrharicot Aug 20, 2019
2d5ade1
Update README.md
mrharicot Aug 26, 2019
0f051af
Fixed identity selection mask visualisation bug
mdfirman Sep 2, 2019
4fe3ad4
Merge branch 'master' of https://github.com/nianticlabs/monodepth2
mdfirman Sep 2, 2019
4c649b6
Added assert to guard against two types of masking conflicting
mdfirman Sep 2, 2019
639b6ca
Update README.md
daniyar-niantic Nov 26, 2019
dff8ef0
Added a note regarding intrinsics normalization
mrharicot Jul 9, 2020
18ed0e0
Added comment about resnet50
mrharicot Jul 9, 2020
a6bf7af
Update README.md
mrharicot Sep 21, 2020
4cbcbf4
Updating licence URL and DATE
mdfirman May 17, 2021
9d786a6
Added option to test_simple.py to directly predict depth. Also datalo…
mdfirman May 17, 2021
959220f
Update issue templates
mdfirman May 18, 2021
593ff6e
Addressing MR comments and updating readme
mdfirman May 18, 2021
45e39be
Merge pull request #345 from nianticlabs/documentation
mdfirman May 20, 2021
9a16b05
use randn on GPU instead of cpu
d4l3k Jan 29, 2022
14a58b0
Merge pull request #413 from d4l3k/master
mrharicot Jan 30, 2022
713a34b
setup env vars for docker
JQuezada0 Jun 4, 2022
deb6b77
add gitignore
JQuezada0 Jun 4, 2022
9436861
Create conda environment template for monodepth2 dependencies + migra…
JQuezada0 Jun 4, 2022
795e86d
Re-organize matplotlib import + .use usage to prior to importing pyplot
JQuezada0 Jun 4, 2022
6a819f7
Dockerfile + docker-compose
JQuezada0 Jun 4, 2022
3860b6f
Merge pull request #1 from JQuezada0/dockerize
JQuezada0 Jun 4, 2022
d819607
Remove submodule deps/monodepth2
JQuezada0 Jun 4, 2022
e09f771
Merge submodule contents for deps/monodepth2/master
JQuezada0 Jun 4, 2022
f9c832c
import layers relatively
JQuezada0 Jun 4, 2022
a4dc778
Merge pull request #2 from JQuezada0/fix-layers-import
JQuezada0 Jun 4, 2022
0bbef9e
add README w/ basic setup instructions
JQuezada0 Jun 4, 2022
8f9b81b
typo
JQuezada0 Jun 4, 2022
5818e0d
Merge pull request #3 from JQuezada0/add-readme
JQuezada0 Jun 4, 2022
c6fe277
rm dividers
JQuezada0 Jun 4, 2022
4ac470b
Merge branch 'master' of github.com:JQuezada0/sea-thru into add-readme
JQuezada0 Jun 4, 2022
a401a3d
Merge pull request #4 from JQuezada0/update-readme-1
JQuezada0 Jun 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SERVICE=seathru
WORKING_DIR=/opt/app
PLATFORM=linux/x86_64
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__
.DS_Store
*.png
models/
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "deps/monodepth2"]
path = deps/monodepth2
url = [email protected]:nianticlabs/monodepth2.git
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
ARG PLATFORM

FROM --platform=${PLATFORM} python:latest

# These will be pulled from the docker-compose.yml file via the `args` parameter
ARG WORKING_DIR
ARG CONDA_ENV_NAME

WORKDIR ${WORKING_DIR}

# Set some known env vars + lift from docker-compose args into env
ENV CONDA_ENV_NAME ${CONDA_ENV_NAME}
ENV CONDA_DIR /opt/conda
ENV PATH=$CONDA_DIR/bin:$PATH

# Dependencies
RUN apt-get update && apt-get install -y \
cmake \
build-essential \
wget \
gettext-base \
ffmpeg \
libsm6 \
libxext6 && \
apt-get clean

# Install miniconda (Basically anaconda without all the defaults, just the CLI.)
# This'll let us use whichever version of python is compatible with seathru and monodepth2. Should also make it less painful to upgrade in the future.
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p $CONDA_DIR

COPY conda-environment.yml ./conda-environment-template.yml
RUN cat conda-environment-template.yml | envsubst > environment.yml

RUN conda env create -f environment.yml
RUN echo "source activate $CONDA_ENV_NAME" > ~/.bashrc
ENV PATH $CONDA_DIR/envs/$CONDA_ENV_NAME/bin:$PATH

ADD . ${WORKING_DIR}

ENTRYPOINT ["tail", "-f", "/dev/null"]
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Sea-Thru
Implementation of Sea-thru by Derya Akkaynak and Tali Treibitz

__Forked from https://github.com/hainh/sea-thru__

This fork's only aim is to standardize the dependencies and environment with [Docker](https://docs.docker.com/get-docker/) and [Anaconda](https://www.anaconda.com/) to make it so that anyone can use it without deep technical knowledge of python.

Additionally, in order to make this an all-in-one package, the [Monodepth2 submodule](https://github.com/nianticlabs/monodepth2/tree/b676244e5a1ca55564eb5d16ab521a48f823af31) has been cloned and commited directly into this repo, preserving the commit history and original authors.

## Prerequisites

[Docker](https://docs.docker.com/get-docker/)

## Setup

1. Run `docker compose up --build`
- This can take around 2 hours the first time; from then onwards you only need to run `docker compose up` to get the container running and it'll boot up instantly.
2. Once the container is built and running, in a separate terminal run `docker exec -it seathru /bin/bash`
- Replace `seathru` in that command if you've modified the `SERVICE` enviornment variable in `.env`
3. From within the container you can now run `python seathru-mono-e2e.py --image ${PATH_TO_IMAGE}`
- This root directory is mounted into the container each time you bring it up via `docker compose up`, meaning any files you add on your host machine to this directory will _also_ be available within the container.

## Description

A recent advance in underwater imaging is the Sea-Thru method, which uses a physical model of light attenuation to reconstruct
the colors in an underwater scene. This method utilizes a known
range map to estimate backscatter and wideband attenuation
coefficients. This range map is generated using structure-from-motion (SFM), which requires multiple underwater images from various perspectives and long processing time. In addition, SFM gives very accurate results, which are generally not required for this method. In this work, we implement and extend Sea-Thru to take advantage of convolutional monocular depth estimation methods, specifically the Monodepth2 network. We obtain satisfactory results with the lower-quality depth estimates with some color inconsistencies using only one image.
27 changes: 27 additions & 0 deletions conda-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Conda Environment https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
name: $CONDA_ENV_NAME
channels:
- conda-forge
- pytorch
dependencies:
# Dependencies for sea-thru migrated from requirements.txt https://github.com/hainh/sea-thru/blob/master/requirements.txt
- scikit-learn=0.24.2
- numpy=1.19.2
- matplotlib=2.2.2
- pillow=5.1.0
- scipy=1.5.2
- scikit-image=0.16.2
- pynng=0.7.1
- pyyaml=5.4.1

# Lock pip version as well to install rawpy, wasn't able to install through conda/mamba
- pip=21.3.1
- pip:
- rawpy==0.16.0

# Dependencies and python version for Monodepth2 described here: https://github.com/nianticlabs/monodepth2#%EF%B8%8F-setup
- python=3.6.6
- pytorch=0.4.1
- torchvision=0.2.1
- tensorboardX=1.4
- opencv=3.3.1
1 change: 0 additions & 1 deletion deps/monodepth2
Submodule monodepth2 deleted from d1c5f0
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Problem training on KITTI
about: Issue when training with default settings
title: ''
labels: ''
assignees: ''

---

If you have problems training on KITTI, please make sure to check:

1. That you are using an unmodified version of the codebase
2. That you are using the correct versions of the dependencies we specified in the README

If you’ve checked both of these, please feel report here the problem you are having, together with your hardware and anything else potentially unusual about your setup.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Training on custom training data
about: Problems training on data which isn't KITTI
title: ''
labels: custom-dataset
assignees: ''

---

Thanks for trying out monodepth2 on a different dataset!

Before logging your issue, please look through the issues already tagged with [custom dataset](https://github.com/nianticlabs/monodepth2/issues?q=label%3Acustom-dataset+) , as your problem may well have been answered there.

In particular please note that:

1. You should know the intrinsics for your custom dataset, and you should set them *normalized* in your dataloader. More details are in the [dataloader comments](https://github.com/nianticlabs/monodepth2/blob/master/datasets/kitti_dataset.py#L24).

2. KITTI is captured at 10 frames per second, and this seems to work well for training in our repo. Most videos are higher frame rate than this, so you may want to consider temporally downsampling your dataset (or setting `--frame_ids` appropriately)

3. If you have moving objects in your training you are likely to still see ‘holes’ punched in your predicted depths, even with automasking turned on (https://github.com/nianticlabs/monodepth2/issues/310)

4. Monodepth2 is unlikely to work on monocular training data from indoor environments, or captured from difficult camera motions. It is best suited to driving scenarios or other simple forward camera motions.

If you still have issues training, we might be able to help. Please report:

1. What you have changed to create your custom dataset
2. Some example training images
3. What do the predicted depths in the tensorboard output look like?
7 changes: 7 additions & 0 deletions deps/monodepth2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
__pycache__
*.pyc
*_disp.jpg
*_disp.npy
*.npz
kitti_data
models
182 changes: 182 additions & 0 deletions deps/monodepth2/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
Copyright © Niantic, Inc. 2018. Patent Pending.

All rights reserved.



================================================================================



This Software is licensed under the terms of the following Monodepth2 license
which allows for non-commercial use only. For any other use of the software not
covered by the terms of this license, please contact [email protected]



================================================================================



Monodepth v2 License


This Agreement is made by and between the Licensor and the Licensee as
defined and identified below.


1. Definitions.

In this Agreement (“the Agreement”) the following words shall have the
following meanings:

"Authors" shall mean C. Godard, O. Mac Aodha, M. Firman, G. Brostow
"Licensee" Shall mean the person or organization agreeing to use the
Software in accordance with these terms and conditions.
"Licensor" shall mean Niantic Inc., a company organized and existing under
the laws of Delaware, whose principal place of business is at 1 Ferry Building,
Suite 200, San Francisco, 94111.
"Software" shall mean the MonoDepth v2 Software uploaded by Licensor to the
GitHub repository at https://github.com/nianticlabs/monodepth2
on May 2nd 2019 in source code or object code form and any
accompanying documentation as well as any modifications or additions uploaded
to the same GitHub repository by Licensor.


2. License.

2.1 The Licensor has all necessary rights to grant a license under: (i)
copyright and rights in the nature of copyright subsisting in the Software; and
(ii) certain patent rights resulting from a patent application filed by the
Licensor in the United States in connection with the Software. The Licensor
grants the Licensee for the duration of this Agreement, a free of charge,
non-sublicenseable, non-exclusive, non-transferable copyright and patent
license (in consequence of said patent application) to use the Software for
non-commercial purpose only, including teaching and research at educational
institutions and research at not-for-profit research institutions in accordance
with the provisions of this Agreement. Non-commercial use expressly excludes
any profit-making or commercial activities, including without limitation sale,
license, manufacture or development of commercial products, use in
commercially-sponsored research, use at a laboratory or other facility owned or
controlled (whether in whole or in part) by a commercial entity, provision of
consulting service, use for or on behalf of any commercial entity, and use in
research where a commercial party obtains rights to research results or any
other benefit. Any use of the Software for any purpose other than
non-commercial research shall automatically terminate this License.


2.2 The Licensee is permitted to make modifications to the Software
provided that any distribution of such modifications is in accordance with
Clause 3.

2.3 Except as expressly permitted by this Agreement and save to the
extent and in the circumstances expressly required to be permitted by law, the
Licensee is not permitted to rent, lease, sell, offer to sell, or loan the
Software or its associated documentation.


3. Redistribution and modifications

3.1 The Licensee may reproduce and distribute copies of the Software, with
or without modifications, in source format only and only to this same GitHub
repository , and provided that any and every distribution is accompanied by an
unmodified copy of this License and that the following copyright notice is
always displayed in an obvious manner: Copyright © Niantic, Inc. 2018. All
rights reserved.


3.2 In the case where the Software has been modified, any distribution must
include prominent notices indicating which files have been changed.

3.3 The Licensee shall cause any work that it distributes or publishes,
that in whole or in part contains or is derived from the Software or any part
thereof (“Work based on the Software”), to be licensed as a whole at no charge
to all third parties entitled to a license to the Software under the terms of
this License and on the same terms provided in this License.


4. Duration.

This Agreement is effective until the Licensee terminates it by destroying
the Software, any Work based on the Software, and its documentation together
with all copies. It will also terminate automatically if the Licensee fails to
abide by its terms. Upon automatic termination the Licensee agrees to destroy
all copies of the Software, Work based on the Software, and its documentation.


5. Disclaimer of Warranties.

The Software is provided as is. To the maximum extent permitted by law,
Licensor provides no warranties or conditions of any kind, either express or
implied, including without limitation, any warranties or condition of title,
non-infringement or fitness for a particular purpose.


6. LIMITATION OF LIABILITY.

IN NO EVENT SHALL THE LICENSOR AND/OR AUTHORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


7. Indemnity.

The Licensee shall indemnify the Licensor and/or Authors against all third
party claims that may be asserted against or suffered by the Licensor and/or
Authors and which relate to use of the Software by the Licensee.


8. Intellectual Property.

8.1 As between the Licensee and Licensor, copyright and all other
intellectual property rights subsisting in or in connection with the Software
and supporting information shall remain at all times the property of the
Licensor. The Licensee shall acquire no rights in any such material except as
expressly provided in this Agreement.

8.2 No permission is granted to use the trademarks or product names of the
Licensor except as required for reasonable and customary use in describing the
origin of the Software and for the purposes of abiding by the terms of Clause
3.1.

8.3 The Licensee shall promptly notify the Licensor of any improvement or
new use of the Software (“Improvements”) in sufficient detail for Licensor to
evaluate the Improvements. The Licensee hereby grants the Licensor and its
affiliates a non-exclusive, fully paid-up, royalty-free, irrevocable and
perpetual license to all Improvements for non-commercial academic research and
teaching purposes upon creation of such improvements.

8.4 The Licensee grants an exclusive first option to the Licensor to be
exercised by the Licensor within three (3) years of the date of notification of
an Improvement under Clause 8.3 to use any the Improvement for commercial
purposes on terms to be negotiated and agreed by Licensee and Licensor in good
faith within a period of six (6) months from the date of exercise of the said
option (including without limitation any royalty share in net income from such
commercialization payable to the Licensee, as the case may be).


9. Acknowledgements.

The Licensee shall acknowledge the Authors and use of the Software in the
publication of any work that uses, or results that are achieved through, the
use of the Software. The following citation shall be included in the
acknowledgement: “Digging Into Self-Supervised Monocular Depth Estimation,
by C. Godard, O. Mac Aodha, M. Firman, G. Brostow, arXiv:1806.01260”.


10. Governing Law.

This Agreement shall be governed by, construed and interpreted in
accordance with English law and the parties submit to the exclusive
jurisdiction of the English courts.


11. Termination.

Upon termination of this Agreement, the licenses granted hereunder will
terminate and Sections 5, 6, 7, 8, 9, 10 and 11 shall survive any termination
of this Agreement.
Loading