Detectron

Detectron uses Singularity containers, so you should refer to that page first for general information.

Detectron-image is based on a Dockerfile from Detectron’s repository. In this image Detectron has been installed to /detectron.

Usage

This example shows how you can launch Detectron on a gpu node. To run example given in Detectron repository one can use the following Slurm script:

#!/bin/bash
#SBATCH --time=00:30:00
#SBATCH --mem=8G
#SBATCH --gres=gpu:teslap100:1
#SBATCH -o detectron.out

module load singularity-detectron

mkdir -p $WRKDIR/detectron/outputs

singularity_wrapper exec python2 /detectron/tools/infer_simple.py \
    --cfg /detectron/configs/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml \
    --output-dir $WRKDIR/detectron/outputs \
    --image-ext jpg \
    --wts https://s3-us-west-2.amazonaws.com/detectron/35861858/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml.02_32_51.SgT4y1cO/output/train/coco_2014_train:coco_2014_valminusminival/generalized_rcnn/model_final.pkl \
    /detectron/demo

Now example can by run on GPU node with:

sbatch detectron.sh

In typical usage one does not want to download models for each run. To use stored models one needs to:

  1. Copy detectron sample configurations from the image to your own configuration folder:

    module load singularity-detectron
    mkdir -p $WRKDIR/detectron/
    singularity_wrapper exec cp -r /detectron/configs $WRKDIR/detectron/configs
    cd $WRKDIR/detectron
    
  2. Create data directory and download example models there:

    mkdir -p data/ImageNetPretrained/MSRA
    mkdir -p data/coco_2014_train:coco_2014_valminusminival/generalized_rcnn
    wget -O data/ImageNetPretrained/MSRA/R-101.pkl \
        https://s3-us-west-2.amazonaws.com/detectron/ImageNetPretrained/MSRA/R-101.pkl
    wget -O data/coco_2014_train:coco_2014_valminusminival/generalized_rcnn/model_final.pkl \
        https://s3-us-west-2.amazonaws.com/detectron/35861858/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml.02_32_51.SgT4y1cO/output/train/coco_2014_train:coco_2014_valminusminival/generalized_rcnn/model_final.pkl
    
  1. Edit the weights-parameter in configuration file 12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml:

    33c33
    <   WEIGHTS: $WRKDIR/detectron/data/ImageNetPretrained/MSRA/R-101.pkl
    ---
    >   WEIGHTS: https://s3-us-west-2.amazonaws.com/detectron/ImageNetPretrained/MSRA/R-101.pkl
    
  2. Edit Slurm script to point to downloaded weigths and models:

#!/bin/bash
#SBATCH --time=00:30:00
#SBATCH --mem=8G
#SBATCH --gres=gpu:teslap100:1
#SBATCH -o detectron.out

module load singularity-detectron

mkdir -p $WRKDIR/detectron/outputs

singularity_wrapper exec python2 /detectron/tools/infer_simple.py \
    --cfg $WRKDIR/detectron/configs/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_2x.yaml \
    --output-dir $WRKDIR/detectron/outputs \
    --image-ext jpg \
    --wts $WRKDIR/detectron/data/coco_2014_train:coco_2014_valminusminival/generalized_rcnn/model_final.pkl \
    /detectron/demo
  1. Submit job:

    sbatch detectron.sh