Mask R-CNN adapted for semantic segmentation of custom dataset for autonomous driving to augment Visual SLAM.
ROOT_DIR = Mask_RCNN/
ROOT_DIR/auto
├── auto.py
├── dataset
│ ├── images
│ │ ├── predicted
│ │ ├── train
│ │ └── val
│ └── masks
├── inspect_balloon_data.ipynb
├── inspect_balloon_model.ipynb
└── train_colab.ipynb
- Make a python3 virtual environment and install the required dependencies.
python3 -m venv env
source env/bin/activate
pip3 install -r requirements.txt
If there is an issue, then follow these steps:
- Use the provided tar env
by extracting it in ROOT_DIR.
- Activate virtual environment from ROOT_DIR by executing source env/bin/activate
. Find more info about virtual environment in this link.
- Download
mask_rcnn_coco.h5
in the ROOT_DIR from this link. If that link fails, open this link and download the file underv2.0
tag. cd ROOT_DIR/auto
- Create the directory structure as above. Particularly, the
dataset
folder should be strictly leveled and named as above. Thepredicted
directory is initially an empty.
Training using pretrained coco weights, execute the following command:
python3 auto.py train --dataset=./dataset/images --weights=coco
Other commands which could be used:
# Train a new model starting from pre-trained COCO weights
python3 auto.py train --dataset=/path/to/auto/dataset --weights=coco
# Resume training a model that you had trained earlier
python3 auto.py train --dataset=/path/to/auto/dataset --weights=last
# Train a new model starting from ImageNet weights
python3 auto.py train --dataset=/path/to/auto/dataset --weights=imagenet
# Apply color overlay to an image
python3 auto.py overlay --weights=/path/to/weights/file.h5 --image=<URL or path to file>
# Apply color overlay to video using the last weights you trained
python3 auto.py overlay --weights=last --video=<URL or path to file>
Logs will be stored in ROOT_DIR/logs
for every epoch. Use the last auto_xxxxxx.h5
file as the trained model weights to use for your dataset.
- Login with the Gmail account.
- Open
colab.research.google.com
. - Click on
Upload
tab. - Upload the
train_colab.ipynb
present inROOT_DIR/auto
. - Follow the instructions written in the notebook.
Points to note
dataset.tar.gz
is the compressed tar ofdataset
directory. Thus it will follow the same directory structure as mentioned above.- Download
mask_rcnn_coco.h5
from this link. If this link fails, open this link and download the file underv2.0
tag.
Overlays a mask on a single image or video, and stores in $PWD
.
python3 auto.py overlay --weights=<.h5 weights path> --image=<path to image>
Evaluates a set of images present in <dataset path>/val
and stores the predicted results in <dataset path>/predicted
.
Also finds stats like Average IOU, per-class IOU, time per image, etc.
python3 auto.py evaluate --dataset=<dataset path> --weights=<.h5 weights path>
Follow the #classchange
comment, using Find
(Ctrl/Cmd + F) in the file auto.py
and change the lines to fulfill custom requirements.