@@ -192,6 +192,7 @@ def add_pointclouds_to_volumes(
192
192
initial_volumes : "Volumes" ,
193
193
mode : str = "trilinear" ,
194
194
min_weight : float = 1e-4 ,
195
+ rescale_features : bool = True ,
195
196
_python : bool = False ,
196
197
) -> "Volumes" :
197
198
"""
@@ -250,6 +251,10 @@ def add_pointclouds_to_volumes(
250
251
min_weight: A scalar controlling the lowest possible total per-voxel
251
252
weight used to normalize the features accumulated in a voxel.
252
253
Only active for `mode==trilinear`.
254
+ rescale_features: If False, output features are just the sum of input and
255
+ added points. If True, they are averaged. In both cases,
256
+ output densities are just summed without rescaling, so
257
+ you may need to rescale them afterwards.
253
258
_python: Set to True to use a pure Python implementation, e.g. for test
254
259
purposes, which requires more memory and may be slower.
255
260
@@ -286,6 +291,7 @@ def add_pointclouds_to_volumes(
286
291
grid_sizes = initial_volumes .get_grid_sizes (),
287
292
mask = mask ,
288
293
mode = mode ,
294
+ rescale_features = rescale_features ,
289
295
_python = _python ,
290
296
)
291
297
@@ -303,6 +309,7 @@ def add_points_features_to_volume_densities_features(
303
309
min_weight : float = 1e-4 ,
304
310
mask : Optional [torch .Tensor ] = None ,
305
311
grid_sizes : Optional [torch .LongTensor ] = None ,
312
+ rescale_features : bool = True ,
306
313
_python : bool = False ,
307
314
) -> Tuple [torch .Tensor , torch .Tensor ]:
308
315
"""
@@ -345,6 +352,10 @@ def add_points_features_to_volume_densities_features(
345
352
grid_sizes: `LongTensor` of shape (minibatch, 3) representing the
346
353
spatial resolutions of each of the the non-flattened `volumes` tensors,
347
354
or None to indicate the whole volume is used for every batch element.
355
+ rescale_features: If False, output features are just the sum of input and
356
+ added points. If True, they are averaged. In both cases,
357
+ output densities are just summed without rescaling, so
358
+ you may need to rescale them afterwards.
348
359
_python: Set to True to use a pure Python implementation.
349
360
Returns:
350
361
volume_features: Output volume of shape `(minibatch, feature_dim, D, H, W)`
@@ -401,12 +412,13 @@ def add_points_features_to_volume_densities_features(
401
412
True , # align_corners
402
413
splat ,
403
414
)
404
- if splat :
405
- # divide each feature by the total weight of the votes
406
- volume_features = volume_features / volume_densities .clamp (min_weight )
407
- else :
415
+
416
+ if rescale_features :
408
417
# divide each feature by the total weight of the votes
409
- volume_features = volume_features / volume_densities .clamp (1.0 )
418
+ if splat :
419
+ volume_features = volume_features / volume_densities .clamp (min_weight )
420
+ else :
421
+ volume_features = volume_features / volume_densities .clamp (1.0 )
410
422
411
423
return volume_features , volume_densities
412
424
0 commit comments