[docs]classConvertBoundingBoxFormat(Transform):"""[BETA] Convert bounding box coordinates to the given ``format``, eg from "CXCYWH" to "XYXY". .. v2betastatus:: ConvertBoundingBoxFormat transform Args: format (str or datapoints.BoundingBoxFormat): output bounding box format. Possible values are defined by :class:`~torchvision.datapoints.BoundingBoxFormat` and string values match the enums, e.g. "XYXY" or "XYWH" etc. """_transformed_types=(datapoints.BoundingBox,)def__init__(self,format:Union[str,datapoints.BoundingBoxFormat])->None:super().__init__()ifisinstance(format,str):format=datapoints.BoundingBoxFormat[format]self.format=formatdef_transform(self,inpt:datapoints.BoundingBox,params:Dict[str,Any])->datapoints.BoundingBox:returnF.convert_format_bounding_box(inpt,new_format=self.format)# type: ignore[return-value]
[docs]classConvertDtype(Transform):"""[BETA] Convert input image or video to the given ``dtype`` and scale the values accordingly. .. v2betastatus:: ConvertDtype transform This function does not support PIL Image. Args: dtype (torch.dtype): Desired data type of the output .. note:: When converting from a smaller to a larger integer ``dtype`` the maximum values are **not** mapped exactly. If converted back and forth, this mismatch has no effect. Raises: RuntimeError: When trying to cast :class:`torch.float32` to :class:`torch.int32` or :class:`torch.int64` as well as for trying to cast :class:`torch.float64` to :class:`torch.int64`. These conversions might lead to overflow errors since the floating point ``dtype`` cannot store consecutive integers over the whole range of the integer ``dtype``. """_v1_transform_cls=_transforms.ConvertImageDtype_transformed_types=(is_simple_tensor,datapoints.Image,datapoints.Video)def__init__(self,dtype:torch.dtype=torch.float32)->None:super().__init__()self.dtype=dtypedef_transform(self,inpt:Union[datapoints._TensorImageType,datapoints._TensorVideoType],params:Dict[str,Any])->Union[datapoints._TensorImageType,datapoints._TensorVideoType]:returnF.convert_dtype(inpt,self.dtype)
# We changed the name to align it with the new naming scheme. Still, `ConvertImageDtype` is# prevalent and well understood. Thus, we just alias it without deprecating the old name.ConvertImageDtype=ConvertDtype
[docs]classClampBoundingBox(Transform):"""[BETA] Clamp bounding boxes to their corresponding image dimensions. The clamping is done according to the bounding boxes' ``spatial_size`` meta-data. .. v2betastatus:: ClampBoundingBox transform """_transformed_types=(datapoints.BoundingBox,)def_transform(self,inpt:datapoints.BoundingBox,params:Dict[str,Any])->datapoints.BoundingBox:returnF.clamp_bounding_box(inpt)# type: ignore[return-value]
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.