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

Rewrite Image archetype #6942

Merged
merged 61 commits into from
Aug 1, 2024
Merged

Rewrite Image archetype #6942

merged 61 commits into from
Aug 1, 2024

Conversation

emilk
Copy link
Member

@emilk emilk commented Jul 18, 2024

What

Breaking changes

  • Image(…).compress(…) is now ImageEncoded.compres(…)
  • ImageEncoded has very different constructor compared to 0.17, and only supports chroma-downsampled images

TODO

  • Fix how enums are handled in Python (I don't understand it). In particular, this code is broken when given a string as a color model:
    color_model = ColorModel(color_model)
    if color_model == ColorModel.L:
    mode = "L"
    elif color_model == ColorModel.RGB:
    mode = "RGB"
    else:
    # TODO(#2340): BGR support!
    raise ValueError(f"Cannot JPEG compress an image of type {color_model}")
  • Fix this test:
    IMAGE_INPUTS: list[Any] = [
    RANDOM_IMAGE_SOURCE,
    RANDOM_IMAGE_SOURCE,
    ]
    # 0 = shape
    # 1 = buffer
    CHECK_FIELDS: list[list[int]] = [
    [0, 1],
    [1],
    ]
    def tensor_data_expected() -> Any:
    return TensorDataBatch(IMAGE_INPUTS[0])
    def compare_images(left: Any, right: Any, check_fields: list[int]) -> None:
    for field in check_fields:
    assert left.as_arrow_array().storage.field(field) == right.as_arrow_array().storage.field(field)
    def test_image() -> None:
    expected = tensor_data_expected()
    for input, check_fields in zip(IMAGE_INPUTS, CHECK_FIELDS):
    arch = rr.Image(input)
    compare_images(arch.data, expected, check_fields)
  • Test detect_and_track_objects
  • Test a bunch of other examples
  • [ ] Log a warning if color_model is missing, so that we can in the future migrate to having BGR be the default
    • BGR should never be the default. This has haunted opencv for over a decade. We need not inherit this trauma.
  • [ ] Consider re-implementing image.compress(…) (with a forward call to ImageEncoded.compress
    • TODO: I don't understand why this was moved in the first place. We should move it back, but it can happen in a follow-on PR.

Checklist

To run all checks from main, comment on the PR with @rerun-bot full-check.

@emilk emilk added include in changelog 🪵 Log & send APIs Affects the user-facing API for all languages labels Jul 18, 2024
@emilk emilk changed the title Add PixelFormat component Rewrite Image archetype Jul 18, 2024
@emilk emilk mentioned this pull request Jul 18, 2024
1 task
Copy link

github-actions bot commented Jul 18, 2024

Deployed docs

Commit Link
c571f58 https://landing-4m4xhhpu9-rerun.vercel.app/docs

@emilk emilk force-pushed the emilk/new-image branch from ac5da5c to 9f08343 Compare July 19, 2024 10:34
@emilk
Copy link
Member Author

emilk commented Jul 19, 2024

@rerun-bot full-check

Copy link

@jleibs jleibs marked this pull request as ready for review July 31, 2024 23:17
@Wumpf Wumpf self-requested a review August 1, 2024 07:53
@jleibs jleibs merged commit 102a226 into main Aug 1, 2024
40 checks passed
@jleibs jleibs deleted the emilk/new-image branch August 1, 2024 17:38
@jleibs jleibs restored the emilk/new-image branch August 1, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include in changelog 🪵 Log & send APIs Affects the user-facing API for all languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encode images as a byte blob + pixel format + resolution; not as a tensor
3 participants