face3d
face3d copied to clipboard
Issue about ValueError: Images of type float must be between -1 and 1
I downloaded 300W-3D dataset which contains .jpg and corresponding .mat files. When I launch script in 8_generate_posmap_300WLP.py on this dataset, on some items I get following error (on the line of saving an image, representing uv position map):
ValueError: Images of type float must be between -1 and 1
Why does it happen? I also tried to make values of such failing image by rerranging its values. It helps to save but saved uv position map image does not seem like uv position map: it's mostly black.
How to fix it?
Partly fixed it by deleting code which applies random perturbation to input data. Number of successed examples doubled :)
can you tell me how to fix it in detail, I am troubled in this problems! Thank you~!
@wqz960 in 8_generate_posmap_300WLP.py there are lines for applying random perturbation for data:
marg = old_size*0.1
t_x = np.random.rand()*marg*2 - marg
t_y = np.random.rand()*marg*2 - marg
center[0] = center[0]+t_x; center[1] = center[1]+t_y
size = size*(np.random.rand()*0.2 + 0.9)
I just commented this. These lines modify parameters, which are used for cropping input image. Theoretically, these lines may be used for data augmentation.
Do you mean to delete these lines? I just viewed the code. the part seems to make data argument, if i delete that part, I will get the uv position map of the original image, is it what you mean? Thank you for your kind help!!! @FelixFox
@FelixFox Deleted these lines but also failed.
@wqz960 I also wrapped code in several functions and used try: except:. So some items of the dataset are processed and some not (the same error with ValueError). I can send you a modified version of the script which can be used on the whole dataset folder.
can you give me the script? my email is [email protected]! thank you very much! @FelixFox
@FelixFox I try your method. almost 60% images fail to process. ... :( what about your code?
@wqz960 in 8_generate_posmap_300WLP.py there are lines for applying random perturbation for data:
marg = old_size*0.1t_x = np.random.rand()*marg*2 - margt_y = np.random.rand()*marg*2 - margcenter[0] = center[0]+t_x; center[1] = center[1]+t_ysize = size*(np.random.rand()*0.2 + 0.9)I just commented this. These lines modify parameters, which are used for cropping input image. Theoretically, these lines may be used for data augmentation.
@wqz960 in 8_generate_posmap_300WLP.py there are lines for applying random perturbation for data:
marg = old_size*0.1t_x = np.random.rand()*marg*2 - margt_y = np.random.rand()*marg*2 - margcenter[0] = center[0]+t_x; center[1] = center[1]+t_ysize = size*(np.random.rand()*0.2 + 0.9)I just commented this. These lines modify parameters, which are used for cropping input image. Theoretically, these lines may be used for data augmentation.
i just changed
max(image_h, image_w)
to
max(image_h, image_w, np.max(uv_position_map))
i think it because of the rotation,some verties out of 256
I have fixed this problem: use 'cv2.imwrite()' instead of 'io.imsave()'
Lossy conversion from float64 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning.
Lossy conversion from float32 to uint8. Range [-7.8455047607421875, 101.833984375]. Convert image to uint8 prior to saving to suppress this warning.
