Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: could not broadcast input array #10

Closed
Kirstihly opened this issue Mar 14, 2023 · 3 comments
Closed

ValueError: could not broadcast input array #10

Kirstihly opened this issue Mar 14, 2023 · 3 comments

Comments

@Kirstihly
Copy link

Thank you for sharing the code base. However, I have tried folders of images or videos but they all raise weird ValueError: could not broadcast input array from shape (N,M,3) into shape (N,0,3).

According to the error message, I've already checked that new_img[new_y[0]:new_y[1], new_x[0]:new_x[1]] and img[old_y[0]:old_y[1], old_x[0]:old_x[1]] are of the same shape. It would be very much appreciated if anyone can provide me with any idea why this error is happening. Thank you!

Running reconstruction on each tracklet...                                                                                                 
  0%|                                                                                                               | 0/42 [00:00<?, ?it/s]
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)                                           
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)                                           
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)                                           
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)                                           
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)                                           
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)                                           
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
[W pthreadpool-cpp.cc:90] Warning: Leaking Caffe2 thread-pool after fork. (function pthreadpool)
/root/anaconda3/envs/pymafx/lib/python3.8/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at  /opt/conda/conda-bld/pytorch_1623448278899/work/c10/core/TensorImpl.h:1156.)
  return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
 29%|█████████████████████████████▏                                                                        | 12/42 [00:15<00:38,  1.29s/it]
Traceback (most recent call last): 
  File "/root/anaconda3/envs/pymafx/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/root/anaconda3/envs/pymafx/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Documents/PyMAF-X/apps/demo_smplx.py", line 604, in <module> 
    run_demo(args)
  File "/Documents/PyMAF-X/apps/demo_smplx.py", line 308, in run_demo 
    for batch in tqdm(dataloader): 
  File "/root/anaconda3/envs/pymafx/lib/python3.8/site-packages/tqdm/std.py", line 1178, in __iter__
    for obj in iterable:
  File "/root/anaconda3/envs/pymafx/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 521, in __next__
    data = self._next_data()
  File "/root/anaconda3/envs/pymafx/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1183, in _next_data
    return self._process_data(data)
  File "/root/anaconda3/envs/pymafx/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data
    data.reraise()
  File "/root/anaconda3/envs/pymafx/lib/python3.8/site-packages/torch/_utils.py", line 425, in reraise
    raise self.exc_type(msg)
ValueError: Caught ValueError in DataLoader worker process 12.
Original Traceback (most recent call last):
  File "/root/anaconda3/envs/pymafx/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
    data = fetcher.fetch(index)
  File "/root/anaconda3/envs/pymafx/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/root/anaconda3/envs/pymafx/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/Documents/PyMAF-X/datasets/inference.py", line 291, in __getitem__
    img_part, _, crop_shape = self.rgb_processing(img_orig, center_part, scale_part, [constants.IMG_RES, constants.IMG_RES])
  File "/Documents/PyMAF-X/datasets/inference.py", line 124, in rgb_processing
    crop_img_resized, crop_img, crop_shape = crop(rgb_img, center, scale, res, rot=rot)
  File "/Documents/PyMAF-X/utils/imutils.py", line 89, in crop
    new_img[new_y[0]:new_y[1], new_x[0]:new_x[1]] = img[old_y[0]:old_y[1],
ValueError: could not broadcast input array from shape (24,1917,3) into shape (24,0,3)
@HongwenZhang
Copy link
Owner

Hi, it seems that the image can not be cropped correctly. Which sample are you using in the demo? You may need to print the values of rgb_img.shape, and center, scale for debugging.
crop_img_resized, crop_img, crop_shape = crop(rgb_img, center, scale, res, rot=rot)

@Kirstihly
Copy link
Author

Kirstihly commented Mar 19, 2023

Hi, it seems that the image can not be cropped correctly. Which sample are you using in the demo? You may need to print the values of rgb_img.shape, and center, scale for debugging. crop_img_resized, crop_img, crop_shape = crop(rgb_img, center, scale, res, rot=rot)

I see. Thank you! I'm using my own dataset and removing some of the noisy frames fixed it.

@hrx20000209
Copy link

Hi! Have you fixed it? I meet the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants