File size: 24,171 Bytes
92142d8
 
 
 
c7e4671
 
92142d8
 
 
 
a3c6a05
 
 
 
 
bd7fb05
92142d8
 
 
 
 
 
69c544e
92142d8
 
 
69c544e
92142d8
69c544e
92142d8
 
 
 
 
 
 
 
 
 
 
 
 
c789516
 
92142d8
c789516
 
 
 
 
 
 
 
 
 
92142d8
 
bd7fb05
 
c789516
 
 
 
92142d8
 
7bc669c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92142d8
 
 
a3c6a05
92142d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a3c6a05
 
 
 
 
 
 
c5302ea
92142d8
 
69c544e
 
92142d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ee41033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92142d8
 
 
 
 
c7e4671
 
 
 
 
92142d8
 
 
 
bd7fb05
c7e4671
 
bd7fb05
c7e4671
bd7fb05
 
 
92142d8
a3c6a05
92142d8
 
69c544e
 
 
92142d8
69c544e
bd7fb05
 
69c544e
bd7fb05
69c544e
 
 
bd7fb05
69c544e
bd7fb05
69c544e
 
 
bd7fb05
 
 
69c544e
bd7fb05
 
 
 
 
 
 
 
 
 
 
69c544e
bd7fb05
 
 
 
 
 
 
 
 
 
 
69c544e
bd7fb05
 
 
 
 
 
 
 
 
 
 
92142d8
2351499
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7368892
2351499
 
 
 
 
 
 
 
 
304b1ab
 
 
 
 
 
2351499
 
 
92142d8
2351499
 
6cd0c61
2351499
 
cbb2b8a
6cd0c61
 
 
 
 
6cb057a
 
 
 
 
 
613c884
6cd0c61
 
 
 
 
c6f77f9
 
 
6cd0c61
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# Dronescapes dataset

As introduced in our ICCV 2023 workshop paper: [link](https://openaccess.thecvf.com/content/ICCV2023W/LIMIT/papers/Marcu_Self-Supervised_Hypergraphs_for_Learning_Multiple_World_Interpretations_ICCVW_2023_paper.pdf)

![Logo](logo.png)

# 1. Downloading the data

## Option 1. Download the pre-processed dataset from HuggingFace repository

```
git lfs install # Make sure you have git-lfs installed (https://git-lfs.com)
git clone https://huggingface.co/datasets/Meehai/dronescapes
```

Note: the dataset has about 500GB, so it may take a while to clone it.

<details>
<summary> <b> Option 2. Generating the dataset from raw videos and basic labels </b>.</summary>

Recommended if you intend on understanding how the dataset was created or add new videos or representations.

### 1.2.1 Raw videos

Follow the commands in each directory under `raw_data/videos/*/commands.txt` if you want to start from the 4K videos.

If you only want the 540p videos as used in the paper, they are already provided in the `raw_data/videos/*` directories.

### 1.2.2 Semantic segmentation labels (human annotated)

These were human annotated and then propagated using [segprop](https://github.com/vlicaret/segprop).

```bash
cd raw_data/
tar -xzvf segprop_npz_540.tar.gz
```

### 1.2.3 Generate the rest of the representations

We use the [video-representations-extractor](https://gitlab.com/meehai/video-representations-extractor) to generate
the rest of the labels using pre-traing networks or algoritms.

Install it via `pip install video-representations-extractor` (or follow the README over there for docker or local env)

```
VRE_DEVICE=cuda CUDA_VISIBLE_DEVICES=0 vre raw_data/videos/atanasie_DJI_0652_full/atanasie_DJI_0652_full_540p.mp4 -o raw_data/npz_540p/atanasie_DJI_0652_full/ --cfg_path scripts/cfg.yaml --batch_size 3 --n_threads_data_storer 4 --output_dir_exist_mode overwrite 
VRE_DEVICE=cuda CUDA_VISIBLE_DEVICES=1 vre raw_data/videos/barsana_DJI_0500_0501_combined_sliced_2700_14700/barsana_DJI_0500_0501_combined_sliced_2700_14700_540p.mp4 -o raw_data/npz_540p/barsana_DJI_0500_0501_combined_sliced_2700_14700/ --cfg_path scripts/cfg.yaml --batch_size 3 --n_threads_data_storer 4 --output_dir_exist_mode overwrite 
VRE_DEVICE=cuda CUDA_VISIBLE_DEVICES=2 vre raw_data/videos/comana_DJI_0881_full/comana_DJI_0881_full_540p.mp4 -o raw_data/npz_540p/comana_DJI_0881_full/ --cfg_path scripts/cfg.yaml --batch_size 3 --n_threads_data_storer 4 --output_dir_exist_mode overwrite 
VRE_DEVICE=cuda CUDA_VISIBLE_DEVICES=3 vre raw_data/videos/gradistei_DJI_0787_0788_0789_combined_sliced_3510_13110/gradistei_DJI_0787_0788_0789_combined_sliced_3510_13110_540p.mp4 -o raw_data/npz_540p/gradistei_DJI_0787_0788_0789_combined_sliced_3510_13110/ --cfg_path scripts/cfg.yaml --batch_size 3 --n_threads_data_storer 4 --output_dir_exist_mode overwrite 
VRE_DEVICE=cuda CUDA_VISIBLE_DEVICES=4 vre raw_data/videos/herculane_DJI_0021_full/herculane_DJI_0021_full_540p.mp4 -o raw_data/npz_540p/herculane_DJI_0021_full/ --cfg_path scripts/cfg.yaml --batch_size 3 --n_threads_data_storer 4 --output_dir_exist_mode overwrite 
VRE_DEVICE=cuda CUDA_VISIBLE_DEVICES=5 vre raw_data/videos/jupiter_DJI_0703_0704_0705_combined_sliced_10650_21715/jupiter_DJI_0703_0704_0705_combined_sliced_10650_21715_540p.mp4 -o raw_data/npz_540p/jupiter_DJI_0703_0704_0705_combined_sliced_10650_21715/ --cfg_path scripts/cfg.yaml --batch_size 3 --n_threads_data_storer 4 --output_dir_exist_mode overwrite 
VRE_DEVICE=cuda CUDA_VISIBLE_DEVICES=6 vre raw_data/videos/norway_210821_DJI_0015_full/norway_210821_DJI_0015_full_540p.mp4 -o raw_data/npz_540p/norway_210821_DJI_0015_full/ --cfg_path scripts/cfg.yaml --batch_size 3 --n_threads_data_storer 4 --output_dir_exist_mode overwrite 
VRE_DEVICE=cuda CUDA_VISIBLE_DEVICES=7 vre raw_data/videos/olanesti_DJI_0416_full/olanesti_DJI_0416_full_540p.mp4 -o raw_data/npz_540p/olanesti_DJI_0416_full/ --cfg_path scripts/cfg.yaml --batch_size 3 --n_threads_data_storer 4 --output_dir_exist_mode overwrite 
VRE_DEVICE=cuda CUDA_VISIBLE_DEVICES=0 vre raw_data/videos/petrova_DJI_0525_0526_combined_sliced_2850_11850/petrova_DJI_0525_0526_combined_sliced_2850_11850_540p.mp4 -o raw_data/npz_540p/petrova_DJI_0525_0526_combined_sliced_2850_11850/ --cfg_path scripts/cfg.yaml --batch_size 3 --n_threads_data_storer 4 --output_dir_exist_mode overwrite 
VRE_DEVICE=cuda CUDA_VISIBLE_DEVICES=1 vre raw_data/videos/slanic_DJI_0956_0957_combined_sliced_780_9780/slanic_DJI_0956_0957_combined_sliced_780_9780_540p.mp4 -o raw_data/npz_540p/slanic_DJI_0956_0957_combined_sliced_780_9780/ --cfg_path scripts/cfg.yaml --batch_size 3 --n_threads_data_storer 4 --output_dir_exist_mode overwrite 
```

Note: `depth_sfm`, `normals_sfm` and `depth_ufo` are not available in VRE. Contact us for more info about them.

Note: Add `--representations "rgb" "opticalflow_rife" "depth_dpt" "edges_dexined" "semantic_mask2former_swin_mapillary" "softseg_gb"` to control if you only want a subset of the representations.

Note: Some batch sizes are overwritten in the config itself.

### 1.2.4 Convert Mask2Former from Mapillary classes to segprop8 classes

Since we are using pre-trained Mask2Former which has either mapillary or COCO panoptic classes, we need to convert them to dronescapes-compatible (8) classes.

To do this, we use the `scripts/convert_m2f_to_dronescapes.py` script:
```
python scripts/convert_m2f_to_dronescapes.py in_dir out_dir mapillary/coco [--overwrite]
```

```
python scripts/convert_m2f_to_dronescapes.py raw_data/npz_540p/atanasie_DJI_0652_full/semantic_mask2former_swin_mapillary raw_data/npz_540p/atanasie_DJI_0652_full/semantic_mask2former_swin_mapillary_converted mapillary
python scripts/convert_m2f_to_dronescapes.py raw_data/npz_540p/barsana_DJI_0500_0501_combined_sliced_2700_14700/semantic_mask2former_swin_mapillary raw_data/npz_540p/barsana_DJI_0500_0501_combined_sliced_2700_14700/semantic_mask2former_swin_mapillary_converted mapillary
python scripts/convert_m2f_to_dronescapes.py raw_data/npz_540p/comana_DJI_0881_full/semantic_mask2former_swin_mapillary raw_data/npz_540p/comana_DJI_0881_full/semantic_mask2former_swin_mapillary_converted mapillary
python scripts/convert_m2f_to_dronescapes.py raw_data/npz_540p/gradistei_DJI_0787_0788_0789_combined_sliced_3510_13110/semantic_mask2former_swin_mapillary raw_data/npz_540p/gradistei_DJI_0787_0788_0789_combined_sliced_3510_13110/semantic_mask2former_swin_mapillary_converted mapillary
python scripts/convert_m2f_to_dronescapes.py raw_data/npz_540p/herculane_DJI_0021_full/semantic_mask2former_swin_mapillary raw_data/npz_540p/herculane_DJI_0021_full/semantic_mask2former_swin_mapillary_converted mapillary
python scripts/convert_m2f_to_dronescapes.py raw_data/npz_540p/jupiter_DJI_0703_0704_0705_combined_sliced_10650_21715/semantic_mask2former_swin_mapillary raw_data/npz_540p/jupiter_DJI_0703_0704_0705_combined_sliced_10650_21715/semantic_mask2former_swin_mapillary_converted mapillary
python scripts/convert_m2f_to_dronescapes.py raw_data/npz_540p/norway_210821_DJI_0015_full/semantic_mask2former_swin_mapillary raw_data/npz_540p/norway_210821_DJI_0015_full/semantic_mask2former_swin_mapillary_converted mapillary
python scripts/convert_m2f_to_dronescapes.py raw_data/npz_540p/olanesti_DJI_0416_full/semantic_mask2former_swin_mapillary raw_data/npz_540p/olanesti_DJI_0416_full/semantic_mask2former_swin_mapillary_converted mapillary
python scripts/convert_m2f_to_dronescapes.py raw_data/npz_540p/petrova_DJI_0525_0526_combined_sliced_2850_11850/semantic_mask2former_swin_mapillary raw_data/npz_540p/petrova_DJI_0525_0526_combined_sliced_2850_11850/semantic_mask2former_swin_mapillary_converted mapillary
python scripts/convert_m2f_to_dronescapes.py raw_data/npz_540p/slanic_DJI_0956_0957_combined_sliced_780_9780/semantic_mask2former_swin_mapillary raw_data/npz_540p/slanic_DJI_0956_0957_combined_sliced_780_9780/semantic_mask2former_swin_mapillary_converted mapillary
```

### 1.2.5 Check counts for consistency

Run: `bash scripts/count_npz.sh raw_data/npz_540p`. At this point it should return:
| scene     |   rgb |   depth_dpt |   depth_sfm_manual20.. |   edges_dexined |   normals_sfm_manual.. |   opticalflow_rife |   semantic_mask2form.. |   semantic_segprop8 |
|:----------|------:|------------:|-----------------------:|----------------:|-----------------------:|-------------------:|-----------------------:|--------------------:|
| atanasie  |  9021 |        9021 |                   9020 |            9021 |                   9020 |               9021 |                   9021 |                9001 |
| barsana   | 12001 |       12001 |                  12001 |           12001 |                  12001 |              12000 |                  12001 |                1573 |
| comana    |  9022 |        9022 |                      0 |            9022 |                      0 |               9022 |                   9022 |                1210 |
| gradistei |  9601 |        9601 |                   9600 |            9601 |                   9600 |               9600 |                   9601 |                1210 |
| herculane |  9022 |        9022 |                   9021 |            9022 |                   9021 |               9022 |                   9022 |                1210 |
| jupiter   | 11066 |       11066 |                  11065 |           11066 |                  11065 |              11066 |                  11066 |                1452 |
| norway    |  2983 |        2983 |                      0 |            2983 |                      0 |               2983 |                   2983 |                2941 |
| olanesti  |  9022 |        9022 |                   9021 |            9022 |                   9021 |               9022 |                   9022 |                1210 |
| petrova   |  9001 |        9001 |                   9001 |            9001 |                   9001 |               9000 |                   9001 |                1210 |
| slanic    |  9001 |        9001 |                   9001 |            9001 |                   9001 |               9000 |                   9001 |                9001 |

### 1.2.6. Split intro train, validation, semisupervised and train

We include 8 splits: 4 using only GT annotated semantic data and 4 using all available data (i.e. segproped between
annotated data). The indexes are taken from `txt_files/*`, i.e. `txt_files/manually_adnotated_files/test_files_116.txt`
refers to the fact that the (unseen at train time) test set (norway + petrova + barsana) contains 116 manually
annotated semantic files. We include all representations from above, not just semantic for all possible splits.
Adding new representations is as simple as running VRE on the 540p mp4 file

```
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file txt_files/annotated_and_segprop/train_files_11664.txt -o data/train_set --overwrite
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file txt_files/annotated_and_segprop/val_files_605.txt -o data/validation_set --overwrite
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file txt_files/annotated_and_segprop/semisup_files_11299.txt -o data/semisupervised_set --overwrite
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file txt_files/annotated_and_segprop/test_files_5603.txt -o data/test_set --overwrite
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file txt_files/manually_annotated_files/train_files_218.txt -o data/train_set_annotated_only --overwrite
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file txt_files/manually_annotated_files/val_files_15.txt -o data/validation_set_annotated_only --overwrite
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file txt_files/manually_annotated_files/semisup_files_207.txt -o data/semisupervised_set_annotated_nly --overwrite
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file txt_files/manually_annotated_files/test_files_116.txt -o data/test_set_annotated_only --overwrite
```

Note: `add --copy_files` if you want to make copies instead of using symlinks.

Upon calling this, you should be able to see something like this:
```
user> ls data/*
data/semisupervised_set:
depth_dpt               edges_dexined             opticalflow_rife  semantic_mask2former_swin_mapillary_converted
depth_sfm_manual202204  normals_sfm_manual202204  rgb               semantic_segprop8

data/semisupervised_set_annotated_nly:
depth_dpt               edges_dexined             opticalflow_rife  semantic_mask2former_swin_mapillary_converted
depth_sfm_manual202204  normals_sfm_manual202204  rgb               semantic_segprop8

data/test_set:
depth_dpt               edges_dexined             opticalflow_rife  semantic_mask2former_swin_mapillary_converted
depth_sfm_manual202204  normals_sfm_manual202204  rgb               semantic_segprop8

data/test_set_annotated_nly:
depth_dpt               edges_dexined             opticalflow_rife  semantic_mask2former_swin_mapillary_converted
depth_sfm_manual202204  normals_sfm_manual202204  rgb               semantic_segprop8

data/train_set:
depth_dpt               edges_dexined             opticalflow_rife  semantic_mask2former_swin_mapillary_converted
depth_sfm_manual202204  normals_sfm_manual202204  rgb               semantic_segprop8

data/train_set_annotated_only:
depth_dpt               edges_dexined             opticalflow_rife  semantic_mask2former_swin_mapillary_converted
depth_sfm_manual202204  normals_sfm_manual202204  rgb               semantic_segprop8

data/validation_set:
depth_dpt               edges_dexined             opticalflow_rife  semantic_mask2former_swin_mapillary_converted
depth_sfm_manual202204  normals_sfm_manual202204  rgb               semantic_segprop8

data/validation_set_annotated_only:
depth_dpt               edges_dexined             opticalflow_rife  semantic_mask2former_swin_mapillary_converted
depth_sfm_manual202204  normals_sfm_manual202204  rgb               semantic_segprop8
```

### 1.2.7 Convert Camera Normals to World Normals

This is an optional step, but for some use cases, it may be better to use world normals instead of camera normals, which
are provided by default in `normals_sfm_manual202204`. To convert, we provide camera rotation matrices in
`raw_data/camera_matrics.tar.gz` for all 8 scenes that also have SfM.

In order to convert, use this function (for each npz file):

```
def convert_camera_to_world(normals: np.ndarray, rotation_matrix: np.ndarray) -> np.ndarray:
  normals = (normals.copy() - 0.5) * 2 # [-1:1] -> [0:1]
  camera_normals = camera_normals @ np.linalg.inv(rotation_matrix)
  camera_normals = (camera_normals / 2) + 0.5 # [0:1] => [-1:1]
  return np.clip(camera_normals, 0.0, 1.0)
```

</details>

## 2. Using the data

As per the split from the paper:

<details>
<summary> Split </summary>
<img src="split.png">
</details>

The data is in `data/*` (see the `ls` call above, it should match even if you download from huggingface).

## 2.1 Using the provided viewer

![Collage](collage.png)

The simplest way to explore the data is to use the [provided notebook](scripts/dronescapes_viewer.ipynb). Upon running
it, you should get a collage with all the default tasks, like the picture at the top.

For a CLI-only method, you can use the provided reader as well:

```
python scripts/dronescapes_viewer.py data/test_set_annotated_only/ # or any of the 8 directories in data/
```

<details>
<summary> Expected output </summary>

```
[MultiTaskDataset]
 - Path: '/export/home/proiecte/aux/mihai_cristian.pirvu/datasets/dronescapes/data/test_set_annotated_only'
 - Tasks (11): [DepthRepresentation(depth_dpt), DepthRepresentation(depth_sfm_manual202204), DepthRepresentation(depth_ufo), ColorRepresentation(edges_dexined), EdgesRepresentation(edges_gb), NpzRepresentation(normals_sfm_manual202204), OpticalFlowRepresentation(opticalflow_rife), ColorRepresentation(rgb), SemanticRepresentation(semantic_mask2former_swin_mapillary_converted), SemanticRepresentation(semantic_segprop8), ColorRepresentation(softseg_gb)]
 - Length: 116
 - Handle missing data mode: 'fill_none'
== Shapes ==
{'depth_dpt': torch.Size([540, 960]),
 'depth_sfm_manual202204': torch.Size([540, 960]),
 'depth_ufo': torch.Size([540, 960, 1]),
 'edges_dexined': torch.Size([540, 960]),
 'edges_gb': torch.Size([540, 960, 1]),
 'normals_sfm_manual202204': torch.Size([540, 960, 3]),
 'opticalflow_rife': torch.Size([540, 960, 2]),
 'rgb': torch.Size([540, 960, 3]),
 'semantic_mask2former_swin_mapillary_converted': torch.Size([540, 960, 8]),
 'semantic_segprop8': torch.Size([540, 960, 8]),
 'softseg_gb': torch.Size([540, 960, 3])}
== Random loaded item ==
{'depth_dpt': tensor[540, 960] n=518400 (2.0Mb) x∈[0.043, 1.000] μ=0.341 σ=0.418,
 'depth_sfm_manual202204': None,
 'depth_ufo': tensor[540, 960, 1] n=518400 (2.0Mb) x∈[0.115, 0.588] μ=0.297 σ=0.138,
 'edges_dexined': tensor[540, 960] n=518400 (2.0Mb) x∈[0.000, 0.004] μ=0.003 σ=0.001,
 'edges_gb': tensor[540, 960, 1] n=518400 (2.0Mb) x∈[0., 1.000] μ=0.063 σ=0.100,
 'normals_sfm_manual202204': None,
 'opticalflow_rife': tensor[540, 960, 2] n=1036800 (4.0Mb) x∈[-0.004, 0.005] μ=0.000 σ=0.000,
 'rgb': tensor[540, 960, 3] n=1555200 (5.9Mb) x∈[0., 1.000] μ=0.392 σ=0.238,
 'semantic_mask2former_swin_mapillary_converted': tensor[540, 960, 8] n=4147200 (16Mb) x∈[0., 1.000] μ=0.125 σ=0.331,
 'semantic_segprop8': tensor[540, 960, 8] n=4147200 (16Mb) x∈[0., 1.000] μ=0.125 σ=0.331,
 'softseg_gb': tensor[540, 960, 3] n=1555200 (5.9Mb) x∈[0., 0.004] μ=0.002 σ=0.001}
== Random loaded batch ==
{'depth_dpt': tensor[5, 540, 960] n=2592000 (9.9Mb) x∈[0.043, 1.000] μ=0.340 σ=0.417,
 'depth_sfm_manual202204': tensor[5, 540, 960] n=2592000 (9.9Mb) NaN!,
 'depth_ufo': tensor[5, 540, 960, 1] n=2592000 (9.9Mb) x∈[0.115, 0.588] μ=0.296 σ=0.137,
 'edges_dexined': tensor[5, 540, 960] n=2592000 (9.9Mb) x∈[0.000, 0.004] μ=0.003 σ=0.001,
 'edges_gb': tensor[5, 540, 960, 1] n=2592000 (9.9Mb) x∈[0., 1.000] μ=0.063 σ=0.102,
 'normals_sfm_manual202204': tensor[5, 540, 960, 3] n=7776000 (30Mb) NaN!,
 'opticalflow_rife': tensor[5, 540, 960, 2] n=5184000 (20Mb) x∈[-0.004, 0.006] μ=0.000 σ=0.000,
 'rgb': tensor[5, 540, 960, 3] n=7776000 (30Mb) x∈[0., 1.000] μ=0.393 σ=0.238,
 'semantic_mask2former_swin_mapillary_converted': tensor[5, 540, 960, 8] n=20736000 (79Mb) x∈[0., 1.000] μ=0.125 σ=0.331,
 'semantic_segprop8': tensor[5, 540, 960, 8] n=20736000 (79Mb) x∈[0., 1.000] μ=0.125 σ=0.331,
 'softseg_gb': tensor[5, 540, 960, 3] n=7776000 (30Mb) x∈[0., 0.004] μ=0.002 σ=0.001}
== Random loaded batch using torch DataLoader ==
{'depth_dpt': tensor[5, 540, 960] n=2592000 (9.9Mb) x∈[0.025, 1.000] μ=0.216 σ=0.343,
 'depth_sfm_manual202204': tensor[5, 540, 960] n=2592000 (9.9Mb) x∈[0., 1.000] μ=0.562 σ=0.335 NaN!,
 'depth_ufo': tensor[5, 540, 960, 1] n=2592000 (9.9Mb) x∈[0.100, 0.580] μ=0.290 σ=0.128,
 'edges_dexined': tensor[5, 540, 960] n=2592000 (9.9Mb) x∈[0.000, 0.004] μ=0.003 σ=0.001,
 'edges_gb': tensor[5, 540, 960, 1] n=2592000 (9.9Mb) x∈[0., 1.000] μ=0.079 σ=0.116,
 'normals_sfm_manual202204': tensor[5, 540, 960, 3] n=7776000 (30Mb) x∈[0.000, 1.000] μ=0.552 σ=0.253 NaN!,
 'opticalflow_rife': tensor[5, 540, 960, 2] n=5184000 (20Mb) x∈[-0.013, 0.016] μ=0.000 σ=0.004,
 'rgb': tensor[5, 540, 960, 3] n=7776000 (30Mb) x∈[0., 1.000] μ=0.338 σ=0.237,
 'semantic_mask2former_swin_mapillary_converted': tensor[5, 540, 960, 8] n=20736000 (79Mb) x∈[0., 1.000] μ=0.125 σ=0.331,
 'semantic_segprop8': tensor[5, 540, 960, 8] n=20736000 (79Mb) x∈[0., 1.000] μ=0.125 σ=0.331,
 'softseg_gb': tensor[5, 540, 960, 3] n=7776000 (30Mb) x∈[0., 0.004] μ=0.002 σ=0.001}
```
</details>

## 3. Evaluation for semantic segmentation

We evaluate in the paper on the 3 test scenes (unsees at train) as well as the semi-supervised scenes (seen, but
different split) against the human annotated frames. The general evaluation script is in
`scripts/evaluate_semantic_segmentation.py`.

General usage is:
```
python scripts/evaluate_semantic_segmentation.py y_dir gt_dir -o results.csv --classes C1 C2 .. Cn
[--class_weights W1 W2 ... Wn] [--scenes s1 s2 ... sm]
```

<details>
<summary> Script explanation </summary>
The script is a bit convoluted, so let's break it into parts:

- `y_dir` and `gt_dir` Two directories of .npz files in the same format as the dataset (y_dir/1.npz, gt_dir/55.npz etc.)
- `classes` A list of classes in the order that they appear in the predictions and gt files
- `class_weights` (optional, but used in paper) How much to weigh each class. In the paper we compute these weights as
the number of pixels in all the dataset (train/val/semisup/test) for each of the 8 classes resulting in the numbers
below.
- `scenes` if the `y_dir` and `gt_dir` contains multiple scenes that you want to evaluate separately, the script allows
you to pass the prefix of all the scenes. For example, in `data/test_set_annotated_only/semantic_segprop8/` there are
actually 3 scenes in the npz files and in the paper, we evaluate each scene independently. Even though the script
outputs one csv file with predictions for each npz file, the scenes are used for proper aggregation at scene level.
</details>

<details>
<summary> Reproducing paper results for Mask2Former </summary>

```
python scripts/evaluate_semantic_segmentation.py \
  data/test_set_annotated_only/semantic_mask2former_swin_mapillary_converted/ \
  data/test_set_annotated_only/semantic_segprop8/ \
  -o results.csv \
  --classes land forest residential road little-objects water sky hill \
  --class_weights 0.28172092 0.30589653 0.13341699 0.05937348 0.00474491 0.05987466 0.08660721 0.06836531 \
  --scenes barsana_DJI_0500_0501_combined_sliced_2700_14700 comana_DJI_0881_full norway_210821_DJI_0015_full
```

Should output:
```
scene                                             iou      f1                                                           
barsana_DJI_0500_0501_combined_sliced_2700_14700  63.371  75.338
comana_DJI_0881_full                              60.559  73.779
norway_210821_DJI_0015_full                       37.986  45.939
mean                                              53.972  65.019

```

Not providing `--scenes` will make an average across all 3 scenes (not average after each metric individually):

```
          iou      f1
scene
all    60.456  73.261
```
</details>

### 3.1 Official benchmark

#### IoU

| method | #paramters |  average | barsana_DJI_0500_0501_combined_sliced_2700_14700 | comana_DJI_0881_full |  norway_210821_DJI_0015_full |
|:-|:-|:-|:-|:-|:-|
| [Mask2Former](https://openaccess.thecvf.com/content/CVPR2022/papers/Cheng_Masked-Attention_Mask_Transformer_for_Universal_Image_Segmentation_CVPR_2022_paper.pdf) | 216M | 53.97 | 63.37 | 60.55 | 37.98 |
| [NGC(LR)](https://openaccess.thecvf.com/content/ICCV2023W/LIMIT/papers/Marcu_Self-Supervised_Hypergraphs_for_Learning_Multiple_World_Interpretations_ICCVW_2023_paper.pdf) | 32M | 40.75  | 46.51 | 45.59 | 30.17 |
| [CShift](https://www.bmvc2021-virtualconference.com/assets/papers/0455.pdf)[^1] | n/a | 39.67 | 46.27 | 43.67 | 29.09 |
| [NGC](https://cdn.aaai.org/ojs/16283/16283-13-19777-1-2-20210518.pdf)[^1] | 32M | 35.32 | 44.34 | 38.99 | 22.63 |
| [SafeUAV](https://openaccess.thecvf.com/content_ECCVW_2018/papers/11130/Marcu_SafeUAV_Learning_to_estimate_depth_and_safe_landing_areas_for_ECCVW_2018_paper.pdf)[^1] | 1.1M | 32.79 | n/a | n/a | n/a |

[^1]: reported in the [Dronescapes paper](https://openaccess.thecvf.com/content/ICCV2023W/LIMIT/papers/Marcu_Self-Supervised_Hypergraphs_for_Learning_Multiple_World_Interpretations_ICCVW_2023_paper.pdf).

#### F1 Score

| method | #paramters |  average | barsana_DJI_0500_0501_combined_sliced_2700_14700 | comana_DJI_0881_full |  norway_210821_DJI_0015_full |
|:-|:-|:-|:-|:-|:-|
| [Mask2Former](https://openaccess.thecvf.com/content/CVPR2022/papers/Cheng_Masked-Attention_Mask_Transformer_for_Universal_Image_Segmentation_CVPR_2022_paper.pdf) | 216M | 65.01 | 75.33 | 73.77 | 45.93 |