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(polygon1, bbox2, eps=1e-06)
Calculate iofs between bbox1 and bbox2.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
polygon1 |
ndarray
|
Polygon coordinates, (n, 8). |
required |
bbox2 |
ndarray
|
Bounding boxes, (n ,4). |
required |
Source code in ultralytics/data/split_dota.py
ultralytics.data.split_dota.load_yolo_dota(data_root, split='train')
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(im_size, crop_sizes=[1024], gaps=[200], im_rate_thr=0.6, eps=0.01)
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
|
Source code in ultralytics/data/split_dota.py
ultralytics.data.split_dota.get_window_obj(anno, windows, iof_thr=0.7)
Get objects for each window.
Source code in ultralytics/data/split_dota.py
ultralytics.data.split_dota.crop_and_save(anno, windows, window_objs, im_dir, lb_dir)
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 |
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(data_root, save_dir, split='train', crop_sizes=[1024], gaps=[200])
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(data_root, save_dir, crop_size=1024, gap=200, rates=[1.0])
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(data_root, save_dir, crop_size=1024, gap=200, rates=[1.0])
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