| 1 |
|
| 2 |
|
| 3 |
import os.path as osp |
| 4 |
|
| 5 |
import numpy as np |
| 6 |
|
| 7 |
here = osp.dirname(osp.abspath(__file__)) |
| 8 |
|
| 9 |
|
| 10 |
def voc(): |
| 11 |
data_file = osp.join(here, "data.npz") |
| 12 |
data = dict(np.load(data_file)) |
| 13 |
|
| 14 |
|
| 15 |
class_label = np.full(data["rgb"].shape[:2], 0, dtype=np.int32) |
| 16 |
for l, mask in zip(data["labels"], data["masks"]): |
| 17 |
class_label[mask == 1] = l |
| 18 |
data["class_label"] = class_label |
| 19 |
|
| 20 |
names_file = osp.join(here, "class_names.txt") |
| 21 |
with open(names_file) as f: |
| 22 |
class_names = [name.strip() for name in f] |
| 23 |
data["class_names"] = class_names |
| 24 |
|
| 25 |
return data |