TextRecognitionDataGenerator icon indicating copy to clipboard operation
TextRecognitionDataGenerator copied to clipboard

Changing the "generate" method parameters to accept meaningful strings.

Open somso2e opened this issue 2 years ago • 0 comments

Parameters of generate, such as distorsion_type only accept integers as input which is not very user-friendly considering there is still no documentations. I had to dig through the code to figure out what each number meant.

I'd suggest something like this as an example:


ACCEPTABLE_DISTORSION_TYPES =  ["none", "sine", "cosine", "random"]
if distorsion_type not in ACCEPTABLE_DISTORSION_TYPES or distorsion_type not in range(4):
    raise ValueError(
        "Specefied distorsion type {} is not valid.".format(distorsion_type))
if isinstance(distorsion_type,int):
    distorsion_type=ACCEPTABLE_DISTORSION_TYPES[distorsion_type]
...

if distorsion_type == "none":
    distorted_img = rotated_img  # Mind = blown
    distorted_mask = rotated_mask
elif distorsion_type == "sine":
    distorted_img, distorted_mask = distorsion_generator.sin(
        rotated_img,
        rotated_mask,
        vertical=(distorsion_orientation == 0 or distorsion_orientation == 2),
        horizontal=(distorsion_orientation == 1 or distorsion_orientation == 2),
    )
...

I would happily make the PR myself but I wanted the devs opinion before starting.

somso2e avatar Jan 03 '23 11:01 somso2e