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

ValueError: image has wrong mode #246

Open
xuanzhiliu opened this issue Jul 29, 2022 · 1 comment
Open

ValueError: image has wrong mode #246

xuanzhiliu opened this issue Jul 29, 2022 · 1 comment

Comments

@xuanzhiliu
Copy link

Hi,I faced a problem when I used:
p.random_color(probability=0.6,min_factor=50,max_factor=120)
p.random_brightness(probability=0.8,min_factor=50,max_factor=255)
the error was:
image
image
however,if I deleted these codes and used other functions like rotate90,rotate270 or random_erasing,the codes worked very well
My codes are as follow:
import Augmentor p=Augmentor.Pipeline("H:\\text\imgs") p.ground_truth("H:\\text\jsons\mask_png") p.rotate(probability=1,max_left_rotation=25,max_right_rotation=25) p.random_color(probability=0.6,min_factor=50,max_factor=120) p.random_brightness(probability=0.8,min_factor=50,max_factor=255) p.random_erasing(probability=1,rectangle_area=0.5) p.sample(50)
Thank you !

@xuanzhiliu
Copy link
Author

xuanzhiliu commented Jul 29, 2022

Hi,I have solved this problem,here is my solution:
I used this method(random_color and random_brightness) to do data augmentation during the semantic segmentation,at first I try to augment both the original images.png and the mask.png so that this problem occured
However, the mask.png shouldn't and unnecessary to be augmented because the objects's location and shape and size isn't changed(except rotate and cutout),so that I deleted the codes:
p.ground_truth()
then the codes worked pretty
After that I got the reason why I can't changed the mask.png,due to the reason that the mode of the mask.png is 'L',which means:
mask.mode=='L',you can use the code to check it
However,the question is,only the imgs which mode is 'RGB' can be used in the image.py,I don't know why and have no idea to solve it.So,if you faced this problem,here are two ways can be taken into consideration:
1.check your img.mode and make sure they are'RGB' not others,like 'P','L'
2.make sure your imgs are png, this is important.I tryed to use jpg,jpeg in all the methods and all of them have bugs
I hope my advice can help you solve your problem
good luck!

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

1 participant