Skip to content

Unable to convert image from 4 to 3 channels #32

@ZzhengSyna

Description

@ZzhengSyna

Running python -m vision.object_detect /home/personWithBoard.png with a 4-channel png will result in the below error:

(.venv) xxx:/home/examples# python -m vision.object_detect /home/personWithBoard.png           
/home/examples/.venv/lib/python3.10/site-packages/synapRT/pipelines/__init__.py:16: UserWarning: Audio classification pipeline not available, please ensure all dependencies are installed:
librosa is required for audio classification pipelines, install with 'pip install librosa'.
  warnings.warn(msg)
Starting Object Detection Stream.
E:SyNAP: assign():180: Unable to convert image from 4 to 3 channels
E:SyNAP: assign():371: Failed to assign data to input tensor 0
Traceback (most recent call last):
  File "/home/examples/.venv/lib/python3.10/site-packages/synapRT/pipelines/base.py", line 185, in _execute_pipeline
    self._runner.run()
  File "/home/examples/.venv/lib/python3.10/site-packages/synapRT/pipelines/runners.py", line 482, in run
    self._infer_func([image])
  File "/home/examples/.venv/lib/python3.10/site-packages/synapRT/pipelines/base.py", line 208, in _infer
    inputs = self.preprocess(data)
  File "/home/examples/.venv/lib/python3.10/site-packages/synapRT/pipelines/base.py", line 506, in preprocess
    self._assigned_rect = self.preprocessor.assign(
RuntimeError: Error while preprocessing data

In the above test, the format of the picture is RGBA.
If I manually convert this png to 3 channels and retry, the command will work well.

I think we should optimize the code to support the 4-channel picture.

Attach the test pictures, one is with 4 channels, the other is with 3:
Image
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions