add arrows
Browse files- app.py +64 -56
- src/experiments/log/gs/temp/form_video.mp4 +0 -0
- src/experiments/log/gs/temp/gs_pred.splat +2 -2
- src/experiments/log/temp/0000.png +2 -2
- src/experiments/log/temp/0001.png +2 -2
- src/experiments/log/temp/0002.png +2 -2
- src/experiments/log/temp/0003.png +2 -2
- src/experiments/log/temp/0004.png +2 -2
- src/experiments/log/temp/0005.png +2 -2
- src/experiments/log/temp/0006.png +2 -2
- src/experiments/log/temp/0007.png +2 -2
- src/experiments/log/temp/0008.png +2 -2
- src/experiments/log/temp/0009.png +2 -2
- src/experiments/log/temp/0010.png +2 -2
- src/experiments/log/temp/0011.png +2 -2
- src/experiments/log/temp/0012.png +2 -2
- src/experiments/log/temp/0013.png +2 -2
- src/experiments/log/temp/0014.png +2 -2
app.py
CHANGED
@@ -9,15 +9,6 @@ import random
|
|
9 |
import math
|
10 |
import hydra
|
11 |
import numpy as np
|
12 |
-
|
13 |
-
# import importlib
|
14 |
-
# import torch
|
15 |
-
# import torch.nn as nn
|
16 |
-
# print(torch.__version__)
|
17 |
-
# print(torch.version.cuda)
|
18 |
-
# import torch.backends.cudnn
|
19 |
-
# from torch.utils.data import DataLoader
|
20 |
-
|
21 |
import glob
|
22 |
import os
|
23 |
import subprocess
|
@@ -32,69 +23,22 @@ import spaces
|
|
32 |
from spaces import zero
|
33 |
zero.startup()
|
34 |
|
35 |
-
# def install_cuda_toolkit():
|
36 |
-
# # CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run"
|
37 |
-
# # CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run"
|
38 |
-
# CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_550.54.14_linux.run"
|
39 |
-
# CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
|
40 |
-
# subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
|
41 |
-
# subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
|
42 |
-
# subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
|
43 |
-
|
44 |
-
# os.environ["CUDA_HOME"] = "/usr/local/cuda"
|
45 |
-
# os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
|
46 |
-
# os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
|
47 |
-
# os.environ["CUDA_HOME"],
|
48 |
-
# "" if "LD_LIBRARY_PATH" not in os.environ else os.environ["LD_LIBRARY_PATH"],
|
49 |
-
# )
|
50 |
-
# # Fix: arch_list[-1] += '+PTX'; IndexError: list index out of range
|
51 |
-
# os.environ["TORCH_CUDA_ARCH_LIST"] = "8.0;8.6"
|
52 |
-
|
53 |
-
# install_cuda_toolkit()
|
54 |
-
|
55 |
-
# gs_path = Path(__file__).parent / "src/third-party/diff-gaussian-rasterization-w-depth"
|
56 |
-
# subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", str(gs_path)])
|
57 |
-
# site.main() # re-processes every *.pth in site-packages
|
58 |
-
# importlib.invalidate_caches()
|
59 |
-
# diff_gaussian_rasterization = importlib.import_module("diff_gaussian_rasterization")
|
60 |
-
|
61 |
-
# subprocess.check_call([sys.executable, "-m", "pip", "install", "--no-deps", "dgl", "-f", "https://data.dgl.ai/wheels/torch-2.4/cu124/repo.html"])
|
62 |
-
|
63 |
-
# subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "-y", "torch", "torchvision", "torchaudio"])
|
64 |
-
# subprocess.check_call([sys.executable, "-m", "pip", "install", "torch==2.4.0", "torchvision==0.19.0", "torchaudio==2.4.0", "--index-url", "https://download.pytorch.org/whl/cu124"])
|
65 |
-
# os.system('conda install conda-forge::ffmpeg')
|
66 |
-
|
67 |
-
# site.main() # re-processes every *.pth in site-packages
|
68 |
-
# importlib.invalidate_caches()
|
69 |
-
# torch = importlib.import_module("torch")
|
70 |
-
|
71 |
import torch
|
72 |
import torch.nn as nn
|
73 |
from torch.utils.data import DataLoader
|
74 |
import kornia
|
75 |
-
# import warp as wp
|
76 |
|
77 |
from diff_gaussian_rasterization import GaussianRasterizer
|
78 |
from diff_gaussian_rasterization import GaussianRasterizationSettings as Camera
|
79 |
|
80 |
-
# print(torch.__version__)
|
81 |
-
# print(torch.version.cuda)
|
82 |
-
|
83 |
import sys
|
84 |
sys.path.insert(0, str(Path(__file__).parent / "src"))
|
85 |
sys.path.append(str(Path(__file__).parent / "src" / "experiments"))
|
86 |
|
87 |
-
# from pgnd.sim import Friction, CacheDiffSimWithFrictionBatch, StaticsBatch, CollidersBatch
|
88 |
-
# from pgnd.material import PGNDModel
|
89 |
-
# from pgnd.utils import Logger, get_root, mkdir
|
90 |
-
|
91 |
from real_world.utils.render_utils import interpolate_motions
|
92 |
from real_world.gs.helpers import setup_camera
|
93 |
from real_world.gs.convert import save_to_splat, read_splat
|
94 |
|
95 |
-
# from diff_gaussian_rasterization import GaussianRasterizer
|
96 |
-
# from diff_gaussian_rasterization import GaussianRasterizationSettings as Camera
|
97 |
-
|
98 |
root = Path(__file__).parent / "src" / "experiments"
|
99 |
|
100 |
def make_video(
|
@@ -172,6 +116,7 @@ class DynamicsVisualizer:
|
|
172 |
self.k_wgt = 16 # knn for weights
|
173 |
self.with_bg = True
|
174 |
self.render_gripper = True
|
|
|
175 |
self.verbose = False
|
176 |
|
177 |
self.dt_base = cfg.sim.dt
|
@@ -840,6 +785,65 @@ class DynamicsVisualizer:
|
|
840 |
opa = torch.cat([opa, g_opacities], dim=0)
|
841 |
scales = torch.cat([scales, g_scales], dim=0)
|
842 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
843 |
# normalize
|
844 |
quat = torch.nn.functional.normalize(quat, dim=-1)
|
845 |
|
@@ -944,6 +948,7 @@ class DynamicsVisualizer:
|
|
944 |
num_particles = self.cfg.sim.n_particles
|
945 |
self.load_scaniverse(in_dir)
|
946 |
self.init_model(batch_size, num_steps, num_particles, ckpt_path=None)
|
|
|
947 |
|
948 |
params = self.preprocess_gs(self.params)
|
949 |
if self.with_bg:
|
@@ -1079,6 +1084,7 @@ class DynamicsVisualizer:
|
|
1079 |
batch_size = 1
|
1080 |
num_particles = self.cfg.sim.n_particles
|
1081 |
self.init_model(batch_size, num_steps, num_particles, ckpt_path=None)
|
|
|
1082 |
|
1083 |
# im_list = []
|
1084 |
for i in range(num_steps):
|
@@ -1090,6 +1096,8 @@ class DynamicsVisualizer:
|
|
1090 |
if self.verbose:
|
1091 |
print('command:', command.cpu().numpy().tolist())
|
1092 |
|
|
|
|
|
1093 |
assert self.state['sub_pos'] is None
|
1094 |
|
1095 |
if self.state['sub_pos'] is None:
|
|
|
9 |
import math
|
10 |
import hydra
|
11 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
import glob
|
13 |
import os
|
14 |
import subprocess
|
|
|
23 |
from spaces import zero
|
24 |
zero.startup()
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
import torch
|
27 |
import torch.nn as nn
|
28 |
from torch.utils.data import DataLoader
|
29 |
import kornia
|
|
|
30 |
|
31 |
from diff_gaussian_rasterization import GaussianRasterizer
|
32 |
from diff_gaussian_rasterization import GaussianRasterizationSettings as Camera
|
33 |
|
|
|
|
|
|
|
34 |
import sys
|
35 |
sys.path.insert(0, str(Path(__file__).parent / "src"))
|
36 |
sys.path.append(str(Path(__file__).parent / "src" / "experiments"))
|
37 |
|
|
|
|
|
|
|
|
|
38 |
from real_world.utils.render_utils import interpolate_motions
|
39 |
from real_world.gs.helpers import setup_camera
|
40 |
from real_world.gs.convert import save_to_splat, read_splat
|
41 |
|
|
|
|
|
|
|
42 |
root = Path(__file__).parent / "src" / "experiments"
|
43 |
|
44 |
def make_video(
|
|
|
116 |
self.k_wgt = 16 # knn for weights
|
117 |
self.with_bg = True
|
118 |
self.render_gripper = True
|
119 |
+
self.render_direction = True
|
120 |
self.verbose = False
|
121 |
|
122 |
self.dt_base = cfg.sim.dt
|
|
|
785 |
opa = torch.cat([opa, g_opacities], dim=0)
|
786 |
scales = torch.cat([scales, g_scales], dim=0)
|
787 |
|
788 |
+
if self.render_direction:
|
789 |
+
gripper_direction = self.gripper_direction
|
790 |
+
gripper_direction = gripper_direction / (torch.norm(gripper_direction, dim=-1, keepdim=True) + 1e-10) # normalize
|
791 |
+
|
792 |
+
R = self.preprocess_metadata['R']
|
793 |
+
# model frame to data frame
|
794 |
+
direction = gripper_direction @ R.T
|
795 |
+
|
796 |
+
n_grippers = 1
|
797 |
+
N = 200
|
798 |
+
length = 0.2
|
799 |
+
kk = 5
|
800 |
+
xyz_test = torch.zeros((n_grippers, N + N // kk + N // kk, 3), device=self.torch_device, dtype=xyz.dtype)
|
801 |
+
|
802 |
+
gripper_now_inv_xyz = self.inverse_preprocess_gripper(self.state['prev_key_pos'][None].clone())
|
803 |
+
gripper_now_inv_rot = torch.eye(3, device=self.torch_device).unsqueeze(0).repeat(n_grippers, 1, 1)
|
804 |
+
|
805 |
+
center_point = torch.tensor([0.0, 0.0, 0.10], device=self.torch_device, dtype=xyz.dtype).reshape(1, 3) # center point in gripper frame
|
806 |
+
gripper_center_inv_xyz = gripper_now_inv_xyz + \
|
807 |
+
torch.einsum('ijk,ik->ij', gripper_now_inv_rot, center_point) # (n_grippers, 3)
|
808 |
+
|
809 |
+
for i in range(N):
|
810 |
+
offset = i / N * length * direction
|
811 |
+
xyz_test[:, i] = gripper_center_inv_xyz + offset
|
812 |
+
|
813 |
+
if direction[0, 2] < 0.9 and direction[0, 2] > -0.9: # not vertical
|
814 |
+
direction_up = -direction + torch.tensor([0.0, 0.0, 0.5], device=self.torch_device, dtype=xyz.dtype)
|
815 |
+
direction_up = direction_up / (torch.norm(direction_up, dim=-1, keepdim=True) + 1e-10) # normalize
|
816 |
+
direction_down = -direction + torch.tensor([0.0, 0.0, -0.5], device=self.torch_device, dtype=xyz.dtype)
|
817 |
+
direction_down = direction_down / (torch.norm(direction_down, dim=-1, keepdim=True) + 1e-10) # normalize
|
818 |
+
else:
|
819 |
+
direction_up = -direction + torch.tensor([0.0, 0.5, 0.0], device=self.torch_device, dtype=xyz.dtype)
|
820 |
+
direction_up = direction_up / (torch.norm(direction_up, dim=-1, keepdim=True) + 1e-10) # normalize
|
821 |
+
direction_down = -direction + torch.tensor([0.0, -0.5, 0.0], device=self.torch_device, dtype=xyz.dtype)
|
822 |
+
direction_down = direction_down / (torch.norm(direction_down, dim=-1, keepdim=True) + 1e-10) # normalize
|
823 |
+
|
824 |
+
for i in range(N, N + N // kk):
|
825 |
+
offset = length * direction + (i - N) / N * length * direction_up
|
826 |
+
xyz_test[:, i] = gripper_center_inv_xyz + offset
|
827 |
+
|
828 |
+
for i in range(N + N // kk, N + N // kk + N // kk):
|
829 |
+
offset = length * direction + (i - N - N // kk) / N * length * direction_down
|
830 |
+
xyz_test[:, i] = gripper_center_inv_xyz + offset
|
831 |
+
|
832 |
+
color_test = torch.zeros_like(xyz_test, device=self.torch_device, dtype=xyz.dtype)
|
833 |
+
color_test[:, :, 0] = 255 / 255 # red
|
834 |
+
color_test[:, :, 1] = 80 / 255 # green
|
835 |
+
color_test[:, :, 2] = 110 / 255 # blue
|
836 |
+
quat_test = torch.zeros((n_grippers, N + N // kk + N // kk, 4), device=self.torch_device, dtype=xyz.dtype)
|
837 |
+
quat_test[:, :, 0] = 1.0 # identity quaternion
|
838 |
+
opa_test = torch.ones((n_grippers, N + N // kk + N // kk, 1), device=self.torch_device, dtype=xyz.dtype)
|
839 |
+
scales_test = torch.ones((n_grippers, N + N // kk + N // kk, 3), device=self.torch_device, dtype=xyz.dtype) * 0.002
|
840 |
+
|
841 |
+
xyz = torch.cat([xyz, xyz_test.reshape(-1, 3)], dim=0)
|
842 |
+
rgb = torch.cat([rgb, color_test.reshape(-1, 3)], dim=0)
|
843 |
+
quat = torch.cat([quat, quat_test.reshape(-1, 4)], dim=0)
|
844 |
+
opa = torch.cat([opa, opa_test.reshape(-1, 1)], dim=0)
|
845 |
+
scales = torch.cat([scales, scales_test.reshape(-1, 3)], dim=0)
|
846 |
+
|
847 |
# normalize
|
848 |
quat = torch.nn.functional.normalize(quat, dim=-1)
|
849 |
|
|
|
948 |
num_particles = self.cfg.sim.n_particles
|
949 |
self.load_scaniverse(in_dir)
|
950 |
self.init_model(batch_size, num_steps, num_particles, ckpt_path=None)
|
951 |
+
self.render_direction = False
|
952 |
|
953 |
params = self.preprocess_gs(self.params)
|
954 |
if self.with_bg:
|
|
|
1084 |
batch_size = 1
|
1085 |
num_particles = self.cfg.sim.n_particles
|
1086 |
self.init_model(batch_size, num_steps, num_particles, ckpt_path=None)
|
1087 |
+
self.render_direction = True
|
1088 |
|
1089 |
# im_list = []
|
1090 |
for i in range(num_steps):
|
|
|
1096 |
if self.verbose:
|
1097 |
print('command:', command.cpu().numpy().tolist())
|
1098 |
|
1099 |
+
self.gripper_direction = command.clone()
|
1100 |
+
|
1101 |
assert self.state['sub_pos'] is None
|
1102 |
|
1103 |
if self.state['sub_pos'] is None:
|
src/experiments/log/gs/temp/form_video.mp4
CHANGED
Binary files a/src/experiments/log/gs/temp/form_video.mp4 and b/src/experiments/log/gs/temp/form_video.mp4 differ
|
|
src/experiments/log/gs/temp/gs_pred.splat
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:753a59d8cb6fb82e29d233db6865e6c6a87fabc5b469619e4310d3fbee619f6c
|
3 |
+
size 7684352
|
src/experiments/log/temp/0000.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0001.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0002.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0003.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0004.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0005.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0006.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0007.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0008.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0009.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0010.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0011.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0012.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0013.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
src/experiments/log/temp/0014.png
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|