Skip to content

Commit

Permalink
Adjusted class names / param names for current version
Browse files Browse the repository at this point in the history
  • Loading branch information
Thelukepet committed Sep 21, 2023
1 parent 1317a5b commit 0cb14df
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/api/batch_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def create_model(model_path: str,
- Logs various messages regarding the model and utility initialization.
"""

from Model import CERMetric, WERMetric, CTCLoss
from model import CERMetric, WERMetric, CTCLoss
from utils import Utils

logger = logging.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions tests/data/sample_list.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/home/tim/Documents/development/loghi-htr/tests/data/test-image1.png bleek cum annexis, staande en gelegen op den Nieuwenbildt
/home/tim/Documents/development/loghi-htr/tests/data/test-image2.png de voorleden jaarse pagters van de aankomende
/home/tim/Documents/development/loghi-htr/tests/data/test-image3.png 138
/home/luke/ai_development/rvankoert/loghi/loghi-htr/tests/data/test-image1.png bleek cum annexis, staande en gelegen op den Nieuwenbildt
/home/luke/ai_development/rvankoert/loghi/loghi-htr/tests/data/test-image2.png de voorleden jaarse pagters van de aankomende
/home/luke/ai_development/rvankoert/loghi/loghi-htr/tests/data/test-image3.png 138
16 changes: 8 additions & 8 deletions tests/test_datagenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class TestDataGenerator(unittest.TestCase):
"""
Tests for the DataGeneratorNew2 class.
Tests for the data_generator class.
Test coverage:
1. `test_initialization` tests that the instance variables are
Expand Down Expand Up @@ -45,18 +45,18 @@ def setUpClass(cls):
src_dir = os.path.join(project_root, "src")
sys.path.append(src_dir)

from DataGeneratorNew2 import DataGeneratorNew2
cls.DataGenerator = DataGeneratorNew2
from data_generator import DataGenerator
cls.DataGenerator = DataGenerator

from utils import Utils
cls.utils = Utils

def test_initialization(self):
utils = self.utils(chars="ABC", use_mask=False)
dg = self.DataGenerator(utils=utils, batchSize=32, height=128)
dg = self.DataGenerator(utils=utils, batch_size=32, height=128)

# Verify that the instance variables are initialized correctly.
self.assertEqual(dg.batchSize, 32)
self.assertEqual(dg.batch_size, 32)
self.assertEqual(dg.height, 128)
self.assertEqual(dg.do_binarize_sauvola, False)
self.assertEqual(dg.do_binarize_otsu, False)
Expand All @@ -72,7 +72,7 @@ def test_initialization(self):
def test_elastic_transform(self, mock_deform_grid, mock_random_normal):
# Create an instance of DataGeneratorNew2
utils = self.utils(chars="ABC", use_mask=False)
dg = self.DataGenerator(utils=utils, batchSize=32, height=128)
dg = self.DataGenerator(utils=utils, batch_size=32, height=128)

# Mock return value for tf.random.normal
mock_random_normal.return_value = np.zeros((2, 3, 3))
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_load_with_distort(self, *mocks):
utils = self.utils(chars="mock", use_mask=False)

height = 128
dg = self.DataGenerator(utils=utils, batchSize=32,
dg = self.DataGenerator(utils=utils, batch_size=32,
height=height, distort_jpeg=True)

# Call the function
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_load_with_random_width(self, mock_uniform, mock_shape, *mocks):
# Create an instance of DataGeneratorNew2
height = 128
utils = self.utils(chars="mock", use_mask=False)
dg = self.DataGenerator(utils=utils, batchSize=32,
dg = self.DataGenerator(utils=utils, batch_size=32,
height=height, random_width=True)

# Call the function
Expand Down
14 changes: 7 additions & 7 deletions tests/test_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class DataLoaderTest(unittest.TestCase):
Test Coverage:
1. `test_initialization`: Checks the correct instantiation of the
DataLoaderNew class and its default values.
DataLoader class and its default values.
2. `test_create_data_simple`: Checks if the create_data function
works as expected.
3. `test_missing_files`: Tests the behavior when data lists contain
references to non-existent files.
4. `test_unsupported_chars`: Validates the handling of labels with
unsupported characters.
5. `test_inference_mode`: Checks the DataLoaderNew"s behavior in
5. `test_inference_mode`: Checks the DataLoader"s behavior in
inference mode.
6. `test_text_normalization`: Verifies the correct normalization of
text labels.
Expand Down Expand Up @@ -72,8 +72,8 @@ def setUpClass(cls):
cls.sample_labels):
f.write(f"{img_path}.png\t{label}\n")

from DataLoaderNew import DataLoaderNew
cls.DataLoader = DataLoaderNew
from data_loader import DataLoader
cls.DataLoader = DataLoader

from utils import Utils
cls.Utils = Utils
Expand Down Expand Up @@ -106,9 +106,9 @@ def test_initialization(self):
"DataLoader not instantiated correctly")

# Check the values
self.assertEqual(data_loader.batchSize, batch_size,
f"batchSize not set correctly. Expected: "
f"{batch_size}, got: {data_loader.batchSize}")
self.assertEqual(data_loader.batch_size, batch_size,
f"batch_size not set correctly. Expected: "
f"{batch_size}, got: {data_loader.batch_size}")
self.assertEqual(data_loader.imgSize, img_size,
f"imgSize not set correctly. Expected: "
f"{img_size}, got: {data_loader.imgSize}")
Expand Down

0 comments on commit 0cb14df

Please sign in to comment.