# How to train YOLOv9 Instance Segmentation on a Custom Dataset

**URL:** https://discuss.roboflow.com/t/how-to-train-yolov9-instance-segmentation-on-a-custom-dataset/5210
**Category:** 🤝  Community Help
**Tags:** export, segmentation, formats, feature-request
**Created:** [April 8, 2024, 9:42pm UTC](https://discuss.roboflow.com/t/how-to-train-yolov9-instance-segmentation-on-a-custom-dataset/5210 "2024-04-08T21:42:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![txctxc](https://avatars.discourse-cdn.com/v4/letter/t/ce7236/32.png) [@txctxc](https://discuss.roboflow.com/u/txctxc)
#### Post date: [April 8, 2024, 9:42pm UTC](https://discuss.roboflow.com/t/how-to-train-yolov9-instance-segmentation-on-a-custom-dataset/5210/1 "2024-04-08T21:42:40Z")

</div>

#feature-request  
Hello, in the official YOLOv9 repository, the code for training YOLOv9 instance segmentation was updated several hours ago as mentioned in the following links: [Is YOLO v9 segmentation task open-sourced? · Issue #174 · WongKinYiu/yolov9 · GitHub](https://github.com/WongKinYiu/yolov9/issues/174#issuecomment-2041676702)  
I am a newbie and quite confused about how to export YOLOv9 Instance Segmentation Dataset format from roboflow.  
I did a try on YOLOv9 Instance Segmentation on my Roboflow dataset several hours ago but failed, and here is what I did:

1. I downloaded the latest official YOLOv9 GitHub repository manually instead of downloading it by

```bash
git clone https://github.com/SkalskiP/yolov9.git

```

as the latest repository has not been released yet.

1. Export YOLOv9 format from my Roboflow dataset version. I have used this dataset format for YOLOv9 Object Detection and it works fine. Now I want to use the same dataset format for YOLOv9 Instance Segmentation. In Roboflow platform, my dataset is well-annotated by polygon masks.

2. train:

```bash
python segment/train.py --epochs 50 --batch 1 --img 1408 --workers 8 --device 0 \
--data /mydatasetroot/data.yaml \
--cfg models/segment/gelan-c-seg.yaml \
--weights /myweightsroot/gelan-c-seg.pt \
--name gelan-c-seg --hyp hyp.scratch-high.yaml --no-overlap --close-mosaic 10

```

where I used this code for training: WongKinYiu/yolov9/blob/main/segment/train.py  
as the training process continued, I found something went wrong. The P, R, and mAP50 values all became 0 after epoch 3:

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/2X/9/93df00b93a003f92f5e96a280ffcf32b02dd3a4e.png)  
I searched for the issues in YOLOv9 repository and found this similar issue: [During training, these parameters are all 0 --- P, R, mAP50 · Issue #252 · WongKinYiu/yolov9 · GitHub](https://github.com/WongKinYiu/yolov9/issues/252#issuecomment-1999632911)  
and the author said referring to his warning messages, it may be because his labels are not in the correct format. But I have not got any warning messages on my labels’ format, so I think my situation is not quite the same as his.

It would be constructive if anyone could provide a demo jupyter notebook on how to train YOLOv9 Instance Segmentation on a custom dataset exported from Roboflow platform.  
I appreciate your patience in reading these.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/bb6edbfa56d0cf2ee603f061e9e09103502cc8cc.png) [@system](https://discuss.roboflow.com/u/system)
#### Post date: [April 29, 2024, 9:43pm UTC](https://discuss.roboflow.com/t/how-to-train-yolov9-instance-segmentation-on-a-custom-dataset/5210/2 "2024-04-29T21:43:24Z")

</div>

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
