The dataset consists of images (.jpg), annotations (.txt), and a YAML file named yolo_seg_train.yaml. The dataset format follows the [Ultralytics/YOLO annotation format for Instance Segmentation tasks](https://docs.ultralytics.com/datasets/segment/). The dataset is divided into three parts: training, validation, and test. For this task, you need to predict masks for the test portion, which has no annotations in the dataset.

A total of 1,320 photographs from 295 patients were used in the study (each patient has multiple photographs available). Nine classes were annotated, as shown in the table below.

## Classes description

| Class ID | English Name       | Description                                                                 |
|----------|--------------------|-----------------------------------------------------------------------------|
| 0        | Abrasion           | Teeth with mechanical wear of hard tissues                                  |
| 1        | Filling            | Dental fillings of various types                                            |
| 2        | Crown              | Dental crown (restoration)                                                 |
| 3        | Caries Class 1     | Caries in fissures and pits (occlusal surfaces of molars/premolars, buccal surfaces of molars, lingual surfaces of upper incisors). |
| 4        | Caries Class 2     | Caries on proximal surfaces of molars and premolars.                       |
| 5        | Caries Class 3     | Caries on proximal surfaces of incisors/canines *without* incisal edge involvement. |
| 6        | Caries Class 4     | Caries on proximal surfaces of incisors/canines *with* incisal edge involvement. |
| 7        | Caries Class 5     | Cervical caries (buccal/lingual surfaces).                                 |
| 8        | Caries Class 6     | Caries on incisal edges of anterior teeth or cusps of molars.              |

The dataset was split by patients, not by images. 273 patients were included in the training set, and 22 patients were allocated to the validation set. Detailed class statistics for the training and validation sets are provided in the table below.

## Train and validation split

| Class Name       | Training Data                   || Validation Data                ||
|------------------|--------------------------------|--------------------------------|
|                  | Images Containing the Class    | Annotated Masks for the Class  | Images Containing the Class    | Annotated Masks for the Class  |
| Abrasion         | 1,065                         | 5,957                          | 73                             | 409                            |
| Filling          | 695                           | 2,187                          | 48                             | 186                            |
| Crown            | 210                           | 570                            | 9                              | 19                             |
| Caries Class 1   | 341                           | 742                            | 30                             | 62                             |
| Caries Class 2   | 471                           | 1,026                          | 41                             | 73                             |
| Caries Class 3   | 238                           | 474                            | 23                             | 33                             |
| Caries Class 4   | 30                            | 43                             | 3                              | 4                              |
| Caries Class 5   | 328                           | 981                            | 21                             | 81                             |
| Caries Class 6   | 33                            | 52                             | 4                              | 5                              |


## Dataset Statistics

    Number of male patients: 131
    Number of female patients: 162
    Average number of images per patient: 4.5
    Most images have a resolution exceeding 5000 × 3000 (15 megapixels).
    Average number of bounding boxes per image: 9.77

Below is the directory structure of the dataset. It is organized to allow direct training of YOLO models without modifications.

## Directory structure 
```
AlphaDent  
│  
└── yolo_seg_train.yaml – YAML file containing class descriptions  
├── images – contains all dataset images, divided into three folders  
│   ├── train  
│   │   ├── p001_F_32_001.jpg  
│   │   ├── p001_F_32_002.jpg  
│   │   └── … (total xxxx images)  
│   ├── valid  
│   │   ├── p001_M_63_001.jpg  
│   │   ├── p001_M_63_002.jpg  
│   │   └── … (total xxxx images)  
│   └── test  
│       ├── test_000.jpg  
│       ├── test_001.jpg  
│       └── … (121 images in total)  
│  
└── labels – contains annotations in the form of polygons and masks  
    ├── train  
    │   ├── p001_F_32_001_masks  
    │   │   ├── 00_class_2.png  
    │   │   ├── 01_class_5.png  
    │   │   └── … (all N masks for 'p001_F_32_001.jpg' in PNG format)  
    │   ├── p001_F_32_002_masks  
    │   │   ├── 00_class_3.png  
    │   │   ├── 01_class_7.png  
    │   │   └── … (all K masks for 'p001_F_32_002.jpg' in PNG format)  
    │   └── … (mask folders for all training images)  
    │   ├── p001_F_32_001.txt  
    │   ├── p001_F_32_002.txt  
    │   └── … (text annotations for all other training images)  
    │  
    ├── valid  
         ├── p001_M_63_001_masks  
         │   ├── 00_class_4.png  
         │   ├── 01_class_5.png  
         │   └── … (all M masks for 'p001_M_63_001.jpg' in PNG format)  
         ├── p001_M_63_002_masks  
         │   ├── 00_class_3.png  
         │   ├── 01_class_7.png  
         │   └── … (all K masks for 'p001_M_63_002.jpg' in PNG format)  
         └── … (mask folders for all validation images)  
         ├── p001_M_63_001.txt  
         ├── p001_M_63_002.txt  
         └── … (text annotations for all other validation images)  
```

If an image is named `p001_F_32_001.jpg`, the naming convention is as follows:
    `p001` – Patient ID
    `_F_` – Patient gender (can be M for male or F for female)
    `_32_` – Patient age
    `_001` – Image ID for the given patient

For masks, the naming structure is as follows. For a file named `01_class_5.png`:
    `01_` – Mask ID for the given image
    `_5` – Class label (ranging from 0 to 8, inclusive).

If an image has the path `images/train/p001_F_32_001.jpg`, its corresponding annotation is located at `labels/train/p001_F_32_001.txt`.

## Dataset Label Format

* One text file per image: Each image in the dataset has a corresponding text file with the same name and a .txt extension.
* One line per object: Each line in the text file corresponds to one object in the image.
* Object information per line: Each line contains the following information about an object instance:
** Class index of the object: An integer representing the object class (0 to 8, as in Table 1).
** Boundary coordinates of the object: Normalized coordinates (0 to 1) outlining the mask region.
* The format of a single line in the segmentation dataset file is as follows:
    `<class-index> <x1> <y1> <x2> <y2> ... <xn> <yn>`

## Test Data

The test data was prepared later than the training data and annotated separately. This simulates the process of applying trained models to new, unseen data. The test data is not split by patients but consists of individual images. In total, there are 135 test images. The images themselves are publicly available, but their annotations are withheld.

## Example solution

You can find example solution in [this repository on github](https://github.com/ZFTurbo/AlphaDent)