diff --git "a/exp_runner_stage_1.py" "b/exp_runner_stage_1.py" --- "a/exp_runner_stage_1.py" +++ "b/exp_runner_stage_1.py" @@ -43,7 +43,7 @@ import tempfile class Runner: def __init__(self, conf_path, data_path, mode='train', case='CASE_NAME', is_continue=False): - self.device = torch.device('cuda') + self.device = torch.device('cpu') self.conf_path = conf_path @@ -700,12 +700,12 @@ class Runner: ###### initialize the dyn model ###### for i_time_idx in range(self.n_timesteps): - self.other_bending_network.timestep_to_vel[i_time_idx] = torch.zeros((3,), dtype=torch.float32).cuda() - self.other_bending_network.timestep_to_point_accs[i_time_idx] = torch.zeros((3,), dtype=torch.float32).cuda() - self.other_bending_network.timestep_to_total_def[i_time_idx] = torch.zeros((3,), dtype=torch.float32).cuda() - self.other_bending_network.timestep_to_angular_vel[i_time_idx] = torch.zeros((3,), dtype=torch.float32).cuda() - self.other_bending_network.timestep_to_quaternion[i_time_idx] = torch.tensor([1., 0., 0., 0.], dtype=torch.float32).cuda() - self.other_bending_network.timestep_to_torque[i_time_idx] = torch.zeros((3,), dtype=torch.float32).cuda() + self.other_bending_network.timestep_to_vel[i_time_idx] = torch.zeros((3,), dtype=torch.float32) + self.other_bending_network.timestep_to_point_accs[i_time_idx] = torch.zeros((3,), dtype=torch.float32) + self.other_bending_network.timestep_to_total_def[i_time_idx] = torch.zeros((3,), dtype=torch.float32) + self.other_bending_network.timestep_to_angular_vel[i_time_idx] = torch.zeros((3,), dtype=torch.float32) + self.other_bending_network.timestep_to_quaternion[i_time_idx] = torch.tensor([1., 0., 0., 0.], dtype=torch.float32) + self.other_bending_network.timestep_to_torque[i_time_idx] = torch.zeros((3,), dtype=torch.float32) # calculate_collision_geometry_bounding_boxes, self.maxx_init_passive_mesh, self.minn_init_passive_mesh # # the best performed DGrasp-tracking? ## @@ -801,7 +801,7 @@ class Runner: ''' set gravity ''' ### gravity ### # self.gravity_acc = 9.8 - self.gravity_dir = torch.tensor([0., 0., -1]).float().cuda() + self.gravity_dir = torch.tensor([0., 0., -1]).float() self.passive_obj_mass = 1. if not self.bending_net_type == "active_force_field_v13": @@ -827,12 +827,12 @@ class Runner: per_vert_mass = self.passive_obj_mass / float(init_passive_mesh.size(0)) # (center to the vertex) # assume the mass is uniformly distributed across all vertices ## - I_ref = torch.zeros((3, 3), dtype=torch.float32).cuda() + I_ref = torch.zeros((3, 3), dtype=torch.float32) for i_v in range(init_passive_mesh.size(0)): cur_vert = init_passive_mesh[i_v] cur_r = cur_vert - init_passive_mesh_center dot_r_r = torch.sum(cur_r * cur_r) - cur_eye_mtx = torch.eye(3, dtype=torch.float32).cuda() + cur_eye_mtx = torch.eye(3, dtype=torch.float32) r_mult_rT = torch.matmul(cur_r.unsqueeze(-1), cur_r.unsqueeze(0)) I_ref += (dot_r_r * cur_eye_mtx - r_mult_rT) * per_vert_mass return init_passive_mesh_center, I_ref @@ -848,12 +848,13 @@ class Runner: per_vert_mass = self.obj_mass / cur_init_passive_mesh_verts.size(0) ## print(f"[Calculating obj inertia] per_vert_mass: {per_vert_mass}") - I_ref = torch.zeros((3, 3), dtype=torch.float32).cuda() ## caclulate I_ref; I_inv_ref; ## + I_ref = torch.zeros((3, 3), dtype=torch.float32) ## caclulate I_ref; I_inv_ref; ## for i_v in range(cur_init_passive_mesh_verts.size(0)): cur_vert = cur_init_passive_mesh_verts[i_v] cur_r = cur_vert # - cur_init_passive_mesh_center cur_v_inertia = per_vert_mass * (torch.sum(cur_r * cur_r) - torch.matmul(cur_r.unsqueeze(-1), cur_r.unsqueeze(0))) # cur_v_inertia = torch.cross(cur_r, cur_r) * per_vert_mass3 # # + # print(f"I_ref: {I_ref.device}, cur_v_inertia: {cur_v_inertia.device}") I_ref += cur_v_inertia print(f"In calculating inertia") @@ -919,13 +920,13 @@ class Runner: print(f"sv_dict: {sv_dict.keys()}") obj_pcs = sv_dict['object_pc'] - obj_pcs = torch.from_numpy(obj_pcs).float().cuda() + obj_pcs = torch.from_numpy(obj_pcs).float() # self.obj_pcs = obj_pcs obj_vertex_normals = sv_dict['obj_vertex_normals'] - obj_vertex_normals = torch.from_numpy(obj_vertex_normals).float().cuda() + obj_vertex_normals = torch.from_numpy(obj_vertex_normals).float() self.obj_normals = obj_vertex_normals object_global_orient = sv_dict['object_global_orient'] # glboal orient @@ -933,7 +934,7 @@ class Runner: obj_faces = sv_dict['obj_faces'] - obj_faces = torch.from_numpy(obj_faces).long().cuda() + obj_faces = torch.from_numpy(obj_faces).long() self.obj_faces = obj_faces obj_verts = sv_dict['obj_verts'] @@ -942,7 +943,7 @@ class Runner: extent = maxx_verts - minn_verts center_ori = (maxx_verts + minn_verts) / 2 scale_ori = np.sqrt(np.sum(extent ** 2)) - obj_verts = torch.from_numpy(obj_verts).float().cuda() + obj_verts = torch.from_numpy(obj_verts).float() @@ -973,10 +974,10 @@ class Runner: for i_fr in range(object_global_orient.shape[0]): cur_glb_rot = object_global_orient[i_fr] cur_transl = object_transl[i_fr] - cur_transl = torch.from_numpy(cur_transl).float().cuda() + cur_transl = torch.from_numpy(cur_transl).float() cur_glb_rot_struct = R.from_rotvec(cur_glb_rot) cur_glb_rot_mtx = cur_glb_rot_struct.as_matrix() - cur_glb_rot_mtx = torch.from_numpy(cur_glb_rot_mtx).float().cuda() + cur_glb_rot_mtx = torch.from_numpy(cur_glb_rot_mtx).float() cur_transformed_verts = torch.matmul( self.obj_verts, cur_glb_rot_mtx @@ -988,7 +989,7 @@ class Runner: cur_glb_rot_struct = R.from_matrix(cur_glb_rot_mtx_reversed.cpu().numpy()) cur_obj_quat = cur_glb_rot_struct.as_quat() cur_obj_quat = cur_obj_quat[[3, 0, 1, 2]] - cur_obj_quat = torch.from_numpy(cur_obj_quat).float().cuda() + cur_obj_quat = torch.from_numpy(cur_obj_quat).float() tot_obj_quat.append(cur_obj_quat) # center_obj_verts = torch.mean(self.obj_verts, dim=0, keepdim=True) @@ -1005,13 +1006,13 @@ class Runner: self.obj_pcs = transformed_obj_verts rhand_verts = sv_dict['rhand_verts'] - rhand_verts = torch.from_numpy(rhand_verts).float().cuda() + rhand_verts = torch.from_numpy(rhand_verts).float() self.rhand_verts = rhand_verts ## rhand verts ## # if '30_sv_dict' in sv_fn: - # bbox_selected_verts_idxes = torch.tensor([1511, 1847, 2190, 2097, 2006, 2108, 1604], dtype=torch.long).cuda() + # bbox_selected_verts_idxes = torch.tensor([1511, 1847, 2190, 2097, 2006, 2108, 1604], dtype=torch.long) # obj_selected_verts = self.obj_verts[bbox_selected_verts_idxes] # else: obj_selected_verts = self.obj_verts.clone() @@ -1045,8 +1046,8 @@ class Runner: ## should save self.object_global_orient and self.object_transl ## # object_global_orient, object_transl # - self.object_global_orient = torch.from_numpy(object_global_orient).float().cuda() - self.object_transl = torch.from_numpy(object_transl).float().cuda() + self.object_global_orient = torch.from_numpy(object_global_orient).float() + self.object_transl = torch.from_numpy(object_transl).float() return transformed_obj_verts, rhand_verts, self.obj_normals @@ -1088,22 +1089,22 @@ class Runner: sv_dict = pkl.load(open(sv_fn, "rb")) - self.hand_faces = torch.from_numpy(sv_dict['hand_faces']).float().cuda() + self.hand_faces = torch.from_numpy(sv_dict['hand_faces']).float() print(f"sv_dict: {sv_dict.keys()}") maxx_ws = min(maxx_ws, len(sv_dict['obj_verts']) - start_idx) obj_pcs = sv_dict['obj_verts'][start_idx: start_idx + maxx_ws] - obj_pcs = torch.from_numpy(obj_pcs).float().cuda() + obj_pcs = torch.from_numpy(obj_pcs).float() self.obj_pcs = obj_pcs # obj_vertex_normals = sv_dict['obj_vertex_normals'] - # obj_vertex_normals = torch.from_numpy(obj_vertex_normals).float().cuda() + # obj_vertex_normals = torch.from_numpy(obj_vertex_normals).float() self.obj_normals = torch.zeros_like(obj_pcs[0]) ### get the obj naormal vectors ## object_pose = sv_dict['obj_pose'][start_idx: start_idx + maxx_ws] - object_pose = torch.from_numpy(object_pose).float().cuda() ### nn_frames x 4 x 4 ### + object_pose = torch.from_numpy(object_pose).float() ### nn_frames x 4 x 4 ### object_global_orient_mtx = object_pose[:, :3, :3 ] ## nn_frames x 3 x 3 ## object_transl = object_pose[:, :3, 3] ## nn_frmaes x 3 ## @@ -1113,7 +1114,7 @@ class Runner: obj_faces = sv_dict['obj_faces'] - obj_faces = torch.from_numpy(obj_faces).long().cuda() + obj_faces = torch.from_numpy(obj_faces).long() self.obj_faces = obj_faces # [0] ### obj faces ## # obj_verts = sv_dict['obj_verts'] @@ -1122,7 +1123,7 @@ class Runner: # extent = maxx_verts - minn_verts # center_ori = (maxx_verts + minn_verts) / 2 # scale_ori = np.sqrt(np.sum(extent ** 2)) - # obj_verts = torch.from_numpy(obj_verts).float().cuda() + # obj_verts = torch.from_numpy(obj_verts).float() init_obj_verts = obj_pcs[0] init_obj_ornt_mtx = object_global_orient_mtx[0] @@ -1156,7 +1157,7 @@ class Runner: self.obj_sdf = np.load(sdf_sv_fn, allow_pickle=True) self.sdf_res = self.obj_sdf.shape[0] - self.obj_sdf = torch.from_numpy(self.obj_sdf).float().cuda() + self.obj_sdf = torch.from_numpy(self.obj_sdf).float() # init_obj_pcs = obj_pcs[0].detach().cpu().numpy() # init_glb_rot = object_global_orient[0] # init_glb_trans = object_transl[0] @@ -1173,7 +1174,7 @@ class Runner: # obj_verts = (sv_dict['obj_verts'] - center_ori[None]) / scale_ori * scale_cur + center_cur[None] - # obj_verts = torch.from_numpy(obj_verts).float().cuda() + # obj_verts = torch.from_numpy(obj_verts).float() # self.obj_verts = obj_verts # sv_fn_obj_fn = sv_fn[:-4] + "_real_obj.obj" @@ -1189,7 +1190,7 @@ class Runner: cur_ornt_rot_struct = R.from_matrix(cur_ornt_mtx_np) cur_ornt_quat = cur_ornt_rot_struct.as_quat() cur_ornt_quat = cur_ornt_quat[[3, 0, 1, 2]] - tot_obj_quat.append(torch.from_numpy(cur_ornt_quat).float().cuda()) ### float cuda ## + tot_obj_quat.append(torch.from_numpy(cur_ornt_quat).float()) ### float cuda ## # tot_obj_quat = np.stack(tot_obj_quat, axis=0) ## obj quat ## tot_obj_quat = torch.stack(tot_obj_quat, dim=0) @@ -1203,10 +1204,10 @@ class Runner: # for i_fr in range(object_global_orient.shape[0]): # cur_glb_rot = object_global_orient[i_fr] # cur_transl = object_transl[i_fr] - # cur_transl = torch.from_numpy(cur_transl).float().cuda() + # cur_transl = torch.from_numpy(cur_transl).float() # cur_glb_rot_struct = R.from_rotvec(cur_glb_rot) # cur_glb_rot_mtx = cur_glb_rot_struct.as_matrix() - # cur_glb_rot_mtx = torch.from_numpy(cur_glb_rot_mtx).float().cuda() + # cur_glb_rot_mtx = torch.from_numpy(cur_glb_rot_mtx).float() # cur_transformed_verts = torch.matmul( # self.obj_verts, cur_glb_rot_mtx @@ -1218,7 +1219,7 @@ class Runner: # cur_glb_rot_struct = R.from_matrix(cur_glb_rot_mtx_reversed.cpu().numpy()) # cur_obj_quat = cur_glb_rot_struct.as_quat() # cur_obj_quat = cur_obj_quat[[3, 0, 1, 2]] - # cur_obj_quat = torch.from_numpy(cur_obj_quat).float().cuda() + # cur_obj_quat = torch.from_numpy(cur_obj_quat).float() # tot_obj_quat.append(cur_obj_quat) # # center_obj_verts = torch.mean(self.obj_verts, dim=0, keepdim=True) @@ -1234,13 +1235,13 @@ class Runner: rhand_verts = sv_dict['hand_verts'][start_idx: start_idx + maxx_ws] - rhand_verts = torch.from_numpy(rhand_verts).float().cuda() + rhand_verts = torch.from_numpy(rhand_verts).float() self.rhand_verts = rhand_verts ## rhand verts ## # if '30_sv_dict' in sv_fn: - # bbox_selected_verts_idxes = torch.tensor([1511, 1847, 2190, 2097, 2006, 2108, 1604], dtype=torch.long).cuda() + # bbox_selected_verts_idxes = torch.tensor([1511, 1847, 2190, 2097, 2006, 2108, 1604], dtype=torch.long) # obj_selected_verts = self.obj_verts[bbox_selected_verts_idxes] # else: # obj_selected_verts = self.obj_verts.clone() @@ -1283,8 +1284,8 @@ class Runner: ## should save self.object_global_orient and self.object_transl ## # object_global_orient, object_transl # - # self.object_global_orient = torch.from_numpy(object_global_orient).float().cuda() - self.object_transl = object_transl.clone() # torch.from_numpy(object_transl).float().cuda() + # self.object_global_orient = torch.from_numpy(object_global_orient).float() + self.object_transl = object_transl.clone() # torch.from_numpy(object_transl).float() return self.obj_pcs, rhand_verts, self.obj_normals @@ -1343,7 +1344,7 @@ class Runner: obj_pcs = sv_dict["verts.object"][start_idx: start_idx + window_size] # obj_pcs = sv_dict['object_pc'] - obj_pcs = torch.from_numpy(obj_pcs).float().cuda() + obj_pcs = torch.from_numpy(obj_pcs).float() obj_vertex_normals = torch.zeros_like(obj_pcs) @@ -1352,7 +1353,7 @@ class Runner: # /data/xueyi/sim/arctic_processed_data/processed_seqs/s01/espressomachine_use_01.npy # obj_vertex_normals = sv_dict['obj_vertex_normals'] - # obj_vertex_normals = torch.from_numpy(obj_vertex_normals).float().cuda() + # obj_vertex_normals = torch.from_numpy(obj_vertex_normals).float() # self.obj_normals = obj_vertex_normals # object_global_orient = sv_dict['object_global_orient'] # glboal orient @@ -1360,7 +1361,7 @@ class Runner: obj_faces = sv_dict['f'][0] - obj_faces = torch.from_numpy(obj_faces).long().cuda() + obj_faces = torch.from_numpy(obj_faces).long() self.obj_faces = obj_faces # obj_verts = sv_dict['verts.object'] @@ -1369,7 +1370,7 @@ class Runner: # extent = maxx_verts - minn_verts # # center_ori = (maxx_verts + minn_verts) / 2 # # scale_ori = np.sqrt(np.sum(extent ** 2)) - # obj_verts = torch.from_numpy(obj_verts).float().cuda() + # obj_verts = torch.from_numpy(obj_verts).float() # obj_sv_path = "/data3/datasets/xueyi/arctic/arctic_data/data/meta/object_vtemplates" @@ -1387,11 +1388,11 @@ class Runner: init_obj_rot_vec = object_global_orient[0] init_obj_transl = object_transl[0] - init_obj_transl = torch.from_numpy(init_obj_transl).float().cuda() + init_obj_transl = torch.from_numpy(init_obj_transl).float() init_rot_struct = R.from_rotvec(init_obj_rot_vec) init_glb_rot_mtx = init_rot_struct.as_matrix() - init_glb_rot_mtx = torch.from_numpy(init_glb_rot_mtx).float().cuda() + init_glb_rot_mtx = torch.from_numpy(init_glb_rot_mtx).float() # ## reverse the global rotation matrix ## init_glb_rot_mtx_reversed = init_glb_rot_mtx.contiguous().transpose(1, 0).contiguous() # nn_obj_verts x 3 ## @@ -1427,7 +1428,7 @@ class Runner: # ) - # obj_verts = torch.from_numpy(template_obj_vs).float().cuda() + # obj_verts = torch.from_numpy(template_obj_vs).float() self.obj_verts = obj_verts.clone() @@ -1463,7 +1464,7 @@ class Runner: # obj_verts = (sv_dict['obj_verts'] - center_ori[None]) / scale_ori * scale_cur + center_cur[None] - # obj_verts = torch.from_numpy(obj_verts).float().cuda() + # obj_verts = torch.from_numpy(obj_verts).float() # self.obj_verts = obj_verts # sv_fn_obj_fn = sv_fn[:-4] + "_real_obj.obj" @@ -1482,10 +1483,10 @@ class Runner: for i_fr in range(object_global_orient.shape[0]): cur_glb_rot = object_global_orient[i_fr] cur_transl = object_transl[i_fr] - cur_transl = torch.from_numpy(cur_transl).float().cuda() + cur_transl = torch.from_numpy(cur_transl).float() cur_glb_rot_struct = R.from_rotvec(cur_glb_rot) cur_glb_rot_mtx = cur_glb_rot_struct.as_matrix() - cur_glb_rot_mtx = torch.from_numpy(cur_glb_rot_mtx).float().cuda() + cur_glb_rot_mtx = torch.from_numpy(cur_glb_rot_mtx).float() # transformed verts ## canon_verts x R + t = transformed_verts # # (transformed_verts - t) x R^T = canon_verts # @@ -1499,7 +1500,7 @@ class Runner: cur_glb_rot_struct = R.from_matrix(cur_glb_rot_mtx_reversed.cpu().numpy()) cur_obj_quat = cur_glb_rot_struct.as_quat() cur_obj_quat = cur_obj_quat[[3, 0, 1, 2]] - cur_obj_quat = torch.from_numpy(cur_obj_quat).float().cuda() + cur_obj_quat = torch.from_numpy(cur_obj_quat).float() tot_obj_quat.append(cur_obj_quat) cur_re_transformed_obj_verts = torch.matmul( @@ -1528,7 +1529,7 @@ class Runner: # rhand_verts = sv_dict['rhand_verts'] - # rhand_verts = torch.from_numpy(rhand_verts).float().cuda() + # rhand_verts = torch.from_numpy(rhand_verts).float() # self.rhand_verts = rhand_verts ## rhand verts ## @@ -1541,7 +1542,7 @@ class Runner: mano_root=self.mano_path, ncomps=45, use_pca=False, - ).cuda() + ) self.lft_mano_layer = ManoLayer( flat_hand_mean=False, @@ -1549,7 +1550,7 @@ class Runner: mano_root=self.mano_path, ncomps=45, use_pca=False, - ).cuda() + ) ##### rhand parameters ##### @@ -1569,10 +1570,10 @@ class Runner: rhand_transl = rhand_transl.reshape(self.window_size, -1).astype(np.float32) rhand_betas = rhand_betas.reshape(-1).astype(np.float32) - rhand_global_orient_var = torch.from_numpy(rhand_global_orient_gt).float().cuda() - rhand_pose_var = torch.from_numpy(rhand_pose_gt).float().cuda() - rhand_beta_var = torch.from_numpy(rhand_betas).float().cuda() - rhand_transl_var = torch.from_numpy(rhand_transl).float().cuda() + rhand_global_orient_var = torch.from_numpy(rhand_global_orient_gt).float() + rhand_pose_var = torch.from_numpy(rhand_pose_gt).float() + rhand_beta_var = torch.from_numpy(rhand_betas).float() + rhand_transl_var = torch.from_numpy(rhand_transl).float() # R.from_rotvec(obj_rot).as_matrix() ##### rhand parameters ##### @@ -1594,10 +1595,10 @@ class Runner: lhand_transl = lhand_transl.reshape(self.window_size, -1).astype(np.float32) lhand_betas = lhand_betas.reshape(-1).astype(np.float32) - lhand_global_orient_var = torch.from_numpy(lhand_global_orient_gt).float().cuda() - lhand_pose_var = torch.from_numpy(lhand_pose_gt).float().cuda() - lhand_beta_var = torch.from_numpy(lhand_betas).float().cuda() - lhand_transl_var = torch.from_numpy(lhand_transl).float().cuda() # self.window_size x 3 + lhand_global_orient_var = torch.from_numpy(lhand_global_orient_gt).float() + lhand_pose_var = torch.from_numpy(lhand_pose_gt).float() + lhand_beta_var = torch.from_numpy(lhand_betas).float() + lhand_transl_var = torch.from_numpy(lhand_transl).float() # self.window_size x 3 # R.from_rotvec(obj_rot).as_matrix() ##### lhand parameters ##### @@ -1631,7 +1632,7 @@ class Runner: if '30_sv_dict' in sv_fn: - bbox_selected_verts_idxes = torch.tensor([1511, 1847, 2190, 2097, 2006, 2108, 1604], dtype=torch.long).cuda() + bbox_selected_verts_idxes = torch.tensor([1511, 1847, 2190, 2097, 2006, 2108, 1604], dtype=torch.long) obj_selected_verts = self.obj_verts[bbox_selected_verts_idxes] else: obj_selected_verts = self.obj_verts.clone() @@ -1679,12 +1680,12 @@ class Runner: self.tot_reversed_obj_rot_mtx = tot_reversed_obj_rot_mtx - # self.tot_reversed_obj_rot_mtx[0] = torch.eye(3, dtype=torch.float32).cuda() + # self.tot_reversed_obj_rot_mtx[0] = torch.eye(3, dtype=torch.float32) ## should save self.object_global_orient and self.object_transl ## # object_global_orient, object_transl # - self.object_global_orient = torch.from_numpy(object_global_orient).float().cuda() - self.object_transl = torch.from_numpy(object_transl).float().cuda() + self.object_global_orient = torch.from_numpy(object_global_orient).float() + self.object_transl = torch.from_numpy(object_transl).float() # self.object_transl[0, :] = self.object_transl[0, :] * 0.0 return transformed_obj_verts, rhand_verts, obj_tot_normals @@ -1753,10 +1754,10 @@ class Runner: if self.other_bending_network.canon_passive_obj_verts is None: init_passive_mesh = self.timestep_to_passive_mesh[0] center_passive_mesh = torch.mean(init_passive_mesh, dim=0) - # center_passive_mesh = torch.zeros((3, )).cuda() + # center_passive_mesh = torch.zeros((3, )) else: init_passive_mesh = self.other_bending_network.canon_passive_obj_verts - center_passive_mesh = torch.zeros((3, )).cuda() + center_passive_mesh = torch.zeros((3, )) pred_passive_mesh = torch.matmul( cur_rot_mtx, (init_passive_mesh - center_passive_mesh.unsqueeze(0)).transpose(1, 0) ).transpose(1, 0) + center_passive_mesh.unsqueeze(0) + cur_translations.unsqueeze(0) @@ -1827,7 +1828,7 @@ class Runner: robo_sampled_verts_idxes_fn = "robo_sampled_verts_idxes.npy" if os.path.exists(robo_sampled_verts_idxes_fn): sampled_verts_idxes = np.load(robo_sampled_verts_idxes_fn) - sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long().cuda() + sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long() else: n_sampling = 1000 pts_fps_idx = data_utils.farthest_point_sampling(robo_init_verts.unsqueeze(0), n_sampling=n_sampling) @@ -1897,25 +1898,25 @@ class Runner: ''' Define MANO robot actions, delta_states, init_states, frictions, and others ''' self.mano_robot_actions = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_actions.weight) # params_to_train += list(self.robot_actions.parameters()) self.mano_robot_delta_states = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_delta_states.weight) # params_to_train += list(self.robot_delta_states.parameters()) self.mano_robot_init_states = nn.Embedding( num_embeddings=1, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_init_states.weight) # params_to_train += list(self.robot_init_states.parameters()) self.mano_robot_glb_rotation = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=4 - ).cuda() + ) self.mano_robot_glb_rotation.weight.data[:, 0] = 1. self.mano_robot_glb_rotation.weight.data[:, 1:] = 0. # params_to_train += list(self.robot_glb_rotation.parameters()) @@ -1923,14 +1924,14 @@ class Runner: self.mano_robot_glb_trans = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_glb_trans.weight) # params_to_train += list(self.robot_glb_trans.parameters()) ## self.mano_robot_states = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, # embedding; a realistic thing # # ## so the optimizable modle deisgn --- approxmimate what you see and approximate the target simulator ## # at a distance; the asymmetric contact froces spring ks -- all of them wold affect model's behaviours ## ## mao robot glb - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_states.weight) self.mano_robot_states.weight.data[0, :] = self.mano_robot_init_states.weight.data[0, :].clone() @@ -1938,7 +1939,7 @@ class Runner: self.mano_expanded_actuator_delta_offset = nn.Embedding( num_embeddings=self.expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_delta_offset.weight) # params_to_train += list(self.mano_expanded_actuator_delta_offset.parameters()) @@ -1946,7 +1947,7 @@ class Runner: # mano_expanded_actuator_friction_forces, mano_expanded_actuator_delta_offset # self.mano_expanded_actuator_friction_forces = nn.Embedding( num_embeddings=self.expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_friction_forces.weight) ## load mano states and actions ## @@ -1978,45 +1979,45 @@ class Runner: ''' parameters for the real robot hand ''' self.robot_actions = nn.Embedding( num_embeddings=num_steps, embedding_dim=22, - ).cuda() + ) torch.nn.init.zeros_(self.robot_actions.weight) params_to_train += list(self.robot_actions.parameters()) # self.robot_delta_states = nn.Embedding( # num_embeddings=num_steps, embedding_dim=60, - # ).cuda() + # ) # torch.nn.init.zeros_(self.robot_delta_states.weight) # params_to_train += list(self.robot_delta_states.parameters()) self.robot_states = nn.Embedding( num_embeddings=num_steps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.robot_states.weight) params_to_train += list(self.robot_states.parameters()) self.robot_init_states = nn.Embedding( num_embeddings=1, embedding_dim=22, - ).cuda() + ) torch.nn.init.zeros_(self.robot_init_states.weight) params_to_train += list(self.robot_init_states.parameters()) ## robot glb rotations ## self.robot_glb_rotation = nn.Embedding( ## robot hand rotation num_embeddings=num_steps, embedding_dim=4 - ).cuda() + ) self.robot_glb_rotation.weight.data[:, 0] = 1. self.robot_glb_rotation.weight.data[:, 1:] = 0. self.robot_glb_trans = nn.Embedding( num_embeddings=num_steps, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.robot_glb_trans.weight) # ### local minimum -> ## robot self.robot_actuator_friction_forces = nn.Embedding( # frictional forces ## num_embeddings=365428 * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.robot_actuator_friction_forces.weight) @@ -2092,13 +2093,13 @@ class Runner: with torch.no_grad(): # init them to zero for cur_ts in range(self.nn_ts * self.mano_nn_substeps): ''' Get rotations, translations, and actions of the current robot ''' ## mano robot glb rotation - cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_rot = cur_glb_rot / torch.clamp(torch.norm(cur_glb_rot, dim=-1, p=2), min=1e-7) # mano glb rot cur_glb_rot = dyn_model_act.quaternion_to_matrix(cur_glb_rot) # mano glboal rotations # - cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) - link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.mano_agent.set_init_states_target_value(link_cur_states) @@ -2109,7 +2110,7 @@ class Runner: cur_visual_pts_idxes = torch.arange( start=cur_ts * self.expanded_visual_pts_nn, end=(cur_ts + 1) * self.expanded_visual_pts_nn, dtype=torch.long - ).cuda() + ) cur_visual_pts_offset = self.mano_expanded_actuator_delta_offset(cur_visual_pts_idxes) ## get the idxes ### @@ -2257,9 +2258,9 @@ class Runner: tot_interpenetration_nns = [] # init global transformations ## - # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32).cuda() + # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32) # for cur_ts in range(self.nn_ts): for cur_ts in range(self.nn_ts * self.mano_nn_substeps): @@ -2269,7 +2270,7 @@ class Runner: self.free_def_bending_weight = 0.0 # mano_robot_glb_rotation, mano_robot_glb_trans, mano_robot_delta_states # - cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_rot = cur_glb_rot + cur_ts_redmax_delta_rotations @@ -2277,14 +2278,14 @@ class Runner: # cur_glb_rot_quat = cur_glb_rot.clone() cur_glb_rot = dyn_model_act.quaternion_to_matrix(cur_glb_rot) - cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # # # cur_ts_delta_rot, cur_ts_redmax_robot_trans # # # # cur_glb_rot = torch.matmul(cur_ts_delta_rot, cur_glb_rot) cur_glb_trans = cur_glb_trans + cur_ts_redmax_robot_trans # redmax robot transj## - link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.mano_agent.set_init_states_target_value(link_cur_states) cur_visual_pts = self.mano_agent.get_init_state_visual_pts(expanded_pts=True) # init state visual pts # @@ -2294,7 +2295,7 @@ class Runner: # expanded_pts # cur_visual_pts_idxes = torch.arange( start=cur_ts * self.expanded_visual_pts_nn, end=(cur_ts + 1) * self.expanded_visual_pts_nn, dtype=torch.long - ).cuda() + ) cur_visual_pts_offset = self.mano_expanded_actuator_delta_offset(cur_visual_pts_idxes) ## get the idxes ### ## get the friction forces ## @@ -2337,16 +2338,16 @@ class Runner: self.timestep_to_raw_active_meshes[cur_ts] = cur_visual_pts.detach().cpu().numpy() self.ts_to_dyn_mano_pts[cur_ts] = cur_dyn_mano_pts.detach().cpu().numpy() - # # ragged_dist = torch.zeros((1,), dtype=torch.float32).cuda().mean() - # # dist_transformed_expanded_visual_pts_to_ori_visual_pts = torch.zeros((1,), dtype=torch.float32).cuda().mean() - # # diff_cur_states_to_ref_states = torch.zeros((1,), dtype=torch.float32).cuda().mean() - # cur_robo_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # # ragged_dist = torch.zeros((1,), dtype=torch.float32).mean() + # # dist_transformed_expanded_visual_pts_to_ori_visual_pts = torch.zeros((1,), dtype=torch.float32).mean() + # # diff_cur_states_to_ref_states = torch.zeros((1,), dtype=torch.float32).mean() + # cur_robo_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # cur_robo_glb_rot = cur_robo_glb_rot / torch.clamp(torch.norm(cur_robo_glb_rot, dim=-1, p=2), min=1e-7) # cur_robo_glb_rot = dyn_model_act.quaternion_to_matrix(cur_robo_glb_rot) # mano glboal rotations # - # cur_robo_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # cur_robo_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) - # robo_links_states = self.robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # robo_links_states = self.robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # self.robot_agent.set_init_states_target_value(robo_links_states) # cur_robo_visual_pts = self.robot_agent.get_init_state_visual_pts() @@ -2443,7 +2444,7 @@ class Runner: # in_func_tracking_loss = self.compute_loss_optimized_transformations_v2(cur_ts + 1, cur_passive_big_ts + 1) # # tot_tracking_loss.append(tracking_loss.detach().cpu().item()) # else: - # in_func_tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + # in_func_tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() # return in_func_tracking_loss @@ -2493,11 +2494,11 @@ class Runner: # net_penetrating_points = (net_penetrating_points * self.extent_robo_pts) + self.minn_robo_pts - # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32).cuda() + # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32) # else: # # penetration_forces = None - # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32).cuda() + # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32) # if contact_pairs_set is not None: # self.contact_pairs_sets[cur_ts] = contact_pairs_set.copy() @@ -2518,7 +2519,7 @@ class Runner: # if self.optimize_with_intermediates: # tracking_loss = self.compute_loss_optimized_transformations(cur_ts + 1) # # else: - # tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + # tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() # # cur_ts % mano_nn_substeps == 0: # @@ -2528,7 +2529,7 @@ class Runner: tracking_loss = self.compute_loss_optimized_transformations_v2(cur_ts + 1, cur_passive_big_ts + 1) tot_tracking_loss.append(tracking_loss.detach().cpu().item()) else: - tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() # # hand_tracking_loss = torch.sum( ## delta states? ## # # (self.timestep_to_active_mesh_w_delta_states[cur_ts] - cur_visual_pts) ** 2, dim=-1 @@ -2547,7 +2548,7 @@ class Runner: tot_interpenetration_nns.append(cur_interpenetration_nns) - # diff_hand_tracking = torch.zeros((1,), dtype=torch.float32).cuda().mean() ## + # diff_hand_tracking = torch.zeros((1,), dtype=torch.float32).mean() ## # ## diff # # diff_hand_tracking_coef @@ -2618,7 +2619,7 @@ class Runner: # self.other_bending_network.reset_timestep_to_quantities(cur_ts) - robot_states_actions_diff_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + robot_states_actions_diff_loss = torch.zeros((1,), dtype=torch.float32).mean() robo_actions_diff_loss.append(reg_delta_offset_loss.item()) @@ -2688,6 +2689,7 @@ class Runner: ''' Load the robot hand ''' + self.hand_type = "shadow_hand" # model_path = self.conf['model.sim_model_path'] # self.hand_type = "redmax_hand" # if model_path.endswith(".xml"): @@ -2703,7 +2705,7 @@ class Runner: # robo_sampled_verts_idxes_fn = "robo_sampled_verts_idxes.npy" # if os.path.exists(robo_sampled_verts_idxes_fn): # sampled_verts_idxes = np.load(robo_sampled_verts_idxes_fn) - # sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long().cuda() + # sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long() # else: # n_sampling = 1000 # pts_fps_idx = data_utils.farthest_point_sampling(robo_init_verts.unsqueeze(0), n_sampling=n_sampling) @@ -2773,25 +2775,25 @@ class Runner: ''' Define MANO robot actions, delta_states, init_states, frictions, and others ''' self.mano_robot_actions = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_actions.weight) # params_to_train += list(self.robot_actions.parameters()) self.mano_robot_delta_states = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_delta_states.weight) # params_to_train += list(self.robot_delta_states.parameters()) self.mano_robot_init_states = nn.Embedding( num_embeddings=1, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_init_states.weight) # params_to_train += list(self.robot_init_states.parameters()) self.mano_robot_glb_rotation = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=4 - ).cuda() + ) self.mano_robot_glb_rotation.weight.data[:, 0] = 1. self.mano_robot_glb_rotation.weight.data[:, 1:] = 0. # params_to_train += list(self.robot_glb_rotation.parameters()) @@ -2799,14 +2801,14 @@ class Runner: self.mano_robot_glb_trans = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_glb_trans.weight) # params_to_train += list(self.robot_glb_trans.parameters()) ## self.mano_robot_states = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, # embedding; a realistic thing # # ## so the optimizable modle deisgn --- approxmimate what you see and approximate the target simulator ## # at a distance; the asymmetric contact froces spring ks -- all of them wold affect model's behaviours ## ## mao robot glb - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_states.weight) self.mano_robot_states.weight.data[0, :] = self.mano_robot_init_states.weight.data[0, :].clone() @@ -2814,25 +2816,25 @@ class Runner: self.mano_expanded_actuator_delta_offset = nn.Embedding( num_embeddings=self.expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_delta_offset.weight) # params_to_train += list(self.mano_expanded_actuator_delta_offset.parameters()) self.mano_expanded_actuator_friction_forces = nn.Embedding( num_embeddings=self.expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_friction_forces.weight) ##### expanded actuators pointact jforces ### self.mano_expanded_actuator_pointact_forces = nn.Embedding( num_embeddings=self.expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_pointact_forces.weight) self.mano_expanded_actuator_pointact_damping_coefs = nn.Embedding( num_embeddings=10, embedding_dim=1 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_pointact_damping_coefs.weight) @@ -2873,45 +2875,45 @@ class Runner: ''' parameters for the real robot hand ''' self.robot_actions = nn.Embedding( num_embeddings=num_steps, embedding_dim=22, - ).cuda() + ) torch.nn.init.zeros_(self.robot_actions.weight) params_to_train += list(self.robot_actions.parameters()) # self.robot_delta_states = nn.Embedding( # num_embeddings=num_steps, embedding_dim=60, - # ).cuda() + # ) # torch.nn.init.zeros_(self.robot_delta_states.weight) # params_to_train += list(self.robot_delta_states.parameters()) self.robot_states = nn.Embedding( num_embeddings=num_steps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.robot_states.weight) params_to_train += list(self.robot_states.parameters()) self.robot_init_states = nn.Embedding( num_embeddings=1, embedding_dim=22, - ).cuda() + ) torch.nn.init.zeros_(self.robot_init_states.weight) params_to_train += list(self.robot_init_states.parameters()) ## robot glb rotations ## self.robot_glb_rotation = nn.Embedding( ## robot hand rotation num_embeddings=num_steps, embedding_dim=4 - ).cuda() + ) self.robot_glb_rotation.weight.data[:, 0] = 1. self.robot_glb_rotation.weight.data[:, 1:] = 0. self.robot_glb_trans = nn.Embedding( num_embeddings=num_steps, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.robot_glb_trans.weight) # ### local minimum -> ## robot self.robot_actuator_friction_forces = nn.Embedding( # frictional forces ## num_embeddings=365428 * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.robot_actuator_friction_forces.weight) @@ -2997,24 +2999,24 @@ class Runner: # ### with torch.no_grad(): - cur_vel_damping_coef = self.mano_expanded_actuator_pointact_damping_coefs(torch.zeros((1,), dtype=torch.long).cuda()).squeeze(0) ### velocity damping coef + cur_vel_damping_coef = self.mano_expanded_actuator_pointact_damping_coefs(torch.zeros((1,), dtype=torch.long)).squeeze(0) ### velocity damping coef for cur_ts in range(self.nn_ts * self.mano_nn_substeps): ''' Get rotations, translations, and actions of the current robot ''' ## mano robot glb rotation - cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_rot = cur_glb_rot / torch.clamp(torch.norm(cur_glb_rot, dim=-1, p=2), min=1e-7) # mano glb rot cur_glb_rot = dyn_model_act.quaternion_to_matrix(cur_glb_rot) # mano glboal rotations # - cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) ### motivate via states #### - # link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # self.mano_agent.set_init_states_target_value(link_cur_states) ### motivate via states #### ### motivate via actions #### - link_cur_actions = self.mano_robot_actions(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_actions = self.mano_robot_actions(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.mano_agent.set_actions_and_update_states_v2( link_cur_actions, cur_ts, penetration_forces=None, sampled_visual_pts_joint_idxes=None) ### motivate via actions #### @@ -3026,7 +3028,7 @@ class Runner: cur_visual_pts_idxes = torch.arange( start=cur_ts * self.expanded_visual_pts_nn, end=(cur_ts + 1) * self.expanded_visual_pts_nn, dtype=torch.long - ).cuda() + ) # cur_visual_pts_offset = self.mano_expanded_actuator_delta_offset(cur_visual_pts_idxes) ## get the idxes ### cur_visual_pts_forces = self.mano_expanded_actuator_pointact_forces(cur_visual_pts_idxes) ## get vsual pts forces ### @@ -3208,9 +3210,9 @@ class Runner: tot_summ_grad_mano_expanded_actuator_pointact_forces_weight = [] # init global transformations ## - # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32).cuda() + # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32) @@ -3221,7 +3223,7 @@ class Runner: self.free_def_bending_weight = 0.0 # mano_robot_glb_rotation, mano_robot_glb_trans, mano_robot_delta_states # - cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_rot = cur_glb_rot + cur_ts_redmax_delta_rotations @@ -3229,27 +3231,27 @@ class Runner: # cur_glb_rot_quat = cur_glb_rot.clone() cur_glb_rot = dyn_model_act.quaternion_to_matrix(cur_glb_rot) - cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # # # cur_ts_delta_rot, cur_ts_redmax_robot_trans # # # # cur_glb_rot = torch.matmul(cur_ts_delta_rot, cur_glb_rot) cur_glb_trans = cur_glb_trans + cur_ts_redmax_robot_trans # redmax robot transj## - # link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # self.mano_agent.set_init_states_target_value(link_cur_states) ### motivate via states #### - # link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # self.mano_agent.set_init_states_target_value(link_cur_states) ### motivate via states #### ### motivate via actions #### - link_cur_actions = self.mano_robot_actions(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_actions = self.mano_robot_actions(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.mano_agent.set_actions_and_update_states_v2( link_cur_actions, cur_ts, penetration_forces=penetration_forces, sampled_visual_pts_joint_idxes=sampled_visual_pts_joint_idxes) ### motivate via actions #### @@ -3265,7 +3267,7 @@ class Runner: # expanded_pts # # expanded pts # cur_visual_pts_idxes = torch.arange( start=cur_ts * self.expanded_visual_pts_nn, end=(cur_ts + 1) * self.expanded_visual_pts_nn, dtype=torch.long - ).cuda() + ) # cur_visual_pts_offset = self.mano_expanded_actuator_delta_offset(cur_visual_pts_idxes) ## get the idxes ### @@ -3370,16 +3372,16 @@ class Runner: self.ts_to_dyn_mano_pts_th[cur_ts] = cur_dyn_mano_pts ## ragged dist ## - # # ragged_dist = torch.zeros((1,), dtype=torch.float32).cuda().mean() - # # dist_transformed_expanded_visual_pts_to_ori_visual_pts = torch.zeros((1,), dtype=torch.float32).cuda().mean() - # # diff_cur_states_to_ref_states = torch.zeros((1,), dtype=torch.float32).cuda().mean() - # cur_robo_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # # ragged_dist = torch.zeros((1,), dtype=torch.float32).mean() + # # dist_transformed_expanded_visual_pts_to_ori_visual_pts = torch.zeros((1,), dtype=torch.float32).mean() + # # diff_cur_states_to_ref_states = torch.zeros((1,), dtype=torch.float32).mean() + # cur_robo_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # cur_robo_glb_rot = cur_robo_glb_rot / torch.clamp(torch.norm(cur_robo_glb_rot, dim=-1, p=2), min=1e-7) # cur_robo_glb_rot = dyn_model_act.quaternion_to_matrix(cur_robo_glb_rot) # mano glboal rotations # - # cur_robo_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # cur_robo_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) - # robo_links_states = self.robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # robo_links_states = self.robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # self.robot_agent.set_init_states_target_value(robo_links_states) # cur_robo_visual_pts = self.robot_agent.get_init_state_visual_pts() @@ -3476,7 +3478,7 @@ class Runner: # in_func_tracking_loss = self.compute_loss_optimized_transformations_v2(cur_ts + 1, cur_passive_big_ts + 1) # # tot_tracking_loss.append(tracking_loss.detach().cpu().item()) # else: - # in_func_tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + # in_func_tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() # return in_func_tracking_loss @@ -3495,9 +3497,9 @@ class Runner: # print(self.timestep_to_active_mesh[cur_ts].size(), cur_visual_pts_friction_forces.size()) ## to active mesh ## # contact_pairs_set = self.other_bending_network.forward2( input_pts_ts=cur_ts, timestep_to_active_mesh=ts_to_act_mesh, timestep_to_passive_mesh=self.timestep_to_passive_mesh, timestep_to_passive_mesh_normals=self.timestep_to_passive_mesh_normals, friction_forces=self.robot_actuator_friction_forces, sampled_verts_idxes=None, reference_mano_pts=None, fix_obj=self.fix_obj, contact_pairs_set=contact_pairs_set, pts_frictional_forces=cur_visual_pts_friction_forces) - if not self.fix_obj: - ### then usin gthe other bending network to forward the simulation ### - contact_pairs_set = self.other_bending_network.forward2( input_pts_ts=cur_ts, timestep_to_active_mesh=ts_to_act_mesh, timestep_to_passive_mesh=self.timestep_to_passive_mesh, timestep_to_passive_mesh_normals=self.timestep_to_passive_mesh_normals, friction_forces=self.robot_actuator_friction_forces, sampled_verts_idxes=None, reference_mano_pts=None, fix_obj=self.fix_obj, contact_pairs_set=contact_pairs_set) + # if not self.fix_obj: + ### then usin gthe other bending network to forward the simulation ### + contact_pairs_set = self.other_bending_network.forward2( input_pts_ts=cur_ts, timestep_to_active_mesh=ts_to_act_mesh, timestep_to_passive_mesh=self.timestep_to_passive_mesh, timestep_to_passive_mesh_normals=self.timestep_to_passive_mesh_normals, friction_forces=self.robot_actuator_friction_forces, sampled_verts_idxes=None, reference_mano_pts=None, fix_obj=self.fix_obj, contact_pairs_set=contact_pairs_set) ### train with force to active ## # if self.train_with_forces_to_active and (not self.use_mano_inputs): @@ -3543,14 +3545,14 @@ class Runner: # # net_penetrating_points = (net_penetrating_points * self.extent_robo_pts) + self.minn_robo_pts # penetration_forces = net_penetrating_forces - # # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32).cuda() + # # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32) # # # else: penetration_forces = None sampled_visual_pts_joint_idxes = None - # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32).cuda() + # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32) ''' the bending network still have this property and we can get force values here for the expanded visual points ''' - self.timestep_to_actuator_points_passive_forces[cur_ts] = self.other_bending_network.penetrating_forces_allpts.detach().clone() + # self.timestep_to_actuator_points_passive_forces[cur_ts] = self.other_bending_network.penetrating_forces_allpts.detach().clone() # if contact_pairs_set is not None: # self.contact_pairs_sets[cur_ts] = contact_pairs_set.copy() @@ -3569,7 +3571,7 @@ class Runner: # if self.optimize_with_intermediates: # tracking_loss = self.compute_loss_optimized_transformations(cur_ts + 1) # # else: - # tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + # tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() ## expanded points set dyn ## @@ -3580,7 +3582,7 @@ class Runner: tracking_loss = self.compute_loss_optimized_transformations_v2(cur_ts + 1, cur_passive_big_ts + 1) tot_tracking_loss.append(tracking_loss.detach().cpu().item()) else: - tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() # # hand_tracking_loss = torch.sum( ## delta states? ## # # (self.timestep_to_active_mesh_w_delta_states[cur_ts] - cur_visual_pts) ** 2, dim=-1 @@ -3600,7 +3602,7 @@ class Runner: tot_interpenetration_nns.append(cur_interpenetration_nns) - # diff_hand_tracking = torch.zeros((1,), dtype=torch.float32).cuda().mean() ## + # diff_hand_tracking = torch.zeros((1,), dtype=torch.float32).mean() ## # # kinematics_proj_loss = kinematics_trans_diff + penetraton_penalty + diff_hand_tracking * self.diff_hand_tracking_coef + tracking_loss @@ -3704,7 +3706,7 @@ class Runner: # self.other_bending_network.reset_timestep_to_quantities(cur_ts) - # robot_states_actions_diff_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + # robot_states_actions_diff_loss = torch.zeros((1,), dtype=torch.float32).mean() robo_actions_diff_loss.append(reg_delta_offset_loss.item()) @@ -3820,7 +3822,7 @@ class Runner: redmax_sampled_verts_idxes_fn = os.path.join("assets", redmax_sampled_verts_idxes_fn) if os.path.exists(redmax_sampled_verts_idxes_fn): sampled_verts_idxes = np.load(redmax_sampled_verts_idxes_fn) - sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long().cuda() + sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long() else: n_sampling = 1000 pts_fps_idx = data_utils.farthest_point_sampling(robo_init_verts.unsqueeze(0), n_sampling=n_sampling) @@ -3896,25 +3898,25 @@ class Runner: ''' Define MANO robot actions, delta_states, init_states, frictions, and others ''' self.mano_robot_actions = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_actions.weight) # params_to_train += list(self.robot_actions.parameters()) self.mano_robot_delta_states = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_delta_states.weight) # params_to_train += list(self.robot_delta_states.parameters()) self.mano_robot_init_states = nn.Embedding( num_embeddings=1, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_init_states.weight) # params_to_train += list(self.robot_init_states.parameters()) self.mano_robot_glb_rotation = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=4 - ).cuda() + ) self.mano_robot_glb_rotation.weight.data[:, 0] = 1. self.mano_robot_glb_rotation.weight.data[:, 1:] = 0. # params_to_train += list(self.robot_glb_rotation.parameters()) @@ -3922,13 +3924,13 @@ class Runner: self.mano_robot_glb_trans = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_glb_trans.weight) # params_to_train += list(self.robot_glb_trans.parameters()) self.mano_robot_states = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_states.weight) self.mano_robot_states.weight.data[0, :] = self.mano_robot_init_states.weight.data[0, :].clone() @@ -3936,7 +3938,7 @@ class Runner: self.mano_expanded_actuator_delta_offset = nn.Embedding( num_embeddings=self.expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_delta_offset.weight) # params_to_train += list(self.mano_expanded_actuator_delta_offset.parameters()) @@ -3944,19 +3946,19 @@ class Runner: # mano_expanded_actuator_friction_forces, mano_expanded_actuator_delta_offset # self.mano_expanded_actuator_friction_forces = nn.Embedding( num_embeddings=self.expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_friction_forces.weight) ##### expanded actuators pointact jforces ### self.mano_expanded_actuator_pointact_forces = nn.Embedding( num_embeddings=self.expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_pointact_forces.weight) self.mano_expanded_actuator_pointact_damping_coefs = nn.Embedding( num_embeddings=10, embedding_dim=1 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_pointact_damping_coefs.weight) @@ -3999,44 +4001,44 @@ class Runner: # # robot actions # # real robot hand ## self.robot_actions = nn.Embedding( num_embeddings=num_steps, embedding_dim=22, - ).cuda() + ) torch.nn.init.zeros_(self.robot_actions.weight) params_to_train += list(self.robot_actions.parameters()) # self.robot_delta_states = nn.Embedding( # num_embeddings=num_steps, embedding_dim=60, - # ).cuda() + # ) # torch.nn.init.zeros_(self.robot_delta_states.weight) # params_to_train += list(self.robot_delta_states.parameters()) self.robot_states = nn.Embedding( num_embeddings=num_steps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.robot_states.weight) params_to_train += list(self.robot_states.parameters()) self.robot_init_states = nn.Embedding( num_embeddings=1, embedding_dim=22, - ).cuda() + ) torch.nn.init.zeros_(self.robot_init_states.weight) params_to_train += list(self.robot_init_states.parameters()) ## robot glb rotations ## self.robot_glb_rotation = nn.Embedding( ## robot hand rotation num_embeddings=num_steps, embedding_dim=4 - ).cuda() + ) self.robot_glb_rotation.weight.data[:, 0] = 1. self.robot_glb_rotation.weight.data[:, 1:] = 0. self.robot_glb_trans = nn.Embedding( num_embeddings=num_steps, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.robot_glb_trans.weight) # ### local minimum -> ## robot self.robot_actuator_friction_forces = nn.Embedding( # frictional forces ## num_embeddings=365428 * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.robot_actuator_friction_forces.weight) @@ -4133,13 +4135,13 @@ class Runner: with torch.no_grad(): # init them to zero for cur_ts in range(self.nn_ts * self.mano_nn_substeps): ''' Get rotations, translations, and actions of the current robot ''' - cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_rot = cur_glb_rot / torch.clamp(torch.norm(cur_glb_rot, dim=-1, p=2), min=1e-7) # mano glb rot cur_glb_rot = dyn_model_act.quaternion_to_matrix(cur_glb_rot) # mano glboal rotations # - cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) ## mano robot states ## mano robot states ## - link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.mano_agent.set_init_states_target_value(link_cur_states) ## set init visual pts ## @@ -4151,7 +4153,7 @@ class Runner: # expanded_pts # cur_visual_pts_idxes = torch.arange( start=cur_ts * self.expanded_visual_pts_nn, end=(cur_ts + 1) * self.expanded_visual_pts_nn, dtype=torch.long - ).cuda() + ) cur_visual_pts_offset = self.mano_expanded_actuator_delta_offset(cur_visual_pts_idxes) ## get the idxes ### @@ -4176,13 +4178,13 @@ class Runner: self.timestep_to_active_mesh_opt_ours_sim[cur_ts] = cur_visual_pts.detach() - cur_robo_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_robo_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_robo_glb_rot = cur_robo_glb_rot / torch.clamp(torch.norm(cur_robo_glb_rot, dim=-1, p=2), min=1e-7) cur_robo_glb_rot = dyn_model_act.quaternion_to_matrix(cur_robo_glb_rot) # mano glboal rotations # - cur_robo_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_robo_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) - robo_links_states = self.robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + robo_links_states = self.robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.robot_agent.set_init_states_target_value(robo_links_states) cur_robo_visual_pts = self.robot_agent.get_init_state_visual_pts() @@ -4328,9 +4330,9 @@ class Runner: # init global transformations ## - # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32).cuda() + # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32) # for cur_ts in range(self.nn_ts): for cur_ts in range(self.nn_ts * self.mano_nn_substeps): @@ -4340,7 +4342,7 @@ class Runner: self.free_def_bending_weight = 0.0 # mano_robot_glb_rotation, mano_robot_glb_trans, mano_robot_delta_states # - cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_rot = cur_glb_rot + cur_ts_redmax_delta_rotations @@ -4348,21 +4350,21 @@ class Runner: # cur_glb_rot_quat = cur_glb_rot.clone() cur_glb_rot = dyn_model_act.quaternion_to_matrix(cur_glb_rot) # mano glboal rotations # # glb rot # trans # - cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # # # cur_ts_delta_rot, cur_ts_redmax_robot_trans # # # # cur_glb_rot = torch.matmul(cur_ts_delta_rot, cur_glb_rot) # cur_glb_trans = cur_glb_trans + cur_ts_redmax_robot_trans # redmax robot transj## - # link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # self.mano_agent.set_init_states_target_value(link_cur_states) # cur_visual_pts = self.mano_agent.get_init_state_visual_pts(expanded_pts=True) # init state visual pts # # cur_dyn_mano_pts = self.mano_agent.get_init_state_visual_pts(expanded_pts=False) # init s ### motivate via actions #### - link_cur_actions = self.mano_robot_actions(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_actions = self.mano_robot_actions(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.mano_agent.set_actions_and_update_states_v2( link_cur_actions, cur_ts, penetration_forces=penetration_forces, sampled_visual_pts_joint_idxes=sampled_visual_pts_joint_idxes) ### motivate via actions #### @@ -4378,7 +4380,7 @@ class Runner: # expanded_pts # cur_visual_pts_idxes = torch.arange( start=cur_ts * self.expanded_visual_pts_nn, end=(cur_ts + 1) * self.expanded_visual_pts_nn, dtype=torch.long - ).cuda() + ) if self.drive_pointset == "actions": @@ -4484,16 +4486,16 @@ class Runner: self.ts_to_dyn_mano_pts_th[cur_ts] = cur_dyn_mano_pts - # ragged_dist = torch.zeros((1,), dtype=torch.float32).cuda().mean() - # dist_transformed_expanded_visual_pts_to_ori_visual_pts = torch.zeros((1,), dtype=torch.float32).cuda().mean() - # diff_cur_states_to_ref_states = torch.zeros((1,), dtype=torch.float32).cuda().mean() - cur_robo_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # ragged_dist = torch.zeros((1,), dtype=torch.float32).mean() + # dist_transformed_expanded_visual_pts_to_ori_visual_pts = torch.zeros((1,), dtype=torch.float32).mean() + # diff_cur_states_to_ref_states = torch.zeros((1,), dtype=torch.float32).mean() + cur_robo_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_robo_glb_rot = cur_robo_glb_rot / torch.clamp(torch.norm(cur_robo_glb_rot, dim=-1, p=2), min=1e-7) cur_robo_glb_rot = dyn_model_act.quaternion_to_matrix(cur_robo_glb_rot) # mano glboal rotations # - cur_robo_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_robo_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) - robo_links_states = self.robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + robo_links_states = self.robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.robot_agent.set_init_states_target_value(robo_links_states) cur_robo_visual_pts = self.robot_agent.get_init_state_visual_pts() @@ -4587,7 +4589,7 @@ class Runner: # in_func_tracking_loss = self.compute_loss_optimized_transformations_v2(cur_ts + 1, cur_passive_big_ts + 1) # # tot_tracking_loss.append(tracking_loss.detach().cpu().item()) # else: - # in_func_tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + # in_func_tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() # return in_func_tracking_loss @@ -4655,12 +4657,12 @@ class Runner: # net_penetrating_points = (net_penetrating_points * self.extent_robo_pts) + self.minn_robo_pts penetration_forces = net_penetrating_forces - # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32).cuda() + # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32) # else: penetration_forces = None sampled_visual_pts_joint_idxes = None - # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32).cuda() + # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32) ''' the bending network still have this property and we can get force values here for the expanded visual points ''' self.timestep_to_actuator_points_passive_forces[cur_ts] = self.other_bending_network.penetrating_forces_allpts.detach().clone() @@ -4709,11 +4711,11 @@ class Runner: # net_penetrating_points = (net_penetrating_points * self.extent_robo_pts) + self.minn_robo_pts - # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32).cuda() + # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32) # else: # # penetration_forces = None - # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32).cuda() + # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32) # if contact_pairs_set is not None: # self.contact_pairs_sets[cur_ts] = contact_pairs_set.copy() @@ -4734,7 +4736,7 @@ class Runner: # if self.optimize_with_intermediates: # tracking_loss = self.compute_loss_optimized_transformations(cur_ts + 1) # # else: - # tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + # tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() # # cur_ts % mano_nn_substeps == 0: # @@ -4744,7 +4746,7 @@ class Runner: tracking_loss = self.compute_loss_optimized_transformations_v2(cur_ts + 1, cur_passive_big_ts + 1) tot_tracking_loss.append(tracking_loss.detach().cpu().item()) else: - tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() # # hand_tracking_loss = torch.sum( ## delta states? ## # # (self.timestep_to_active_mesh_w_delta_states[cur_ts] - cur_visual_pts) ** 2, dim=-1 @@ -4757,7 +4759,7 @@ class Runner: # penetraton_penalty = self.other_bending_network.penetrating_depth_penalty * self.penetrating_depth_penalty_coef - # diff_hand_tracking = torch.zeros((1,), dtype=torch.float32).cuda().mean() ## + # diff_hand_tracking = torch.zeros((1,), dtype=torch.float32).mean() ## # ## diff # # diff_hand_tracking_coef @@ -4816,7 +4818,7 @@ class Runner: # self.other_bending_network.reset_timestep_to_quantities(cur_ts) - # robot_states_actions_diff_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + # robot_states_actions_diff_loss = torch.zeros((1,), dtype=torch.float32).mean() # diff_actions robot_states_actions_diff_loss = diff_actions robo_actions_diff_loss.append(robot_states_actions_diff_loss) @@ -4920,7 +4922,7 @@ class Runner: redmax_sampled_verts_idxes_fn = os.path.join("assets", redmax_sampled_verts_idxes_fn) if os.path.exists(redmax_sampled_verts_idxes_fn): sampled_verts_idxes = np.load(redmax_sampled_verts_idxes_fn) - sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long().cuda() + sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long() else: n_sampling = 1000 pts_fps_idx = data_utils.farthest_point_sampling(robo_init_verts.unsqueeze(0), n_sampling=n_sampling) @@ -5000,25 +5002,25 @@ class Runner: ''' Define MANO robot actions, delta_states, init_states, frictions, and others ''' self.mano_robot_actions = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_actions.weight) # params_to_train += list(self.robot_actions.parameters()) self.mano_robot_delta_states = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_delta_states.weight) # params_to_train += list(self.robot_delta_states.parameters()) self.mano_robot_init_states = nn.Embedding( num_embeddings=1, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_init_states.weight) # params_to_train += list(self.robot_init_states.parameters()) self.mano_robot_glb_rotation = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=4 - ).cuda() + ) self.mano_robot_glb_rotation.weight.data[:, 0] = 1. self.mano_robot_glb_rotation.weight.data[:, 1:] = 0. # params_to_train += list(self.robot_glb_rotation.parameters()) @@ -5026,13 +5028,13 @@ class Runner: self.mano_robot_glb_trans = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_glb_trans.weight) # params_to_train += list(self.robot_glb_trans.parameters()) self.mano_robot_states = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_states.weight) self.mano_robot_states.weight.data[0, :] = self.mano_robot_init_states.weight.data[0, :].clone() @@ -5040,7 +5042,7 @@ class Runner: self.mano_expanded_actuator_delta_offset = nn.Embedding( num_embeddings=self.expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_delta_offset.weight) # params_to_train += list(self.mano_expanded_actuator_delta_offset.parameters()) @@ -5048,19 +5050,19 @@ class Runner: # mano_expanded_actuator_friction_forces, mano_expanded_actuator_delta_offset # self.mano_expanded_actuator_friction_forces = nn.Embedding( num_embeddings=self.expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_friction_forces.weight) ##### expanded actuators pointact jforces ### self.mano_expanded_actuator_pointact_forces = nn.Embedding( num_embeddings=self.expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_pointact_forces.weight) self.mano_expanded_actuator_pointact_damping_coefs = nn.Embedding( num_embeddings=10, embedding_dim=1 - ).cuda() + ) torch.nn.init.zeros_(self.mano_expanded_actuator_pointact_damping_coefs.weight) @@ -5103,50 +5105,50 @@ class Runner: # # robot actions # # real robot hand ## self.robot_actions = nn.Embedding( num_embeddings=num_steps, embedding_dim=22, - ).cuda() + ) torch.nn.init.zeros_(self.robot_actions.weight) params_to_train += list(self.robot_actions.parameters()) # self.robot_delta_states = nn.Embedding( # num_embeddings=num_steps, embedding_dim=60, - # ).cuda() + # ) # torch.nn.init.zeros_(self.robot_delta_states.weight) # params_to_train += list(self.robot_delta_states.parameters()) self.robot_states = nn.Embedding( num_embeddings=num_steps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.robot_states.weight) params_to_train += list(self.robot_states.parameters()) self.robot_init_states = nn.Embedding( num_embeddings=1, embedding_dim=22, - ).cuda() + ) torch.nn.init.zeros_(self.robot_init_states.weight) params_to_train += list(self.robot_init_states.parameters()) ## robot glb rotations ## self.robot_glb_rotation = nn.Embedding( ## robot hand rotation num_embeddings=num_steps, embedding_dim=4 - ).cuda() + ) self.robot_glb_rotation.weight.data[:, 0] = 1. self.robot_glb_rotation.weight.data[:, 1:] = 0. self.robot_glb_trans = nn.Embedding( num_embeddings=num_steps, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.robot_glb_trans.weight) # ### local minimum -> ## robot self.robot_actuator_friction_forces = nn.Embedding( # frictional forces ## num_embeddings=365428 * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.robot_actuator_friction_forces.weight) self.expanded_actuator_delta_offset = nn.Embedding( num_embeddings=self.robo_expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.expanded_actuator_delta_offset.weight) # params_to_train += list(self.mano_expanded_actuator_delta_offset.parameters()) @@ -5155,12 +5157,12 @@ class Runner: ##### expanded actuators pointact jforces ### self.expanded_actuator_pointact_forces = nn.Embedding( num_embeddings=self.robo_expanded_visual_pts_nn * 60, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.expanded_actuator_pointact_forces.weight) self.expanded_actuator_pointact_damping_coefs = nn.Embedding( num_embeddings=10, embedding_dim=1 - ).cuda() + ) torch.nn.init.zeros_(self.expanded_actuator_pointact_damping_coefs.weight) @@ -5277,13 +5279,13 @@ class Runner: with torch.no_grad(): # init them to zero for cur_ts in range(self.nn_ts * self.mano_nn_substeps): ''' Get rotations, translations, and actions of the current robot ''' - cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_rot = cur_glb_rot / torch.clamp(torch.norm(cur_glb_rot, dim=-1, p=2), min=1e-7) # mano glb rot cur_glb_rot = dyn_model_act.quaternion_to_matrix(cur_glb_rot) # mano glboal rotations # - cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) ## mano robot states ## mano robot states ## - link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.mano_agent.set_init_states_target_value(link_cur_states) ## set init visual pts ## @@ -5295,7 +5297,7 @@ class Runner: # expanded_pts # cur_visual_pts_idxes = torch.arange( start=cur_ts * self.expanded_visual_pts_nn, end=(cur_ts + 1) * self.expanded_visual_pts_nn, dtype=torch.long - ).cuda() + ) cur_visual_pts_offset = self.mano_expanded_actuator_delta_offset(cur_visual_pts_idxes) ## get the idxes ### @@ -5320,13 +5322,13 @@ class Runner: self.timestep_to_active_mesh_opt_ours_sim[cur_ts] = cur_visual_pts.detach() - cur_robo_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_robo_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_robo_glb_rot = cur_robo_glb_rot / torch.clamp(torch.norm(cur_robo_glb_rot, dim=-1, p=2), min=1e-7) cur_robo_glb_rot = dyn_model_act.quaternion_to_matrix(cur_robo_glb_rot) # mano glboal rotations # - cur_robo_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_robo_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) - robo_links_states = self.robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + robo_links_states = self.robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.robot_agent.set_init_states_target_value(robo_links_states) cur_robo_visual_pts = self.robot_agent.get_init_state_visual_pts() @@ -5498,9 +5500,9 @@ class Runner: # init global transformations ## - # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32).cuda() + # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32) # for cur_ts in range(self.nn_ts): for cur_ts in range(self.nn_ts * self.mano_nn_substeps): @@ -5512,7 +5514,7 @@ class Runner: ''' Get dynamic mano pts, expanded pts, etc ''' # mano_robot_glb_rotation, mano_robot_glb_trans, mano_robot_delta_states # - cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_rot = cur_glb_rot + cur_ts_redmax_delta_rotations @@ -5520,21 +5522,21 @@ class Runner: # cur_glb_rot_quat = cur_glb_rot.clone() cur_glb_rot = dyn_model_act.quaternion_to_matrix(cur_glb_rot) # mano glboal rotations # # glb rot # trans # - cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # # # cur_ts_delta_rot, cur_ts_redmax_robot_trans # # # # cur_glb_rot = torch.matmul(cur_ts_delta_rot, cur_glb_rot) # cur_glb_trans = cur_glb_trans + cur_ts_redmax_robot_trans # redmax robot transj## - # link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # self.mano_agent.set_init_states_target_value(link_cur_states) # cur_visual_pts = self.mano_agent.get_init_state_visual_pts(expanded_pts=True) # init state visual pts # # cur_dyn_mano_pts = self.mano_agent.get_init_state_visual_pts(expanded_pts=False) # init s ### motivate via actions #### - link_cur_actions = self.mano_robot_actions(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_actions = self.mano_robot_actions(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.mano_agent.set_actions_and_update_states_v2( link_cur_actions, cur_ts, penetration_forces=penetration_forces, sampled_visual_pts_joint_idxes=sampled_visual_pts_joint_idxes) ### motivate via actions #### @@ -5550,7 +5552,7 @@ class Runner: # expanded_pts # cur_visual_pts_idxes = torch.arange( start=cur_ts * self.expanded_visual_pts_nn, end=(cur_ts + 1) * self.expanded_visual_pts_nn, dtype=torch.long - ).cuda() + ) @@ -5634,13 +5636,13 @@ class Runner: - cur_robo_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_robo_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_robo_glb_rot = cur_robo_glb_rot / torch.clamp(torch.norm(cur_robo_glb_rot, dim=-1, p=2), min=1e-7) cur_robo_glb_rot = dyn_model_act.quaternion_to_matrix(cur_robo_glb_rot) # mano glboal rotations # - cur_robo_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_robo_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) ### drive by states, not the acts ### - robo_links_states = self.robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + robo_links_states = self.robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.robot_agent.set_init_states_target_value(robo_links_states) cur_robo_visual_pts = self.robot_agent.get_init_state_visual_pts() cur_robo_expanded_visual_pts, robo_visual_pts_joint_idxes = self.robot_agent.get_init_state_visual_pts(expanded_pts=True, ret_joint_idxes=True) # init state visual pts # @@ -5677,7 +5679,7 @@ class Runner: # expanded_pts # cur_robo_visual_pts_idxes = torch.arange( start=cur_ts * self.robo_expanded_visual_pts_nn, end=(cur_ts + 1) * self.robo_expanded_visual_pts_nn, dtype=torch.long - ).cuda() + ) # expanded_actuator_pointact_forces, expanded_actuator_delta_offset if self.drive_pointset == "actions": @@ -5724,7 +5726,7 @@ class Runner: if self.sampled_robo_expanded_pts_idxes is None: # if os.path.exists(redmax_sampled_verts_idxes_fn): # sampled_verts_idxes = np.load(redmax_sampled_verts_idxes_fn) - # sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long().cuda() + # sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long() # else: # print(f"Sampling fps idxes for robot expanded pts...") n_sampling = 10000 @@ -5795,7 +5797,7 @@ class Runner: # in_func_tracking_loss = self.compute_loss_optimized_transformations_v2(cur_ts + 1, cur_passive_big_ts + 1) # # tot_tracking_loss.append(tracking_loss.detach().cpu().item()) # else: - # in_func_tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + # in_func_tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() # return in_func_tracking_loss @@ -5862,11 +5864,11 @@ class Runner: tracking_loss = self.compute_loss_optimized_transformations_v2(cur_ts + 1, cur_passive_big_ts + 1) tot_tracking_loss.append(tracking_loss.detach().cpu().item()) else: - tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() - # diff_hand_tracking = torch.zeros((1,), dtype=torch.float32).cuda().mean() ## + # diff_hand_tracking = torch.zeros((1,), dtype=torch.float32).mean() ## # ## diff # # diff_hand_tracking_coef @@ -5933,7 +5935,7 @@ class Runner: # self.other_bending_network.reset_timestep_to_quantities(cur_ts) - # robot_states_actions_diff_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + # robot_states_actions_diff_loss = torch.zeros((1,), dtype=torch.float32).mean() # diff_actions robot_states_actions_diff_loss = diff_actions robo_actions_diff_loss.append(robot_states_actions_diff_loss) @@ -6029,7 +6031,7 @@ class Runner: robo_sampled_verts_idxes_fn = "robo_sampled_verts_idxes.npy" sampled_verts_idxes = np.load(robo_sampled_verts_idxes_fn) - sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long().cuda() + sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long() self.robo_hand_faces = self.robot_agent.robot_faces @@ -6038,45 +6040,45 @@ class Runner: ### adfte loadingjthe robot hand ## self.robot_delta_angles = nn.Embedding( num_embeddings=num_steps, embedding_dim=4, - ).cuda() + ) torch.nn.init.zeros_(self.robot_delta_angles.weight) self.robot_delta_angles.weight.data[:, 0] = 1.0 self.robot_delta_trans = nn.Embedding( num_embeddings=num_steps, embedding_dim=3, - ).cuda() + ) torch.nn.init.zeros_(self.robot_delta_trans.weight) self.robot_delta_glb_trans = nn.Embedding( num_embeddings=num_steps, embedding_dim=3, - ).cuda() + ) torch.nn.init.zeros_(self.robot_delta_glb_trans.weight) ### adfte loadingjthe robot hand ## self.robot_delta_states = nn.Embedding( num_embeddings=num_steps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.robot_delta_states.weight) self.robot_delta_states.weight.data[0, 24] = 1.0 self.robot_states = nn.Embedding( num_embeddings=num_steps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.robot_states.weight) self.robot_states.weight.data[:, 24] = 1.0 self.robot_init_states = nn.Embedding( num_embeddings=1, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.robot_init_states.weight) self.robot_init_states.weight.data[0, 24] = 1.0 self.robot_glb_rotation = nn.Embedding( num_embeddings=num_steps, embedding_dim=4 - ).cuda() + ) # [6.123234e-17, 0.000000e+00 0.000000e+00 1.000000e+00 ] # if self.hand_type == "redmax": @@ -6091,7 +6093,7 @@ class Runner: self.robot_glb_trans = nn.Embedding( num_embeddings=num_steps, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.robot_glb_trans.weight) # params_to_train += list(self.robot_glb_trans.parameters()) @@ -6238,8 +6240,8 @@ class Runner: # # optimize with intermediates # - self.mano_fingers = torch.tensor(self.mano_fingers, dtype=torch.long).cuda() - self.robot_fingers = torch.tensor(self.robot_fingers, dtype=torch.long).cuda() + self.mano_fingers = torch.tensor(self.mano_fingers, dtype=torch.long) + self.robot_fingers = torch.tensor(self.robot_fingers, dtype=torch.long) self.nn_ts = self.nn_timesteps - 1 # self.optimize_with_intermediates = False @@ -6320,9 +6322,9 @@ class Runner: # robo_actions_diff_loss = [] # init global transformations ## - # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32).cuda() + # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32) for cur_ts in range(self.nn_ts): tot_redmax_actions = [] @@ -6334,7 +6336,7 @@ class Runner: if self.drive_glb_delta: print(f"drive_glb_delta!") if cur_ts == 0: - cur_glb_rot_quat = self.robot_delta_angles(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot_quat = self.robot_delta_angles(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_rot_quat = cur_glb_rot_quat / torch.clamp(torch.norm(cur_glb_rot_quat, dim=-1, p=2), min=1e-7) # cur_glb_rot_quat = cur_glb_rot.clone() @@ -6342,7 +6344,7 @@ class Runner: self.ts_to_glb_quat[cur_ts] = cur_glb_rot_quat.detach().clone() - cur_glb_trans = self.robot_delta_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_trans = self.robot_delta_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.ts_to_glb_trans[cur_ts] = cur_glb_trans.detach().clone() @@ -6351,7 +6353,7 @@ class Runner: else: prev_glb_quat = self.ts_to_glb_quat[cur_ts - 1] - cur_glb_rot_angle = self.robot_delta_angles(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0)[1:] + cur_glb_rot_angle = self.robot_delta_angles(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0)[1:] cur_glb_rot_quat = prev_glb_quat + fields.update_quaternion(cur_glb_rot_angle, prev_glb_quat) cur_glb_rot_quat = cur_glb_rot_quat / torch.clamp(torch.norm(cur_glb_rot_quat, dim=-1, p=2), min=1e-7) @@ -6359,7 +6361,7 @@ class Runner: self.ts_to_glb_quat[cur_ts] = cur_glb_rot_quat.detach().clone() - cur_delta_glb_trans = self.robot_delta_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_delta_glb_trans = self.robot_delta_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) prev_glb_trans = self.ts_to_glb_trans[cur_ts - 1].detach().clone() cur_glb_trans = prev_glb_trans + cur_delta_glb_trans @@ -6371,19 +6373,19 @@ class Runner: elif self.retar_delta_glb_trans: print("fzzzzzzz") if cur_ts == 0: - cur_glb_trans = self.robot_delta_glb_trans(torch.zeros((1,), dtype=torch.long).cuda()).squeeze(0) + cur_glb_trans = self.robot_delta_glb_trans(torch.zeros((1,), dtype=torch.long)).squeeze(0) else: prev_trans = torch.sum( self.robot_delta_glb_trans.weight.data[:cur_ts], dim=0).detach() - cur_delta_glb_trans = self.robot_delta_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_delta_glb_trans = self.robot_delta_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_trans = prev_trans + cur_delta_glb_trans self.robot_glb_trans.weight.data[cur_ts, :] = cur_glb_trans[:].detach().clone() - cur_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_rot = cur_glb_rot / torch.clamp(torch.norm(cur_glb_rot, dim=-1, p=2), min=1e-7) cur_glb_rot = dyn_model_act.quaternion_to_matrix(cur_glb_rot) else: - cur_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot = self.robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # cur_glb_rot = cur_glb_rot + cur_ts_redmax_delta_rotations @@ -6393,22 +6395,22 @@ class Runner: cur_glb_rot = dyn_model_act.quaternion_to_matrix(cur_glb_rot) # mano glboal rotations # - cur_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_trans = self.robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # cur_glb_trans = cur_glb_trans + cur_ts_redmax_robot_trans # ########### Delta states ########### if self.drive_glb_delta: - robo_delta_states = self.robot_delta_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + robo_delta_states = self.robot_delta_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.robot_agent.active_robot.set_delta_state_and_update_v2(robo_delta_states, cur_ts) ## delta states ## self.robot_states.weight.data[cur_ts, :] = self.robot_agent.get_joint_state(cur_ts - 1, self.robot_states.weight.data[cur_ts, :]) # self.robot_states_sv[cur_ts, : ] = self.robot_agent.get_joint_state(cur_ts - 1, self.robot_states_sv[cur_ts, :]) else: # if self.hand_type == "shadow_hand": - link_cur_states = self.robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_states = self.robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.robot_agent.set_init_states_target_value(link_cur_states) - # robo_delta_states = self.robot_delta_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + # robo_delta_states = self.robot_delta_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) # self.robot_agent.active_robot.set_delta_state_and_update_v2(robo_delta_states, cur_ts) ## delta states ## # self.robot_states.weight.data[cur_ts, :] = self.robot_agent.get_joint_state(cur_ts - 1, self.robot_states.weight.data[cur_ts, :]) cur_visual_pts = self.robot_agent.get_init_state_visual_pts() # get init state visual pts @@ -6473,9 +6475,9 @@ class Runner: self.timestep_to_active_mesh[cur_ts] = cur_visual_pts self.timestep_to_raw_active_meshes[cur_ts] = cur_visual_pts.detach().cpu().numpy() - # ragged_dist = torch.zeros((1,), dtype=torch.float32).cuda().mean() - # dist_transformed_expanded_visual_pts_to_ori_visual_pts = torch.zeros((1,), dtype=torch.float32).cuda().mean() - # diff_cur_states_to_ref_states = torch.zeros((1,), dtype=torch.float32).cuda().mean() + # ragged_dist = torch.zeros((1,), dtype=torch.float32).mean() + # dist_transformed_expanded_visual_pts_to_ori_visual_pts = torch.zeros((1,), dtype=torch.float32).mean() + # diff_cur_states_to_ref_states = torch.zeros((1,), dtype=torch.float32).mean() self.free_def_bending_weight = 0.0 @@ -6636,7 +6638,7 @@ class Runner: # robo_sampled_verts_idxes_fn = "robo_sampled_verts_idxes.npy" # if os.path.exists(robo_sampled_verts_idxes_fn): # sampled_verts_idxes = np.load("robo_sampled_verts_idxes.npy") - # sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long().cuda() + # sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long() # else: # n_sampling = 1000 # pts_fps_idx = data_utils.farthest_point_sampling(robo_init_verts.unsqueeze(0), n_sampling=n_sampling) @@ -6690,25 +6692,25 @@ class Runner: ''' Define MANO robot actions, delta_states, init_states, frictions, and others ''' self.mano_robot_actions = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_actions.weight) params_to_train += list(self.mano_robot_actions.parameters()) # self.mano_robot_delta_states = nn.Embedding( # num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - # ).cuda() + # ) # torch.nn.init.zeros_(self.mano_robot_delta_states.weight) # # params_to_train += list(self.robot_delta_states.parameters()) # self.mano_robot_init_states = nn.Embedding( # num_embeddings=1, embedding_dim=60, - # ).cuda() + # ) # torch.nn.init.zeros_(self.mano_robot_init_states.weight) # # params_to_train += list(self.robot_init_states.parameters()) self.mano_robot_glb_rotation = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=4 - ).cuda() + ) self.mano_robot_glb_rotation.weight.data[:, 0] = 1. self.mano_robot_glb_rotation.weight.data[:, 1:] = 0. params_to_train += list(self.mano_robot_glb_rotation.parameters()) @@ -6716,13 +6718,13 @@ class Runner: self.mano_robot_glb_trans = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_glb_trans.weight) params_to_train += list(self.mano_robot_glb_trans.parameters()) # self.mano_robot_states = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_states.weight) # self.mano_robot_states.weight.data[0, :] = self.mano_robot_init_states.weight.data[0, :].clone() params_to_train += list(self.mano_robot_states.parameters()) @@ -6766,7 +6768,7 @@ class Runner: if not os.path.exists(mano_to_dyn_corr_pts_idxes_fn): mano_to_dyn_corr_pts_idxes_fn = "/data/xueyi/diffsim/NeuS/rsc/mano/nearest_dyn_verts_idxes.npy" self.mano_to_dyn_corr_pts_idxes = np.load(mano_to_dyn_corr_pts_idxes_fn, allow_pickle=True) - self.mano_to_dyn_corr_pts_idxes = torch.from_numpy(self.mano_to_dyn_corr_pts_idxes).long().cuda() + self.mano_to_dyn_corr_pts_idxes = torch.from_numpy(self.mano_to_dyn_corr_pts_idxes).long() print(f"mano_to_dyn_corr_pts_idxes: {self.mano_to_dyn_corr_pts_idxes.size()}") @@ -6781,13 +6783,13 @@ class Runner: # params_to_train += list(self.redmax_robot_actions.parameters()) self.optimizer = torch.optim.Adam(params_to_train, lr=self.learning_rate) # init_rot = R.random().as_quat() - # init_rot = torch.from_numpy(init_rot).float().cuda() + # init_rot = torch.from_numpy(init_rot).float() # self.robot_glb_rotation.weight.data[0, :] = init_rot[:] # init rot # ### Constraint set ### - # self.robot_hand_states_only_allowing_neg = torch.tensor( [3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16], dtype=torch.long).cuda() + # self.robot_hand_states_only_allowing_neg = torch.tensor( [3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16], dtype=torch.long) self.timestep_to_active_mesh = {} @@ -6847,9 +6849,9 @@ class Runner: mano_tracking_loss = [] # init global transformations ## - # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32).cuda() + # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32) # for cur_ts in range(self.nn_ts): for cur_ts in range(self.nn_ts * self.mano_nn_substeps): @@ -6861,7 +6863,7 @@ class Runner: self.free_def_bending_weight = 0.0 # mano_robot_glb_rotation, mano_robot_glb_trans, mano_robot_delta_states # - cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_rot = cur_glb_rot + cur_ts_redmax_delta_rotations @@ -6869,18 +6871,18 @@ class Runner: # cur_glb_rot_quat = cur_glb_rot.clone() cur_glb_rot = dyn_model_act.quaternion_to_matrix(cur_glb_rot) # mano glboal rotations # - cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_trans = cur_glb_trans + cur_ts_redmax_robot_trans if self.optimize_dyn_actions: ''' Articulated joint forces-driven mano robot ''' ### current -> no penetration setting; no contact setting ### - link_cur_actions = self.mano_robot_actions(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_actions = self.mano_robot_actions(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.mano_agent.set_actions_and_update_states_v2( link_cur_actions, cur_ts, penetration_forces=None, sampled_visual_pts_joint_idxes=None) else: ''' Articulated states-driven mano robot ''' - link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.mano_agent.set_init_states_target_value(link_cur_states) # optimize_dyn_actions @@ -6999,7 +7001,7 @@ class Runner: # robo_sampled_verts_idxes_fn = "robo_sampled_verts_idxes.npy" # if os.path.exists(robo_sampled_verts_idxes_fn): # sampled_verts_idxes = np.load("robo_sampled_verts_idxes.npy") - # sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long().cuda() + # sampled_verts_idxes = torch.from_numpy(sampled_verts_idxes).long() # else: # n_sampling = 1000 # pts_fps_idx = data_utils.farthest_point_sampling(robo_init_verts.unsqueeze(0), n_sampling=n_sampling) @@ -7053,25 +7055,25 @@ class Runner: ''' Define MANO robot actions, delta_states, init_states, frictions, and others ''' self.mano_robot_actions = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_actions.weight) params_to_train += list(self.mano_robot_actions.parameters()) # self.mano_robot_delta_states = nn.Embedding( # num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - # ).cuda() + # ) # torch.nn.init.zeros_(self.mano_robot_delta_states.weight) # # params_to_train += list(self.robot_delta_states.parameters()) # self.mano_robot_init_states = nn.Embedding( # num_embeddings=1, embedding_dim=60, - # ).cuda() + # ) # torch.nn.init.zeros_(self.mano_robot_init_states.weight) # # params_to_train += list(self.robot_init_states.parameters()) ## params to train the aaa ## self.mano_robot_glb_rotation = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=4 - ).cuda() + ) self.mano_robot_glb_rotation.weight.data[:, 0] = 1. self.mano_robot_glb_rotation.weight.data[:, 1:] = 0. params_to_train += list(self.mano_robot_glb_rotation.parameters()) @@ -7079,13 +7081,13 @@ class Runner: self.mano_robot_glb_trans = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=3 - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_glb_trans.weight) params_to_train += list(self.mano_robot_glb_trans.parameters()) # self.mano_robot_states = nn.Embedding( num_embeddings=num_steps * mano_nn_substeps, embedding_dim=60, - ).cuda() + ) torch.nn.init.zeros_(self.mano_robot_states.weight) # self.mano_robot_states.weight.data[0, :] = self.mano_robot_init_states.weight.data[0, :].clone() params_to_train += list(self.mano_robot_states.parameters()) @@ -7130,7 +7132,7 @@ class Runner: if not os.path.exists(mano_to_dyn_corr_pts_idxes_fn): mano_to_dyn_corr_pts_idxes_fn = "/data/xueyi/diffsim/NeuS/rsc/mano/nearest_dyn_verts_idxes.npy" self.mano_to_dyn_corr_pts_idxes = np.load(mano_to_dyn_corr_pts_idxes_fn, allow_pickle=True) - self.mano_to_dyn_corr_pts_idxes = torch.from_numpy(self.mano_to_dyn_corr_pts_idxes).long().cuda() + self.mano_to_dyn_corr_pts_idxes = torch.from_numpy(self.mano_to_dyn_corr_pts_idxes).long() print(f"mano_to_dyn_corr_pts_idxes: {self.mano_to_dyn_corr_pts_idxes.size()}") @@ -7156,7 +7158,7 @@ class Runner: ### construct optimizer ### self.optimizer = torch.optim.Adam(params_to_train, lr=self.learning_rate) # init_rot = R.random().as_quat() - # init_rot = torch.from_numpy(init_rot).float().cuda() + # init_rot = torch.from_numpy(init_rot).float() # self.robot_glb_rotation.weight.data[0, :] = init_rot[:] @@ -7221,9 +7223,9 @@ class Runner: mano_tracking_loss = [] # init global transformations ## - # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32).cuda() - cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32).cuda() + # cur_ts_redmax_delta_rotations = torch.tensor([1., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_delta_rotations = torch.tensor([0., 0., 0., 0.], dtype=torch.float32) + cur_ts_redmax_robot_trans = torch.zeros((3,), dtype=torch.float32) # for cur_ts in range(self.nn_ts): for cur_ts in range(self.nn_ts * self.mano_nn_substeps - 1): @@ -7234,7 +7236,7 @@ class Runner: self.free_def_bending_weight = 0.0 # mano_robot_glb_rotation, mano_robot_glb_trans, mano_robot_delta_states # - cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_rot = self.mano_robot_glb_rotation(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_rot = cur_glb_rot + cur_ts_redmax_delta_rotations @@ -7242,18 +7244,18 @@ class Runner: # cur_glb_rot_quat = cur_glb_rot.clone() # cur_glb_rot = dyn_model_act.quaternion_to_matrix(cur_glb_rot) # mano glboal rotations # - cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + cur_glb_trans = self.mano_robot_glb_trans(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) cur_glb_trans = cur_glb_trans + cur_ts_redmax_robot_trans if self.optimize_dyn_actions: ''' Articulated joint forces-driven mano robot ''' ### current -> no penetration setting; no contact setting ### - link_cur_actions = self.mano_robot_actions(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_actions = self.mano_robot_actions(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.mano_agent.set_actions_and_update_states_v2( link_cur_actions, cur_ts, penetration_forces=penetration_forces, sampled_visual_pts_joint_idxes=sampled_visual_pts_joint_idxes) ## else: ''' Articulated states-driven mano robot ''' - link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long).cuda() + cur_ts).squeeze(0) + link_cur_states = self.mano_robot_states(torch.zeros((1,), dtype=torch.long) + cur_ts).squeeze(0) self.mano_agent.set_init_states_target_value(link_cur_states) # optimize_dyn_actions @@ -7335,7 +7337,7 @@ class Runner: # net_penetrating_points = (net_penetrating_points * self.extent_robo_pts) + self.minn_robo_pts penetration_forces = net_penetrating_forces ## get the penetration forces and net penetration forces ## - # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32).cuda() + # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32) # penetration_forces_values = penetration_forces['penetration_forces'].detach() # penetration_forces_points = penetration_forces['penetration_forces_points'].detach() @@ -7351,7 +7353,7 @@ class Runner: # 'penetration_forces': penetration_forces, # 'penetration_forces_points': None, # } - # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32).cuda() ## pointset ## + # link_maximal_contact_forces = torch.zeros((redmax_ndof_r, 6), dtype=torch.float32) ## pointset ## ''' the bending network still have this property and we can get force values here for the expanded visual points ''' # self.timestep_to_actuator_points_passive_forces[cur_ts] = self.other_bending_network.penetrating_forces_allpts.detach().clone() @@ -7372,7 +7374,7 @@ class Runner: # if self.optimize_with_intermediates: # tracking_loss = self.compute_loss_optimized_transformations(cur_ts + 1) # # else: - # tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + # tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() # # cur_ts % mano_nn_substeps == 0: # @@ -7382,7 +7384,7 @@ class Runner: tracking_loss = self.compute_loss_optimized_transformations_v2(cur_ts + 1, cur_passive_big_ts + 1) tot_tracking_loss.append(tracking_loss.detach().cpu().item()) else: - tracking_loss = torch.zeros((1,), dtype=torch.float32).cuda().mean() + tracking_loss = torch.zeros((1,), dtype=torch.float32).mean() # # hand_tracking_loss = torch.sum( ## delta states? ## # # (self.timestep_to_active_mesh_w_delta_states[cur_ts] - cur_visual_pts) ** 2, dim=-1 @@ -7401,7 +7403,7 @@ class Runner: # tot_interpenetration_nns.append(cur_interpenetration_nns) # - # diff_hand_tracking = torch.zeros((1,), dtype=torch.float32).cuda().mean() ## + # diff_hand_tracking = torch.zeros((1,), dtype=torch.float32).mean() ## # # kinematics_proj_loss = kinematics_trans_diff + penetraton_penalty + diff_hand_tracking * self.diff_hand_tracking_coef + tracking_loss @@ -7870,7 +7872,7 @@ class Runner: init_passive_obj_verts_center = np.mean(init_passive_obj_verts, axis=0, keepdims=True) else: init_passive_obj_verts = self.other_bending_network.canon_passive_obj_verts.detach().cpu().numpy() - init_passive_obj_verts_center = torch.zeros((3, )).cuda().detach().cpu().numpy() + init_passive_obj_verts_center = torch.zeros((3, )).detach().cpu().numpy() # init_passive_obj_verts = self.timestep_to_passive_mesh[0].detach().cpu().numpy() # init_passive_obj_verts_center = np.mean(init_passive_obj_verts, axis=0, keepdims=True) @@ -8201,7 +8203,7 @@ class Runner: init_passive_obj_verts_center = np.mean(init_passive_obj_verts, axis=0, keepdims=True) else: init_passive_obj_verts = self.other_bending_network.canon_passive_obj_verts.detach().cpu().numpy() - init_passive_obj_verts_center = torch.zeros((3, )).cuda().detach().cpu().numpy() + init_passive_obj_verts_center = torch.zeros((3, )).detach().cpu().numpy() # init_passive_obj_verts = self.timestep_to_passive_mesh[0].detach().cpu().numpy() # init_passive_obj_verts_center = np.mean(init_passive_obj_verts, axis=0, keepdims=True) @@ -8319,7 +8321,7 @@ class Runner: init_passive_obj_verts_center = np.mean(init_passive_obj_verts, axis=0, keepdims=True) else: init_passive_obj_verts = self.other_bending_network.canon_passive_obj_verts.detach().cpu().numpy() - init_passive_obj_verts_center = torch.zeros((3, )).cuda().detach().cpu().numpy() + init_passive_obj_verts_center = torch.zeros((3, )).detach().cpu().numpy() # init_passive_obj_verts = self.timestep_to_passive_mesh[0].detach().cpu().numpy() # init_passive_obj_verts_center = np.mean(init_passive_obj_verts, axis=0, keepdims=True) @@ -8454,10 +8456,10 @@ class Runner: if self.other_bending_network.canon_passive_obj_verts is None: init_passive_obj_verts = self.timestep_to_passive_mesh[0].detach().cpu().numpy() # init_passive_obj_verts_center = np.mean(init_passive_obj_verts, axis=0, keepdims=True) - init_passive_obj_verts_center = torch.zeros((3, )).cuda().detach().cpu().numpy() + init_passive_obj_verts_center = torch.zeros((3, )).detach().cpu().numpy() else: init_passive_obj_verts = self.other_bending_network.canon_passive_obj_verts.detach().cpu().numpy() - init_passive_obj_verts_center = torch.zeros((3, )).cuda().detach().cpu().numpy() + init_passive_obj_verts_center = torch.zeros((3, )).detach().cpu().numpy() # init_passive_obj_verts = self.timestep_to_passive_mesh[0].detach().cpu().numpy() # init_passive_obj_verts_center = np.mean(init_passive_obj_verts, axis=0, keepdims=True) @@ -8932,7 +8934,7 @@ if __name__ == '__main__': print('Hello Wooden') - torch.set_default_tensor_type('torch.cuda.FloatTensor') + # torch.set_default_tensor_type('torch.cuda.FloatTensor') FORMAT = "[%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s" logging.basicConfig(level=logging.DEBUG, format=FORMAT) @@ -8948,8 +8950,8 @@ if __name__ == '__main__': args = parser.parse_args() - torch.cuda.set_device(args.gpu) - runner = Runner(args.conf, args.mode, args.case, args.is_continue) + # torch.cuda.set_device(args.gpu) + runner = Runner(args.conf, args.data_fn, args.mode, args.case, args.is_continue) bending_net_type = runner.conf['model.bending_net_type']