xizaoqu commited on
Commit ·
71dc0c9
1
Parent(s): 3e832e9
fix
Browse files
algorithms/worldmem/df_video.py
CHANGED
|
@@ -706,6 +706,7 @@ class WorldMemMinecraft(DiffusionForcingBase):
|
|
| 706 |
condition_similar_length = self.condition_similar_length
|
| 707 |
xs_raw, conditions, pose_conditions, c2w_mat, frame_idx = self._preprocess_batch(batch)
|
| 708 |
|
|
|
|
| 709 |
# Encode frames in chunks if necessary
|
| 710 |
total_frame = xs_raw.shape[0]
|
| 711 |
if total_frame > 10:
|
|
@@ -847,27 +848,17 @@ class WorldMemMinecraft(DiffusionForcingBase):
|
|
| 847 |
last_frame = xs_pred[-1].clone()
|
| 848 |
curr_actions = new_actions[ai:ai+next_horizon].clone()
|
| 849 |
|
| 850 |
-
# last_pose_condition = self_poses[-1].clone()
|
| 851 |
-
# new_pose_condition_list = []
|
| 852 |
-
# for hi in range(next_horizon):
|
| 853 |
-
# last_pose_condition[:,3:] = last_pose_condition[:,3:] // 15
|
| 854 |
-
# new_pose_condition_offset = self.pose_prediction_model(last_frame.to(device), curr_actions[None, hi], last_pose_condition)
|
| 855 |
-
# new_pose_condition_offset[:,3:] = torch.round(new_pose_condition_offset[:,3:])
|
| 856 |
-
# new_pose_condition = last_pose_condition + new_pose_condition_offset
|
| 857 |
-
# new_pose_condition[:,3:] = new_pose_condition[:,3:] * 15
|
| 858 |
-
# new_pose_condition[:,3:] %= 360
|
| 859 |
-
# last_pose_condition = new_pose_condition.clone()
|
| 860 |
-
# new_pose_condition_list.append(new_pose_condition[None])
|
| 861 |
-
# new_pose_condition = torch.cat(new_pose_condition_list, 0)
|
| 862 |
new_pose_condition = new_pose_condition_list[ai:ai+next_horizon].clone()
|
| 863 |
|
| 864 |
new_c2w_mat = euler_to_camera_to_world_matrix(new_pose_condition)
|
| 865 |
self_poses = torch.cat([self_poses, new_pose_condition])
|
| 866 |
self_actions = torch.cat([self_actions, curr_actions[:, None]])
|
| 867 |
self_memory_c2w = torch.cat([self_memory_c2w, new_c2w_mat])
|
| 868 |
-
new_indices = self_frame_idx[-1,0] + torch.arange(next_horizon, device=self_frame_idx.device)
|
|
|
|
| 869 |
self_frame_idx = torch.cat([self_frame_idx, new_indices[:, None]])
|
| 870 |
|
|
|
|
| 871 |
conditions = self_actions.clone()
|
| 872 |
pose_conditions = self_poses.clone()
|
| 873 |
c2w_mat = self_memory_c2w .clone()
|
|
@@ -906,9 +897,6 @@ class WorldMemMinecraft(DiffusionForcingBase):
|
|
| 906 |
image_width=first_frame.shape[-1], image_height=first_frame.shape[-2]
|
| 907 |
)
|
| 908 |
|
| 909 |
-
from time import time
|
| 910 |
-
start_time = time()
|
| 911 |
-
|
| 912 |
# Perform sampling for each step in the scheduling matrix
|
| 913 |
for m in range(scheduling_matrix.shape[0] - 1):
|
| 914 |
from_noise_levels, to_noise_levels = self._prepare_noise_levels(
|
|
@@ -927,8 +915,7 @@ class WorldMemMinecraft(DiffusionForcingBase):
|
|
| 927 |
frame_idx=frame_idx_list
|
| 928 |
).cpu()
|
| 929 |
|
| 930 |
-
|
| 931 |
-
print(f"Time taken for {next_horizon} frames: {end_time - start_time:.2f} seconds")
|
| 932 |
if condition_similar_length:
|
| 933 |
xs_pred = xs_pred[:-condition_similar_length]
|
| 934 |
|
|
|
|
| 706 |
condition_similar_length = self.condition_similar_length
|
| 707 |
xs_raw, conditions, pose_conditions, c2w_mat, frame_idx = self._preprocess_batch(batch)
|
| 708 |
|
| 709 |
+
|
| 710 |
# Encode frames in chunks if necessary
|
| 711 |
total_frame = xs_raw.shape[0]
|
| 712 |
if total_frame > 10:
|
|
|
|
| 848 |
last_frame = xs_pred[-1].clone()
|
| 849 |
curr_actions = new_actions[ai:ai+next_horizon].clone()
|
| 850 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 851 |
new_pose_condition = new_pose_condition_list[ai:ai+next_horizon].clone()
|
| 852 |
|
| 853 |
new_c2w_mat = euler_to_camera_to_world_matrix(new_pose_condition)
|
| 854 |
self_poses = torch.cat([self_poses, new_pose_condition])
|
| 855 |
self_actions = torch.cat([self_actions, curr_actions[:, None]])
|
| 856 |
self_memory_c2w = torch.cat([self_memory_c2w, new_c2w_mat])
|
| 857 |
+
new_indices = self_frame_idx[-1,0] + torch.arange(next_horizon, device=self_frame_idx.device) + 1
|
| 858 |
+
|
| 859 |
self_frame_idx = torch.cat([self_frame_idx, new_indices[:, None]])
|
| 860 |
|
| 861 |
+
print(self_frame_idx)
|
| 862 |
conditions = self_actions.clone()
|
| 863 |
pose_conditions = self_poses.clone()
|
| 864 |
c2w_mat = self_memory_c2w .clone()
|
|
|
|
| 897 |
image_width=first_frame.shape[-1], image_height=first_frame.shape[-2]
|
| 898 |
)
|
| 899 |
|
|
|
|
|
|
|
|
|
|
| 900 |
# Perform sampling for each step in the scheduling matrix
|
| 901 |
for m in range(scheduling_matrix.shape[0] - 1):
|
| 902 |
from_noise_levels, to_noise_levels = self._prepare_noise_levels(
|
|
|
|
| 915 |
frame_idx=frame_idx_list
|
| 916 |
).cpu()
|
| 917 |
|
| 918 |
+
|
|
|
|
| 919 |
if condition_similar_length:
|
| 920 |
xs_pred = xs_pred[:-condition_similar_length]
|
| 921 |
|