This competition is evaluated on the mean Dice coefficient. The Dice coefficient can be used to compare the pixel-wise agreement between a predicted segmentation and its corresponding ground truth. The formula is given by:
$$ \frac{2* |X \cap Y|}{|X|+|Y|} $$
where X is the predicted set of pixels and Y is the ground truth. The Dice coefficient is defined to be 1 when both X and Y are empty. The leaderboard score is the mean of the Dice coefficients for each *<ImageId, ClassId>* pair in the test set. ClassId = 0 means neoplastic polyp, while ClassId = 1 means non-neoplastic polyp.

**Expected results**
In order to reduce the submission file size, our metric uses run-length encoding on the pixel values. Instead of submitting an exhaustive list of indices for your segmentation, you will submit pairs of values that contain a start position and a run length. For example, '1 3' implies starting at pixel 1 and running a total of 3 pixels 1,2,3.

The competition format requires a space-delimited list of pairs. For example, '1 3 10 5' implies pixels 1,2,3,10,11,12,13,14 are to be included in the mask. The metric checks that the pairs are sorted, positive, and the decoded pixel values are not duplicated. The pixels are numbered from top to bottom, then left to right: 1 is pixel 1,1, 2 is pixel 2,1, etc.

**File Format**
Your submission file should be in csv format, with a header and columns names: Id, Expected.
Each row in your submission represents a single predicted polyp segmentation for the given ImageId and predicted ClassId, and you should have the same number of rows as num_images * 2, i.e., 400 rows. The segment for each polyp class will be encoded into a single row, even if there are several non-contiguous polyp regions on an image.

```
Id,Expected  
633a8d5b2b2b55157b7781e2c706c75c_0, 200 10    
633a8d5b2b2b55157b7781e2c706c75c_1, 500 11    
60a633a8d5b2b2b55157b7781e2c706c_0, 650 15    
60a633a8d5b2b2b55157b7781e2c706c_1, 1 50    
etc...
```
You can use the [sample code here](https://github.com/sangdv/rle_encode/blob/main/mask2csv.py) to convert segmentation masks into a csv file.

**Important Note**
It should be emphasized that the predicted segmentation results must match the size of the original image. Therefore, if you resize the input image to fit your models, you must also <strong>resize the prediction output back to the original size</strong> of the input image before converting it to the required format.