0

I want to apply augmentation methods to my image. For this, I chose codes from this website https://pytorch.org/vision/stable/transforms.html

image = cv2.imread('image.png')

augmentation = torch.nn.Sequential(
    torchvision.transforms.RandomGrayscale(.5), 
    torchvision.transforms.RandomVerticalFlip(.5)
)
cv.imwrite('test.png', augmentation)

Unfortunately, it doesn't work. I hope someone can help me here. Thank You

I'mahdi
  • 23,382
  • 5
  • 22
  • 30
Interpreter67
  • 57
  • 2
  • 6
  • What is the error? Secondly, try using `cv2` instead of just **cv** – Deshwal Jun 20 '22 at 14:19
  • `error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'imwrite' > Overload resolution failed: > - img is not a numpy array, neither a scalar > - Expected Ptr for argument 'img'` – Interpreter67 Jun 20 '22 at 14:42
  • What do you expect `cv.imwrite('test.png', augmentation)` exactly? Please read your code again, this doesn't make any sense, you are trying to write a function as an image. – Ivan Jun 20 '22 at 14:54
  • @Deshwal no. use `import cv2 as cv` – Christoph Rackwitz Jun 20 '22 at 22:35

0 Answers0