# Mask2Former for Binary segmentation

**URL:** <https://discuss.huggingface.co/t/mask2former-for-binary-segmentation/45120>\
**Category:** 🤗Transformers\
**Created:** [June 30, 2023, 9:40am UTC](https://discuss.huggingface.co/t/mask2former-for-binary-segmentation/45120 "2023-06-30T09:40:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![manuCeron96](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@manuCeron96](https://discuss.huggingface.co/u/manuCeron96)\
**Post date:** [June 30, 2023, 9:40am UTC](https://discuss.huggingface.co/t/mask2former-for-binary-segmentation/45120/1 "2023-06-30T09:40:13Z")

</div>

Hey. I’m doing binary segmentation using Mask2FormerForUniversalSegmentation.from\_pretrained and Mask2FormerImageProcessor. I’m following this tutorial [Transformers-Tutorials/MaskFormer/Fine-tuning/Fine\_tuning\_MaskFormerForInstanceSegmentation\_on\_semantic\_sidewalk.ipynb at master · NielsRogge/Transformers-Tutorials · GitHub](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/MaskFormer/Fine-tuning/Fine_tuning_MaskFormerForInstanceSegmentation_on_semantic_sidewalk.ipynb)

My custom dataset contains a single class. I’m not quite sure if Mask2Former supports binary segmentation or should I treat this task as a 2-class segmentation, considering 0-background and 1-myClass.  
I have tried both cases but I’m struggling with the arguments ignore\_index and reduce\_labels.

The model does not learn and the IoU is around 0.2 for both classes (background and myClass) along all epochs.

I’m stuck in this point, any idea?

Thanks.

---

<div class="post-metadata">

**Author:** ![beschmitt](https://avatars.discourse-cdn.com/v4/letter/b/b4bc9f/32.png) [@beschmitt](https://discuss.huggingface.co/u/beschmitt)\
**Post date:** [July 9, 2024, 9:26am UTC](https://discuss.huggingface.co/t/mask2former-for-binary-segmentation/45120/2 "2024-07-09T09:26:57Z")

</div>

Maybe a long shot but have you ever found out the correct settings for binary segmentation? I’m also trying to train mask2former for a binary task with 0-background and 1-myClass and I just don’t understand the different settings in the model and the image processor.  
My model is always just returning a null-tensor no matter what I do and the documentation on the model and image-processor are practically non-existent.
