Fiftyone field deleted bug

73 Views Asked by At

I've run into this bug a couple times in recent months, and it seems to be occur when deleting a sample field from a fiftyone dataset.

To reproduce the bug you can:

  1. Load a dataset into fityone
  2. Add some sort of field to the samples, a prediction field for instance.
  3. Delete that field from the dataset using the following python code
dataset = fiftyone.load_dataset("my_dataset")
dataset.delete_sample_field("sample_field_to_delete")

Then, when I go to add a sample field or even iterate over the samples in the dataset I'm greeted with this error:

mongoengine.errors.FieldDoesNotExist: The fields "{'3c_320_30_01'}" do not exist on the document "samples.65cd2482057b2fee23505215"

This is a mongoengine error, so I'm thinking that something is out of sync with mongodb and fiftyone.

If anyone has run into this error before and knows a fix that would be appreciated.

1

There are 1 best solutions below

0
On

I was working on something similar today and was not able to reproduce. For reference here was my block.

import fiftyone as fo
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset("quickstart")

session = fo.launch_app(dataset)

#can run below over and over again
#dataset.delete_sample_field("all_predictions")
labels = []
field_names = list(dataset.get_field_schema().keys())
for name in field_names:
    if type(dataset.get_field(name)) == fo.core.fields.EmbeddedDocumentField:
        if "detections" in  list(dataset.get_field(name).get_field_schema().keys()):
            labels.append(name + ".detections")

for sample in dataset:
    all_preds = []
    for label in labels:
        for det in sample[label]:
            bbox = det.bounding_box
            det_label = det.label
            all_preds.append(fo.Detection(label=det_label,bounding_box=bbox))
    
    sample["all_predictions"] = fo.Detections(detections=all_preds)
    sample.save()

Can you try this and let me know? Maybe try updating to the latest version