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 with shape (n, 8). |
required |
bbox2
|
ndarray
|
Bounding boxes with shape (n, 4). |
required |
eps
|
float
|
Small value to prevent division by zero. |
1e-06
|
Returns:
Type | Description |
---|---|
ndarray
|
IoF scores with shape (n, 1) or (n, m) if bbox2 is (m, 4). |
Notes
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 directory. |
required |
split
|
str
|
The split data set, could be |
'train'
|
Returns:
Type | Description |
---|---|
List[Dict]
|
List of annotation dictionaries containing image information. |
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 areas. |
0.6
|
eps
|
float
|
Epsilon value for math operations. |
0.01
|
Returns:
Type | Description |
---|---|
ndarray
|
Array of window coordinates with shape (n, 4) where each row is [x_start, y_start, x_stop, y_stop]. |
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
|
ndarray
|
Array of windows coordinates with shape (n, 4). |
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_root
|
str
|
Root directory of the dataset. |
required |
save_dir
|
str
|
Directory to save the split dataset. |
required |
split
|
str
|
The split data set, could be |
'train'
|
crop_sizes
|
tuple
|
Tuple of crop sizes. |
(1024,)
|
gaps
|
tuple
|
Tuple of gaps between crops. |
(200,)
|
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_root
|
str
|
Root directory of the dataset. |
required |
save_dir
|
str
|
Directory to save the split dataset. |
required |
crop_size
|
int
|
Base crop size. |
1024
|
gap
|
int
|
Base gap between crops. |
200
|
rates
|
tuple
|
Scaling rates for crop_size and gap. |
(1.0,)
|
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_root
|
str
|
Root directory of the dataset. |
required |
save_dir
|
str
|
Directory to save the split dataset. |
required |
crop_size
|
int
|
Base crop size. |
1024
|
gap
|
int
|
Base gap between crops. |
200
|
rates
|
tuple
|
Scaling rates for crop_size and gap. |
(1.0,)
|
Notes
The directory structure assumed for the DOTA dataset: - data_root - images - test and the output directory structure is: - save_dir - images - test