MCPcopy Create free account
hub / github.com/Gabesarch/ICAL / plot_object_tracks

Function plot_object_tracks

TEACh/utils/plot_utils.py:276–306  ·  view source on GitHub ↗
(samples, unique_obj_instance, boxes,B,S,M,W,H, idx=0)

Source from the content-addressed store, hash-verified

274 ax.set_zlabel("y axis")
275
276def plot_object_tracks(samples, unique_obj_instance, boxes,B,S,M,W,H, idx=0):
277 image_mean = torch.tensor([0.485,0.456,0.406]).reshape(1,1,3,1,1).to(device)
278 image_std = torch.tensor([0.229,0.224,0.225]).reshape(1,1,3,1,1).to(device)
279 images = samples.tensors.reshape(B,S,3,W,H) * image_std + image_mean
280 images = images * 255
281 images = images.permute(0,1,3,4,2)
282 images = images.cpu().numpy().astype(np.int32)
283 plt.figure(1); plt.clf()
284 unique_obj_instance_b = unique_obj_instance[idx]
285 color = (0, 255, 0)
286 rect_th = 1
287 for idx2 in range(1,len(unique_obj_instance_b[0])):
288 boxes_b = boxes[idx]
289 image_b = images[idx].copy()
290 where_objs = torch.where(unique_obj_instance_b[1]==idx2)[0]
291 s_ind = where_objs//M
292 box_ind = where_objs%M
293 for idx3 in range(len(where_objs)):
294 box = boxes_b[s_ind[idx3],box_ind[idx3]] #.cpu().numpy()
295 box = box_ops.box_cxcywh_to_xyxy(box)
296 box[[0,2]] = box[[0,2]] * W
297 box[[1,3]] = box[[1,3]] * H
298 box = box.cpu().numpy()
299 rgb = np.float32(image_b[s_ind[idx3]].copy())
300 cv2.rectangle(rgb, (int(box[0]), int(box[1])), (int(box[2]), int(box[3])),color, rect_th)
301 image_b[s_ind[idx3]] = rgb
302 for s in range(S):
303 plt.figure(1); plt.clf()
304 plt.imshow(image_b[s])
305 plt.savefig(f'data/images/object_tracks/track_s{s}_{idx2}.png')
306 st()
307

Callers

nothing calls this directly

Calls 1

toMethod · 0.45

Tested by

no test coverage detected