solve merge

This commit is contained in:
hofee 2024-10-28 18:25:53 +00:00
parent bd27226f0f
commit 3c9e2c8d12
4 changed files with 22 additions and 11 deletions

View File

@ -16,14 +16,14 @@ runner:
compute_with_normal: False compute_with_normal: False
scan_points_threshold: 10 scan_points_threshold: 10
overwrite: False overwrite: False
seq_num: 15 seq_num: 10
dataset_list: dataset_list:
- OmniObject3d - OmniObject3d
datasets: datasets:
OmniObject3d: OmniObject3d:
root_dir: C:\\Document\\Local Project\\nbv_rec\\nbv_reconstruction\\temp root_dir: /data/hofee/nbv_rec_part2_preprocessed
from: 0 from: 155
to: 1 # -1 means end to: 165 # ..-1 means end

View File

@ -1,4 +1,5 @@
import torch import torch
import time
from torch import nn from torch import nn
import PytorchBoot.namespace as namespace import PytorchBoot.namespace as namespace
import PytorchBoot.stereotype as stereotype import PytorchBoot.stereotype as stereotype
@ -58,7 +59,10 @@ class NBVReconstructionGlobalPointsPipeline(nn.Module):
return perturbed_x, random_t, target_score, std return perturbed_x, random_t, target_score, std
def forward_train(self, data): def forward_train(self, data):
start_time = time.time()
main_feat = self.get_main_feat(data) main_feat = self.get_main_feat(data)
end_time = time.time()
print("get_main_feat time: ", end_time - start_time)
""" get std """ """ get std """
best_to_world_pose_9d_batch = data["best_to_world_pose_9d"] best_to_world_pose_9d_batch = data["best_to_world_pose_9d"]
perturbed_x, random_t, target_score, std = self.pertube_data( perturbed_x, random_t, target_score, std = self.pertube_data(
@ -117,7 +121,7 @@ class NBVReconstructionGlobalPointsPipeline(nn.Module):
for seq_idx in range(seq_len): for seq_idx in range(seq_len):
partial_idx_in_combined_pts = scanned_mask == seq_idx # Ndarray(V), N->V idx mask partial_idx_in_combined_pts = scanned_mask == seq_idx # Ndarray(V), N->V idx mask
partial_perpoint_feat = perpoint_scanned_feat[partial_idx_in_combined_pts] # Ndarray(V x Dl) partial_perpoint_feat = perpoint_scanned_feat[partial_idx_in_combined_pts] # Ndarray(V x Dl)
partial_feat = torch.mean(partial_perpoint_feat, dim=0) # Tensor(Dl) partial_feat = torch.max(partial_perpoint_feat, dim=0) # Tensor(Dl)
partial_feat_seq.append(partial_feat) partial_feat_seq.append(partial_feat)
scanned_target_pts_num.append(partial_perpoint_feat.shape[0]) scanned_target_pts_num.append(partial_perpoint_feat.shape[0])

View File

@ -86,13 +86,17 @@ class StrategyGenerator(Runner):
nrm_path = os.path.join(root,scene_name, "nrm", f"{frame_idx}.npy") nrm_path = os.path.join(root,scene_name, "nrm", f"{frame_idx}.npy")
idx_path = os.path.join(root,scene_name, "scan_points_indices", f"{frame_idx}.npy") idx_path = os.path.join(root,scene_name, "scan_points_indices", f"{frame_idx}.npy")
pts = np.load(pts_path) pts = np.load(pts_path)
if pts.shape[0] == 0: if self.compute_with_normal:
nrm = np.zeros((0,3)) if pts.shape[0] == 0:
else: nrm = np.zeros((0,3))
nrm = np.load(nrm_path) else:
indices = np.load(idx_path) nrm = np.load(nrm_path)
nrm_list.append(nrm)
pts_list.append(pts) pts_list.append(pts)
nrm_list.append(nrm)
indices = np.load(idx_path)
scan_points_indices_list.append(indices) scan_points_indices_list.append(indices)
if pts.shape[0] > 0: if pts.shape[0] > 0:
non_zero_cnt += 1 non_zero_cnt += 1

View File

@ -75,6 +75,7 @@ class ReconstructionUtil:
cnt_processed_view = 0 cnt_processed_view = 0
remaining_views.remove(init_view) remaining_views.remove(init_view)
curr_rec_pts_num = combined_point_cloud.shape[0] curr_rec_pts_num = combined_point_cloud.shape[0]
drop_output_ratio = 0.4
import time import time
while remaining_views: while remaining_views:
@ -84,6 +85,8 @@ class ReconstructionUtil:
best_covered_num = 0 best_covered_num = 0
for view_index in remaining_views: for view_index in remaining_views:
if np.random.rand() < drop_output_ratio:
continue
if point_cloud_list[view_index].shape[0] == 0: if point_cloud_list[view_index].shape[0] == 0:
continue continue
if selected_views: if selected_views: