Reputation: 39
I used images and annotation data from the open images dataset v6.
I was able to retrieve the images, but not the annotation information.
Can you please tell me what to do?
Current status
I ran the code on GoogleColaboratory, referring to the demonstration of fiftyone.
I was able to run it up to the following point
dataset = foz.load_zoo_dataset(
"open-images-v6",
split="validation",
label_types=["detections", "classifications"],
classes=["Bottle"],
max_samples=250,
seed=51,
shuffle=True,
dataset_name="open-images-sample-mix-data",
)
person_subset = foz.load_zoo_dataset(
"open-images-v6",
split="validation",
label_types=["detections", "classifications"],
classes=["Person"],
max_samples=250,
seed=51,
shuffle=True,
dataset_name="Person-subset",
)
can_subset = foz.load_zoo_dataset(
"open-images-v6",
split="validation",
label_types=["detections", "classifications"],
classes={'Tin can'},
max_samples=250,
seed=51,
shuffle=True,
dataset_name="Tin_can-subset",
)
box_subset = foz.load_zoo_dataset(
"open-images-v6",
split="validation",
label_types=["detections", "classifications"],
classes=["Box"],
max_samples=250,
seed=51,
shuffle=True,
dataset_name="Box-subset",
)
_ = dataset.merge_samples(person_subset)
_ = dataset.merge_samples(box_subset)
_ = dataset.merge_samples(can_subset)
However, from here I want to open the file detections.csv and type the coordinate information into the generated text, but the file is too huge to open.
Could you please tell me how to get the coordinate information?
Upvotes: 0
Views: 1011
Reputation: 584
The base Open Images annotation csv files are quite large. The best way to access the bounding box coordinates would be to just iterate of the FiftyOne dataset directly and access the coordinates from the FiftyOne Detection label objects.
bboxes = []
for sample in dataset:
for detection in sample.detections.detections:
bbox = detection.bounding_box
bboxes.append(bbox)
In this loop, you can also access other information to store in your text file like the sample ids and classification annotations. While this loop is the most flexible way to get other information that you want from the dataset, if you just want the bounding box coordinates, the most efficient way to get that information is to use dataset.values()
bboxes = dataset.values("detections.detections.bounding_box")
Either way, you would then write these lists of box coordinates to a text file programmatically.
Upvotes: 1