rishizek / tensorflow-deeplab-v3-plus

DeepLabv3+ built in TensorFlow
MIT License
833 stars 307 forks source link

Train on single channel images #28

Open avipartho opened 5 years ago

avipartho commented 5 years ago

Thanks for the repo!!! It worked great on Pascal VOC dataset. I have a few questions for my own case though. Is it possible to run the scripts for single channel image by changing the _WIDTH,_HEIGHT and _DEPTH parameter in train.py to img_width,img_height,1 respectively? If it is, then for the two colors -black and white, should I just use (0,0,0) and (255,255,255) for the color map in preprocessing.py? Or is there something else I need to do? I have already changed color map to (0,0,0) and (255,255,255). The code is running without any error but apparently, it's learning nothing. Thanks for any sort of help.

rishizek commented 5 years ago

Hi @avipartho, Thanks for your interest in the repo. Yes. You should be able to change _DEPTH = 1, although I've never tried it. It may cause importing error when you import pretrained ImageNet model, unless you properly ignore appropriate layers. Alternative approach is simply converting your single channel to RGB somehow and then apply the model, and then convert the predicted results to single channel. The other thing that I concern is whether you are labeling appropriate. If your dataset have 3 classes, you need to set num_classes = 4 (= 3 classes + background). And you need to set your classes with 1, 2, 3, and 0 (background), respectively.

huangenwu commented 5 years ago

Thanks for the repo!!! It worked great on Pascal VOC dataset. I have a few questions for my own case though. Is it possible to run the scripts for single channel image by changing the _WIDTH,_HEIGHT and _DEPTH parameter in train.py to img_width,img_height,1 respectively? If it is, then for the two colors -black and white, should I just use (0,0,0) and (255,255,255) for the color map in preprocessing.py? Or is there something else I need to do? I have already changed color map to (0,0,0) and (255,255,255). The code is running without any error but apparently, it's learning nothing. Thanks for any sort of help.

do you successfully train the model on the single channel images?can you tell me how to change the config file?thank you.

avipartho commented 5 years ago

@rishizek I had two classes including the background, hence I said black and white as the color map. So I used num_classes = 2, giving background to 0(black) and desired segmentation to 1(black). Your script automatically converts my single channel image to 3 channel image I believe and using _DEPTH = 1 gives an error due to the pretrained ImageNet model as you mentioned. Maybe there is a problem somewhere else. It just considers everything as background after 1 epoch. What do you think?

@huangenwu No, I haven't been able to train the model successfully yet.

huangenwu commented 5 years ago

@rishizek I had two classes including the background, hence I said black and white as the color map. So I used num_classes = 2, giving background to 0(black) and desired segmentation to 1(black). Your script automatically converts my single channel image to 3 channel image I believe and using _DEPTH = 1 gives an error due to the pretrained ImageNet model as you mentioned. Maybe there is a problem somewhere else. It just considers everything as background after 1 epoch. What do you think?

@huangenwu No, I haven't been able to train the model successfully yet.

I change my single channel images into three channels images at first and then train the model,finally i success.but the model perform so bad.

orhunolgun commented 5 years ago

I created 3 channels images from my 1 channel training dataset by creating 2 empty channels and copying same information to empty channels to mimic 3 channel input, however I think this is not ideal and very time consuming. I wonder is there any way possible to avoid 3 channel input and train with 1 channel data, for example by manipulating the code but not data?

maruidodo commented 5 years ago

The picture in the VOC folder is grayscale image L. How do you generate the single channel image? Running evalut.py has been a failure.can you tell me ?

Raywoo1 commented 1 year ago

@rishizek我有两节课,包括背景,因此我说黑白作为颜色图。所以我使用 ,将背景设置为 0(黑色),将所需的分割为 1(黑色)。我相信您的脚本会自动将我的单通道图像转换为 3 通道图像,并且由于您提到的预训练 ImageNet 模型而使用会出现错误。也许其他地方有问题。它只是将所有内容视为 1 个纪元后的背景。你觉得怎么样?num_classes = 2``_DEPTH = 1 @huangenwu不,我还没有能够成功训练模型。

我先把我的单通道图像改成三通道图像,然后训练模型,最后我成功了,但模型表现太差了。

@rishizek I had two classes including the background, hence I said black and white as the color map. So I used num_classes = 2, giving background to 0(black) and desired segmentation to 1(black). Your script automatically converts my single channel image to 3 channel image I believe and using _DEPTH = 1 gives an error due to the pretrained ImageNet model as you mentioned. Maybe there is a problem somewhere else. It just considers everything as background after 1 epoch. What do you think? @huangenwu No, I haven't been able to train the model successfully yet.

I change my single channel images into three channels images at first and then train the model,finally i success.but the model perform so bad.

Me too. Have you solve this problem?