Dolorousrtur / ContourCraft

Code for SIGGRAPH2024 paper "ContourCraft: Learning to Resolve Intersections in Neural Multi-Garment Simulations"
https://dolorousrtur.github.io/contourcraft/
MIT License
70 stars 2 forks source link

When running inference.py, it encounters the error #4

Open gitPZH opened 1 month ago

gitPZH commented 1 month ago

A% {Y$IC8{)Y2 S5K%`}8J5 Hello, your work is really great, but I recently encountered the error shown in the picture when running Inference.py, I'm not sure what caused it, I hope I can get your reply in your free time, thank you very much!

Dolorousrtur commented 1 month ago

Hi, could you send the full traceback?

Dene33 commented 1 month ago

I'm getting a similar issue when trying to process the multilayer garments (HOOD's one-layer garments work well). I managed to add to garments .pkl different types of .objs but on the simulation step it fails:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/home/ubuntu/repos/ContourCraft/Inference.ipynb Cell 24 line 3
      1 sequence = next(iter(dataloader))
      2 sequence = move2device(sequence, 'cuda:0')
----> 3 trajectories_dict = runner.valid_rollout(sequence,  bare=True, n_steps=200)

File ~/repos/ContourCraft/runners/ccraft.py:153, in Runner.valid_rollout(self, sequence, n_steps, bare, record_time, safecheck)
    150     st_time = time.time()
    152 st = 0
--> 153 trajectories, metrics_dict = self._rollout(sequence, st, n_samples - st,
    154                                             progressbar=True, bare=bare, safecheck=safecheck)
    156 if record_time:
    157     total_time = time.time() - st_time

File ~/repos/ContourCraft/runners/ccraft.py:246, in Runner._rollout(self, sample, start_idx, n_steps, progressbar, bare, safecheck)
    242     break
    245 with TorchTimer(metrics_dict, 'hood_time', start=start, end=end):
--> 246     sample_step = self.model(sample_step, is_training=False)
    249 ncoll = self.safecheck_solver.calc_tritri_collisions2(sample_step, verts_key='pred_pos')
    250 metrics_dict['ncoll'].append(ncoll)

File ~/anaconda3/envs/hood/lib/python3.10/site-packages/torch/nn/modules/module.py:1501, in Module._call_impl(self, *args, **kwargs)
   1496 # If we don't have any hooks, we want to skip the rest of the logic in
   1497 # this function, and just call forward.
...
---> 65 value = value.narrow(cat_dim or 0, start, end - start)
     66 value = value.squeeze(0) if cat_dim is None else value
     67 if decrement and (incs.dim() > 1 or int(incs[idx]) != 0):

RuntimeError: start (0) + length (31437) exceeds dimension size (2).

I also got the same problem described above before the latest commits (Oct 24, 2024) in the initial version.

Another problem is in the repos/ContourCraft/configs/contourcraft.yaml, here:

  dataset:
    ccraft:

I had to change it back to postcvpr.

Error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/home/ubuntu/repos/ContourCraft/Inference.ipynb Cell 23 line 3
     30 sequence_loader = 'hood_pkl'
     33 # ====================================================================================================
---> 36 dataloader = create_postcvpr_one_sequence_dataloader(sequence_path, garment_name, 
     37                                             garment_dict_file, sequence_loader=sequence_loader, 
     38                                             obstacle_dict_file=None)

File ~/repos/ContourCraft/utils/validation.py:102, in create_postcvpr_one_sequence_dataloader(sequence_path, garment_name, garment_dict_file, config, **kwargs)
     98 if config is None:
     99     config = 'contourcraft'
--> 102 dataloader = create_one_sequence_dataloader(use_config=config, data_root=data_root, single_sequence_file=file_name,
    103                                             single_sequence_garment=garment_name, garment_dict_file=garment_dict_file,
    104                                             **kwargs)
    106 return dataloader

File ~/repos/ContourCraft/utils/validation.py:82, in create_one_sequence_dataloader(use_config, dataset_name, **kwargs)
     79 else:
     80     dataset_config_dict = {}
---> 82 dataset_module = importlib.import_module(f'datasets.{dataset_name}')
     83 DatasetConfig = dataset_module.Config
     84 create_dataset = dataset_module.create

File ~/anaconda3/envs/hood/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
...
File <frozen importlib._bootstrap>:1027, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1004, in _find_and_load_unlocked(name, import_)

ModuleNotFoundError: No module named 'datasets.ccraft'

It seems the ccraft.py is missing from ContourCraft/datasets

Dolorousrtur commented 1 month ago

@Dene33

  1. I have added datasets/ccraft.py
  2. I have updated the Inference.ipynb and the data file with the multi-layer outfits used in the paper. Can you try following the updated Inference.ipynb to run it with one of the multi-garment outfits there?
Dene33 commented 1 month ago

@Dolorousrtur

I tried with the default multilayer mesh, but still got the similar error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/home/ubuntu/repos/ContourCraft/Inference.ipynb Cell 25 line 3
      1 sequence = next(iter(dataloader))
      2 sequence = move2device(sequence, 'cuda:0')
----> 3 trajectories_dict = runner.valid_rollout(sequence,  bare=True, n_steps=200)

File ~/repos/ContourCraft/runners/ccraft.py:153, in Runner.valid_rollout(self, sequence, n_steps, bare, record_time, safecheck)
    150     st_time = time.time()
    152 st = 0
--> 153 trajectories, metrics_dict = self._rollout(sequence, st, n_samples - st,
    154                                             progressbar=True, bare=bare, safecheck=safecheck)
    156 if record_time:
    157     total_time = time.time() - st_time

File ~/repos/ContourCraft/runners/ccraft.py:246, in Runner._rollout(self, sample, start_idx, n_steps, progressbar, bare, safecheck)
    242     break
    245 with TorchTimer(metrics_dict, 'hood_time', start=start, end=end):
--> 246     sample_step = self.model(sample_step, is_training=False)
    249 ncoll = self.safecheck_solver.calc_tritri_collisions2(sample_step, verts_key='pred_pos')
    250 metrics_dict['ncoll'].append(ncoll)

File ~/anaconda3/envs/hood/lib/python3.10/site-packages/torch/nn/modules/module.py:1501, in Module._call_impl(self, *args, **kwargs)
   1496 # If we don't have any hooks, we want to skip the rest of the logic in
   1497 # this function, and just call forward.
...
---> 65 value = value.narrow(cat_dim or 0, start, end - start)
     66 value = value.squeeze(0) if cat_dim is None else value
     67 if decrement and (incs.dim() > 1 or int(incs[idx]) != 0):

RuntimeError: start (0) + length (23605) exceeds dimension size (32).

I'm using the sequence_loader = 'hood_pkl'

Dolorousrtur commented 1 month ago

Which body model do you use for the pose sequence and the garment template?

Could you send here the pose sequence and the garment template you use so that I can try to replicate this error. I haven't encountered it before and the message does not tell me much.

Apart from this, I would suggest moving to .npz format for pose sequences same as in AMASS dataset, either SMPL or SMPLX. hood_pkl is a legacy format.

Dene33 commented 1 month ago

@Dolorousrtur

I tried 01_01_poses.npz from AMASS, and tried both female and male SMPL models. I also tried cindy_20_combined and aaron_22_combined but still no luck, the same error.

Here are the .pkl with the garment aaron_022_combined and pose sequence 01_01_poses.npz from AMASS: https://drive.google.com/drive/folders/1j2LgNolbgJ77a_jQGNsg0R5WaQYEkPao?usp=sharing

Dolorousrtur commented 4 weeks ago

That's strange, but I can not reproduce this error even with the exact files you have sent.

I suppose the problem might be in the different library versions we use. Judging by the error message it may be a problem of pytorch or torch-geometric.

I use the following package versions:

pytorch                   2.0.1           py3.10_cuda11.7_cudnn8.5.0_0    pytorch
pytorch-cuda              11.7                 h778d358_5    pytorch
torch-geometric           2.4.0                    pypi_0    pypi

Here is also an environment file for the conda env I use at the moment: https://drive.google.com/file/d/1zS8BTWAoqbrCUU6xRxWNDW0gCW69khfi/view?usp=drive_link

I want to make a clean environment file and installation instructions once I have free time, but it may take a while.

Dene33 commented 4 weeks ago

@Dolorousrtur Thanks a lot! The problem was the torch-geometric version. It was 2.3 on my side. Now it works, thank you again!

Dolorousrtur commented 4 weeks ago

Glad it works! Note that in the example you sent me, the garment was not aligned with SMPL model (but with SMPLX). Because of this, the initial garment geometry is off. You'll need to realign the mesh from obj file to SMPL body and add it to garment_dict.pkl again

gitPZH commented 3 weeks ago

c30e6dd703fbdf439caf15e93d0d6c1Hello author, I opened the environment file of your conda env and found a package named ccraft-collisions==0.0.0, how is this package installed?

Dolorousrtur commented 2 weeks ago

@gitPZH It's a custom library, please see README