1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How do you use resize augmentations with albumentations?

Discussão em 'Python' iniciado por Stack, Setembro 14, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to resize an image with albumentations and came across this roboflow tutorial and copied the code exactly.

    import albumentations as A
    import cv2

    image = cv2.imread("img.jpg")

    pipeline = A.Compose([
    A.Resize(height=640, width=640, p=1),
    ])

    augmented_image = pipeline(image=image)["image"]

    cv2.imwrite("augmented_image.jpg", augmented_image)


    However, when I run it I get the following error:

    Traceback (most recent call last):
    File "/Users/user/Documents/test.py", line 16, in <module>
    augmented_image = pipeline(image=image)["image"]
    ^^^^^^^^^^^^^^^^^^^^^
    File "/Users/user/anaconda3/envs/venv/lib/python3.12/site-packages/albumentations/core/composition.py", line 334, in __call__
    self.preprocess(data)
    File "/Users/user/anaconda3/envs/venv/lib/python3.12/site-packages/albumentations/core/composition.py", line 363, in preprocess
    self._check_args(**data)
    File "/Users/user/anaconda3/envs/venv/lib/python3.12/site-packages/albumentations/core/composition.py", line 412, in _check_args
    raise TypeError(f"{data_name} must be numpy array type")
    TypeError: image must be numpy array type


    I have confirmed with type(image) that it is a <class 'numpy.ndarray'>

    I have also tried with different images and both jpgs and pngs

    Any ideas?

    Continue reading...

Compartilhe esta Página