Skip to content

Commit

Permalink
Dockerized object_detection package (#32)
Browse files Browse the repository at this point in the history
* initialized docker file

* git clone in dockerfile

* git checkout to topguns/dockerfile added in dockerfile

* replaced COPY with cp command

* replaced ssh with https link of the repo

* seperate RUN for each bash command

* added / after mkdir commands

* removed trailing && after RUN commands

* correction in directory structure

* cloning directly into topguns/dockerfile branch

* removed copying docker scripts to container command

* trying to install Python requirements using requirements.txt

* changed matplotlib version to 3.7.2 in requirements.txt

* conflicts in requirements.txt

* changed numpy version in requirements.txt

* enter_bash.sh working

* testing base.sh and start.sh

* added cv-bridge dependency

* working on exposing ros2 topics inside the container to host machine

* tested docker container, clip and ship

* changed model dir path for docker container

* cleaned Dockerfile

* added requirement.txt, docker instructions

* Initialized new Dockerfile with nvidia/cuda as base image

* Changes in Readme

* Minor changes to detector scripts

* Docker container working

* Added code to install nano in Dockerfile

* Added arg in dockerfile to specify CUDA Version and added docker stop in run_devel.sh

* Added feature to enter bash if container is running and remove the container after exit in run_devel. Changed tensorflow version to 2.14.0

* Added feature in run_devel to build docker image if it doesnt exist

* Updated readme

* Updated readme

* correction in run_devel.sh

* Attempting to build OpenCV from source

* Added option to select base image in run_devel.sh

* Env Variable for percep_ws

* Updated readme

* README.md changes

* additions to README.md (#50)

* fixed superimposed predictions on consecutive frames

* Resolved the error : can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory

* Added output class labels and confidences to output image, fixed issue with wrong sizes of bounding boxes

* Removed code for building opencv from source from the dockerfiles

* Code cleanup and fixed minor bugs

* Code cleanup and fixed minor bugs

* Changed model weight location

---------

Co-authored-by: AaksharGarg <[email protected]>
Co-authored-by: deepansh <[email protected]>
Co-authored-by: Deepansh Goel <[email protected]>
Co-authored-by: topguns837 <[email protected]>
Co-authored-by: Jasmeet Singh <[email protected]>
  • Loading branch information
6 people authored Feb 4, 2024
1 parent afde1f2 commit efb16f7
Show file tree
Hide file tree
Showing 19 changed files with 455 additions and 478 deletions.
87 changes: 80 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,82 @@
#Ignore the test node
/object_detection/object_detection/test_node.py
# Custom settings asset
*.settings.asset*

#Ignore pycache dirs
object_detection/object_detection/Detectors/__pycache__/
object_detection/object_detection/__pycache__/
# Visual Studio 2015 cache directory
/Project/.vs/

#Ignore .vscode dir
.vscode
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Mm]emoryCaptures/

# Autogenerated VS/MD/Consulo solution and project files
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb

# Unity3D generated meta files
*.pidb.meta

# Builds
*.apk
*.unitypackage
*.app
*.exe
*.x86_64
*.x86

# Generated doc folders
/docs/html

# Mac hidden files
*.DS_Store
*/.ipynb_checkpoints
*/.idea
*.pyc
*.idea/misc.xml
*.idea/modules.xml
*.idea/
*.iml
*.cache
*/build/
*/dist/
*.egg-info*
*.eggs*
*.gitignore.swp

# VSCode hidden files
.vscode/

.DS_Store
.ipynb_checkpoints

# pytest cache
*.pytest_cache/

# Ignore PyPi build files.
dist/
build/

# Python virtual environment
venv/
.mypy_cache/

# Code coverage report
.coverage
coverage.xml
/htmlcov/

**/UserSettings/*

ROSConnectionPrefab.prefab
80 changes: 80 additions & 0 deletions Dockerfile.cuda
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Use cuda_version arg to take CUDA version as input from user
ARG cuda_version=11.8.0

# Use NVIDA-CUDA's base image
FROM nvcr.io/nvidia/cuda:${cuda_version}-devel-ubuntu22.04

# Prevent console from interacting with the user
ARG DEBIAN_FRONTEND=noninteractive

# Prevent hash mismatch error for apt-get update, qqq makes the terminal quiet while downloading pkgs
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get update -yqqq

# Set folder for RUNTIME_DIR. Only to prevent warnings when running RViz2 and Gz
RUN mkdir tmp/runtime-root && chmod 0700 tmp/runtime-root
ENV XDG_RUNTIME_DIR='/tmp/runtime-root'

RUN apt-get update

RUN apt-get install --no-install-recommends -yqqq \
apt-utils \
nano \
git

# Using shell to use bash commands like 'source'
SHELL ["/bin/bash", "-c"]

# Python Dependencies
RUN apt-get install --no-install-recommends -yqqq \
python3-pip

# Add locale
RUN locale && \
apt update && apt install --no-install-recommends -yqqq locales && \
locale-gen en_US en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
export LANG=en_US.UTF-8 && \
locale

# Setup the sources
RUN apt-get update && apt-get install --no-install-recommends -yqqq software-properties-common curl && \
add-apt-repository universe && \
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/nul

# Install ROS 2 Humble
RUN apt update && apt install --no-install-recommends -yqqq \
ros-humble-ros-base \
ros-dev-tools

# Install cv-bridge
RUN apt update && apt install --no-install-recommends -yqqq \
ros-humble-cv-bridge

# Target workspace for ROS2 packages
ARG WORKSPACE=/root/percep_ws

# Add target workspace in environment
ENV WORKSPACE=$WORKSPACE

# Creating the models folder
RUN mkdir -p $WORKSPACE/models && \
mkdir -p $WORKSPACE/src

# Installing Python dependencies
COPY object_detection/requirements.txt .
RUN pip3 install -r requirements.txt

# ROS Dependencies
RUN apt update && apt install --no-install-recommends -yqqq \
ros-humble-cyclonedds \
ros-humble-rmw-cyclonedds-cpp

# Use cyclone DDS by default
ENV RMW_IMPLEMENTATION rmw_cyclonedds_cpp

WORKDIR /root/percep_ws

# Update .bashrc
RUN echo "source /opt/ros/humble/setup.bash" >> /root/.bashrc

77 changes: 77 additions & 0 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Use Ubuntu's base image
FROM ubuntu:22.04

# Prevent console from interacting with the user
ARG DEBIAN_FRONTEND=noninteractive

# Prevent hash mismatch error for apt-get update, qqq makes the terminal quiet while downloading pkgs
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get update -yqqq

# Set folder for RUNTIME_DIR. Only to prevent warnings when running RViz2 and Gz
RUN mkdir tmp/runtime-root && chmod 0700 tmp/runtime-root
ENV XDG_RUNTIME_DIR='/tmp/runtime-root'

RUN apt-get update

RUN apt-get install --no-install-recommends -yqqq \
apt-utils \
nano \
git

# Using shell to use bash commands like 'source'
SHELL ["/bin/bash", "-c"]

# Python Dependencies
RUN apt-get install --no-install-recommends -yqqq \
python3-pip

# Add locale
RUN locale && \
apt update && apt install --no-install-recommends -yqqq locales && \
locale-gen en_US en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
export LANG=en_US.UTF-8 && \
locale

# Setup the sources
RUN apt-get update && apt-get install --no-install-recommends -yqqq software-properties-common curl && \
add-apt-repository universe && \
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/nul

# Install ROS 2 Humble
RUN apt update && apt install --no-install-recommends -yqqq \
ros-humble-ros-base \
ros-dev-tools

# Install cv-bridge
RUN apt update && apt install --no-install-recommends -yqqq \
ros-humble-cv-bridge

# Target workspace for ROS2 packages
ARG WORKSPACE=/root/percep_ws

# Add target workspace in environment
ENV WORKSPACE=$WORKSPACE

# Creating the models folder
RUN mkdir -p $WORKSPACE/models && \
mkdir -p $WORKSPACE/src

# Installing Python dependencies
COPY object_detection/requirements.txt .
RUN pip3 install -r requirements.txt

# ROS Dependencies
RUN apt update && apt install --no-install-recommends -yqqq \
ros-humble-cyclonedds \
ros-humble-rmw-cyclonedds-cpp

# Use cyclone DDS by default
ENV RMW_IMPLEMENTATION rmw_cyclonedds_cpp

WORKDIR /root/percep_ws

# Update .bashrc
RUN echo "source /opt/ros/humble/setup.bash" >> /root/.bashrc

Loading

0 comments on commit efb16f7

Please sign in to comment.