From 24c5d10a67b3dcfc82697ed37db3f5639e259892 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Sat, 10 Feb 2024 12:30:59 +0000 Subject: [PATCH] Add docstring to `untransform_image` --- ocrs_models/datasets/util.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ocrs_models/datasets/util.py b/ocrs_models/datasets/util.py index 58bede2..8ceef4f 100644 --- a/ocrs_models/datasets/util.py +++ b/ocrs_models/datasets/util.py @@ -36,6 +36,12 @@ def transform_image(img: torch.Tensor) -> torch.Tensor: def untransform_image(img: torch.Tensor) -> torch.Tensor: + """ + Invert the transforms done by `transform_image`. + + :param img: CHW tensor with pixel values in [-0.5, 0.5] + :return: 8-bit CHW tensor with values in [0, 255] + """ return ((img + 0.5) * 255.0).type(torch.uint8)