-
Notifications
You must be signed in to change notification settings - Fork 376
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
Fix python's send_columns
failing to convert correctly from ComponentBatch
to ComponentColumn
in some cases
#7155
Conversation
@rerun-bot full-check |
Started a full build: https://github.com/rerun-io/rerun/actions/runs/10356336574 |
crates/store/re_types/definitions/rerun/datatypes/tensor_data.fbs
Outdated
Show resolved
Hide resolved
You guys are amazing, thanks for trying to make this work! I'm on version: I'm getting further this time, but stumbled onto two errors: But the other error I'm unable to fix:
|
I definitely would -- it works, it's useful to people, and it isn't even hackish. |
I'll bring up another pr today with snippets that integrate into Scalar and Image types at least! |
@Famok thank you so much again for testing the pre-release out! I'll fix the |
@Wumpf testing this is fun, since rerun is evolving exactly into what I need to replace my current solution. Btw.: is there a way to use "|" in 3.9? I hoped there was some way like I'm using the example from the first post above.
|
Hmmm no the pipe for type concatentation is a feature they added in later Python versions. We usually don't use this for compatibility, but it slipped me through here. Phew, if you're using the snippet from above then the other error makes sense as well, this is addressed in here but hasn't landed yet 🙂. For trying out that you'd need to checkout this branch and do your own build of the sdk/wheel. |
@Famok, awesome to hear that, thanks! Would you mind sharing what it is you're working on now that needs where Rerun is going? |
@Wumpf I'll wait for the nightly and then report again @nikolausWest I'll contact you directly |
…resence of the `partition` method)
…entBatch` to `ComponentColumn` in some cases (#7155) ### What * Fixes #6592 * technically not for tensors which is covered by it's union-avoidance-ticket, but this PR adds a note about this Makes it a lot easier to log batches of images in python: ```python from __future__ import annotations import numpy as np import rerun as rr rr.init("rerun_example_send_columns", spawn=True) COUNT = 64 WIDTH = 100 HEIGHT = 50 CHANNELS = 3 # Create our time times = np.arange(0, COUNT) # Create a batch of images rng = np.random.default_rng(12345) image_batch = rng.uniform(0, 255, size=[COUNT, HEIGHT, WIDTH, CHANNELS]).astype( dtype=np.uint8 ) # Log the ImageFormat and indicator once, as static. format_static = rr.components.ImageFormat( width=WIDTH, height=HEIGHT, color_model="RGB", channel_datatype="U8" ) rr.log("images", [format_static, rr.Image.indicator()], static=True) # Reshape the images so `ImageBufferBatch` can tell that this is several blobs. rr.send_columns( "images", times=[rr.TimeSequenceColumn("step", times)], components=[rr.components.ImageBufferBatch(image_batch.reshape(COUNT, -1))], ) ``` cc: @Famok Related things that went into this PR: * add a note to tensors not supporting batching right now * support arrays of bytes for blob arrays Manually tested the snippets for `send_columns` to make sure nothing else broke. Considered adding the above as a snippet, but I'm still not sure if we want to advertise this prominently. There's some situations where this is useful, but generally we don't have a great usecase for it. Not sure about this 🤔 ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/7155?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/7155?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! * [x] If have noted any breaking changes to the log API in `CHANGELOG.md` and the migration guide - [PR Build Summary](https://build.rerun.io/pr/7155) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) To run all checks from `main`, comment on the PR with `@rerun-bot full-check`.
@Famok yes it should override the |
@Wumpf amazing! Imagebatches are working fine now. (Using the example from above) |
@Wumpf I've played with you code and noticed that the image is black when I try this with 16 bit images:
|
Ah sorry, wrong ticket! This is the right one in other words: Rerun doesn't allow specifying the data range yet and instead tries to guess it from the look of the datatype, this is done intransparently (https://github.com/rerun-io/rerun/blob/main/crates/viewer/re_viewer_context/src/gpu_bridge/image_to_gpu.rs#L160). So but for your case everything is 0-255 so that thing should already guess correctly that this is the range.
The reason why is a little bit hard to spot in the new components=[rr.components.ImageBufferBatch(image_batch.reshape(COUNT, -1))], Image buffers are just raw bytes. So this works fine for u8 images, but for anything else it should be something like this: rr.components.ImageBufferBatch(
np.frombuffer(image_batch.tobytes(), dtype=np.uint8).reshape([COUNT, WIDTH * HEIGHT * CHANNELS * 2])
) Or more explicitely maybe: image_size_in_bytes = WIDTH * HEIGHT * CHANNELS * 2
image_batch_bytes = image_batch.tobytes()
rr.send_columns(
"images",
times=[rr.TimeSequenceColumn("step", times)],
components=[
rr.components.ImageBufferBatch([
image_batch_bytes[i : (i + image_size_in_bytes)]
for i in range(0, len(image_batch_bytes), image_size_in_bytes)
])
],
) I'll bring it up with the rest of the team what we should recommend (I don't know what's more efficient in python, afaik these slice operations don't copy though) and if we can make this more obvious somehow 🤔 Unrelatedly: If possible it would be great if you could bring these questions up on Discord instead in the future. Posting on closed PRs & Issues has a very high risk of getting lost (github notification system is so-so and I get a lot of them) and it's not very visible overall. Thanks! |
I've opened a thread here: discord lets continue discussion there :) |
What
Batch
constructors. #6592Makes it a lot easier to log batches of images in python:
cc: @Famok
Related things that went into this PR:
Manually tested the snippets for
send_columns
to make sure nothing else broke.Considered adding the above as a snippet, but I'm still not sure if we want to advertise this prominently. There's some situations where this is useful, but generally we don't have a great usecase for it. Not sure about this 🤔
Checklist
main
build: rerun.io/viewernightly
build: rerun.io/viewerCHANGELOG.md
and the migration guideTo run all checks from
main
, comment on the PR with@rerun-bot full-check
.