augraphy
augraphy copied to clipboard
TypeError: Augmentation.should_run() missing 1 required positional argument: 'self'
python3.12 augraphy 8.2.6
from augraphy import *
import cv2
import numpy as np
ink_phase = [InkShifter]
paper_phase = [VoronoiTessellation(p=1)]
post_phase = [GlitchEffect]
pipeline = AugraphyPipeline(ink_phase=ink_phase, paper_phase=paper_phase, post_phase=post_phase)
image = np.full((1200, 1200,3), 250, dtype="uint8")
cv2.putText(
image,
"Lorem ipsum dolor sit amet, consectetur adipiscing elit",
(80, 250),
cv2.FONT_HERSHEY_SIMPLEX,
1.2,
0,
3,
)
augmented_image = pipeline(image)
cv2.imshow("input image", image)
cv2.imshow("augmented",augmented_image)
augmented_image = pipeline(image)
^^^^^^^^^^^^^^^
File "D:\anaconda3\envs\py312\Lib\site-packages\augraphy\base\augmentationpipeline.py", line 859, in __call__
return self.augment(image, return_dict=0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\anaconda3\envs\py312\Lib\site-packages\augraphy\base\augmentationpipeline.py", line 213, in augment
data = self.augment_single_image(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\anaconda3\envs\py312\Lib\site-packages\augraphy\base\augmentationpipeline.py", line 375, in augment_single_image
self.apply_phase(data, layer="ink", phase=self.ink_phase)
File "D:\anaconda3\envs\py312\Lib\site-packages\augraphy\base\augmentationpipeline.py", line 737, in apply_phase
if augmentation.should_run():
^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Augmentation.should_run() missing 1 required positional argument: 'self'
Hi, you should have a parentheses () after each augmentation because we are creating a class instance. Using it without the parentheses is actually pointing to the class instead of initializing a class instance. You can try:
ink_phase = [InkShifter()]
paper_phase = [VoronoiTessellation(p=1)]
post_phase = [GlitchEffect()]
https://augraphy.readthedocs.io/en/latest/doc/source/how_augraphy_works.html This should be modified to the correct code
Thanks for your help