The code is to get segmentation image by darknet
In the process of my project, I have referenced nithi89/unet_darknet in some points and nithilan has give me many important
advices, thanks to him, and if you have interest you can visit his homepage.
This is my third version, I added dilation convolutional, and now it has not so perfect result, but i think it's good enough for me.
I will continue to update afterwards, please stay tuned.
Train:
./darknet segmenter train [data_file path] cfg/segment.cfg [pretrain weights file I gave to you]
Test:
./darknet segmenter test [data_file path] cfg/segment.cfg [weights file] [image path]
Merge two images:
python Merge.py
And you will get the mask image named final.png
The Way is so easy, you only need three files:
original colorful image;
0101 binary label image;
train.list.
For example with cityscape dataset:
I only have one class so the label image with pixels 0101, as 0 is background and 1 is object. If you have 2 classes, the label image pixel value should be 012 and so on:
Maybe you can't see the pixels with value 1 because it's close to 0, just see the image below(not for training, just watch as example):
1. prepare train images and label images like above images
I have added below function call in my code according to my pictures, you have to change it according to your image name
#######################################################
find_replace(labelpath, "_leftImg8bit.png", "_gtFine_instanceIds.png", labelpath);
#######################################################
2. put label images and original images together
3. generate the train.list file just like:
/home/user/Desktop/YOLO_train/leftImg8bit/train/aachen_resize/jena_000012_000019_leftImg8bit.png
4. start train
./darknet segmenter train [data_file path] cfg/segment.cfg [pretrain weights file I gave to you]
If you want to see my Result Video, I have put it in: https://pan.baidu.com/s/1uJwFYLHEQ9DGFZ8RkGuagg, and the password is: ic3q
If you want to get how to change the code, see https://github.com/ArtyZe/yolo_segmentation/blob/master/Train_Details.md
What I did to change Yolo for image segmentation, I have written a blog in: https://blog.csdn.net/Artyze/article/details/82721147
After I will do some work in semantic segmentation with yolo.
If you want to get the cfg and weights file, or you want to do something with Yolo with me, contact me with E-mail: Gaoyang917528@163.com.