PRNet icon indicating copy to clipboard operation
PRNet copied to clipboard

I got some issues while generating depth image

Open shanjianwu opened this issue 5 years ago • 13 comments

I got the following issue when I try to generate my own depth image: RuntimeError: Unsupported image type, must be 8bit gray or RGB image. I wouldn't get this issue if I use pictures from the web, but once I use my own picture which is screenshot this issue will happen. Do you know how to solve this problem?

shanjianwu avatar Apr 04 '20 03:04 shanjianwu

It should be a bug of skimage.rescale.

wenbinTse avatar Jun 17 '20 10:06 wenbinTse

@wenbinTse

@shanjianwu

Traceback (most recent call last): File "E:/yzu/lab/face anti spoofing/PRNet-master/demo.py", line 168, in main(parser.parse_args()) File "E:/yzu/lab/face anti spoofing/PRNet-master/demo.py", line 56, in main pos = prn.process(image) # use dlib to detect face File "E:\yzu\lab\face anti spoofing\PRNet-master\api.py", line 101, in process detected_faces = self.dlib_detect(image) File "E:\yzu\lab\face anti spoofing\PRNet-master\api.py", line 55, in dlib_detect return self.face_detector(image, 1) RuntimeError: Unsupported image type, must be 8bit gray or RGB image.

i always get this error, when i tried for the depth map

can you please help me to explain it?

Thanks in advance

punitha-valli avatar Jul 29 '20 08:07 punitha-valli

RuntimeError: Unsupported image type, must be 8bit gray or RGB image.

@wenbinTse @shanjianwu @ksachdeva

How to overcome this error?

Thanks in advance

punitha-valli avatar Jul 29 '20 15:07 punitha-valli

It's should be a bug of skimage.rescale. You can try another version of skimage or use cv2.resize like me.

wenbinTse avatar Jul 29 '20 15:07 wenbinTse

Really happy for your response, Thank you so much

But this shape changes, is happens at the But api.py at line 58,

Def dlib_detect(self,image):

Self.face_detector Return self.face_detector(image,1)

When I print and see at here ,... The image size is like (1000,562,2). But the input image size is (1920,1080,3).

Can you please tell me where did you changed the size of the image Thanks in advance.

On Wed 29 Jul, 2020, 11:06 PM wenbin, [email protected] wrote:

It's should be a bug of skimage.rescale. You can try another version of skimage or use cv2.resize like me.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/YadiraF/PRNet/issues/172#issuecomment-665720704, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMM7B26ZJO6UXFWBRKFKIA3R6A3HRANCNFSM4L47GOQQ .

punitha-valli avatar Jul 30 '20 04:07 punitha-valli

@wenbinTse Really happy for your response, Thank you so much

But this shape changes is happening at the But api.py at line 58,

Def dlib_detect(self,image):

Self.face_detector Return self.face_detector(image,1)

When I print and see here,... The image size is like (1000,562,2). But the input image size is (1920,1080,3).

Can you please tell me where did you change the size of the image Thanks in advance.

punitha-valli avatar Jul 30 '20 09:07 punitha-valli

@wenbinTse

The shape changes because of the output_shape, and its scale. It has a value of 1.567 and makes a round-off and its changing into 2. But we need 3 to carry out the code

scale = np.atleast_1d(scale) if len(scale) > 1: if ((not multichannel and len(scale) != image.ndim) or (multichannel and len(scale) != image.ndim - 1)): raise ValueError("Supply a single scale, or one value per spatial " "axis") if multichannel: scale = np.concatenate((scale, [1])) orig_shape = np.asarray(image.shape) output_shape = np.round(scale * orig_shape)

punitha-valli avatar Jul 30 '20 09:07 punitha-valli

Sorry, I don't remember the details and my code is on the server which is unavailable now.

wenbinTse avatar Jul 30 '20 10:07 wenbinTse

@wenbinTse

Can you please tell me the size, because when I choose (256,256) so my image size will be (256,256,3), I am not getting any depth map, my depth_map value is full of 0 (zeros). and then I tried with (1000,562) as (1000,562,3) still, the values remain zero. And then I get one error as Bad allocation

punitha-valli avatar Jul 31 '20 02:07 punitha-valli

@wenbinTse , Thank you so much, for your kind response,...

Can you please tell me the size, because when I choose (256,256) so my image size will be (256,256,3), I am not getting any depth map, my depth_map value is full of 0 (zeros). and then I tried with (1000,562) as (1000,562,3) still, the values remain zero. And then I get one error as Bad allocation.

When I display and see the values of the depth_map, which is fully zeros (0), I am quite confused about it.

Thanks in advance

punitha-valli avatar Aug 01 '20 05:08 punitha-valli

It should be a bug of skimage.rescale.

same problem here: https://github.com/YadiraF/PRNet/pull/154#issue-329571724

关于

if max_size> 1000:
    image = rescale(image, 1000./max_size)
    image = (image*255).astype(np.uint8)

可能出现的问题

The rescale algorithm will be called with maxsize>1000 and the size of the channels will be reduced from 3 to 2.

This should be because the rescale algorithm thinks that the third channel also needs to rescale

The solution is to set multichannel flag to True:

image = rescale(image, 1000./max_size, multichannel=True)

ikalista avatar Apr 24 '21 00:04 ikalista

in scikit_image-0.20.0,it is Invalid because of “rescale() got an unexpected keyword argument 'multichannel'” image = rescale(image, 1000./max_size, multichannel=True)

TheSleepGod avatar Mar 30 '23 14:03 TheSleepGod

in scikit_image-0.20.0,it is Invalid because of “rescale() got an unexpected keyword argument 'multichannel'” image = rescale(image, 1000./max_size, multichannel=True)

Please use channel_axis instead

TheSleepGod avatar Mar 30 '23 14:03 TheSleepGod