The repository contains:
- Procedures to use VIA Dataset with two tasks: Object detection and semantic segmentation.
- How to implement into your custom dataset.
Object detection folder contains: dataset folder, two files .csv (test.csv, train.csv). The train.csv has 12,764 images and the test.csv has 2561 images.
Object Detection
│─── Data
|───000000_10.png
|───000001_10.png
|─── ...
│─── test.csv
│─── train.csv
The structure of .csv:
filename | xmin | ymin | xmax | ymax | class_id |
---|---|---|---|---|---|
00072.jpg | 148 | 53 | 159 | 63 | 4 |
In object detection task, we have 6 traffic signs (6 classes): Turn left, Turn Right, Straight, Stop, No Turn Left, No Turn Right.
Setup sementation data folders
Segmentation
│─── GGDataSet
|─── train_frames
|─── train
|─── train_000001.png
|─── train_masks
|─── train
|─── train_000001.png
|─── val_frames
|─── val
|─── val_000001.png
|─── val_masks
|─── val
|─── val_000001.png
|─── label_colors.txt
│─── model_pb
│─── models
│─── train.py
│─── convert_pb.py
VIA segmentation dataset has 6,240 training images, 1,448 validation images. In our task, we have to predict 3 classes: Background, Line, Road. The label_colors.txt contains RGB color code of classes and we handle it to convert classes into one-hot vector.
In VIA experiment, we implement Single Shot Detection (SSD). You do not need to follow our instructions if you want to handle the data for only your purposes.
- Upload VIA Dataset to Google Drive
- Upload object_detection.ipynb to Google Colab
- Modify your dataset locate path in Google Drive and your dataset path link to images and .csv files.
You can run notebook in local with requirements: Keras version 2.2.4, Tensorflow version 1.15 and git clone this repository:
git clone https://github.com/pierluigiferrari/ssd_keras
In VIA experiment, we implement PSPNet and use combine-loss is Dice Loss and Focal Loss. We use a library segmentation, you can read the docs to modify segmentation architecture.
To train segmentation task by VIA dataset, run the following commands
# Keras 2.2.4, Tensorflow >= 1.15
pip install -U segmentation-models
# Modify dataset path in train.py
img_dir = 'your_path/GGDataSet/'
DATA_PATH = 'your_path/GGDataSet/'
# Train
python3 train.py
# If you want to run pretrained model faster, you need to convert model to frozen graph
python3 convert_pb.py
In object detection task, we use the labelimg tool and the labelme tool to label segmentation dataset.
To object detection, we need to convert .xml files to .csv as (train.csv above). This xml_to_csv.py to help you handle it, remember that in our .csv we only contains (filename, xmin,ymin,xmax,ymax,class_id).
To semantic segmentation, the labelme tool export .json, we need to convert .json files to .png. Run the following commands
git clone https://github.com/wkentaro/labelme.git
cd labelme/examples/semantic_segmentation
./labelme2voc.py data_annotated data_dataset_voc --labels labels.txt
You can see the label PNG file in data_dataset_voc/SegmentationClassPNG/
folder.
Modify data_annotated
folder to your_dataset
.
Website: https://via.makerviet.org/