yolov3-tf2 icon indicating copy to clipboard operation
yolov3-tf2 copied to clipboard

Use of pure grayscale images

Open RobbStarkAustria opened this issue 4 years ago • 2 comments

Hi,

I use this yolo implementation for the detection of a lot of small objects (200 - 400) on images sized 960x960. I converted the images to grayscale for better detection results. Detection will be done also with grayscale images.

To use this images in this implementation I convert the grayscale images back to RGB, so I have more dimensions that I need. Training is then more memory consuming than necessary.

How do I have to modify the code to train and detect pure grayscale images?

Thank you in advance!

RobbStarkAustria avatar Jul 31 '20 05:07 RobbStarkAustria

@RobbStarkAustria Hey, first of all you should change the following line from the training file

model = YoloV3(image_size, channels=3, training=True, classes=num_classes)

In this line you have to decrease the channels from 3 to 1. In addition, you have to change the channels in the models.py file so that the 3 channels are always reduced to 1. I hope that this approach is sufficient for you to implement the changes.

johnny-mueller avatar Aug 05 '20 15:08 johnny-mueller

Hi @RobbStarkAustria , I know this is already an old issue, but as it is still open, I will comment how I made training on gray scale (or any number of channels actually) images possible for me:

  1. as @johnny-mueller johnny-mueller said, in train.py add a channels parameter to the YoloV3 call.
  2. in dataset.py change the signature of parse_tfrecord to include the channels parameter and set the channels accordingly in adjust x_train = tf.image.decode_jpeg(x['image/encoded'], channels=channels)
  3. for training from scratch: in models.py adjust darknet function to include the channels parameter and set the channels accordingly in x = inputs = Input([None, None, channels])

I think you can only do transfer learning from darknet with channel=3, as it was trained on rgb images

linaouro avatar Nov 17 '20 14:11 linaouro