Repository: EPFL-VILAB/XTConsistency
Branch: master
Commit: 6d051610358d
Files: 32
Total size: 208.2 KB
Directory structure:
gitextract_hs8roq0r/
├── .gitignore
├── Dockerfile
├── README.md
├── config/
│ ├── jobinfo.txt
│ ├── split.txt
│ ├── split_fullplus.txt
│ └── split_medium.txt
├── datasets.py
├── demo.py
├── energy.py
├── graph.py
├── hooks/
│ └── build
├── logger.py
├── models.py
├── modules/
│ ├── __init__.py
│ ├── depth_nets.py
│ ├── percep_nets.py
│ ├── resnet.py
│ ├── unet.py
│ └── unet_mirrored.py
├── plotting.py
├── requirements.txt
├── scripts/
│ ├── energy_calc.py
│ └── jobinfo.txt
├── task_configs.py
├── tools/
│ ├── download_data.sh
│ ├── download_energy_graph_edges.sh
│ ├── download_models.sh
│ └── download_percep_models.sh
├── train.py
├── transfers.py
└── utils.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.vscode
raw
__pycache__/*
sftp-config*.json
models
processed
*.pth
*.tar
output
*.gz
.DS_Store/*
result
checkpoints
*.pyc
data/results
.DS_Store
local
command.txt
*.ipynb_checkpoints
================================================
FILE: Dockerfile
================================================
FROM nvidia/cuda:10.1-base-ubuntu16.04
LABEL version="1.0"
LABEL description="Build using the command \
'docker build -t epflvil/xtconsistency:latest .'"
ARG DEFAULT_GIT_BRANCH=master
ARG DEFAULT_GIT_REPO=git@github.com:EPFL-VIL/XTConsistency.git
ARG GITHUB_DEPLOY_KEY_PATH=docker_key
ARG GITHUB_DEPLOY_KEY
ARG GITHUB_DEPLOY_KEY_PUBLIC
RUN apt-get update && apt-get install -y \
curl \
wget \
ca-certificates \
sudo \
git \
unzip \
bzip2 \
libx11-6 \
nano \
screen \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir /root/.ssh
RUN echo "DEPLOY" "${GITHUB_DEPLOY_KEY}"
RUN echo "DEPLOY" "${GITHUB_DEPLOY_KEY_PUBLIC}"
RUN echo "${GITHUB_DEPLOY_KEY}" > /root/.ssh/id_rsa
RUN echo "${GITHUB_DEPLOY_KEY_PUBLIC}" > /root/.ssh/id_rsa.pub
RUN chmod 600 /root/.ssh/id_rsa
RUN cat /root/.ssh/id_rsa*
RUN eval $(ssh-agent) && \
ssh-add /root/.ssh/id_rsa && \
ssh-keyscan -H github.com >> /etc/ssh/ssh_known_hosts
RUN git clone --single-branch --branch "${DEFAULT_GIT_BRANCH}" "${DEFAULT_GIT_REPO}" /app
#############################
# Pull code
#############################
# RUN mkdir /app
WORKDIR /app
RUN cd /app && git config core.filemode false
RUN chmod -R 777 /app
#############################
# Create non-root user
#############################
# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
&& chown -R user:user /app
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
USER user
# All users can use /home/user as their home directory
ENV HOME=/home/user
RUN chmod 777 /home/user
#############################
# Create conda environment
#############################
# Install Miniconda
RUN curl -Lso ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-4.5.11-Linux-x86_64.sh \
&& chmod +x ~/miniconda.sh \
&& ~/miniconda.sh -b -p ~/miniconda \
&& rm ~/miniconda.sh
ENV PATH=/home/user/miniconda/bin:$PATH
ENV CONDA_AUTO_UPDATE_CONDA=false
# Create a Python 3.6 environment
RUN /home/user/miniconda/bin/conda create -y --name py36 python=3.6.9 \
&& /home/user/miniconda/bin/conda clean -ya
ENV CONDA_DEFAULT_ENV=py36
ENV CONDA_PREFIX=/home/user/miniconda/envs/$CONDA_DEFAULT_ENV
ENV PATH=$CONDA_PREFIX/bin:$PATH
RUN /home/user/miniconda/bin/conda install conda-build=3.18.9=py36_3 \
&& /home/user/miniconda/bin/conda clean -ya
#############################
# Python packages
#############################
RUN conda install -y -c pytorch \
cudatoolkit=10.1 \
"pytorch=1.4.0" \
"torchvision=0.5.0" \
&& conda clean -ya
RUN conda install -y \
ipython==6.5.0 \
matplotlib==3.0.3 \
plac==0.9.6 \
py==1.6.0 \
scipy==1.3.1 \
tqdm==4.36.1 \
pathlib==1.0.1 \
seaborn==0.10.0 \
scikit-learn==0.22.1 \
scikit-image==0.16.2 \
&& conda clean -ya
RUN conda install -c conda-forge jupyterlab && conda clean -ya
RUN pip install runstats==1.8.0 \
fire==0.2.1 \
visdom==0.1.8.9 \
parse==1.12.1
###############################################
# Default command and environment variables
###############################################
RUN sudo touch /root/.bashrc && sudo chmod 770 /root/.bashrc
RUN echo export PATH="\$PATH:"$PATH >> /tmp/.bashrc
RUN sudo su -c 'cat /tmp/.bashrc >> /root/.bashrc' && rm /tmp/.bashrc
# Set the default command to bash
CMD ["bash"]
================================================
FILE: README.md
================================================
# Robust Learning Through Cross-Task Consistency
[](https://consistency.epfl.ch)
| Above: A comparison of the results from consistency-based learning and learning each task individually. The yellow markers highlight the improvement in fine grained details. |
](https://consistency.epfl.ch/demo/) | Visualize models with and without consistency, evaluated on a (non-cherry picked) YouTube video.
](https://consistency.epfl.ch/visuals/) |
|
|
|
| _Sample image from the Stanford 2D3DS dataset._ | _Some chair legs are missing in the `RGB -> Normal` prediction._ | _The white pixels indicate higher uncertainty about areas with missing chair legs._ |
To compute energy locally, over many images, and/or to plot energy vs error, you can use the following `energy_calc.py` script. For example, to reproduce the following scatterplot using `energy_calc.py`:
| Energy vs. Error |
|:----------------------------------------:|
|  |
| _Result from running the command below._ |
First download a subset of images from the Taskonomy buildings `almena` and `albertville` (512 images per domain, 388MB):
```bash
sh ./tools/download_data.sh
```
Second, download all the networks necessary to compute the consistency energy. The following script will download them for you (skipping previously downloaded models) (0.8GB - 4.0GB):
```bash
sh ./tools/download_energy_graph_edges.sh
```
Now we are ready to compute energy. The following command generates a scatter plot of _consistency energy_ vs. prediction error:
```bash
python -m scripts.energy_calc energy_calc --batch_size 2 --subset_size=128 --save_dir=results
```
By default, it computes the energy and error of the `subset_size` number of points on the Taskonomy buildings `almena` and `albertville`. The error is computed for the `normal` target. The resulting plot is saved to `energy.pdf` in `RESULTS_DIR` and the corresponding data to `data.csv`.
#### Compute energy on arbitrary images
_Consistency energy_ is an unsupervised quantity and as such, no ground-truth labels are necessary. To compute the energy for all query images in a directory, run:
```bash
python -m scripts.energy_calc energy_calc_nogt
--data-dir=PATH_TO_QUERY_IMAGE --batch_size 1 --save_dir=RESULTS_DIR \
--subset_size=NUMBER_OF_IMAGES --cont=PATH_TO_TRAINED_MODEL
```
It will append a dashed horizontal line to the plot above where the energy of the query image(s) are. This plot is saved to `energy.pdf` in `RESULTS_DIR`.