-
|
Hi all, This is a very strange issue. I trained a model using Ultralytics on SAHI sliced dataset and set the gray jpg image channel as 1: The model seemed to be good. However, when I predict on gray png images using SAHI, there is a dilemma: If I directly pass the gray picture, it went error: Given groups=1, weight of size [64, 1, 3, 3], expected input[1, 3, 1280, 1280] to have 1 channels, but got 3 channels instead; I dont know what I should pass... My code: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
I test Ultralytics prediction, it works well on cpu/gpu for gray image but it can not work for BGR image: When I input a gray image (4096, 4096, 1) to SAHI, the line 3308 of Image.py would cause error: Cannot handle this data type: (1, 1, 1) When I input a (4096, 4096) image to SAHI, the line 85 of ultralytics.py would cause error: too many indices for array: array is 2-dimensional, but 3 were indexed When I input a (4096, 4096, 3) image to SAHI, it would cause the same error above: Given groups=1, weight of size [64, 1, 3, 3], expected input[1, 3, 1280, 1280] to have 1 channels, but got 3 channels instead YOLO does not expect numpy arrays to have BGR, I think this might be a bug? |
Beta Was this translation helpful? Give feedback.
-
|
So I solved this issue by modifying line 85 of ultralytics.py to |
Beta Was this translation helpful? Give feedback.
So I solved this issue by modifying line 85 of ultralytics.py to
prediction_result = self.model(image[:, :], **kwargs) # YOLO does not expect numpy arrays to have BGR