Commit 851660d3 authored by zimenglan's avatar zimenglan Committed by Francisco Massa

make pixel indexes 0-based for bounding box in pascal voc dataset (#209)

parent 9a1ba140
...@@ -88,22 +88,24 @@ class PascalVOCDataset(torch.utils.data.Dataset): ...@@ -88,22 +88,24 @@ class PascalVOCDataset(torch.utils.data.Dataset):
boxes = [] boxes = []
gt_classes = [] gt_classes = []
difficult_boxes = [] difficult_boxes = []
TO_REMOVE = 1
for obj in target.iter("object"): for obj in target.iter("object"):
difficult = int(obj.find("difficult").text) == 1 difficult = int(obj.find("difficult").text) == 1
if not self.keep_difficult and difficult: if not self.keep_difficult and difficult:
continue continue
name = obj.find("name").text.lower().strip() name = obj.find("name").text.lower().strip()
bb = obj.find("bndbox") bb = obj.find("bndbox")
# Make pixel indexes 0-based
# Refer to "https://github.com/rbgirshick/py-faster-rcnn/blob/master/lib/datasets/pascal_voc.py#L208-L211"
box = [
bb.find("xmin").text,
bb.find("ymin").text,
bb.find("xmax").text,
bb.find("ymax").text,
]
bndbox = tuple( bndbox = tuple(
map( map(lambda x: x - TO_REMOVE, list(map(int, box)))
int,
[
bb.find("xmin").text,
bb.find("ymin").text,
bb.find("xmax").text,
bb.find("ymax").text,
],
)
) )
boxes.append(bndbox) boxes.append(bndbox)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment