Skip to content

Commit

Permalink
update readme and add docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
Youshaa Murhij committed Feb 11, 2024
1 parent 1bfb33d commit d98aac3
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 3 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
/vis/vis_results
/outputs*
**.pth
/docker
/evaluation/**.txt
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 HYOJUN LEE
Copyright (c) 2023 YOUSHAA MURHIJ

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,81 @@ ${CODE Root}
- Download annotation files to fill in `apollo_annot` [[hear](https://drive.google.com/file/d/1qCUdjJEnKS7jyXDVuDBO5wCYZFeo1VsY/view?usp=sharing)].

- Download image files to fill in `images` [[hear](https://apolloscape.auto/car_instance.html)].


## Usage:
For Docker container usage, run:
```bash
git clone DAGM-Mono
cd DAGM-Mono

bash docker/build.sh

bash docker/start.sh
bash docker/into.sh
```
From Conda environment usage, run:
```bash
conda create -n dagm_mono python=3.9
conda activate dagm_mono

#pytorch
conda install pytorch==1.10.1 torchvision==0.11.2 torchaudio==0.10.1 cudatoolkit=11.3 -c pytorch -c conda-forge

# detectron2
python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu113/torch1.10/index.html


conda install -c fvcore -c iopath -c conda-forge fvcore iopath

conda install -c bottler nvidiacub

conda install pytorch3d -c pytorch3d

pip install -r requirements.txt
pip install open3d==0.14.1

```

## Train
1. To stable model convergence, we follow BAAM method to first train the 2D modules (Box, Keypoint). You can downlod pre-trained 2D module weights from [here](https://drive.google.com/file/d/1aX_-SfHtXAdE-frgrbrlQYuWddhwX3V3/view?usp=drive_link).
2. Replace it the third line of `configs/custom.yaml`.
3. Run the command below.
```bash
python main.py -t
```

## Inference
To run inference, update the weights path in the yaml config file and run:
```bash
python main.py
```


## Evaluation
1. Finish either inference process or train process.
2. Move to `evaluation` folder.
3. Run the command below.
```bash
python eval.py \
--light \
--test_dir ../outputs/res \
--gt_dir ../data/apollo/val/apollo_annot \
--res_file test_results.txt
```
4. You can show A3DP results in `test_results.txt`.

## Visualization
1. Install open3D python library
2. Move to 'vis' folder.
3. Run the command below.
```bash
python vis_apollo.py \
--output [path where the results are saved] \
--file [file name to vis] \
--save [path to save vis results]

```

## License
DAGM-Mono is released under MIT license (see LICENSE). It is developed based on a forked version of BAAM. We also used code from OFMPNet, Swin-Transformer and FMFNet. Note that the used dataset (ApolloCar3D) is subject to their respective licenses and may not grant commercial use.
2 changes: 1 addition & 1 deletion configs/custom.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_BASE_: "res2net-bifpn.yaml"
MODEL:
WEIGHTS: best_rel_model.pth #res2net_bifpn.pth
WEIGHTS: pretrained/res2net_bifpn.pth
DEVICE: 'cuda:0'
BACKBONE:
FREEZE_AT: 2
Expand Down
63 changes: 63 additions & 0 deletions docker/Dockerfile.x86_64
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive

#Install required apt libs and packages
RUN apt-get update -y && \
apt-get autoremove -y && \
apt-get install -y --no-install-recommends \
wget \
curl \
python3.9 \
python3-pip \
python3-dev\
python3-tk \
ca-certificates \
lsb-release \
ninja-build \
build-essential \
git \
software-properties-common \
cmake \
libx11-6 ffmpeg libsm6 libxext6 \
libegl1 \
libgl1 \
libgomp1 \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean

# Update pip & install pytorch
RUN python3 -m pip install pip --upgrade

RUN pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 --index-url https://download.pytorch.org/whl/cu118

# Set up environment Arch
ENV TORCH_CUDA_ARCH_LIST="5.2 6.0 6.1 7.0 7.5 8.0 8.6+PTX"


RUN FORCE_CUDA=1 python3 -m pip install 'git+https://github.com/facebookresearch/[email protected]'
RUN python3 -m pip install "git+https://github.com/facebookresearch/pytorch3d.git"

RUN python3 -m pip install \
setuptools \
tim \
opencv-python

# Install Open3D from the PyPI repositories
# RUN python3 -m pip install --no-cache-dir --upgrade pip && \
# python3.9 -m pip install --no-cache-dir --upgrade open3d==0.14.1

# User setup
ARG USER=user
ARG UID=1000
ARG GID=1000
# default password
ARG PW=user

RUN useradd -m ${USER} --uid=${UID} && echo "${USER}:${PW}" | chpasswd && adduser ${USER} sudo

WORKDIR /home/${USER}
RUN cd /home/${USER} && mkdir -p dagm_mono && chown -R ${UID}:${GID} ./

USER ${UID}:${GID}

22 changes: 22 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

yellow=`tput setaf 3`
green=`tput setaf 2`
violet=`tput setaf 5`
reset_color=`tput sgr0`

ARCH="$(uname -m)"

main () {
pushd "$(dirname "$0")";
if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "aarch64" ]; then
file="./Dockerfile.${ARCH}"
else
echo "There is no Dockerfile for ${yellow}${ARCH}${reset_color} arch"
fi
echo "Building image for ${yellow}${ARCH}${reset_color} arch. from Dockerfile: ${yellow}${file}${reset_color}"
docker build -f ${file} . -t ${ARCH}/dagm_mono:latest;
popd;
}

main "$@"; exit;
7 changes: 7 additions & 0 deletions docker/into.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

docker exec -it --user "user" dagm_mono \
/bin/bash -c "
cd /home/user/dagm_mono;
export PYTHONPATH=\"${PYTHONPATH}:/home/user/dagm_mono\";
/bin/bash"
52 changes: 52 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

cd "$(dirname "$0")"
cd ..

workspace_dir=$PWD
desktop_start() {
docker run --ipc=host -it -d --rm \
--gpus 'all,"capabilities=compute,utility,graphics"' \
--env="DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--privileged \
--name dagm_mono \
--net "host" \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
-v $workspace_dir/:/home/user/dagm_mono:rw \
${ARCH}/dagm_mono:latest

XAUTH=/tmp/.docker.xauth

xauth_list=$(xauth nlist :0 | tail -n 1 | sed -e 's/^..../ffff/')
if [ ! -f $XAUTH ]; then
if [ ! -z "$xauth_list" ]; then
echo $xauth_list | xauth -f $XAUTH nmerge -
else
touch $XAUTH
fi
chmod a+r $XAUTH
fi

file $XAUTH
ls -FAlh $XAUTH
}


main () {
if [ "$(docker ps -aq -f status=exited -f name=dagm_mono)" ]; then
docker rm dagm_mono;
fi

ARCH="$(uname -m)"

desktop_start;

docker exec -it --user "user" dagm_mono \
/bin/bash -c "
cd /home/user/dagm_mono;
";
}

main;

0 comments on commit d98aac3

Please sign in to comment.