Pytorch-yolov3: Varying the number of input channels

Created on 27 Jan 2020  路  3Comments  路  Source: eriklindernoren/PyTorch-YOLOv3

Thank you for the great work!
I got it working for my greyscale images since they are expanded to a three dimensional RGB image. But I wondered if its possible to simply change the code so the pipeline takes only one channel and computes faster (or even multiple channels > 3 for detection of 3D objects in series of concatenated Images).
And if yes, where do I have to change the code?

Thanks for the help!

Most helpful comment

For processing single channel below changes should be done in the code

  1. Changechannels=1 in config/yolov3-custom.cfg
  2. Update line 47 and 86 in utils/datasets.py with desired image conversion mode
img = transforms.ToTensor()(Image.open(img_path).convert('1'))

https://pillow.readthedocs.io/en/stable/handbook/concepts.html#concept-modes

All 3 comments

how to solve it?

For processing single channel below changes should be done in the code

  1. Changechannels=1 in config/yolov3-custom.cfg
  2. Update line 47 and 86 in utils/datasets.py with desired image conversion mode
img = transforms.ToTensor()(Image.open(img_path).convert('1'))

https://pillow.readthedocs.io/en/stable/handbook/concepts.html#concept-modes

For point 2, the following change worked for me

img = transforms.ToTensor()(Image.open(img_path)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghimiredhikura picture ghimiredhikura  路  4Comments

hezhangubc picture hezhangubc  路  4Comments

MAP
nationalflag picture nationalflag  路  5Comments

codeyogi911 picture codeyogi911  路  4Comments

mylife126 picture mylife126  路  3Comments