Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] with dynamic sample field and keypoints #3178

Closed
3 of 6 tasks
ArthurTrehet opened this issue Jun 9, 2023 · 1 comment · Fixed by #3152
Closed
3 of 6 tasks

[BUG] with dynamic sample field and keypoints #3178

ArthurTrehet opened this issue Jun 9, 2023 · 1 comment · Fixed by #3152
Labels
bug Bug fixes

Comments

@ArthurTrehet
Copy link

System information

  • OS Platform and Distribution : ubuntu 20.04
  • Python version : python 3.9.5
  • FiftyOne version : 0.21.0
  • FiftyOne installed from : pip

Describe the problem

When I create a dataset with a sample containing keypoints, and use the method dataset.add_dynamic_sample_fields(), fiftyone crashes when I try to show the details of the keypoints. It also fails when I try to get the get sample manually with a view on the dataset

Code to reproduce issue

import fiftyone as fo
import fiftyone.zoo as foz

filepath = foz.load_zoo_dataset("quickstart", max_samples=1).first().filepath
sample = fo.Sample(
    filepath=filepath,
    ground_truth=fo.Keypoints(
        keypoints=[
            fo.Keypoint(
                label="head",
                points=[[0.7,0.8]],
                confidence=[0.2]
            )
        ]
    )
)

dataset = fo.Dataset("bug_testing")
dataset.add_sample(sample)
dataset.add_dynamic_sample_fields()

with either

session = fo.launch_app(dataset, port=5151)
session.wait()

or

view=dataset.view()
view.take(1).first()

Other info/logs

the error returned when using view.take(1).first() is the following

Traceback (most recent call last):
  File "/home/arthurtrehet/.cache/pypoetry/virtualenvs/code-db5bzWv4-py3.9/lib/python3.9/site-packages/fiftyone/core/dataset.py", line 6202, in _sample_dict_to_doc
    return self._sample_doc_cls.from_dict(d, extended=False)
  File "/home/arthurtrehet/.cache/pypoetry/virtualenvs/code-db5bzWv4-py3.9/lib/python3.9/site-packages/fiftyone/core/odm/document.py", line 410, in from_dict
    return cls._from_son(d)
  File "/home/arthurtrehet/.cache/pypoetry/virtualenvs/code-db5bzWv4-py3.9/lib/python3.9/site-packages/mongoengine/base/document.py", line 836, in _from_son
    obj = cls(__auto_convert=False, _created=created, **data)
  File "/home/arthurtrehet/.cache/pypoetry/virtualenvs/code-db5bzWv4-py3.9/lib/python3.9/site-packages/mongoengine/base/document.py", line 128, in __init__
    setattr(self, key, value)
  File "/home/arthurtrehet/.cache/pypoetry/virtualenvs/code-db5bzWv4-py3.9/lib/python3.9/site-packages/fiftyone/core/odm/mixins.py", line 63, in __setattr__
    self._fields[name].validate(value)
  File "/home/arthurtrehet/.cache/pypoetry/virtualenvs/code-db5bzWv4-py3.9/lib/python3.9/site-packages/fiftyone/core/fields.py", line 1345, in validate
    v.validate(val)
  File "/home/arthurtrehet/.cache/pypoetry/virtualenvs/code-db5bzWv4-py3.9/lib/python3.9/site-packages/mongoengine/fields.py", line 972, in validate
    super().validate(value)
  File "/home/arthurtrehet/.cache/pypoetry/virtualenvs/code-db5bzWv4-py3.9/lib/python3.9/site-packages/mongoengine/base/fields.py", line 481, in validate
    self.error(f"Invalid {field_class} item ({value})", errors=errors)
  File "/home/arthurtrehet/.cache/pypoetry/virtualenvs/code-db5bzWv4-py3.9/lib/python3.9/site-packages/mongoengine/base/fields.py", line 171, in error
    raise ValidationError(message, errors=errors, field_name=field_name)
mongoengine.errors.ValidationError: Invalid EmbeddedDocumentField item ([<Keypoint: {
    'id': '6483112be1e4b4c5b385d6ac',
    'attributes': {},
    'tags': [],
    'label': 'head',
    'points': [[0.7, 0.8]],
    'confidence': [0.2],
    'index': None,
}>])([0.7, 0.8] could not be converted to float: [0])

print(dataset.get_dynamic_field_schema()) just before using dataset.add_dynamic_sample_fields() returns {'ground_truth.keypoints.points[]': <fiftyone.core.fields.FloatField object at 0x7f7a69f5ca30>}. Which makes me think keypoints are considered dynamic by default even though they shouldn't.

What areas of FiftyOne does this bug affect?

  • App: FiftyOne application issue
  • Core: Core Python library issue
  • Server: FiftyOne server issue

Willingness to contribute

The FiftyOne Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the FiftyOne codebase?

  • Yes. I can contribute a fix for this bug independently
  • Yes. I would be willing to contribute a fix for this bug with guidance from the FiftyOne community
  • No. I cannot contribute a bug fix at this time
@ArthurTrehet ArthurTrehet added the bug Bug fixes label Jun 9, 2023
@ArthurTrehet ArthurTrehet changed the title [BUG] [BUG] with dynamic sample field and keypoints Jun 9, 2023
@brimoor
Copy link
Contributor

brimoor commented Jun 12, 2023

This is fixed by #3152 and will be included in fiftyone==0.21.1 (releasing in a few days).

@brimoor brimoor closed this as completed Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug fixes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants