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] Custom Keypoint Field Does Not Detect Data Type In App #3125

Closed
2 of 6 tasks
paultreadel opened this issue May 28, 2023 · 1 comment
Closed
2 of 6 tasks

[BUG] Custom Keypoint Field Does Not Detect Data Type In App #3125

paultreadel opened this issue May 28, 2023 · 1 comment
Labels
bug Bug fixes

Comments

@paultreadel
Copy link

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 10.0.19045
  • Python version (python --version): 3.9.9
  • FiftyOne version (fiftyone --version): 0.20.1
  • FiftyOne installed from (pip or source): pip

Commands to reproduce

As thoroughly as possible, please provide the Python and/or shell commands used to encounter the issue. Application steps can be described in the next section.

import random
from contextlib import contextmanager
from tempfile import TemporaryDirectory

import fiftyone as fo
from PIL import Image


def create_valid_image(
    fileobj,
) -> str:
    color_rgb = tuple(random.randint(0, 255) for _ in range(3))
    valid_image = Image.new(mode="RGB", size=(192, 108), color=color_rgb)
    valid_image.save(fileobj)


@contextmanager
def create_test_images(number_of_images):
    with TemporaryDirectory() as temp_dir:
        test_image_fileobjs = []
        for i in range(number_of_images):
            filepath = rf"{temp_dir}\image{i}.png"
            create_valid_image(filepath)
            test_image_fileobjs.append(filepath)

        yield test_image_fileobjs


def random_keypoint():
    return fo.Keypoint(
        label="some_label",
        points=[(random.random(), random.random())],
        float_attribute=random.uniform(0, 50),
    )


with create_test_images(2) as temp_images:
    fo_dataset = fo.Dataset.from_images(temp_images)
    sample_id = fo_dataset.last().id
    # value of 2 or more renders correctly in app
    num_keypoints = 1
    keypoints_dict = {
        sample_id: fo.Keypoints(
            keypoints=[random_keypoint() for _ in range(num_keypoints)]
        )
    }
    fo_dataset.set_values("keypoint_detection", keypoints_dict, key_field="id")
    fo_dataset.add_sample_field(
        "keypoint_detection.keypoints.float_attribute", fo.FloatField
    )
    session = fo.launch_app(fo_dataset)
    session.wait()

Describe the problem

The custom field for a single keypoint does not work as expected in the side when only a single Keypoints detection is added to a dataset. Instead of showing the value for the float field, None is shown instead.

This prevents filtering to the single image containing the keypoint using the sidebar app filter for the custom attribute field.

This issue does not occur if 2 or more keypoints are included anywhere in a dataset. Tested scenarios 1) 2 or more keypoints on a single image only 2) 2 or more keypoints spread across multiple images. As long as at least 2 keypoints exist the sidebar filter renders as expected.

One Keypoint in Dataset

image

2 or More Keypoints in Dataset

image

Code to reproduce issue

Provide a reproducible test case that is the bare minimum necessary to generate the problem.

Other info/logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Please do not use screenshots for sharing text. Code snippets should be used instead when providing tracebacks, logs, etc.

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
@paultreadel paultreadel added the bug Bug fixes label May 28, 2023
@benjaminpkane
Copy link
Contributor

Resolved by #3280

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

No branches or pull requests

2 participants