Skip to content

Commit

Permalink
ocr.dataset.data: provide predefined element_length_fn for pipeline.b…
Browse files Browse the repository at this point in the history
…ucket_boundaries
  • Loading branch information
bertsky committed Oct 2, 2024
1 parent f0139d6 commit 27a055e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion calamari_ocr/ocr/dataset/data.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import logging
import os
from typing import Type, Optional
from typing import Callable, Dict, Type, Optional

import tensorflow as tf
from tfaip.util.tftyping import AnyTensor
from tfaip.data.data import DataBase
from tfaip.data.databaseparams import DataPipelineParams
from tfaip.data.pipeline.datapipeline import DataPipeline
Expand Down Expand Up @@ -84,6 +85,11 @@ def _target_layer_specs(self):
"gt_len": tf.TensorSpec([1], dtype=tf.int32),
}

def element_length_fn(self) -> Callable[[Dict[str, AnyTensor]], AnyTensor]:
def img_len(x):
return x["img_len"]
return img_len

def create_pipeline(
self,
pipeline_params: DataPipelineParams,
Expand Down

0 comments on commit 27a055e

Please sign in to comment.