open-mmlab / mmsegmentation

OpenMMLab Semantic Segmentation Toolbox and Benchmark.
https://mmsegmentation.readthedocs.io/en/main/
Apache License 2.0
8.26k stars 2.62k forks source link

Using mmseg for secondary classification can only predict the background #2713

Open iakRulan opened 1 year ago

iakRulan commented 1 year ago

I can use mmseg to detect my own dataset, the JPG format used in the original image, and the binary PNG format used in the mask. I can train and predict, but the training process and reasoning process cannot split the target area. I can't detect it using the cross entropy loss function and Dice Loss,

``2023-03-07 14:30:11,324 - mmseg - INFO - workflow: [('train', 1)], max: 1600 iters 2023-03-07 14:30:11,324 - mmseg - INFO - Checkpoints will be saved to /root/mmsegmentation/work_dirs/segformer_mit-b5_8x1_1024x1024_160k_cityscapes by HardDiskBackend. 2023-03-07 14:31:24,458 - mmseg - INFO - Iter [50/1600] lr: 1.900e-06, eta: 0:37:44, time: 1.461, data_time: 0.018, memory: 20549, decode.loss_dice: 0.5979, decode.acc_seg: 73.8272, loss: 0.5979 2023-03-07 14:32:32,725 - mmseg - INFO - Iter [100/1600] lr: 3.715e-06, eta: 0:35:19, time: 1.365, data_time: 0.010, memory: 20549, decode.loss_dice: 0.5748, decode.acc_seg: 88.4181, loss: 0.5748 2023-03-07 14:33:41,799 - mmseg - INFO - Iter [150/1600] lr: 5.405e-06, eta: 0:33:53, time: 1.381, data_time: 0.010, memory: 20549, decode.loss_dice: 0.5558, decode.acc_seg: 97.9252, loss: 0.5558 2023-03-07 14:33:55,382 - mmseg - INFO - Saving checkpoint at 160 iterations [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 411/411, 0.9 task/s, elapsed: 456s, ETA: 0s2023-03-07 14:41:34,486 - mmseg - INFO - per class results: 2023-03-07 14:41:34,487 - mmseg - INFO - +-------------+-------+-------+ | Class | IoU | Acc | +-------------+-------+-------+ | background | 99.58 | 99.97 | | Tamper_area | 0.0 | 0.0 | +-------------+-------+-------+ 2023-03-07 14:41:34,487 - mmseg - INFO - Summary: 2023-03-07 14:41:34,487 - mmseg - INFO - +-------+-------+-------+ | aAcc | mIoU | mAcc | +-------+-------+-------+ | 99.58 | 49.79 | 49.99 | +-------+-------+-------+ 2023-03-07 14:41:34,488 - mmseg - INFO - Iter(val) [411] aAcc: 0.9958, mIoU: 0.4979, mAcc: 0.4999, IoU.background: 0.9958, IoU.Tamper_area: 0.0000, Acc.background: 0.9997, Acc.Tamper_area: 0.0000

stone-cloud commented 1 year ago

I have had this problem and have solved it. I recommend that you first check that the label data in the data set (both the training set and the validation set) contains only 2 classes and that the target class has a value of 1. If there's no problem, let's think about the sample imbalance problem. This problem is really troublesome, I hope it can help you.

qiu-pinggaizi commented 1 year ago

I have the same problem. There are two categories. The label data mask is 0, 1; Do you have any suggestions? @xiexinch @MeowZheng

iakRulan commented 1 year ago

I have had this problem and have solved it. I recommend that you first check that the label data in the data set (both the training set and the validation set) contains only 2 classes and that the target class has a value of 1. If there's no problem, let's think about the sample imbalance problem. This problem is really troublesome, I hope it can help you.

The label is indeed 0 and 1, I use the pre -training weight, I don't know why the effect is so bad

MeowZheng commented 1 year ago

I have checked DiceLoss implementation in mmseg, there might be some problems with it. We are working on fixing it.