diff --git a/tests/data/forestdamage/Data_Set_Larch_Casebearer.zip b/tests/data/forestdamage/Data_Set_Larch_Casebearer.zip
index d472a94a0f1..4c9f246aa6b 100644
Binary files a/tests/data/forestdamage/Data_Set_Larch_Casebearer.zip and b/tests/data/forestdamage/Data_Set_Larch_Casebearer.zip differ
diff --git a/tests/data/forestdamage/Data_Set_Larch_Casebearer/Bebehojd_20190527/Annotations/B01_0004.xml b/tests/data/forestdamage/Data_Set_Larch_Casebearer/Bebehojd_20190527/Annotations/B01_0004.xml
index bf5a549fb68..45cd7c9b9ad 100644
--- a/tests/data/forestdamage/Data_Set_Larch_Casebearer/Bebehojd_20190527/Annotations/B01_0004.xml
+++ b/tests/data/forestdamage/Data_Set_Larch_Casebearer/Bebehojd_20190527/Annotations/B01_0004.xml
@@ -1 +1 @@
-B01_0004.xml32323
\ No newline at end of file
+B01_0004.xml32323
\ No newline at end of file
diff --git a/tests/data/forestdamage/Data_Set_Larch_Casebearer/Bebehojd_20190527/Annotations/B01_0005.xml b/tests/data/forestdamage/Data_Set_Larch_Casebearer/Bebehojd_20190527/Annotations/B01_0005.xml
index f6e8957d533..dd7e356a0dd 100644
--- a/tests/data/forestdamage/Data_Set_Larch_Casebearer/Bebehojd_20190527/Annotations/B01_0005.xml
+++ b/tests/data/forestdamage/Data_Set_Larch_Casebearer/Bebehojd_20190527/Annotations/B01_0005.xml
@@ -1 +1 @@
-B01_0005.xml32323
\ No newline at end of file
+B01_0005.xml32323
\ No newline at end of file
diff --git a/tests/data/forestdamage/data.py b/tests/data/forestdamage/data.py
index bd026a1c204..264b5e97ffb 100644
--- a/tests/data/forestdamage/data.py
+++ b/tests/data/forestdamage/data.py
@@ -24,6 +24,7 @@
"Bebehojd_20190527/Annotations/B01_0004.xml",
"Bebehojd_20190527/Annotations/B01_0005.xml",
],
+ "labels": [True, False],
}
@@ -38,15 +39,17 @@ def create_annotation(path: str) -> None:
ET.SubElement(size, "height").text = str(SIZE)
ET.SubElement(size, "depth").text = str(3)
- annotation = ET.SubElement(root, "object")
+ for label in PATHS["labels"]:
+ annotation = ET.SubElement(root, "object")
- ET.SubElement(annotation, "damage").text = "other"
+ if label:
+ ET.SubElement(annotation, "damage").text = "other"
- bbox = ET.SubElement(annotation, "bndbox")
- ET.SubElement(bbox, "xmin").text = str(0 + int(SIZE / 4))
- ET.SubElement(bbox, "ymin").text = str(0 + int(SIZE / 4))
- ET.SubElement(bbox, "xmax").text = str(SIZE - int(SIZE / 4))
- ET.SubElement(bbox, "ymax").text = str(SIZE - int(SIZE / 4))
+ bbox = ET.SubElement(annotation, "bndbox")
+ ET.SubElement(bbox, "xmin").text = str(0 + int(SIZE / 4))
+ ET.SubElement(bbox, "ymin").text = str(0 + int(SIZE / 4))
+ ET.SubElement(bbox, "xmax").text = str(SIZE - int(SIZE / 4))
+ ET.SubElement(bbox, "ymax").text = str(SIZE - int(SIZE / 4))
tree = ET.ElementTree(root)
tree.write(path)
diff --git a/tests/datasets/test_forestdamage.py b/tests/datasets/test_forestdamage.py
index 5db2e160d1f..3bfd9d2e542 100644
--- a/tests/datasets/test_forestdamage.py
+++ b/tests/datasets/test_forestdamage.py
@@ -27,7 +27,7 @@ def dataset(self, monkeypatch: MonkeyPatch, tmp_path: Path) -> ForestDamage:
url = os.path.join(data_dir, "Data_Set_Larch_Casebearer.zip")
- md5 = "a6adc19879c1021cc1ba8d424e19c9e0"
+ md5 = "52d82ac38899e6e6bb40aacda643ee15"
monkeypatch.setattr(ForestDamage, "url", url)
monkeypatch.setattr(ForestDamage, "md5", md5)
diff --git a/torchgeo/datasets/forestdamage.py b/torchgeo/datasets/forestdamage.py
index 35676a4d277..c4646baceb4 100644
--- a/torchgeo/datasets/forestdamage.py
+++ b/torchgeo/datasets/forestdamage.py
@@ -40,7 +40,12 @@ def parse_pascal_voc(path: str) -> Dict[str, Any]:
int(bndbox.find("xmax").text), # type: ignore[union-attr, arg-type]
int(bndbox.find("ymax").text), # type: ignore[union-attr, arg-type]
]
- label = obj.find("damage").text # type: ignore[union-attr]
+
+ label_var = obj.find("damage")
+ if label_var is not None:
+ label = label_var.text
+ else:
+ label = "other"
bboxes.append(bbox)
labels.append(label)
return dict(filename=filename, bboxes=bboxes, labels=labels)