Reference for ultralytics/data/split_dota.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/split_dota.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.data.split_dota.bbox_iof
Calculate Intersection over Foreground (IoF) between polygons and bounding boxes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
polygon1 | ndarray | Polygon coordinates, shape (n, 8). | required |
bbox2 | ndarray | Bounding boxes, shape (n, 4). | required |
eps | float | Small value to prevent division by zero. Defaults to 1e-6. | 1e-06 |
Returns:
Type | Description |
---|---|
ndarray | IoF scores, shape (n, 1) or (n, m) if bbox2 is (m, 4). |
Note
Polygon format: [x1, y1, x2, y2, x3, y3, x4, y4]. Bounding box format: [x_min, y_min, x_max, y_max].
Source code in ultralytics/data/split_dota.py
ultralytics.data.split_dota.load_yolo_dota
Load DOTA dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_root | str | Data root. | required |
split | str | The split data set, could be train or val. | 'train' |
Notes
The directory structure assumed for the DOTA dataset: - data_root - images - train - val - labels - train - val
Source code in ultralytics/data/split_dota.py
ultralytics.data.split_dota.get_windows
Get the coordinates of windows.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
im_size | tuple | Original image size, (h, w). | required |
crop_sizes | List(int | Crop size of windows. | (1024) |
gaps | List(int | Gap between crops. | (200) |
im_rate_thr | float | Threshold of windows areas divided by image ares. | 0.6 |
eps | float | Epsilon value for math operations. | 0.01 |
Source code in ultralytics/data/split_dota.py
ultralytics.data.split_dota.get_window_obj
Get objects for each window.
Source code in ultralytics/data/split_dota.py
ultralytics.data.split_dota.crop_and_save
Crop images and save new labels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anno | dict | Annotation dict, including | required |
windows | list | A list of windows coordinates. | required |
window_objs | list | A list of labels inside each window. | required |
im_dir | str | The output directory path of images. | required |
lb_dir | str | The output directory path of labels. | required |
allow_background_images | bool | Whether to include background images without labels. | True |
Notes
The directory structure assumed for the DOTA dataset: - data_root - images - train - val - labels - train - val
Source code in ultralytics/data/split_dota.py
ultralytics.data.split_dota.split_images_and_labels
Split both images and labels.
Notes
The directory structure assumed for the DOTA dataset: - data_root - images - split - labels - split and the output directory structure is: - save_dir - images - split - labels - split
Source code in ultralytics/data/split_dota.py
ultralytics.data.split_dota.split_trainval
Split train and val set of DOTA.
Notes
The directory structure assumed for the DOTA dataset: - data_root - images - train - val - labels - train - val and the output directory structure is: - save_dir - images - train - val - labels - train - val
Source code in ultralytics/data/split_dota.py
ultralytics.data.split_dota.split_test
Split test set of DOTA, labels are not included within this set.
Notes
The directory structure assumed for the DOTA dataset: - data_root - images - test and the output directory structure is: - save_dir - images - test