yolov3-tf2
yolov3-tf2 copied to clipboard
Use of pure grayscale images
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 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.
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:
- as @johnny-mueller johnny-mueller said, in train.py add a channels parameter to the
YoloV3
call. - in dataset.py change the signature of
parse_tfrecord
to include the channels parameter and set the channels accordingly inadjust x_train = tf.image.decode_jpeg(x['image/encoded'], channels=channels)
- for training from scratch: in models.py adjust
darknet
function to include the channels parameter and set the channels accordingly inx = 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