summaryrefslogtreecommitdiff
path: root/tests/support/create_iam_lines_support_files.py
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2022-02-06 23:23:02 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2022-02-06 23:23:02 +0100
commit41b2ff656b927aee53549cba564dfd872ff4c9d2 (patch)
tree8965e254cdabea09482fe81a0a2190ebbe1a8407 /tests/support/create_iam_lines_support_files.py
parente3aad99e8bb672740bb47cba5a073f087a1eaa90 (diff)
chore: remove support files for old tests
Diffstat (limited to 'tests/support/create_iam_lines_support_files.py')
-rw-r--r--tests/support/create_iam_lines_support_files.py50
1 files changed, 0 insertions, 50 deletions
diff --git a/tests/support/create_iam_lines_support_files.py b/tests/support/create_iam_lines_support_files.py
deleted file mode 100644
index 50f9e3d..0000000
--- a/tests/support/create_iam_lines_support_files.py
+++ /dev/null
@@ -1,50 +0,0 @@
-"""Module for creating IAM Lines test support files."""
-# flake8: noqa
-from pathlib import Path
-import shutil
-
-import numpy as np
-
-from text_recognizer.datasets import IamLinesDataset
-import text_recognizer.util as util
-
-
-SUPPORT_DIRNAME = Path(__file__).parents[0].resolve() / "iam_lines"
-
-
-def create_emnist_lines_support_files() -> None:
- """Create IAM Lines test images."""
- shutil.rmtree(SUPPORT_DIRNAME, ignore_errors=True)
- SUPPORT_DIRNAME.mkdir()
-
- # TODO: maybe have to add args to dataset.
- dataset = IamLinesDataset(
- init_token="<sos>",
- pad_token="_",
- eos_token="<eos>",
- transform=[{"type": "ToTensor", "args": {}}],
- target_transform=[
- {
- "type": "AddTokens",
- "args": {"init_token": "<sos>", "pad_token": "_", "eos_token": "<eos>"},
- }
- ],
- )
- dataset.load_or_generate_data()
-
- for index in [0, 1, 3]:
- image, target = dataset[index]
- if len(image.shape) == 3:
- image = image.squeeze(0)
- print(image.sum(), image.dtype)
-
- label = "".join(dataset.mapper(label) for label in target[1:]).strip(
- dataset.mapper.pad_token
- )
- print(label)
- image = image.numpy()
- util.write_image(image, str(SUPPORT_DIRNAME / f"{label}.png"))
-
-
-if __name__ == "__main__":
- create_emnist_lines_support_files()