little fixes and added depth_ufo plus edges_gb
Browse files- dronescapes_reader/__init__.py +3 -1
- dronescapes_reader/dronescapes_representations.py +12 -5
- dronescapes_reader/multitask_dataset.py +1 -1
- scripts/collage.png +3 -0
- scripts/collage2.png +3 -0
- scripts/collage3.png +3 -0
- scripts/dronescapes_viewer.ipynb +0 -0
- scripts/lel.txt +8 -0
dronescapes_reader/__init__.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
"""init file"""
|
2 |
from .multitask_dataset import MultiTaskDataset, NpzRepresentation
|
3 |
from .dronescapes_representations import DepthRepresentation, OpticalFlowRepresentation, SemanticRepresentation, \
|
4 |
-
ColorRepresentation
|
5 |
|
6 |
_color_map = [[0, 255, 0], [0, 127, 0], [255, 255, 0], [255, 255, 255],
|
7 |
[255, 0, 0], [0, 0, 255], [0, 255, 255], [127, 127, 63]]
|
@@ -11,8 +11,10 @@ dronescapes_task_types = { # some pre-baked representations
|
|
11 |
"edges_dexined": ColorRepresentation("edges_dexined"),
|
12 |
"depth_dpt": DepthRepresentation("depth_dpt", min_depth=0, max_depth=0.999),
|
13 |
"depth_sfm_manual202204": DepthRepresentation("depth_sfm_manual202204", min_depth=0, max_depth=300),
|
|
|
14 |
"opticalflow_rife": OpticalFlowRepresentation,
|
15 |
"semantic_segprop8": SemanticRepresentation("semantic_segprop8", classes=8, color_map=_color_map),
|
16 |
_m2f_name: SemanticRepresentation(_m2f_name, classes=8, color_map=_color_map),
|
17 |
"softseg_gb": ColorRepresentation("softseg_gb"),
|
|
|
18 |
}
|
|
|
1 |
"""init file"""
|
2 |
from .multitask_dataset import MultiTaskDataset, NpzRepresentation
|
3 |
from .dronescapes_representations import DepthRepresentation, OpticalFlowRepresentation, SemanticRepresentation, \
|
4 |
+
ColorRepresentation, EdgesRepresentation
|
5 |
|
6 |
_color_map = [[0, 255, 0], [0, 127, 0], [255, 255, 0], [255, 255, 255],
|
7 |
[255, 0, 0], [0, 0, 255], [0, 255, 255], [127, 127, 63]]
|
|
|
11 |
"edges_dexined": ColorRepresentation("edges_dexined"),
|
12 |
"depth_dpt": DepthRepresentation("depth_dpt", min_depth=0, max_depth=0.999),
|
13 |
"depth_sfm_manual202204": DepthRepresentation("depth_sfm_manual202204", min_depth=0, max_depth=300),
|
14 |
+
"depth_ufo": DepthRepresentation("depth_ufo", min_depth=0, max_depth=1),
|
15 |
"opticalflow_rife": OpticalFlowRepresentation,
|
16 |
"semantic_segprop8": SemanticRepresentation("semantic_segprop8", classes=8, color_map=_color_map),
|
17 |
_m2f_name: SemanticRepresentation(_m2f_name, classes=8, color_map=_color_map),
|
18 |
"softseg_gb": ColorRepresentation("softseg_gb"),
|
19 |
+
"edges_gb": EdgesRepresentation("edges_gb"),
|
20 |
}
|
dronescapes_reader/dronescapes_representations.py
CHANGED
@@ -17,6 +17,15 @@ class ColorRepresentation(NpzRepresentation):
|
|
17 |
def save_to_disk(self, data: tr.Tensor, path: Path):
|
18 |
return super().save_to_disk((data * 255).byte(), path)
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
class DepthRepresentation(NpzRepresentation):
|
21 |
"""DepthRepresentation. Implements depth task-specific stuff, like hotmap."""
|
22 |
def __init__(self, *args, min_depth: float, max_depth: float, **kwargs):
|
@@ -27,11 +36,9 @@ class DepthRepresentation(NpzRepresentation):
|
|
27 |
|
28 |
@overrides
|
29 |
def plot_fn(self, x: tr.Tensor) -> np.ndarray:
|
30 |
-
x = x.detach().cpu().numpy()
|
31 |
-
|
32 |
-
y
|
33 |
-
y = np.uint8(y * 255)
|
34 |
-
return y
|
35 |
|
36 |
def load_from_disk(self, path: Path) -> tr.Tensor:
|
37 |
res = super().load_from_disk(path)
|
|
|
17 |
def save_to_disk(self, data: tr.Tensor, path: Path):
|
18 |
return super().save_to_disk((data * 255).byte(), path)
|
19 |
|
20 |
+
class EdgesRepresentation(NpzRepresentation):
|
21 |
+
def load_from_disk(self, path: Path) -> tr.Tensor:
|
22 |
+
res = super().load_from_disk(path).float()
|
23 |
+
assert len(res.shape) == 3 and res.shape[-1] == 1
|
24 |
+
return res
|
25 |
+
|
26 |
+
def plot_fn(self, x: tr.Tensor) -> np.ndarray:
|
27 |
+
return (x.repeat(1, 1, 3) * 255).cpu().numpy().astype(np.uint8)
|
28 |
+
|
29 |
class DepthRepresentation(NpzRepresentation):
|
30 |
"""DepthRepresentation. Implements depth task-specific stuff, like hotmap."""
|
31 |
def __init__(self, *args, min_depth: float, max_depth: float, **kwargs):
|
|
|
36 |
|
37 |
@overrides
|
38 |
def plot_fn(self, x: tr.Tensor) -> np.ndarray:
|
39 |
+
x = x.detach().clip(0, 1).squeeze().cpu().numpy()
|
40 |
+
y: np.ndarray = hot(x)[..., 0:3] * 255
|
41 |
+
return y.astype(np.uint8)
|
|
|
|
|
42 |
|
43 |
def load_from_disk(self, path: Path) -> tr.Tensor:
|
44 |
res = super().load_from_disk(path)
|
dronescapes_reader/multitask_dataset.py
CHANGED
@@ -124,7 +124,7 @@ class MultiTaskDataset(Dataset):
|
|
124 |
except Exception:
|
125 |
pass
|
126 |
self._tasks.append(t)
|
127 |
-
assert all(t.name == t_n for t, t_n in zip(self._tasks, self.task_names)), (self.
|
128 |
return self._tasks
|
129 |
|
130 |
def collate_fn(self, items: list[MultiTaskItem]) -> MultiTaskItem:
|
|
|
124 |
except Exception:
|
125 |
pass
|
126 |
self._tasks.append(t)
|
127 |
+
assert all(t.name == t_n for t, t_n in zip(self._tasks, self.task_names)), (self.task_names, self._tasks)
|
128 |
return self._tasks
|
129 |
|
130 |
def collate_fn(self, items: list[MultiTaskItem]) -> MultiTaskItem:
|
scripts/collage.png
ADDED
![]() |
Git LFS Details
|
scripts/collage2.png
ADDED
![]() |
Git LFS Details
|
scripts/collage3.png
ADDED
![]() |
Git LFS Details
|
scripts/dronescapes_viewer.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
scripts/lel.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file raw_data/txt_files/annotated_and_segprop/train_files_11664.txt -o data/train_set --copy_files
|
2 |
+
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file raw_data/txt_files/annotated_and_segprop/semisup_files_11299.txt -o data/semisupervised_set --copy_files
|
3 |
+
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file raw_data/txt_files/annotated_and_segprop/test_files_5603.txt -o data/test_set --copy_files
|
4 |
+
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file raw_data/txt_files/annotated_and_segprop/val_files_605.txt -o data/validation_set --copy_files
|
5 |
+
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file raw_data/txt_files/manually_annotated_files/train_files_218.txt -o data/train_set_annotated_only --copy_files
|
6 |
+
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file raw_data/txt_files/manually_annotated_files/val_files_15.txt -o data/validation_set_annotated_only --copy_files
|
7 |
+
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file raw_data/txt_files/manually_annotated_files/semisup_files_207.txt -o data/semisupervised_set_annotated_nly --copy_files
|
8 |
+
python scripts/symlinks_from_txt_list.py raw_data/npz_540p/ --txt_file raw_data/txt_files/manually_annotated_files/test_files_116.txt -o data/test_set_annotated_only --copy_files
|