facebookresearch / facebookresearch/detectron2

Created Dockerfile & Python Script to Run all Models for Images and Videos

Open
#5,437 0 comments 2 reactions 0 assignees View on GitHub
documentation
Dominant language
Python
Stars
34.7k
Forks
7.9k
PR merge metrics
No merged PRs in 30d

Description

## 📚 Documentation Issue

I know... the documentation is hard to follow, and there are a million dependencies to get this project to work. Well no worries, because I have created a Dockerfile and a Python Script to run and process all your images/videos in a GPU accelerated environment!

The Dockerfile and Repo is available here [michaelslice Github Link](https://github.com/michaelslice/detectron2_dockerfile)

I was able to do so with these commands below in a Dockerfile, and a Python Script available on my Github.
```
# Base image with CUDA 11.3.1 and cuDNN 8
FROM nvidia/cuda:11.3.1-cudnn8-runtime-ubuntu20.04

# Install system dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
git \
python3.8 \
python3.8-dev \
python3.8-distutils \
python3-pip \
libgl1 \
ffmpeg \
wget \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libqt5x11extras5 \
g++ \
gcc \
cmake \
libgtk2.0-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*

# Set Python 3.8 as the default Python version
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1

# Upgrade pip and install Python dependencies
RUN python3 -m pip install --upgrade pip && \
pip3 install opencv-python-headless && \
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu113 && \
python3 -m pip install 'git+https://github.com/facebookresearch/detectron2.git'

# Create data directory
RUN mkdir -p data
COPY ./data data

# Download the model file and set permissions
RUN wget https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl -O model_final_cafdb1.pkl && \
chmod 644 model_final_cafdb1.pkl

# Copy the rest of the application code
COPY . .

# Set proper permissions for the data directory
RUN chmod -R 755 data

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.