summaryrefslogtreecommitdiff
path: root/src/text_recognizer/datasets/iam_paragraphs_dataset.py
diff options
context:
space:
mode:
authoraktersnurra <gustaf.rydholm@gmail.com>2020-12-07 22:54:04 +0100
committeraktersnurra <gustaf.rydholm@gmail.com>2020-12-07 22:54:04 +0100
commit25b5d6983d51e0e791b96a76beb7e49f392cd9a8 (patch)
tree526ba739714b3d040f7810c1a6be3ff0ba37fdb1 /src/text_recognizer/datasets/iam_paragraphs_dataset.py
parent5529e0fc9ca39e81fe0f08a54f257d32f0afe120 (diff)
Segmentation working!
Diffstat (limited to 'src/text_recognizer/datasets/iam_paragraphs_dataset.py')
-rw-r--r--src/text_recognizer/datasets/iam_paragraphs_dataset.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/text_recognizer/datasets/iam_paragraphs_dataset.py b/src/text_recognizer/datasets/iam_paragraphs_dataset.py
index c1e8fe2..8ba5142 100644
--- a/src/text_recognizer/datasets/iam_paragraphs_dataset.py
+++ b/src/text_recognizer/datasets/iam_paragraphs_dataset.py
@@ -1,4 +1,5 @@
"""IamParagraphsDataset class and functions for data processing."""
+import random
from typing import Callable, Dict, List, Optional, Tuple, Union
import click
@@ -71,13 +72,18 @@ class IamParagraphsDataset(Dataset):
data = self.data[index]
targets = self.targets[index]
+ seed = np.random.randint(SEED)
+ random.seed(seed) # apply this seed to target tranfsorms
+ torch.manual_seed(seed) # needed for torchvision 0.7
if self.transform:
data = self.transform(data)
+ random.seed(seed) # apply this seed to target tranfsorms
+ torch.manual_seed(seed) # needed for torchvision 0.7
if self.target_transform:
targets = self.target_transform(targets)
- return data, targets
+ return data, targets.long()
@property
def ids(self) -> Tensor: