Skip to content

Commit

Permalink
Fix tracking_hf example: put scaled thing under its own root entity (#…
Browse files Browse the repository at this point in the history
…2419)

### What
Before:

![image](https://github.com/rerun-io/rerun/assets/1148717/5308685e-9a70-43aa-85ca-fc7d7bc2e00a)

After:

![image](https://github.com/rerun-io/rerun/assets/1148717/398857ef-3d08-4ef9-8018-cb79ae4ee4bf)

### 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)

<!-- This line will get updated when the PR build summary job finishes.
-->
PR Build Summary: https://build.rerun.io/pr/2419

<!-- pr-link-docs:start -->
Docs preview: https://rerun.io/preview/501a2c6/docs
Examples preview: https://rerun.io/preview/501a2c6/examples
<!-- pr-link-docs:end -->
  • Loading branch information
emilk committed Jun 15, 2023
1 parent 37ee89d commit 50230d8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions examples/python/tracking_hf_opencv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ def detect_objects_to_track(self, rgb: npt.NDArray[np.uint8], frame_idx: int) ->
_, _, scaled_height, scaled_width = inputs["pixel_values"].shape
scaled_size = (scaled_width, scaled_height)
rgb_scaled = cv.resize(rgb, scaled_size)
rr.log_image("image/scaled/rgb", rgb_scaled)
rr.log_disconnected_space("image/scaled") # Note: Haven't implemented 2D transforms yet.
rr.log_image("image_scaled/rgb", rgb_scaled)

logging.debug("Pass image to detection network")
outputs = self.model(**inputs)
Expand All @@ -99,7 +98,7 @@ def detect_objects_to_track(self, rgb: npt.NDArray[np.uint8], frame_idx: int) ->
)[0]

mask = segmentation_mask.detach().cpu().numpy().astype(np.uint8)
rr.log_segmentation_image("image/scaled/segmentation", mask)
rr.log_segmentation_image("image_scaled/segmentation", mask)

boxes = detections["boxes"].detach().cpu().numpy()
class_ids = detections["labels"].detach().cpu().numpy()
Expand Down Expand Up @@ -130,7 +129,7 @@ def log_detections(self, boxes: npt.NDArray[np.float32], class_ids: list[int], t
thing_boxes = boxes[things_np, :]
thing_class_ids = class_ids_np[things_np]
rr.log_rects(
"image/scaled/detections/things",
"image_scaled/detections/things",
thing_boxes,
rect_format=rr.log.rects.RectFormat.XYXY,
class_ids=thing_class_ids,
Expand All @@ -139,7 +138,7 @@ def log_detections(self, boxes: npt.NDArray[np.float32], class_ids: list[int], t
background_boxes = boxes[~things_np, :]
background_class_ids = class_ids[~things_np]
rr.log_rects(
"image/scaled/detections/background",
"image_scaled/detections/background",
background_boxes,
rect_format=rr.log.rects.RectFormat.XYXY,
class_ids=background_class_ids,
Expand Down

0 comments on commit 50230d8

Please sign in to comment.