CoinCheung / BiSeNet

Add bisenetv2. My implementation of BiSeNet
MIT License
1.42k stars 305 forks source link

train question #256

Closed miscedence12 closed 1 year ago

miscedence12 commented 2 years ago

Hello@CoinCheung! I train this code but I have some questions, As follows: In base_dataset.py, when reading the label, why did you set the mode=0? def get_image(self, impth, lbpth): img = cv2.imread(impth)[:, :, ::-1].copy() label = cv2.imread(lbpth, 0)

    return img, label

And then, when training your code with no changes, I meet this question: IndexError: Target 119 is out of bounds.

Could you give me a hand in solving this question? Best wishes!

CoinCheung commented 2 years ago

0 means gray mode, your label file should be single channel image, and that is what gray mode image is like. If you do not set it to 0, you will have a 3 channel label image.

Which dataset are you using? Did you prepare dataset following the step in readme?

miscedence12 commented 2 years ago

@CoinCheung,Thanks for your reply.I use the cityscapes dataset,the label has 3 channels, what should i do to change the code?

miscedence12 commented 2 years ago

@CoinCheung Hello!I still have to bother you, I was stuck in this place for many days,I use the cityscapes dataset,but when I run the training code ,it appeared this error: Traceback (most recent call last): File "D:/GitHub/BiSeNet/tools/train_amp.py", line 220, in main() File "D:/GitHub/BiSeNet/tools/train_amp.py", line 216, in main train() File "D:/GitHub/BiSeNet/tools/train_amp.py", line 163, in train loss_pre = criteria_pre(logits, lb) File "D:\LenovoSoftstore\Install\python3.8\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl return forward_call(*input, *kwargs) File "D:\GitHub\BiSeNet\lib\ohem_ce_loss.py", line 37, in forward loss = self.criteria(logits, labels).view(-1) #logits:4 19 1024 1024 labels:4 1024 1024 File "D:\LenovoSoftstore\Install\python3.8\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl return forward_call(input, **kwargs) File "D:\LenovoSoftstore\Install\python3.8\lib\site-packages\torch\nn\modules\loss.py", line 1163, in forward return F.cross_entropy(input, target, weight=self.weight, File "D:\LenovoSoftstore\Install\python3.8\lib\site-packages\torch\nn\functional.py", line 2996, in cross_entropy return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing) RuntimeError: CUDA error: an illegal memory access was encountered Hope you help me,thanks!

CoinCheung commented 2 years ago

Did you prepared dataset as the method in readme ? Are you really using the cityscapes dataset with 19 categories, or have you pre-processed it in some way?

CoinCheung commented 2 years ago

I tried it locally, and the training status is normal. Would you please show me how you prepared the dataset?

miscedence12 commented 2 years ago

D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000000_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000000_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000001_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000001_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000002_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000002_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000003_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000003_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000004_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000004_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000005_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000005_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000006_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000006_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000007_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000007_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000008_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000008_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000009_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000009_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000010_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000010_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000011_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000011_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000012_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000012_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000013_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000013_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000014_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000014_000019_gtFine_color.png D:/Datasets/cityscapes/leftImg8bit/train/aachen/aachen_000015_000019_leftImg8bit.png,D:/Datasets/cityscapes/gtFine/train/aachen/aachen_000015_000019_gtFine_color.png

miscedence12 commented 2 years ago

@CoinCheung ,this is my train.txt follwing your readme

miscedence12 commented 2 years ago

@CoinCheung I have never change others

CoinCheung commented 2 years ago

That is weird, did you modify the code?

miscedence12 commented 2 years ago

@CoinCheung ,I have never change the code,but the label has 3 channels ,Is it related to this? label = cv2.imread(lbpth,0)?

CoinCheung commented 2 years ago

Maybe you are not using the correct label file. See my anno file: https://github.com/CoinCheung/BiSeNet/blob/befab8b643bc049b9425cb5741f9817050c1813e/datasets/cityscapes/train.txt#L2 My label file name ends with labelIdx, but yours end with color.

miscedence12 commented 2 years ago

@CoinCheung Thanks for helping with this question, if I want to use label having 3 channels, what should I do to modify the code?

CoinCheung commented 2 years ago

You cannot do this if your task is semantic segmantation. As far as I know, it is not impossible, or it is beyond my knowledge scope. If you can do this, please share your method, and I would like to learn.

miscedence12 commented 2 years ago

@CoinCheung Thank you very much for answering my questions, I will make changes on this to complete the semantic segmentation task, and if I can achieve it, I will share my method.

miscedence12 commented 2 years ago

@CoinCheung 你好,我能问下您当时训练bisenetv1大概训练了多久?还有训练过程中是否会有loss震荡?能否提供训练日志? 谢谢!

CoinCheung commented 1 year ago

Close this with love&peace.