elyha7 / yoloface

Yolov5 Face Detection
GNU General Public License v3.0
120 stars 37 forks source link

How to use it together with a vertical photo? #4

Closed coalus closed 2 years ago

coalus commented 2 years ago

Hi! Firstly, thank you so much for such a convenient wrapper, you saved a lot of time, thank you again! When trying to "drive away" a vertical photo, unfortunately I encounter an error

RuntimeError: Given groups=1, weight of size [32, 3, 3, 3], expected input[1, 4, 608, 608] to have 3 channels, but got 4 channels instead

I will be glad to help, thanks a lot in advance! Have a nice day :D

elyha7 commented 2 years ago

Model works fine with vertical photos. In your case, you probably have RGBA image with 4 channels instead of RGB with 3 channels. Try something like this to convert you image to rgb:

from PIL import Image
import numpy as np

rgba_image = Image.open(path_to_image)
rgb_image = rgba_image.convert('RGB')
image_numpy = np.array(rgb_image)
coalus commented 2 years ago

Ok, спасибо большое за столь быстрый ответ, глупейший вопрос задал, еще раз большое спасибо!