From 3b06ef615a8db67a03927576e0c12fbfb2501f5f Mon Sep 17 00:00:00 2001 From: aktersnurra Date: Mon, 14 Sep 2020 22:15:47 +0200 Subject: Fixed CTC loss. --- src/text_recognizer/datasets/transforms.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/text_recognizer/datasets/transforms.py (limited to 'src/text_recognizer/datasets/transforms.py') diff --git a/src/text_recognizer/datasets/transforms.py b/src/text_recognizer/datasets/transforms.py new file mode 100644 index 0000000..17231a8 --- /dev/null +++ b/src/text_recognizer/datasets/transforms.py @@ -0,0 +1,13 @@ +"""Transforms for PyTorch datasets.""" +import numpy as np +from PIL import Image +import torch +from torch import Tensor + + +class Transpose: + """Transposes the EMNIST image to the correct orientation.""" + + def __call__(self, image: Image) -> np.ndarray: + """Swaps axis.""" + return np.array(image).swapaxes(0, 1) -- cgit v1.2.3-70-g09d2