HongwenZhang / PyMAF-X

[TPAMI 2023] PyMAF-X: Towards Well-aligned Full-body Model Regression from Monocular Images
https://www.liuyebin.com/pymaf-x
Other
224 stars 28 forks source link

I ran into this problem when running a demo with my own video #18

Open zbc-l opened 1 year ago

zbc-l commented 1 year ago

ValueError: Caught ValueError in DataLoader worker process 2.Original Traceback (most recent call last): File"/home/tia/anaconda3/envs/pymafx/tib/python3.8/site-packageline 287,in _worker_loopdata = fetcher .fetch(index)_utils/fetch.py", line 44,in fetchFile "/home/tia/anaconda3/envs/pymafx/lib/python3.8/site-packagesdata = [self.datasetlidx] for idx in possibly_batched indexFile "/home/lia/anaconda3/envs/pymafx/lib/python3.8/site-packages/torch/utils/data/utils/fetch.py", line 44, in <listcomp3data = [self.dataset[idx] for idx in possiblybatched index]File "/home/lia/projects/PyMAF-X-smplx/datasets/inference.py", line 291,in --getitem-img_part, -, crop_shape = self.rg-processing(img_orig, center_part, scale_part, [constants.IM6_RES, constants.IM6_RESJ)File "/home/lia/projects/PyMAF-X-smplx/datasets/inference.py", line 124, in rgb_processingcrop_img_resized, crop_img, crop_shape = crop(rgb_img, center, scale, res, rot=rot)File"/home/lia/projects/PyMAF-X-smplx/utils/imutils.py",line 89,in cropnew_img[new_y[o]:new_y[1],new_x[o]:new_x[1]] = img[old_y[o]:old_y[1l,ValueError: could not broadcast input array from shape (12,358,3) into shape (12,0,3)

lithiumice commented 1 year ago

I had the same problem. I wonder there are some bug in this version of the code

hrx20000209 commented 10 months ago

I meet this problem too.

hrx20000209 commented 10 months ago

I have solved this problem by addint this code to the utils/imutils.py:

def crop(img, center, scale, res, rot=0):
    # ...

    # Range to fill new array
    new_x = max(0, -ul[0]), min(br[0], len(img[0])) - ul[0]
    new_y = max(0, -ul[1]), min(br[1], len(img)) - ul[1]
    # Range to sample from original image
    old_x = max(0, ul[0]), min(len(img[0]), br[0])
    old_y = max(0, ul[1]), min(len(img), br[1])

    a, b = min(new_y[0], new_y[1]), max(new_y[0], new_y[1])
    c, d = min(new_x[0], new_x[1]), max(new_x[0], new_x[1])
    e, f = min(old_y[0], old_y[1]), max(old_y[0], old_y[1])
    g, h = min(old_x[0], old_x[1]), max(old_x[0], old_x[1])

    new_img[a:b, c:d] = img[e:f, g:h]

    # new_img[new_y[0]:new_y[1], new_x[0]:new_x[1]] = img[old_y[0]:old_y[1], old_x[0]:old_x[1]]
    # ...

    return new_img_resized, new_img, new_shape