mkt1412 / GraspGPT_public

code implementation of GraspGPT and FoundationGrasp
77 stars 11 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 (32,) + inhomogeneous part. #1

Closed Trav1slaflame closed 12 months ago

Trav1slaflame commented 12 months ago

Hi, team Thanks for sharing the wonderful project! I followed the README and successfully configured the env. However, when I was running the Database version Demo (Objetc class: pan, task: pour) by: _python gcngrasp/demo_db.py --cfg_file cfg/eval/gcngrasp/gcngrasp_split_mode_o_split_idx0.yml --obj_name pan --objclass saucepan --task pour, I met this BUG: ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (32,) + inhomogeneous part. ################################################ Here is the content shown in my terminal when I was running the demo:

-task pour algorithm_class: GCNGrasp base_dir: gcngrasp/../data batch_size: 16 dataset_class: GCNTaskGrasp distrib_backend: dp embedding_mode: 2 embedding_model: numberbatch embedding_size: 300 epochs: 50 folder_dir: taskgrasp gcn_conv_type: GCNConv gcn_num_layers: 6 gcn_skip_mode: 0 gpus: [0] graph_data_path: kb2_task_wn_noi include_reverse_relations: True instance_agnostic_mode: 1 log_dir: checkpoints/ model: use_normal: False use_xyz: True name: gcngrasp_split_mode_o_split_idx0 num_points: 4096 optimizer: bn_momentum: 0.5 bnm_clip: 0.01 bnm_decay: 0.5 decay_step: 20000.0 lr: 0.0001 lr_clip: 1e-05 lr_decay: 0.7 weight_decay: 0.0001 patience: 50 pc_scaling: True pretrained_weight_file: pretraining_mode: 0 sampling_radius: 2 split_idx: 0 split_mode: o split_version: 1 subgraph_sampling: True use_class_list: True use_task1_grasps: True weight_file: checkpoints/gcngrasp_split_mode_o_split_idx_0__2023-08-15-18-59/weights/_ckpt_epoch_42.ckpt weighted_sampling: True ######################## Namespace(cfg_file='cfg/eval/gcngrasp/gcngrasp_split_mode_o_split_idx0.yml', data_dir='gcngrasp/../data/sample_data', obj_class='saucepan', obj_name='pan', task='pour') Unable to find clean pc and grasps Traceback (most recent call last): File "gcngrasp/demo_db.py", line 273, in main(args, cfg) File "gcngrasp/demo_db.py", line 126, in main pc, grasps = load_pc_and_grasps(os.path.join(data_dir, 'pcs'), obj_name) File "gcngrasp/demo_db.py", line 97, in load_pc_and_grasps grasps = farthest_grasps( File "/home/zhengshen/GraspGPT_public/gcngrasp/data/../../geometry_utils.py", line 230, in farthest_grasps grasps_fps = cluster_grasps(grasps, num_clusters=num_clusters) File "/home/zhengshen/GraspGPT_public/gcngrasp/data/../../geometry_utils.py", line 107, in cluster_grasps output_grasps = np.asarray(output_grasps) ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (32,) + inhomogeneous part. ################################################ When I tried the other two examples (Objetc class: spatula, task: scoop, Objetc class: mug, task: drink), I also met the same BUG. Could you please help me to solve this BUG?

Best regards, Zhengshen

mkt1412 commented 12 months ago

@Trav1slaflame Hi Zhengshen! Thanks for being interested in our work. The error messages says "Unable to find clean pc and grasps". Did you download the LA-TaskGrasp dataset properly?

Trav1slaflame commented 12 months ago

Hi, team

Thank you so much for your reply!

Yes, I have already downloaded the LA-TaskGrasp dataset properly following the instruction in the README: download the dataset here and place it in the root folder.

I think the error messages says "Unable to find clean pc and grasps" was generated by the code: File "gcngrasp/demo_db.py", line 80, in load_pc_and_grasps, you wrote: if not os.path.exists(pc_file): print('Unable to find clean pc and grasps ') pc_file = os.path.join(obj_dir, 'fused_pc.npy') grasps_file = os.path.join(obj_dir, 'fused_grasps.npy') if not os.path.exists(pc_file): raise ValueError( 'Unable to find un-processed point cloud file {}'.format(pc_file))

mkt1412 commented 12 months ago

@Trav1slaflame I see. Can you successfully locate the point cloud file under the path "gcngrasp/../data/sample_data/pcs/pan/fused_pc_clean.npy"?

Trav1slaflame commented 12 months ago

@mkt1412 NO, I think for "gcngrasp/../data/sample_data/pcs/pan" only contains two files: fused_grasps.npy and fused_pc.npy.

Trav1slaflame commented 12 months ago

@mkt1412 "gcngrasp/../data/sample_data/pcs/pan1" has "fused_grasps_clean.npy" and "fused_pc_clean.npy". And for MUG, even I won't get the massage: Unable to find clean pc and grasps, I still met the BUG: Traceback (most recent call last): File "gcngrasp/demo_db.py", line 273, in main(args, cfg) File "gcngrasp/demo_db.py", line 126, in main pc, grasps = load_pc_and_grasps(os.path.join(data_dir, 'pcs'), obj_name) File "gcngrasp/demo_db.py", line 97, in load_pc_and_grasps grasps = farthest_grasps( File "/home/zhengshen/GraspGPT_public/gcngrasp/data/../../geometry_utils.py", line 230, in farthest_grasps grasps_fps = cluster_grasps(grasps, num_clusters=num_clusters) File "/home/zhengshen/GraspGPT_public/gcngrasp/data/../../geometry_utils.py", line 107, in cluster_grasps output_grasps = np.asarray(output_grasps) ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (32,) + inhomogeneous part.

mkt1412 commented 12 months ago

@Trav1slaflame I seems that there is a problem with function "np.asarray"? Can you try use numpy 1.21.5? That version works for me. Another solution is to inspect every element in output_grasps to make sure np.asarray works properly. For my case, output_grasps is a list with a length of 32. Each element in that list is with a shape of (30, 4, 4) and with dtype of float64.

Trav1slaflame commented 12 months ago

@mkt1412 I change to numpy 1.21.5 and it works! Thank you so much for your time!