MCPcopy
hub / github.com/pytorch/vision / _make_transform_sample

Function _make_transform_sample

test/test_transforms_v2.py:286–351  ·  view source on GitHub ↗
(transform, *, image_or_video, adapter)

Source from the content-addressed store, hash-verified

284
285
286def _make_transform_sample(transform, *, image_or_video, adapter):
287 device = image_or_video.device if isinstance(image_or_video, torch.Tensor) else "cpu"
288 size = F.get_size(image_or_video)
289 input = dict(
290 image_or_video=image_or_video,
291 image_tv_tensor=make_image(size, device=device),
292 video_tv_tensor=make_video(size, device=device),
293 image_pil=make_image_pil(size),
294 bounding_boxes_xyxy=make_bounding_boxes(size, format=tv_tensors.BoundingBoxFormat.XYXY, device=device),
295 bounding_boxes_xywh=make_bounding_boxes(size, format=tv_tensors.BoundingBoxFormat.XYWH, device=device),
296 bounding_boxes_cxcywh=make_bounding_boxes(size, format=tv_tensors.BoundingBoxFormat.CXCYWH, device=device),
297 bounding_boxes_degenerate_xyxy=tv_tensors.BoundingBoxes(
298 [
299 [0, 0, 0, 0], # no height or width
300 [0, 0, 0, 1], # no height
301 [0, 0, 1, 0], # no width
302 [2, 0, 1, 1], # x1 > x2, y1 < y2
303 [0, 2, 1, 1], # x1 < x2, y1 > y2
304 [2, 2, 1, 1], # x1 > x2, y1 > y2
305 ],
306 format=tv_tensors.BoundingBoxFormat.XYXY,
307 canvas_size=size,
308 device=device,
309 ),
310 bounding_boxes_degenerate_xywh=tv_tensors.BoundingBoxes(
311 [
312 [0, 0, 0, 0], # no height or width
313 [0, 0, 0, 1], # no height
314 [0, 0, 1, 0], # no width
315 [0, 0, 1, -1], # negative height
316 [0, 0, -1, 1], # negative width
317 [0, 0, -1, -1], # negative height and width
318 ],
319 format=tv_tensors.BoundingBoxFormat.XYWH,
320 canvas_size=size,
321 device=device,
322 ),
323 bounding_boxes_degenerate_cxcywh=tv_tensors.BoundingBoxes(
324 [
325 [0, 0, 0, 0], # no height or width
326 [0, 0, 0, 1], # no height
327 [0, 0, 1, 0], # no width
328 [0, 0, 1, -1], # negative height
329 [0, 0, -1, 1], # negative width
330 [0, 0, -1, -1], # negative height and width
331 ],
332 format=tv_tensors.BoundingBoxFormat.CXCYWH,
333 canvas_size=size,
334 device=device,
335 ),
336 keypoints=make_keypoints(canvas_size=size),
337 detection_mask=make_detection_masks(size, device=device),
338 segmentation_mask=make_segmentation_mask(size, device=device),
339 int=0,
340 float=0.0,
341 bool=True,
342 none=None,
343 str="str",

Callers 1

Calls 7

make_imageFunction · 0.90
make_videoFunction · 0.90
make_image_pilFunction · 0.90
make_bounding_boxesFunction · 0.90
make_keypointsFunction · 0.90
make_detection_masksFunction · 0.90
make_segmentation_maskFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…