importtorchfrom._bounding_boxesimportBoundingBoxes,BoundingBoxFormatfrom._imageimportImagefrom._maskimportMaskfrom._torch_function_helpersimportset_return_typefrom._tv_tensorimportTVTensorfrom._videoimportVideo# TODO: Fix this. We skip this method as it leads to# RecursionError: maximum recursion depth exceeded while calling a Python object# Until `disable` is removed, there will be graph breaks after all calls to functional transforms
[docs]@torch.compiler.disabledefwrap(wrappee,*,like,**kwargs):"""Convert a :class:`torch.Tensor` (``wrappee``) into the same :class:`~torchvision.tv_tensors.TVTensor` subclass as ``like``. If ``like`` is a :class:`~torchvision.tv_tensors.BoundingBoxes`, the ``format`` and ``canvas_size`` of ``like`` are assigned to ``wrappee``, unless they are passed as ``kwargs``. Args: wrappee (Tensor): The tensor to convert. like (:class:`~torchvision.tv_tensors.TVTensor`): The reference. ``wrappee`` will be converted into the same subclass as ``like``. kwargs: Can contain "format" and "canvas_size" if ``like`` is a :class:`~torchvision.tv_tensor.BoundingBoxes`. Ignored otherwise. """ifisinstance(like,BoundingBoxes):returnBoundingBoxes._wrap(wrappee,format=kwargs.get("format",like.format),canvas_size=kwargs.get("canvas_size",like.canvas_size),)else:returnwrappee.as_subclass(type(like))
Docs
Access comprehensive developer documentation for PyTorch
To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.