BiSeNet icon indicating copy to clipboard operation
BiSeNet copied to clipboard

train question

Open miscedence12 opened this issue 3 years ago • 15 comments
trafficstars

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!

miscedence12 avatar Aug 19 '22 09:08 miscedence12

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?

CoinCheung avatar Aug 19 '22 10:08 CoinCheung

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

miscedence12 avatar Aug 19 '22 10:08 miscedence12

@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!

miscedence12 avatar Aug 19 '22 13:08 miscedence12

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 avatar Aug 19 '22 14:08 CoinCheung

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

CoinCheung avatar Aug 19 '22 14:08 CoinCheung

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 avatar Aug 19 '22 14:08 miscedence12

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

miscedence12 avatar Aug 19 '22 14:08 miscedence12

@CoinCheung I have never change others

miscedence12 avatar Aug 19 '22 14:08 miscedence12

That is weird, did you modify the code?

CoinCheung avatar Aug 19 '22 14:08 CoinCheung

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

miscedence12 avatar Aug 19 '22 14:08 miscedence12

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.

CoinCheung avatar Aug 19 '22 14:08 CoinCheung

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

miscedence12 avatar Aug 20 '22 01:08 miscedence12

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.

CoinCheung avatar Aug 20 '22 01:08 CoinCheung

@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 avatar Aug 20 '22 01:08 miscedence12

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

miscedence12 avatar Aug 29 '22 12:08 miscedence12

Close this with love&peace.

CoinCheung avatar Nov 15 '22 03:11 CoinCheung