yingkaisha / keras-unet-collection

The Tensorflow, Keras implementation of U-net, V-net, U-net++, UNET 3+, Attention U-net, R2U-net, ResUnet-a, U^2-Net, TransUNET, and Swin-UNET with optional ImageNet-trained backbones.
MIT License
659 stars 184 forks source link

Multiclass input #20

Closed marcodelmoral closed 3 years ago

marcodelmoral commented 3 years ago

Hello, I'm wondering how to do multiclass classification with Unet. I saw that a previous hot encode step is needed. My dataset consists in two classes + background. Thanks in advance!

yingkaisha commented 3 years ago

Sorry, the question is too general to be answered.

Would this example help you? https://github.com/yingkaisha/keras-unet-collection/blob/main/examples/human-seg_atten-unet-backbone_coco.ipynb

atgc1984 commented 3 years ago

My understanding is that if your pixel labels are something like 0/1/2 you may use _keras.losses.sparse_categoricalcrossentropy. For _keras.losses.categoricalcrossentropy, the labels should be in one-hot format.

marcodelmoral commented 3 years ago

My understanding is that if your pixel labels are something like 0/1/2 you may use _keras.losses.sparse_categoricalcrossentropy. For _keras.losses.categoricalcrossentropy, the labels should be in one-hot format.

Ok I understand, I was used to work with implementations that use (h,w,c) where c = number of classes. For this implementation a (h,w) mask with integer labeled pixels as classes. Thank you very much!

yingkaisha commented 3 years ago

Great to see the progress. Closing.