Oxford-IIIT Pet Dataset - Instance Segmentation
- Data analysis here.
- Convert a custom dataset to COCO format here.
- When making a custom dataset check if your data is compatible with the COCO format here.
- Create a config to train the model here.
- Demo training here.
Nice virtualenv tutorial here
pip3 install --upgrade pip
which python3.8
mkvirtualenv -p <path to python3> <name>
workon <name>
For example:
mkvirtualenv -p /usr/bin/python3.8 Febrin
workon Febrin
Ensure that you have properly installed all the required packages:
- CUDA 11.0
- GCC 7.5
- torch 1.7.1+cu110
- torchvision 0.8.2+cu110
- Comet ML 3.9.0
- OpenCV: 4.1.2
- MMCV: 1.3.1
- MMDetection: 2.11.0+187774b
In our case we use torch 1.7.1
and Cuda 11.0
$ nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.102.04 Driver Version: 450.102.04 CUDA Version: 11.0 |
|-------------------------------+----------------------+----------------------+
Install correct pytorch
pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
Install mmdetection with mmcv
rm -rf mmdetection
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -e .
So this is matching mmcv
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html
Download dataset and models
python download.py
Test Your own images
python inference.py image.jpg
Our goal is to create an instance segmentation model based on the Oxford-IIIT Pet Dataset.
Instance segmentation is a task in Computer Vision that aims to identify each instance of each object within the image at the pixel level. In our case, each image contains a single object, which means our goal is to predict which pixels belong to the object and which to the background as well as predict the object's class.
Our dataset contains ~200 images for each from 37 classes.
Near 2/3 of those classes are dog breeds, the rest of them are cat breeds.
The images have different sizes and rations, therefore they need to be resized. There's a high variance in background colors and the amount of light on the pictures.
We will build our model using MMDetection - an open-source object detection toolbox based on PyTorch. We will experiment with different types of backbones, for example, ResNet, ResNext, or VGG.
├── /model - folder for keeping models
│ └── download_model.py - script for downloading dataset
│
├── /trainer - training scripts
│ └── train.py
| └── test.py
│
├── /mains - main files responsible for the whole pipeline
│ └── main.py
|
├── /figures - figures generated during analysis and used in README
│ └── ...
│
├── /notebooks - notebook files created for tests on Colaboratory
│ ├── /Convert_to_COCO_format.ipynb
│ ├── /Create_config.ipynb
│ ├── /Demo training.ipynb
│ ├── /Demo.ipynb
│ ├── /Pycoco-test.ipynb
│ └── /Data_analysis.ipynb
|
├── /dataset - things related to the dataset
│ ├── /train - train datapoints and labels
│ ├── /test - test datapoints and labels
│ ├── /valid - valid datapoints and labels
│ └── divide_dataset.py - script that divides the dataset into /train/test/valid
│
└── /utils
├── logger.py
└── ...
This template also supports reporting to Comet.ml which allows you to see all your hyper-params, metrics, graphs, dependencies and more including real-time metric.
Here's how it looks after you start training:
You can also link your Github repository to your comet.ml project for full version control. Here's a live page showing the example from this repo
Project started: 09.03.2021
-
Week 1:
- Created the repository
- Analyzed the dataset
- Investigated data storing options (GCS) and model training (GCP machine)
- Created a Kanban board where we track the tasks and progress.
-
Week 2:
- Downloaded the data and created a dataloader
- Started to familiarize ourselves with mmdet environment
- Tested CometML and played with it
- Created requirements.txt
-
Week 3:
- Created our own CometML logger hook and integrated it with their API
- Created a proper DataLoader
- Started writing a mmdet notebook that will transition to train.py soon
- Read some papers i.e. Feature Pyramid Network
-
Week 4:
- Validated our coco using: https://github.com/cocodataset/cocoapi/tree/master/PythonAPI/pycocotools
- Cleaned the repo and README
- Train on the second model to show that COMET ML
-
Week 5:
- Moved our code from Colab files to Python scripts
- Created Docerfile to be used as an environment created inside Colab
Project ended: 27.04.2021