slight updates to viewer
Browse files
scripts/dronescapes_viewer/dronescapes_viewer.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
scripts/dronescapes_viewer/dronescapes_viewer.py
CHANGED
@@ -1,33 +1,24 @@
|
|
|
|
1 |
import sys
|
2 |
import os
|
3 |
os.environ["STATS_PBAR"] = "1"
|
4 |
os.environ["VRE_LOGLEVEL"] = "0"
|
|
|
5 |
from pathlib import Path
|
6 |
sys.path.append(Path.cwd().parent.__str__())
|
7 |
from pprint import pprint
|
8 |
-
import
|
9 |
-
from vre.readers.multitask_dataset import MultiTaskDataset, MultiTaskItem
|
10 |
from vre.representations import Representation, ReprOut
|
11 |
-
from vre.utils import MemoryData, reorder_dict
|
12 |
import numpy as np
|
13 |
import torch as tr
|
14 |
from media_processing_lib.collage_maker import collage_fn
|
15 |
from media_processing_lib.image import image_add_title, image_write
|
16 |
import matplotlib.pyplot as plt
|
17 |
|
18 |
-
from dronescapes_representations import
|
19 |
-
|
20 |
-
data_path = "../../data/test_set"
|
21 |
-
stats_path = "../../data/train_set/.task_statistics.npz"
|
22 |
-
reader = MultiTaskDataset(data_path, task_names=list(dronescapes_task_types),
|
23 |
-
task_types=dronescapes_task_types, handle_missing_data="fill_nan",
|
24 |
-
normalization="min_max", cache_task_stats=True, batch_size_stats=300,
|
25 |
-
statistics=np.load(stats_path, allow_pickle=True)["arr_0"].item())
|
26 |
-
print(reader)
|
27 |
-
print("== Shapes ==")
|
28 |
-
pprint(reader.data_shape)
|
29 |
|
30 |
-
def plot_one(data:
|
31 |
order: list[str] | None = None) -> np.ndarray:
|
32 |
def vre_plot_fn(rgb: tr.Tensor, x: tr.Tensor, node: Representation) -> np.ndarray:
|
33 |
node.data = ReprOut(rgb.cpu().detach().numpy()[None], MemoryData(x.cpu().detach().numpy()[None]), [0])
|
@@ -39,13 +30,24 @@ def plot_one(data: MultiTaskItem, title: str, name_to_task: dict[str, Representa
|
|
39 |
collage = image_add_title(collage, title, size_px=55, top_padding=110)
|
40 |
return collage
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
print("== Random loaded item ==")
|
43 |
-
|
44 |
-
rand_ix = "norway_210821_DJI_0015_full_2774.npz"
|
45 |
data, name = reader[rand_ix] # get a random item
|
46 |
print(name)
|
47 |
-
|
48 |
-
|
49 |
# plt.figure(figsize=(20, 10))
|
50 |
# plt.imshow(collage)
|
51 |
-
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
import sys
|
3 |
import os
|
4 |
os.environ["STATS_PBAR"] = "1"
|
5 |
os.environ["VRE_LOGLEVEL"] = "0"
|
6 |
+
import random
|
7 |
from pathlib import Path
|
8 |
sys.path.append(Path.cwd().parent.__str__())
|
9 |
from pprint import pprint
|
10 |
+
from vre.readers.multitask_dataset import MultiTaskDataset
|
|
|
11 |
from vre.representations import Representation, ReprOut
|
12 |
+
from vre.utils import MemoryData, reorder_dict, lo
|
13 |
import numpy as np
|
14 |
import torch as tr
|
15 |
from media_processing_lib.collage_maker import collage_fn
|
16 |
from media_processing_lib.image import image_add_title, image_write
|
17 |
import matplotlib.pyplot as plt
|
18 |
|
19 |
+
from dronescapes_representations import get_dronescapes_task_types
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
def plot_one(data: dict[str, tr.Tensor], title: str, name_to_task: dict[str, Representation],
|
22 |
order: list[str] | None = None) -> np.ndarray:
|
23 |
def vre_plot_fn(rgb: tr.Tensor, x: tr.Tensor, node: Representation) -> np.ndarray:
|
24 |
node.data = ReprOut(rgb.cpu().detach().numpy()[None], MemoryData(x.cpu().detach().numpy()[None]), [0])
|
|
|
30 |
collage = image_add_title(collage, title, size_px=55, top_padding=110)
|
31 |
return collage
|
32 |
|
33 |
+
data_path = "../../data/test_set"
|
34 |
+
stats_path = "../../data/train_set/.task_statistics.npz"
|
35 |
+
dronescapes_task_types = get_dronescapes_task_types(include_semantics_original=False, include_gt=True, include_ci=False)
|
36 |
+
reader = MultiTaskDataset(data_path, task_names=list(dronescapes_task_types),
|
37 |
+
task_types=dronescapes_task_types, handle_missing_data="fill_nan",
|
38 |
+
normalization="min_max", cache_task_stats=True, batch_size_stats=300,
|
39 |
+
statistics=np.load(stats_path, allow_pickle=True)["arr_0"].item())
|
40 |
+
print(reader)
|
41 |
+
print("== Shapes ==")
|
42 |
+
pprint(reader.data_shape)
|
43 |
+
|
44 |
print("== Random loaded item ==")
|
45 |
+
rand_ix = random.randint(0, len(reader) - 1)
|
46 |
+
# rand_ix = "norway_210821_DJI_0015_full_2774.npz"
|
47 |
data, name = reader[rand_ix] # get a random item
|
48 |
print(name)
|
49 |
+
collage = plot_one(data, title=name, name_to_task=reader.name_to_task)
|
50 |
+
print(lo(collage))
|
51 |
# plt.figure(figsize=(20, 10))
|
52 |
# plt.imshow(collage)
|
53 |
+
image_write(collage, f"collage_{name[0:-4]}.png")
|