Spaces:
Running
on
Zero
Running
on
Zero
fix examples
Browse files- .gitattributes +3 -0
- app.py +4 -2
- assets/test4.jpeg +0 -0
- assets/test4.jpg +3 -0
- assets/test5.jpeg +0 -0
- assets/test6.jpg +2 -2
- assets/test7.jpg +3 -0
- assets/test8.jpeg +3 -0
- hort/models/tgs/models/snowflake/SPD_pp.py +5 -4
- hort/models/tgs/models/snowflake/model_spdpp.py +9 -4
.gitattributes
CHANGED
@@ -36,3 +36,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
36 |
assets/test1.png filter=lfs diff=lfs merge=lfs -text
|
37 |
assets/test2.png filter=lfs diff=lfs merge=lfs -text
|
38 |
assets/test6.jpg filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
36 |
assets/test1.png filter=lfs diff=lfs merge=lfs -text
|
37 |
assets/test2.png filter=lfs diff=lfs merge=lfs -text
|
38 |
assets/test6.jpg filter=lfs diff=lfs merge=lfs -text
|
39 |
+
assets/test4.jpg filter=lfs diff=lfs merge=lfs -text
|
40 |
+
assets/test7.jpg filter=lfs diff=lfs merge=lfs -text
|
41 |
+
assets/test8.jpeg filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -238,9 +238,11 @@ with gr.Blocks(theme=theme, title="HORT: Monocular Hand-held Objects Reconstruct
|
|
238 |
['/home/user/app/assets/test1.png'],
|
239 |
['/home/user/app/assets/test2.png'],
|
240 |
['/home/user/app/assets/test3.jpg'],
|
241 |
-
['/home/user/app/assets/test4.
|
242 |
['/home/user/app/assets/test5.jpeg'],
|
243 |
-
['/home/user/app/assets/test6.jpg']
|
|
|
|
|
244 |
],
|
245 |
inputs=input_image)
|
246 |
|
|
|
238 |
['/home/user/app/assets/test1.png'],
|
239 |
['/home/user/app/assets/test2.png'],
|
240 |
['/home/user/app/assets/test3.jpg'],
|
241 |
+
['/home/user/app/assets/test4.jpg'],
|
242 |
['/home/user/app/assets/test5.jpeg'],
|
243 |
+
['/home/user/app/assets/test6.jpg'],
|
244 |
+
['/home/user/app/assets/test7.jpg'],
|
245 |
+
['/home/user/app/assets/test8.jpeg']
|
246 |
],
|
247 |
inputs=input_image)
|
248 |
|
assets/test4.jpeg
DELETED
Binary file (3.65 kB)
|
|
assets/test4.jpg
ADDED
![]() |
Git LFS Details
|
assets/test5.jpeg
CHANGED
![]() |
![]() |
assets/test6.jpg
CHANGED
![]() |
Git LFS Details
|
![]() |
Git LFS Details
|
assets/test7.jpg
ADDED
![]() |
Git LFS Details
|
assets/test8.jpeg
ADDED
![]() |
Git LFS Details
|
hort/models/tgs/models/snowflake/SPD_pp.py
CHANGED
@@ -33,7 +33,7 @@ class SPD_pp(nn.Module):
|
|
33 |
|
34 |
self.mlp_delta = MLP_CONV(in_channel=128, layer_dims=[64, 3])
|
35 |
|
36 |
-
def forward(self, pcd_prev, feat_cond=None, K_prev=None):
|
37 |
"""
|
38 |
Args:
|
39 |
pcd_prev: Tensor, (B, 3, N_prev)
|
@@ -45,15 +45,16 @@ class SPD_pp(nn.Module):
|
|
45 |
K_curr: Tensor, displacement feature of current step, (B, 128, N_prev * up_factor)
|
46 |
"""
|
47 |
b, _, n_prev = pcd_prev.shape
|
48 |
-
feat_1 = self.mlp_1(pcd_prev)
|
49 |
feat_1 = torch.cat([feat_1,
|
50 |
torch.max(feat_1, 2, keepdim=True)[
|
51 |
0].repeat((1, 1, feat_1.size(2))),
|
52 |
-
feat_cond], 1) if self.global_feat else feat_1
|
53 |
Q = self.mlp_2(feat_1)
|
54 |
|
55 |
H = self.skip_transformer(
|
56 |
-
|
|
|
57 |
|
58 |
feat_child = self.mlp_ps(H)
|
59 |
feat_child = self.ps(feat_child) # (B, 128, N_prev * up_factor)
|
|
|
33 |
|
34 |
self.mlp_delta = MLP_CONV(in_channel=128, layer_dims=[64, 3])
|
35 |
|
36 |
+
def forward(self, pcd_prev, hand_pcd, hand_feat_cond, feat_cond=None, K_prev=None):
|
37 |
"""
|
38 |
Args:
|
39 |
pcd_prev: Tensor, (B, 3, N_prev)
|
|
|
45 |
K_curr: Tensor, displacement feature of current step, (B, 128, N_prev * up_factor)
|
46 |
"""
|
47 |
b, _, n_prev = pcd_prev.shape
|
48 |
+
feat_1 = self.mlp_1(torch.cat([pcd_prev, hand_pcd], -1))
|
49 |
feat_1 = torch.cat([feat_1,
|
50 |
torch.max(feat_1, 2, keepdim=True)[
|
51 |
0].repeat((1, 1, feat_1.size(2))),
|
52 |
+
torch.cat([feat_cond, hand_feat_cond], -1)], 1) if self.global_feat else feat_1
|
53 |
Q = self.mlp_2(feat_1)
|
54 |
|
55 |
H = self.skip_transformer(
|
56 |
+
torch.cat([pcd_prev, hand_pcd], -1), torch.cat([K_prev, hand_feat_cond], -1) if K_prev is not None else Q, Q)
|
57 |
+
H = H[:, :, :-778]
|
58 |
|
59 |
feat_child = self.mlp_ps(H)
|
60 |
feat_child = self.ps(feat_child) # (B, 128, N_prev * up_factor)
|
hort/models/tgs/models/snowflake/model_spdpp.py
CHANGED
@@ -162,7 +162,7 @@ class Decoder(nn.Module):
|
|
162 |
up_token = F.interpolate(pcl_token, scale_factor=up_factor, mode='nearest')
|
163 |
return up_token
|
164 |
|
165 |
-
def calculate_image_token(self, pcd, input_image_tokens, batch):
|
166 |
"""
|
167 |
Args:
|
168 |
"""
|
@@ -174,7 +174,10 @@ class Decoder(nn.Module):
|
|
174 |
local_features_proj = points_projection_v2(pcd * batch['scale'] + batch['trans'].unsqueeze(1), batch['intrinsic_cond'], local_features)
|
175 |
local_features_proj = local_features_proj.permute(0, 2, 1).contiguous()
|
176 |
|
177 |
-
|
|
|
|
|
|
|
178 |
|
179 |
def forward(self, x):
|
180 |
"""
|
@@ -184,6 +187,7 @@ class Decoder(nn.Module):
|
|
184 |
# partial_coarse: Tensor, (b, n_coarse, 3)
|
185 |
"""
|
186 |
points = x['points']
|
|
|
187 |
if self.token_type == 'pcl_token':
|
188 |
feat_cond = x['pcl_token']
|
189 |
elif self.token_type == 'image_token':
|
@@ -194,14 +198,15 @@ class Decoder(nn.Module):
|
|
194 |
|
195 |
pcd = torch.permute(points, (0, 2, 1)).contiguous()
|
196 |
pcl_up_scale = 1
|
|
|
197 |
for upper in self.uppers:
|
198 |
if self.token_type == 'pcl_token':
|
199 |
up_cond = self.calculate_pcl_token(
|
200 |
feat_cond, pcl_up_scale)
|
201 |
pcl_up_scale *= upper.up_factor
|
202 |
elif self.token_type == 'image_token':
|
203 |
-
up_cond = self.calculate_image_token(points, feat_cond, x)
|
204 |
-
pcd, feat_prev = upper(pcd, up_cond, feat_prev)
|
205 |
points = torch.permute(pcd, (0, 2, 1)).contiguous()
|
206 |
arr_pcd.append(points)
|
207 |
return arr_pcd
|
|
|
162 |
up_token = F.interpolate(pcl_token, scale_factor=up_factor, mode='nearest')
|
163 |
return up_token
|
164 |
|
165 |
+
def calculate_image_token(self, pcd, hand_pcd, input_image_tokens, batch):
|
166 |
"""
|
167 |
Args:
|
168 |
"""
|
|
|
174 |
local_features_proj = points_projection_v2(pcd * batch['scale'] + batch['trans'].unsqueeze(1), batch['intrinsic_cond'], local_features)
|
175 |
local_features_proj = local_features_proj.permute(0, 2, 1).contiguous()
|
176 |
|
177 |
+
local_features_proj_hand = points_projection_v2(hand_pcd, batch['intrinsic_cond'], local_features)
|
178 |
+
local_features_proj_hand = local_features_proj_hand.permute(0, 2, 1).contiguous()
|
179 |
+
|
180 |
+
return local_features_proj, local_features_proj_hand
|
181 |
|
182 |
def forward(self, x):
|
183 |
"""
|
|
|
187 |
# partial_coarse: Tensor, (b, n_coarse, 3)
|
188 |
"""
|
189 |
points = x['points']
|
190 |
+
hand_points = x['hand_points']
|
191 |
if self.token_type == 'pcl_token':
|
192 |
feat_cond = x['pcl_token']
|
193 |
elif self.token_type == 'image_token':
|
|
|
198 |
|
199 |
pcd = torch.permute(points, (0, 2, 1)).contiguous()
|
200 |
pcl_up_scale = 1
|
201 |
+
hand_pcd = torch.permute((hand_points - x['trans'].unsqueeze(1)) / x['scale'], (0, 2, 1)).contiguous()
|
202 |
for upper in self.uppers:
|
203 |
if self.token_type == 'pcl_token':
|
204 |
up_cond = self.calculate_pcl_token(
|
205 |
feat_cond, pcl_up_scale)
|
206 |
pcl_up_scale *= upper.up_factor
|
207 |
elif self.token_type == 'image_token':
|
208 |
+
up_cond, up_cond_hand = self.calculate_image_token(points, hand_points, feat_cond, x)
|
209 |
+
pcd, feat_prev = upper(pcd, hand_pcd, up_cond_hand, up_cond, feat_prev)
|
210 |
points = torch.permute(pcd, (0, 2, 1)).contiguous()
|
211 |
arr_pcd.append(points)
|
212 |
return arr_pcd
|