yuangan / EAT_code

Official code for ICCV 2023 paper: "Efficient Emotional Adaptation for Audio-Driven Talking-Head Generation".
Other
269 stars 30 forks source link

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part. #26

Closed lililuya closed 5 months ago

lililuya commented 5 months ago

Hi,thanks for your great work , I‘ve encountered a problem when I use my own image for testing in the proceeding of extract_keypoints. The error sources from the function extract_keypoints in part of "np.save(file_path, [kc, he])", it reminds that "NumPy requires that all elements of a multi-dimensional array have the same shape." To find out the dim problem, I use the provided image latent npy file, the dim for the he are "yaw(1, 66)、pitch(1, 66)、roll(1, 66)、t(1, 3)、exp(1, 45)" When in testing , I also print the dim, It's exactly the same dim, but can't save the npy file, it seems only can use pkl for saving.

Python version 3.9.19 Numpy version 1.23.5 in /home/miniconda3/envs/EAT/lib/python3.9/site-packages/numpy/lib/npyio.py


def save(file, arr, allow_pickle=True, fix_imports=True):
    if hasattr(file, 'write'):
        file_ctx = contextlib.nullcontext(file)
    else:
        file = os_fspath(file)
        if not file.endswith('.npy'):
            file = file + '.npy'
        file_ctx = open(file, "wb")

    with file_ctx as fid:
        arr = np.asanyarray(arr)  # call error
        format.write_array(fid, arr, allow_pickle=allow_pickle,
                           pickle_kwargs=dict(fix_imports=fix_imports))
lililuya commented 5 months ago

Hi,thanks for your great work , I‘ve encountered a problem when I use my own image for testing in the proceeding of extract_keypoints. The error sources from the function extract_keypoints in part of "np.save(file_path, [kc, he])", it reminds that "NumPy requires that all elements of a multi-dimensional array have the same shape." To find out the dim problem, I use the provided image latent npy file, the dim for the he are "yaw(1, 66)、pitch(1, 66)、roll(1, 66)、t(1, 3)、exp(1, 45)" When in testing , I also print the dim, It's exactly the same dim, but can't save the npy file, it seems only can use pkl for saving.

Python version 3.9.19 Numpy version 1.23.5 in /home/miniconda3/envs/EAT/lib/python3.9/site-packages/numpy/lib/npyio.py

def save(file, arr, allow_pickle=True, fix_imports=True):
    if hasattr(file, 'write'):
        file_ctx = contextlib.nullcontext(file)
    else:
        file = os_fspath(file)
        if not file.endswith('.npy'):
            file = file + '.npy'
        file_ctx = open(file, "wb")

    with file_ctx as fid:
        arr = np.asanyarray(arr)  # call error
        format.write_array(fid, arr, allow_pickle=allow_pickle,
                           pickle_kwargs=dict(fix_imports=fix_imports))

in /home/miniconda3/envs/EAT/lib/python3.9/site-packages/numpy/lib/npyio.py add dtype="object" in image

lililuya commented 5 months ago

Another problem encountered in modules/transformer "RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use ".reshape(...) instead."

Fixed by change the .view(...) to .contiguous().view(...)" from https://stackoverflow.com/questions/66750391/runtimeerror-view-size-is-not-compatible-with-input-tensors-size-and-stride-a . Modify as

return yaw, pitch, roll, yaw_mat.contiguous().view(yaw_mat.shape[0], 9), pitch_mat.contiguous().view(pitch_mat.shape[0], 9), roll_mat.contiguous().view(roll_mat.shape[0], 9), rot_mat.contiguous().view(rot_mat.shape[0], 9)