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

Fix tracking_hf example: put scaled thing under its own root entity #2419

Merged
merged 1 commit into from
Jun 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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