Summary of problems when doing Semantic Segmentation with Pytorch

Problems with semantic segmentation with Pytorch

When I wrote my graduation thesis, I did a semantic segmentation with pytorch, but I have a lot of troubles, so I will summarize it as a memorandum.

IoU There is a box_iou in torchvision, but I was in trouble because I could not find a guy for segmentation. I ended up using this implementation

torch.nn.CrossEntropyLoss This guy is really annoying Looking at document, it says $ Input: [Minibatch, C, d_1 ...] $, so the inferred result and the mask of the correct answer data When I made the shape of the one-hot expression like [number of batches, number of classes, H, W], I got an infinite number of errors and got stuck for a day or two.

Actually, the shape of the inference result is good as above, but the correct answer data seems to be $ target: [Minibatch, d_1 ...] $, the shape is [number of batches, H, W] and each pixel has a label. It seems that the answer is correct. BinaryCrossEntropy had the same shape for both input and target, so I got angry when I matched them. ~~ Check it properly ~~

Also, for target, it seems that the label of each pixel must match the index of the input class. In other words, if the number of classes is 20, the label of target must be a value from 0 to 19.

Recommended Posts

Summary of problems when doing Semantic Segmentation with Pytorch
Summary of snippets when developing with Go
Try Semantic Segmentation (Pytorch)
Prediction of Nikkei 225 with Pytorch 2
Prediction of Nikkei 225 with Pytorch
Summary of basic implementation by PyTorch
Prediction of Nikkei 225 with Pytorch ~ Intermission ~
Multi-class, multi-label classification of images with pytorch
Precautions when solving DP problems with Python
Memorandum of Understanding when migrating with GORM
Summary of operations often performed with asyncpg
The story of doing deep learning with TPU
Personal tips when doing various things with Python 3
Story of trying to use tensorboard with pytorch
[Python] Summary of S3 file operations with boto3
Summary of frequently used commands (with petit commentary)
Summary of error handling methods when installing TensorFlow (2)
Summary of reference sites when editing Blender Script with an external editor (VS Code)