svip-lab / impersonator

PyTorch implementation of our ICCV 2019 paper: Liquid Warping GAN: A Unified Framework for Human Motion Imitation, Appearance Transfer and Novel View Synthesis
https://svip-lab.github.io/project/impersonator
Other
1.72k stars 317 forks source link

IndexError: tensors used as indices must be long, byte or bool tensors #5

Closed JinglUO703 closed 4 years ago

JinglUO703 commented 4 years ago

G`476VFFL)UXJP `R{9LRDK

fuzuoyi commented 4 years ago

res[indices.cpu().numpy()] = updates that will work

StevenLiuWen commented 4 years ago

@JinglUO703

  1. The fast way is

    res[indices.long()] = updates
  2. (Optional way) Also, since indices here are not dynamic index, np.ndarray might be better in compatibility. It can be fixed by following codes:

    
    # indices = torch.from_numpy(np.reshape(
    #     np.reshape(np.arange(0, batch_size) * 9, [-1, 1]) + col_inds,
    #     newshape=(-1,))).to(device)

For better compatibility, since if indices is torch.tensor, it must be long dtype.

For fixed index, np.ndarray might be better.

indices = np.reshape(np.reshape(np.arange(0, batch_size) * 9, [-1, 1]) + col_inds, newshape=(-1, ))


We will fix this soon, and the solution proposed by @fuzuoyi is also feasible.
JinglUO703 commented 4 years ago

res[indices.cpu().numpy()] = updates 那可行

JinglUO703 commented 4 years ago

res[indices.cpu().numpy()] = updates 那可行

Thanks,at first I thought it was numpy version

JinglUO703 commented 4 years ago

@ JinglUO703

  1. 快速的方法是
res [indices.long()] =更新
  1. (可选方式)而且,由于indices这里不是动态索引,因此np.ndarray的兼容性可能更好。可以通过以下代码进行修复:
#索引= torch.from_numpy(np.reshape(
#      np.reshape(np.arange(0,batch_size)* 9,[-1,1])+ col_inds,
#      newshape =(-1,)))。to(设备)

#为了更好的兼容性,由于索引为torch.tensor,因此必须为long dtype。
#对于固定索引,np.ndarray可能更好。
指数 = np.reshape(np.reshape(np.arange( 0,的batch_size) *  9,[ - 1, 1 ]) + col_inds, newshape =( - 1))

我们将尽快修复此问题,@ fuzuoyi提出的解决方案也是可行的。

3Q,I have solved this problem through @fuzuoyi method.