Skip to content

Commit

Permalink
Fix warnings and errors introduced with new versions of tensorflow an…
Browse files Browse the repository at this point in the history
…d skimage
  • Loading branch information
andbue committed Oct 23, 2023
1 parent 13b544b commit 9c8fb00
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,6 @@ def _compute_current_cer_on_validation_set(self, count):
def generate_cer():
it = iter(self.data_gen)
for _ in range(count):
yield np.mean(self.predict_func(next(it))[0])
yield np.mean(self.predict_func(next(it)[0])[0])

return np.mean([cer for cer in tqdm_wrapper(generate_cer(), total=count, progress_bar=self.progress_bar, desc="Early stopping") if np.isfinite(cer)])
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ def on_epoch_end(self, epoch, logs):

def _generate(self, count):
it = iter(self.data_gen)
cer, target, decoded = zip(*[self.predict_func(next(it)) for _ in range(count)])
cer, target, decoded = zip(*[self.predict_func(next(it)[0]) for _ in range(count)])
return np.mean(cer), sum(map(sparse_to_lists, target), []), sum(map(sparse_to_lists, decoded), [])
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def train(self, dataset, validation_dataset, checkpoint_params, text_post_proc,
else:
val_dataset_gen = None

predict_func = K.function({t.op.name: t for t in [self.input_data, self.input_length, self.input_params, self.targets, self.targets_length]}, [self.cer, self.sparse_targets, self.sparse_decoded])
predict_func = K.function({t.name: t for t in [self.input_data, self.input_length, self.input_params, self.targets, self.targets_length]}, [self.cer, self.sparse_targets, self.sparse_decoded])
steps_per_epoch = max(1, int(dataset.epoch_size() / checkpoint_params.batch_size))
v_cb = VisCallback(training_callback, self.codec, dataset_gen, predict_func, checkpoint_params, steps_per_epoch, text_post_proc)
es_cb = EarlyStoppingCallback(training_callback, self.codec, val_dataset_gen, predict_func, checkpoint_params,
Expand Down
2 changes: 1 addition & 1 deletion calamari_ocr/ocr/data_processing/center_normalizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from scipy.ndimage import filters
import scipy.ndimage as filters
from calamari_ocr.ocr.data_processing.data_preprocessor import DataPreprocessor
from calamari_ocr.ocr.data_processing.scale_to_height_processor import ScaleToHeightProcessor

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from calamari_ocr.ocr.data_processing.data_preprocessor import DataPreprocessor
from calamari_ocr.proto import DataPreprocessorParams
from scipy.ndimage import interpolation
import scipy.ndimage as interpolation


class ScaleToHeightProcessor(DataPreprocessor):
Expand Down
3 changes: 3 additions & 0 deletions calamari_ocr/test/test_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def __init__(self):
# self.checkpoint = sorted(glob_all([os.path.join(this_dir, "..", "..", "..", "calamari_models/antiqua_modern/*.ckpt.json")]))
self.processes = 1
self.batch_size = 1
self.beam_width = 25
self.dictionary = False
self.dataset_pad = 0
self.verbose = True
self.voter = "confidence_voter_default_ctc"
self.output_dir = None
Expand Down

0 comments on commit 9c8fb00

Please sign in to comment.