Getting "cannot write mode RGBA as JPEG" with Object Detection

Hi,

While using the Open Source Object Detection ML Skill I receive the following error for some images:

"> KeyError: ‘RGBA’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/home/aicenter/.local/lib/python3.8/site-packages/UiPath_core/plugin.py”, line 156, in _model_predict
output = self.model.predict(processed_data)
File “/microservice/main.py”, line 59, in predict
images.save(image_path)
File “/home/aicenter/.local/lib/python3.8/site-packages/PIL/Image.py”, line 2320, in save
save_handler(self, fp, filename)
File “/home/aicenter/.local/lib/python3.8/site-packages/PIL/JpegImagePlugin.py”, line 632, in _save
raise OSError(f"cannot write mode {im.mode} as JPEG") from e
OSError: cannot write mode RGBA as JPEG"

Should I add some logic to detect the image properties and convert it to another format before processing? or there is any kind of parameter to set?

Thanks in Advance

@hgaber105

May I know the steps you have performed and where you got his error exactly?

cheers

1 Like

Hi @Anil_G ,

The error raised by MLSkill Activity
image

The error is raised for some images not all of them. It seems it can not read the image or it is expected a specific property.
By the way I’ve tested the same set of images with UiPath’s ImageClassification package and it did not raise any errors.

Thanks for any hints.

@hgaber105
Can you test the skill first with any image

Also is currentimage.Tostring giving fullpath to string?

Cheers

Hi Anil,

The whole process is working as expected except few images. I’ve tested it tens of time and it works fine except for few images.

Thanks

@hgaber105

Looks like the issue with jpeg images…try saving them as png and then check if the issue is resolved

Cheers

1 Like

Thanks a lot for the hint. In fact the files were in png, when I saved them as jpg the issue resolved.

Thanks a lot for your support.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.