fudan-generative-vision / champ

Champ: Controllable and Consistent Human Image Animation with 3D Parametric Guidance
https://fudan-generative-vision.github.io/champ/
MIT License
3.98k stars 481 forks source link

KeyError: 'scaled_focal_length is not a file in the archive' in 4.Transfer SMPL step #105

Open lognat0704 opened 4 months ago

lognat0704 commented 4 months ago

Hi I follow the instruction trying to build up my own motion data. In the 4.Transfer SMPL step. I encounter the following error:

CACHE_DIR_4DHUMANS: /home/nelson/.cache/4DHumans
Lightning automatically upgraded your loaded checkpoint from v1.8.1 to v2.2.2. To apply the upgrade to your files permanently, run `python -m pytorch_lightning.utilities.upgrade_checkpoint ../.cache/4DHumans/logs/train/multiruns/hmr2/0/checkpoints/epoch=35-step=1000000.ckpt`
WARNING: You are using a SMPL model, with only 10 shape coefficients.
['images', 'smpl_results']
Traceback (most recent call last):
  File "/opt/conda/envs/champ/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/conda/envs/champ/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/nelson/champ/scripts/data_processors/smpl/smpl_transfer.py", line 103, in <module>
    zip(result_dict_list["smpl"], result_dict_list["camera"], result_dict_list["scaled_focal_length"], driving_paths)
  File "/opt/conda/envs/champ/lib/python3.10/site-packages/numpy/lib/npyio.py", line 260, in __getitem__
    raise KeyError("%s is not a file in the archive" % key)
KeyError: 'scaled_focal_length is not a file in the archive'

How do I solve the issue?

TianQi-777 commented 4 months ago

Same problem. Try the following changes.

old

if os.path.exists(group_smpl_path):
    result_dict_list = np.load(group_smpl_path, allow_pickle=True)
    result_dict_first = np.load(driving_paths[0], allow_pickle=True).item()
    i = 0
    for smpl_outs, cam_t, foc_len, file_path in tqdm(
        zip(result_dict_list["smpl"], result_dict_list["camera"], result_dict_list["scaled_focal_length"], driving_paths)
    ):
        img_fn, _ = os.path.splitext(os.path.basename(file_path))
        result_dict = {key: value for key, value in result_dict_first.items()}
        result_dict["smpls"] = smpl_outs
        result_dict["cam_t"] = cam_t
        result_dict["scaled_focal_length"] = foc_len
        if args.view_transfer:
            scaled_focal_length = reference_dict["scaled_focal_length"]
            result_dict["cam_t"] = reference_dict["cam_t"]
            result_dict["scaled_focal_length"] = scaled_focal_length

new

if os.path.exists(group_smpl_path):
    result_dict_list = np.load(group_smpl_path, allow_pickle=True)
    result_dict_first = np.load(driving_paths[0], allow_pickle=True).item()
    i = 0
    for smpl_outs, cam_t, file_path in tqdm(
        zip(result_dict_list["smpl"], result_dict_list["camera"], driving_paths)
    ):
        img_fn, _ = os.path.splitext(os.path.basename(file_path))
        result_dict = {key: value for key, value in result_dict_first.items()}
        result_dict["smpls"] = smpl_outs
        result_dict["cam_t"] = cam_t
        if args.view_transfer:
            scaled_focal_length = reference_dict["scaled_focal_length"]
            result_dict["cam_t"] = reference_dict["cam_t"]
            result_dict["scaled_focal_length"] = scaled_focal_length
subazinga commented 4 months ago

It's a bug. We will fix it in the following couple of days.

faiimea commented 4 months ago

for smpl_outs, cam_t, file_path in tqdm( zip(result_dict_list["smpl"], result_dict_list["camera"], driving_paths) ): imgfn, = os.path.splitext(os.path.basename(file_path)) result_dict = {key: value for key, value in result_dict_first.items()} result_dict["smpls"] = smpl_outs result_dict["cam_t"] = cam_t if args.view_transfer: scaled_focal_length = reference_dict["scaled_focal_length"] result_dict["cam_t"] = reference_dict["cam_t"] result_dict["scaled_focal_length"] = scaled_focal_length

It works.