File size: 7,552 Bytes
5c43e5b
 
 
 
 
 
 
 
 
 
 
 
028d86b
 
4cc33ef
 
 
 
 
 
5c43e5b
8975f8f
0899b9a
8975f8f
 
 
 
 
 
 
 
 
089ff9a
8975f8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
089ff9a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8975f8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
---
license: other
task_categories:
- object-detection
tags:
- finedet
configs:
- config_name: v1.0
  default: true
  data_files:
  - split: train
    path: v1.0/train-*.parquet
  - split: validation
    path: v1.0/validation-*.parquet
- config_name: v1.5
  data_files:
  - split: train
    path: v1.5/train-*.parquet
  - split: validation
    path: v1.5/validation-*.parquet
---

# FineDOTA — DOTA v1.0 / v1.5 in the unified detection format

Source: the Ultralytics-hosted DOTA release archives (github.com/ultralytics/assets, DOTAv1 / DOTAv1.5 / DOTAv2), which bundle the original DOTA-format annotations (labels/*_original) used for this conversion. Images are the original resolution, re-encoded by upstream from PNG to JPEG.

Converted by the finedet project into a unified, AutoTrain-compatible layout:
`image` / `width` / `height` / `objects{bbox, category}` with COCO-format
`[x, y, w, h]` boxes in absolute pixels. Boxes are clipped to the image and
empty boxes dropped; category ids are densified per the category tables
below.

This repository hosts one config per source release: `v1.0`, `v1.5` (default: `v1.0`). Load one with `load_dataset("finedet/dota", "<config>")`.

## Box format

`objects.bbox` follows the COCO convention: `[x, y, w, h]` in absolute pixels,
origin at the image's top-left corner.

<img src="assets/bbox_format.png" width="480"/>

## Schema notes

Each object carries three box representations. Which is original and which is derived:

- `objects.polygon` — the **original** annotation: the raw DOTA 8-point oriented box `[x1, y1, x2, y2, x3, y3, x4, y4]` in absolute pixels, vertex order exactly as in the source label file (DOTA annotates the four vertices in clockwise order, starting from a category-specific starting vertex), **not clipped** to the image bounds.
- `objects.bbox` — **derived**: the axis-aligned hull of the polygon (`[min x, min y, max x - min x, max y - min y]` over the 4 points), then clipped to the image; an object whose clipped hull has zero width or height is dropped entirely (polygon and obb included).
- `objects.obb` — **derived**: `[cx, cy, w, h, theta]`, the minimum-area rectangle over the 4 polygon points (`cv2.minAreaRect`), normalized to the long-edge convention: `w >= h`, `theta` = angle of the `w` edge against the +x axis, in radians within `[-pi/2, pi/2)` (for squares the two equivalent angles are not disambiguated). Not clipped.
- `objects.difficult` — the original DOTA difficult flag (kept, not filtered).

The sample galleries below draw the derived axis-aligned `bbox` hulls.

## License

Original dataset: DOTA (all releases share the same terms). Official terms: 'All images and their associated annotations in DOTA can be used for academic purposes only, but any commercial use is prohibited.' The same terms apply to the redistributed archives used as the source here. Imagery originates from Google Earth, CycloMedia B.V., and the GF-2 / JL-1 satellites (panchromatic), and remains subject to the respective providers' terms — the Google Earth terms of use in particular. Academic use only.

## Config `v1.0`

### Example images

Boxes are colored by category: near-transparent fill, opaque outline.

<table>
<tr><td><img src="assets/v1.0/sample_0.jpg" width="360"/></td><td><img src="assets/v1.0/sample_1.jpg" width="360"/></td></tr>
<tr><td><img src="assets/v1.0/sample_2.jpg" width="360"/></td><td><img src="assets/v1.0/sample_3.jpg" width="360"/></td></tr>
</table>

### Conversion notes

Converted from the Ultralytics DOTA v1.0 archive using the bundled original-format annotations. 15 categories; train 1,411 / validation 458 images. difficult boxes are kept and flagged via objects.difficult. No tiling — original image sizes are preserved (up to ~20,000 px per side); image files are upstream JPEG re-encodes of the official PNGs. The test / test-dev / test-challenge splits are excluded (annotations not public).

### Splits

- train: 1411 images
- validation: 458 images

### Categories

| id | name |
|---|---|
| 0 | plane |
| 1 | ship |
| 2 | storage-tank |
| 3 | baseball-diamond |
| 4 | tennis-court |
| 5 | basketball-court |
| 6 | ground-track-field |
| 7 | harbor |
| 8 | bridge |
| 9 | large-vehicle |
| 10 | small-vehicle |
| 11 | helicopter |
| 12 | roundabout |
| 13 | soccer-ball-field |
| 14 | swimming-pool |

## Config `v1.5`

### Example images

Boxes are colored by category: near-transparent fill, opaque outline.

<table>
<tr><td><img src="assets/v1.5/sample_0.jpg" width="360"/></td><td><img src="assets/v1.5/sample_1.jpg" width="360"/></td></tr>
<tr><td><img src="assets/v1.5/sample_2.jpg" width="360"/></td><td><img src="assets/v1.5/sample_3.jpg" width="360"/></td></tr>
</table>

### Conversion notes

Converted from the Ultralytics DOTA v1.5 archive using the bundled original-format annotations. 16 categories (adds container-crane); the same images as v1.0, relabeled — including very small instances. difficult boxes are kept and flagged via objects.difficult. No tiling — original image sizes are preserved (up to ~20,000 px per side); image files are upstream JPEG re-encodes of the official PNGs. The test / test-dev / test-challenge splits are excluded (annotations not public).

### Splits

- train: 1411 images
- validation: 458 images

### Categories

| id | name |
|---|---|
| 0 | plane |
| 1 | ship |
| 2 | storage-tank |
| 3 | baseball-diamond |
| 4 | tennis-court |
| 5 | basketball-court |
| 6 | ground-track-field |
| 7 | harbor |
| 8 | bridge |
| 9 | large-vehicle |
| 10 | small-vehicle |
| 11 | helicopter |
| 12 | roundabout |
| 13 | soccer-ball-field |
| 14 | swimming-pool |
| 15 | container-crane |

## Training with transformers

The boxes are already in the absolute-pixel COCO `[x, y, w, h]` format that
`AutoImageProcessor` expects, so fine-tuning a detector needs no bbox
conversion:

```python
import torch
from datasets import load_dataset
from transformers import (AutoImageProcessor, AutoModelForObjectDetection,
                          Trainer, TrainingArguments)

ds = load_dataset("finedet/dota", "v1.0")
obj_feat = ds["train"].features["objects"]
if hasattr(obj_feat, "feature"):
    obj_feat = obj_feat.feature
cat_feat = obj_feat["category"]
names = (cat_feat.feature if hasattr(cat_feat, "feature") else cat_feat).names

checkpoint = "facebook/detr-resnet-50"
processor = AutoImageProcessor.from_pretrained(checkpoint)
model = AutoModelForObjectDetection.from_pretrained(
    checkpoint,
    id2label=dict(enumerate(names)),
    label2id={n: i for i, n in enumerate(names)},
    ignore_mismatched_sizes=True,
)


def transform(batch):
    images = [img.convert("RGB") for img in batch["image"]]
    annotations = [
        {"image_id": i,
         "annotations": [
             {"bbox": box, "category_id": cat, "area": box[2] * box[3], "iscrowd": 0}
             for box, cat in zip(objs["bbox"], objs["category"])
         ]}
        for i, objs in enumerate(batch["objects"])
    ]
    return processor(images=images, annotations=annotations, return_tensors="pt")


def collate(batch):
    return {"pixel_values": torch.stack([x["pixel_values"] for x in batch]),
            "labels": [x["labels"] for x in batch]}


trainer = Trainer(
    model=model,
    args=TrainingArguments(output_dir="out", per_device_train_batch_size=4,
                           num_train_epochs=10, learning_rate=1e-5,
                           remove_unused_columns=False),
    train_dataset=ds["train"].with_transform(transform),
    data_collator=collate,
)
trainer.train()
```