Skip to content

Commit

Permalink
update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjurado committed Apr 26, 2024
1 parent 0db618f commit 573f782
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 105 deletions.
27 changes: 26 additions & 1 deletion object_detection/README.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,87 @@
# 1. Problem

Object detection and segmentation. Metrics are mask and box mAP.

# 2. Directions

### Steps to configure machine

1. Checkout the MLPerf repository

```
mkdir -p mlperf
cd mlperf
git clone https://github.com/mlperf/training.git
```

2. Install CUDA and Docker

```
source training/install_cuda_docker.sh
```

3. Build the docker image for the object detection task

```
cd training/object_detection/
nvidia-docker build . -t mlperf/object_detection
```

### Steps to download data

```
# From training/object_detection/
source download_dataset.sh
```

### Steps to run benchmark.
### Steps to run benchmark

```
nvidia-docker run -v .:/workspace -t -i --rm --ipc=host mlperf/object_detection \
"cd mlperf/training/object_detection && ./run_and_time.sh"
```

# 3. Dataset/Environment

### Publication/Attribution

Microsoft COCO: Common Objects in Context

### Data preprocessing

Only horizontal flips are allowed.

### Training and test data separation

As provided by MS-COCO (2017 version).

### Training data order

Randomly.

### Test data order

Any order.

# 4. Model

### Publication/Attribution

He, Kaiming, et al. "Mask r-cnn." Computer Vision (ICCV), 2017 IEEE International Conference on.
IEEE, 2017.

We use a version of Mask R-CNN with a ResNet-50 backbone.

### List of layers

Running the timing script will display a list of layers.

### Weight and bias initialization

The ResNet-50 base must be loaded from the provided weights. They may be quantized.

### Loss function

Multi-task loss (classification, box, mask). Described in the Mask R-CNN paper.

Classification: Smooth L1 loss
Expand All @@ -72,17 +91,23 @@ Box: Log loss for true class.
Mask: per-pixel sigmoid, average binary cross-entropy loss.

### Optimizer

Momentum SGD. Weight decay of 0.0001, momentum of 0.9.

# 5. Quality

### Quality metric

As Mask R-CNN can provide both boxes and masks, we evaluate on both box and mask mAP.

### Quality target

Box mAP of 0.377, mask mAP of 0.339

### Evaluation frequency

Once per epoch, 118k.

### Evaluation thoroughness

Evaluate over the entire validation set. Use the official COCO API to compute mAP.
38 changes: 24 additions & 14 deletions object_detection/download_dataset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ while [ $# -gt 0 ]; do
shift
done


# Get COCO 2017 data sets
echo "Downloaading to folder: $DATA_ROOT_DIR"
mkdir -p $DATA_ROOT_DIR
Expand All @@ -25,30 +24,41 @@ tar -xzf coco_annotations_minival.tgz &>/dev/null
echo "Downloading annotations_trainval2017.zip:"
curl -O http://images.cocodataset.org/annotations/annotations_trainval2017.zip
echo "Extracting annotations_trainval2017.zip:"
n_files=`unzip -l annotations_trainval2017.zip| grep .json | wc -l`
unzip annotations_trainval2017.zip | { I=-1; while read; do printf "Progress: $((++I*100/$n_files))%%\r"; done; echo ""; }
n_files=$(unzip -l annotations_trainval2017.zip | grep .json | wc -l)
unzip annotations_trainval2017.zip | {
I=-1
while read; do printf "Progress: $((++I * 100 / $n_files))%%\r"; done
echo ""
}

echo "Downloading val2017.zip:"
curl -O http://images.cocodataset.org/zips/val2017.zip
echo "Extracting val2017.zip:"
n_files=`unzip -l val2017.zip| grep .jpg | wc -l`
unzip val2017.zip | { I=-1; while read; do printf "Progress: $((++I*100/$n_files))%%\r"; done; echo ""; }
n_files=$(unzip -l val2017.zip | grep .jpg | wc -l)
unzip val2017.zip | {
I=-1
while read; do printf "Progress: $((++I * 100 / $n_files))%%\r"; done
echo ""
}

echo "Downloading train2017.zip:"
curl -O http://images.cocodataset.org/zips/train2017.zip
echo "Extracting train2017.zip:"
n_files=`unzip -l train2017.zip| grep .jpg | wc -l`
unzip train2017.zip | { I=-1; while read; do printf "Progress: $((++I*100/$n_files))%%\r"; done; echo ""; }
n_files=$(unzip -l train2017.zip | grep .jpg | wc -l)
unzip train2017.zip | {
I=-1
while read; do printf "Progress: $((++I * 100 / $n_files))%%\r"; done
echo ""
}

# MD5 verification
echo "Running MD5 verification ... this might take a while"
checkMD5 () {
if [ $(pv -f $1| md5sum | cut -d' ' -f1) = $2 ];
then
echo "$1 MD5 is valid"
else
echo "*ERROR* $1 MD5 is NOT valid"
fi
checkMD5() {
if [ $(pv -f $1 | md5sum | cut -d' ' -f1) = $2 ]; then
echo "$1 MD5 is valid"
else
echo "*ERROR* $1 MD5 is NOT valid"
fi
}

echo "validating annotations_trainval2017.zip:"
Expand Down
14 changes: 6 additions & 8 deletions object_detection/download_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ while [ $# -gt 0 ]; do
shift
done


echo "Downloaading demo to folder: $DATA_ROOT_DIR"
mkdir -p $DATA_ROOT_DIR
pushd $DATA_ROOT_DIR
Expand All @@ -24,13 +23,12 @@ echo "Done!"

# MD5 verification
echo "Running MD5 verification ..."
checkMD5 () {
if [ $(pv -f $1| md5sum | cut -d' ' -f1) = $2 ];
then
echo "$1 MD5 is valid"
else
echo "*ERROR* $1 MD5 is NOT valid"
fi
checkMD5() {
if [ $(pv -f $1 | md5sum | cut -d' ' -f1) = $2 ]; then
echo "$1 MD5 is valid"
else
echo "*ERROR* $1 MD5 is NOT valid"
fi
}

echo "validating demo_data.zip:"
Expand Down
67 changes: 0 additions & 67 deletions object_detection/mlcube.py

This file was deleted.

16 changes: 8 additions & 8 deletions object_detection/run_and_time.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ SOLVER_MAX_ITER="${SOLVER_MAX_ITER:-40000}"

#Link input data paths
if [ "$DATA_DIR" != "$DATA_ROOT_TARGET" ]; then
mkdir -p $DATA_ROOT_TARGET
ln -s $DATA_DIR/annotations $DATA_ROOT_TARGET/annotations
ln -s $DATA_DIR/train2017 $DATA_ROOT_TARGET/train2017
ln -s $DATA_DIR/test2017 $DATA_ROOT_TARGET/test2017
ln -s $DATA_DIR/val2017 $DATA_ROOT_TARGET/val2017
mkdir -p $DATA_ROOT_TARGET
ln -s $DATA_DIR/annotations $DATA_ROOT_TARGET/annotations
ln -s $DATA_DIR/train2017 $DATA_ROOT_TARGET/train2017
ln -s $DATA_DIR/test2017 $DATA_ROOT_TARGET/test2017
ln -s $DATA_DIR/val2017 $DATA_ROOT_TARGET/val2017
fi

pwd

# Single GPU training
time python tools/train_mlperf.py --config-file "configs/e2e_mask_rcnn_R_50_FPN_1x.yaml" \
SOLVER.IMS_PER_BATCH 2 TEST.IMS_PER_BATCH 1 SOLVER.MAX_ITER 720000 \
SOLVER.STEPS "(480000, 640000)" SOLVER.BASE_LR 0.0025 OUTPUT_DIR $OUTPUT_DIR
SOLVER.IMS_PER_BATCH 2 TEST.IMS_PER_BATCH 1 SOLVER.MAX_ITER 720000 \
SOLVER.STEPS "(480000, 640000)" SOLVER.BASE_LR 0.0025 OUTPUT_DIR $OUTPUT_DIR

popd
14 changes: 7 additions & 7 deletions object_detection/run_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ SOLVER_MAX_ITER="${SOLVER_MAX_ITER:-40000}"

#Link input data paths
if [ "$DATA_DIR" != "$DATA_ROOT_TARGET" ]; then
mkdir -p $DATA_ROOT_TARGET
ln -s $DATA_DIR/annotations $DATA_ROOT_TARGET/annotations
ln -s $DATA_DIR/train2017 $DATA_ROOT_TARGET/train2017
ln -s $DATA_DIR/val2017 $DATA_ROOT_TARGET/val2017
mkdir -p $DATA_ROOT_TARGET
ln -s $DATA_DIR/annotations $DATA_ROOT_TARGET/annotations
ln -s $DATA_DIR/train2017 $DATA_ROOT_TARGET/train2017
ln -s $DATA_DIR/val2017 $DATA_ROOT_TARGET/val2017
fi

pwd

# Single GPU training
time python tools/train_mlperf.py --config-file "configs/e2e_mask_rcnn_R_50_FPN_1x.yaml" \
SOLVER.IMS_PER_BATCH 2 TEST.IMS_PER_BATCH 1 SOLVER.MAX_ITER 720 \
SOLVER.STEPS "(480, 640)" SOLVER.BASE_LR 0.0025 OUTPUT_DIR $OUTPUT_DIR
SOLVER.IMS_PER_BATCH 2 TEST.IMS_PER_BATCH 1 SOLVER.MAX_ITER 720 \
SOLVER.STEPS "(480, 640)" SOLVER.BASE_LR 0.0025 OUTPUT_DIR $OUTPUT_DIR

popd

0 comments on commit 573f782

Please sign in to comment.