modify class
Browse files- pascal_voc.py +40 -17
pascal_voc.py
CHANGED
|
@@ -72,6 +72,11 @@ LAYOUT_INFOS = [
|
|
| 72 |
# fmt: on
|
| 73 |
|
| 74 |
CLASS_NAMES = [CLASS_INFO[0] for CLASS_INFO in CLASS_INFOS]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
ACTION_NAMES = [ACTION_INFO[0] for ACTION_INFO in ACTION_INFOS]
|
| 76 |
LAYOUT_NAMES = [LAYOUT_INFO[0] for LAYOUT_INFO in LAYOUT_INFOS]
|
| 77 |
|
|
@@ -87,7 +92,9 @@ action_features = datasets.Features(
|
|
| 87 |
"image": datasets.features.Image(),
|
| 88 |
"height": datasets.Value("int32"),
|
| 89 |
"width": datasets.Value("int32"),
|
| 90 |
-
"classes": datasets.features.Sequence(
|
|
|
|
|
|
|
| 91 |
"objects": datasets.features.Sequence(
|
| 92 |
{
|
| 93 |
"bboxes": datasets.Sequence(datasets.Value("float32")),
|
|
@@ -104,7 +111,9 @@ layout_features = datasets.Features(
|
|
| 104 |
"image": datasets.features.Image(),
|
| 105 |
"height": datasets.Value("int32"),
|
| 106 |
"width": datasets.Value("int32"),
|
| 107 |
-
"classes": datasets.features.Sequence(
|
|
|
|
|
|
|
| 108 |
"objects": datasets.features.Sequence(
|
| 109 |
{
|
| 110 |
"bboxes": datasets.Sequence(datasets.Value("float32")),
|
|
@@ -121,7 +130,9 @@ main_features = datasets.Features(
|
|
| 121 |
"image": datasets.features.Image(),
|
| 122 |
"height": datasets.Value("int32"),
|
| 123 |
"width": datasets.Value("int32"),
|
| 124 |
-
"classes": datasets.features.Sequence(
|
|
|
|
|
|
|
| 125 |
"objects": datasets.features.Sequence(
|
| 126 |
{
|
| 127 |
"bboxes": datasets.Sequence(datasets.Value("float32")),
|
|
@@ -376,7 +387,11 @@ class PASCALDataset(datasets.GeneratorBasedBuilder):
|
|
| 376 |
|
| 377 |
if self.config.task_name == "layout":
|
| 378 |
example["objects"] = [
|
| 379 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
for object_info in objects_info
|
| 381 |
if "pose" in object_info
|
| 382 |
]
|
|
@@ -385,7 +400,11 @@ class PASCALDataset(datasets.GeneratorBasedBuilder):
|
|
| 385 |
|
| 386 |
if self.config.task_name == "main":
|
| 387 |
example["objects"] = [
|
| 388 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
for object_info in objects_info
|
| 390 |
if "class" in object_info
|
| 391 |
]
|
|
@@ -393,19 +412,23 @@ class PASCALDataset(datasets.GeneratorBasedBuilder):
|
|
| 393 |
continue
|
| 394 |
|
| 395 |
if self.config.task_name == "segmentation":
|
| 396 |
-
example["class_gt_image"] = Image.open(
|
| 397 |
-
os.path.
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
|
|
|
|
|
|
| 401 |
)
|
| 402 |
-
)
|
| 403 |
-
example["object_gt_image"] = Image.open(
|
| 404 |
-
os.path.
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
|
|
|
|
|
|
| 408 |
)
|
| 409 |
-
)
|
| 410 |
|
| 411 |
yield id_, example
|
|
|
|
| 72 |
# fmt: on
|
| 73 |
|
| 74 |
CLASS_NAMES = [CLASS_INFO[0] for CLASS_INFO in CLASS_INFOS]
|
| 75 |
+
CLASS_NAMES_ALONE = [
|
| 76 |
+
CLASS_INFO[0]
|
| 77 |
+
for CLASS_INFO in CLASS_INFOS
|
| 78 |
+
if CLASS_INFO[1] not in ["background", "borderingregion"]
|
| 79 |
+
]
|
| 80 |
ACTION_NAMES = [ACTION_INFO[0] for ACTION_INFO in ACTION_INFOS]
|
| 81 |
LAYOUT_NAMES = [LAYOUT_INFO[0] for LAYOUT_INFO in LAYOUT_INFOS]
|
| 82 |
|
|
|
|
| 92 |
"image": datasets.features.Image(),
|
| 93 |
"height": datasets.Value("int32"),
|
| 94 |
"width": datasets.Value("int32"),
|
| 95 |
+
"classes": datasets.features.Sequence(
|
| 96 |
+
datasets.features.ClassLabel(names=ACTION_NAMES)
|
| 97 |
+
),
|
| 98 |
"objects": datasets.features.Sequence(
|
| 99 |
{
|
| 100 |
"bboxes": datasets.Sequence(datasets.Value("float32")),
|
|
|
|
| 111 |
"image": datasets.features.Image(),
|
| 112 |
"height": datasets.Value("int32"),
|
| 113 |
"width": datasets.Value("int32"),
|
| 114 |
+
"classes": datasets.features.Sequence(
|
| 115 |
+
datasets.features.ClassLabel(names=LAYOUT_NAMES)
|
| 116 |
+
),
|
| 117 |
"objects": datasets.features.Sequence(
|
| 118 |
{
|
| 119 |
"bboxes": datasets.Sequence(datasets.Value("float32")),
|
|
|
|
| 130 |
"image": datasets.features.Image(),
|
| 131 |
"height": datasets.Value("int32"),
|
| 132 |
"width": datasets.Value("int32"),
|
| 133 |
+
"classes": datasets.features.Sequence(
|
| 134 |
+
datasets.features.ClassLabel(names=CLASS_NAMES_ALONE)
|
| 135 |
+
),
|
| 136 |
"objects": datasets.features.Sequence(
|
| 137 |
{
|
| 138 |
"bboxes": datasets.Sequence(datasets.Value("float32")),
|
|
|
|
| 387 |
|
| 388 |
if self.config.task_name == "layout":
|
| 389 |
example["objects"] = [
|
| 390 |
+
{
|
| 391 |
+
"bboxes": object_info["bbox"],
|
| 392 |
+
"classes": object_info["pose"],
|
| 393 |
+
"difficult": object_info["difficult"],
|
| 394 |
+
}
|
| 395 |
for object_info in objects_info
|
| 396 |
if "pose" in object_info
|
| 397 |
]
|
|
|
|
| 400 |
|
| 401 |
if self.config.task_name == "main":
|
| 402 |
example["objects"] = [
|
| 403 |
+
{
|
| 404 |
+
"bboxes": object_info["bbox"],
|
| 405 |
+
"classes": object_info["class"],
|
| 406 |
+
"difficult": object_info["difficult"],
|
| 407 |
+
}
|
| 408 |
for object_info in objects_info
|
| 409 |
if "class" in object_info
|
| 410 |
]
|
|
|
|
| 412 |
continue
|
| 413 |
|
| 414 |
if self.config.task_name == "segmentation":
|
| 415 |
+
example["class_gt_image"] = Image.open(
|
| 416 |
+
os.path.abspath(
|
| 417 |
+
os.path.join(
|
| 418 |
+
data_folder,
|
| 419 |
+
"SegmentationClass",
|
| 420 |
+
anno_info["image"].replace(".jpg", ".png"),
|
| 421 |
+
)
|
| 422 |
)
|
| 423 |
+
)
|
| 424 |
+
example["object_gt_image"] = Image.open(
|
| 425 |
+
os.path.abspath(
|
| 426 |
+
os.path.join(
|
| 427 |
+
data_folder,
|
| 428 |
+
"SegmentationObject",
|
| 429 |
+
anno_info["image"].replace(".jpg", ".png"),
|
| 430 |
+
)
|
| 431 |
)
|
| 432 |
+
)
|
| 433 |
|
| 434 |
yield id_, example
|