Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Augmentation.should_run() missing 1 required positional argument: 'self' #447

Open
monkeycc opened this issue Dec 7, 2024 · 2 comments

Comments

@monkeycc
Copy link

monkeycc commented Dec 7, 2024

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'
@kwcckw
Copy link
Collaborator

kwcckw commented Dec 7, 2024

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()]

@monkeycc
Copy link
Author

monkeycc commented Dec 7, 2024

https://augraphy.readthedocs.io/en/latest/doc/source/how_augraphy_works.html
This should be modified to the correct code

Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants