-
-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
Hello! Thanks for good library for doc augmentations.
I faced problem with bounding boxes. When I run augraphy pipeline with bounding boxes and there is the OneOf inside it crashes. When I delete OneOf everything works well.
import random
import numpy as np
from src.augmentations import get_augmentation_phases
import augraphy
from PIL import Image, ImageDraw
ink_phase_one_of = [
augraphy.OneOf(
[
augraphy.Dithering(
dither=random.choice(["ordered", "floyd-steinberg"]),
order=(3, 5),
),
augraphy.InkBleed(
intensity_range=(0.1, 0.2),
kernel_size=random.choice([(7, 7), (5, 5), (3, 3)]),
severity=(0.4, 0.6),
),
],
p=1,
),
]
ink_phase = [
augraphy.Dithering(
dither=random.choice(["ordered", "floyd-steinberg"]),
order=(3, 5),
),
augraphy.InkBleed(
intensity_range=(0.1, 0.2),
kernel_size=random.choice([(7, 7), (5, 5), (3, 3)]),
severity=(0.4, 0.6),
),
]
image = Image.open('data/im_2.png')
bounding_boxes = [
[150, 90, 235, 105],
[150, 150, 298, 170]
]
pipeline = augraphy.AugraphyPipeline(
bounding_boxes=bounding_boxes,
log=True,
paper_phase=[],
ink_phase=ink_phase_one_of,
post_phase=[],
pre_phase=[])
output = pipeline.augment(np.array(image))Error log:
Traceback (most recent call last):
File "/home/dedoc/shevtsov/WordPaletteDocumenter/test_aug.py", line 50, in <module>
output = pipeline.augment(np.array(image))
File "/home/dedoc/.virtualenvs/wpd/lib/python3.10/site-packages/augraphy/base/augmentationpipeline.py", line 213, in augment
data = self.augment_single_image(
File "/home/dedoc/.virtualenvs/wpd/lib/python3.10/site-packages/augraphy/base/augmentationpipeline.py", line 375, in augment_single_image
self.apply_phase(data, layer="ink", phase=self.ink_phase)
File "/home/dedoc/.virtualenvs/wpd/lib/python3.10/site-packages/augraphy/base/augmentationpipeline.py", line 758, in apply_phase
result, mask, keypoints, bounding_boxes = result
ValueError: not enough values to unpack (expected 4, got 2)
It seems like augmentationpipeline.py:754 line should filter OneOf and AugmentationSequence objects. However, both of them are children of Augmentation class. isinstance(augmentation, Augmentation) is True when augmentation variable is OneOf or AugmentationSequence and this objects are not filtered.
Metadata
Metadata
Assignees
Labels
No labels