yolov5-net icon indicating copy to clipboard operation
yolov5-net copied to clipboard

Can not work with Gray images

Open MrXin95 opened this issue 3 years ago • 7 comments

When I tested, I found that the input gray image(8bit) can not work. Is it necessary to add the code that converts the gray image(8bit) into RGB image(24bit)? SharedScreenshot

MrXin95 avatar Nov 02 '21 07:11 MrXin95

@MrXin95 can you provide test image? for now it works with rgb images, maybe I'll add auto-convertion.

kkarahainko avatar Nov 02 '21 09:11 kkarahainko

0

0 image

I've tested that any image with a bit depth of 8 doesn't work. Because the images processed in the code are RGB images (24bit) The first is the image I need to test, and the second is the gray image I download freely on the Internet

MrXin95 avatar Nov 03 '21 00:11 MrXin95

I use OpenCvSharp4.Windows to solve it.

                Mat mat = new Mat(img_root, ImreadModes.Color);      //read any images witch RGB mode

                using var image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat);    //convert mat to bitmap

                List<YoloPrediction> predictions = scorer.Predict(image);

However, I found that the prediction speed of the model almost did not change, but the speed of drawing the prediction box was a few seconds slow. At first, I thought that the incoming original image was in image format, and the image I converted was in bitmap format, but after I converted bitmap to image format, the drawing speed did not increase. What other good methods do you have?

MrXin95 avatar Nov 03 '21 05:11 MrXin95

@MrXin95 thanks, model trained on 8bit images? (as I know its not supported in yolov5 as well)

kkarahainko avatar Nov 03 '21 10:11 kkarahainko

Yes, I trained model with 8-bit images, because in my project, the image provided by the camera is like this. The images in the model are indeed three channels, but yolov5 can automatically convert 8-bit images into 24bit before training. You can have a try. We can train the model with 8bit images, and the test is also no problem in python with them.

MrXin95 avatar Nov 04 '21 00:11 MrXin95

Yes, I trained model with 8-bit images, because in my project, the image provided by the camera is like this. The images in the model are indeed three channels, but yolov5 can automatically convert 8-bit images into 24bit before training. You can have a try. We can train the model with 8bit images, and the test is also no problem in python with them.

兄弟,你用自己的模型测试图片,一张图大概多长时间?

kankanjiuzou123 avatar Jan 10 '22 08:01 kankanjiuzou123

Yes, I trained model with 8-bit images, because in my project, the image provided by the camera is like this. The images in the model are indeed three channels, but yolov5 can automatically convert 8-bit images into 24bit before training. You can have a try. We can train the model with 8bit images, and the test is also no problem in python with them.

兄弟,你用自己的模型测试图片,一张图大概多长时间?

纯推理二十几毫秒,加上前后处理一百多毫秒

MrXin95 avatar Jan 10 '22 08:01 MrXin95