Does not support images with an alpha channel

#11
by entityinarray - opened
Traceback (most recent call last):
  File "/home/user/app/app.py", line 76, in websocket_handler
    res = await engine.load_image(msg.data)
  File "/home/user/.local/lib/python3.10/site-packages/async_lru/__init__.py", line 294, in __call__
    return await self.__wrapper(self.__instance, *fn_args, **fn_kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/async_lru/__init__.py", line 227, in __call__
    return await asyncio.shield(fut)
  File "/home/user/app/engine.py", line 73, in load_image
    crop_info = await asyncio.to_thread(self.live_portrait.cropper.crop_single_image, img_rgb)
  File "/usr/lib/python3.10/asyncio/threads.py", line 25, in to_thread
    return await loop.run_in_executor(None, func_call)
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/user/app/liveportrait/utils/cropper.py", line 73, in crop_single_image
    src_face = self.face_analysis_wrapper.get(
  File "/home/user/app/liveportrait/utils/face_analysis_diy.py", line 47, in get
    bboxes, kpss = self.det_model.detect(img_bgr, max_num=max_num, metric='default')
  File "/home/user/app/liveportrait/utils/dependencies/insightface/model_zoo/retinaface.py", line 222, in detect
    det_img[:new_height, :new_width, :] = resized_img
ValueError: could not broadcast input array from shape (352,512,4) into shape (352,512,3)

You could fix this by removing the alpha channel from the image

Thank you @entityinarray , I think this new update should fix it:
https://huggingface.co/spaces/jbilcke-hf/FacePoke/commit/1a40fccab736d775eaffe2713fdc5286743022ab

I've deployed this fix to production

does that solve the issue when you try with your image?

I will close this issue as normally this is now now fixed, it should not come back

but do not hesitate to re-open a new one if you see any other problem

jbilcke-hf changed discussion status to closed

Sign up or log in to comment