YuliangXiu / ECON

[CVPR'23, Highlight] ECON: Explicit Clothed humans Optimized via Normal integration
https://xiuyuliang.cn/econ
Other
1.1k stars 105 forks source link

I got IndexError but i have no idea what is problem #10

Closed JinEui-Kim closed 1 year ago

JinEui-Kim commented 1 year ago
Traceback (most recent call last):
  File "/home/td/anaconda3/envs/econ/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/td/anaconda3/envs/econ/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/td/Project/ECON/apps/infer.py", line 116, in <module>
    for data in pbar:
  File "/home/td/anaconda3/envs/econ/lib/python3.8/site-packages/tqdm/std.py", line 1195, in __iter__
    for obj in iterable:
  File "/home/td/Project/ECON/lib/dataset/TestDataset.py", line 178, in __getitem__
    arr_dict = process_image(img_path, self.hps_type, self.single, 512, self.detector)
  File "/home/td/Project/ECON/lib/common/imutils.py", line 152, in process_image
    img_raw, (in_height, in_width) = load_img(img_file)
  File "/home/td/Project/ECON/lib/common/imutils.py", line 60, in load_img
    return torch.tensor(img).permute(2, 0, 1).unsqueeze(0).float(), img.shape[:2]
TypeError: can't convert np.ndarray of type numpy.uint16. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.

the first error i met is above. so i changed the code (/lib/common/imutils.py - line 60)

return torch.tensor(img).permute(2, 0, 1).unsqueeze(0).float(), img.shape[:2]
->
return torch.tensor(img.astype(np.int32)).permute(2, 0, 1).unsqueeze(0).float(), img.shape[:2]

Then I infered png image that size is (3840,2160) extracted from mp4 video, but i got error.

(econ) td@td-AI-server:~/Project/ECON$ CUDA_VISIBLE_DEVICES=1 python -m apps.infer -cfg ./configs/econ.yaml -in_dir /data/ECON/frames/ -out_dir /data/ECON/result
Resume Normal Estimator from  ./data/ckpt/normal.ckpt 
Complete with  SMPL-X (Explicit) 
SMPL-X estimate with  PIXIE 
Dataset Size: 2763
  0%|                                                                                                                                         | 0/2763 [00:00<?, ?it/s]
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Body Fitting -- normal: 0.000 | silhouette: 0.076 | joint: 0.000 | Total: 0.076| loose:1, occluded:0: 100%|████████████████████████████| 50/50 [00:27<00:00,  1.80it/s]
frame00001:   0%|                                                                                                                             | 0/2763 [05:01<?, ?it/s]
Traceback (most recent call last):
  File "/home/td/anaconda3/envs/econ/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/td/anaconda3/envs/econ/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/td/Project/ECON/apps/infer.py", line 433, in <module>
    BNI_object.extract_surface(False)
  File "/home/td/Project/ECON/lib/common/BNI.py", line 45, in extract_surface
    bni_result = double_side_bilateral_normal_integration(
  File "/home/td/Project/ECON/lib/common/BNI_utils.py", line 608, in double_side_bilateral_normal_integration
    vertices_front, faces_front = remove_stretched_faces(vertices_front, faces_front)
  File "/home/td/Project/ECON/lib/common/BNI_utils.py", line 119, in remove_stretched_faces
    faces_cam_angles = np.dot(mesh.face_normals, camera_ray)
  File "/home/td/anaconda3/envs/econ/lib/python3.8/site-packages/trimesh/base.py", line 340, in face_normals
    triangles=self.triangles,
  File "/home/td/anaconda3/envs/econ/lib/python3.8/site-packages/trimesh/caching.py", line 139, in get_cached
    value = function(*args, **kwargs)
  File "/home/td/anaconda3/envs/econ/lib/python3.8/site-packages/trimesh/base.py", line 782, in triangles
    triangles = self.vertices.view(np.ndarray)[self.faces]
IndexError: index 0 is out of bounds for axis 0 with size 0

here is my environment ubuntu 20.04.5 LTS Ryzen 5900x NVIDIA RTX A6000 48GB CUDA 11.6 and other libraries installed following your installation script. did i miss something?

YuliangXiu commented 1 year ago

Would you mind sharing the testing image with me?

JinEui-Kim commented 1 year ago

I found the reason why this problem occured. The image was 16bit image, so the image pixel value has range of 0~65535. hint was the first error

TypeError: can't convert np.ndarray of type numpy.uint16

therefore, i change the imread parameter (delete the FLAG)

img = cv2.imread(img_file, cv2.IMREAD_UNCHANGED)
->
img = cv2.imread(img_file)

then img pixel value has range of 0~255, and inference is no problem.

JinEui-Kim commented 1 year ago

I find better way to inference 16-bit image, so i pull request to your repository.