欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > 名人名企 > FPS(Farthest Point Sampling) 编译笔记

FPS(Farthest Point Sampling) 编译笔记

2025/2/22 16:26:43 来源:https://blog.csdn.net/jacke121/article/details/142623906  浏览:    关键词:FPS(Farthest Point Sampling) 编译笔记

目录

作者自己实现了一版:

c代码:

FPS(Farthest Point Sampling)--最远点采样算法

报错代码:

报错解决方法:


作者自己实现了一版:

extension-cpp/cuda/setup.py at dbf58c505fe5035eccdb71195b6e49c6694f7bbc · hetong007/extension-cpp · GitHub

c代码:

https://github.com/Barbany/fps_cuda/tree/main

FPS(Farthest Point Sampling)--最远点采样算法

新版代码:

pointnet2_ops_lib/pointnet2_ops_lib/pointnet2_ops/pointnet2_utils.py at main · ybhhdt/pointnet2_ops_lib · GitHub


class BallQuery(Function):@staticmethoddef forward(ctx, radius, nsample, xyz, new_xyz):# type: (Any, float, int, torch.Tensor, torch.Tensor) -> torch.Tensorr"""Parameters----------radius : floatradius of the ballsnsample : intmaximum number of features in the ballsxyz : torch.Tensor(B, N, 3) xyz coordinates of the featuresnew_xyz : torch.Tensor(B, npoint, 3) centers of the ball queryReturns-------torch.Tensor(B, npoint, nsample) tensor with the indicies of the features that form the query balls"""idx, pts_cnt= _ext.ball_query(new_xyz, xyz, radius, nsample)ctx.mark_non_differentiable(idx)ctx.mark_non_differentiable(pts_cnt)return idx, pts_cnt

报错代码:

 import torch
from torch.autograd import Functiontry:import builtins
except:import __builtin__ as builtinstry:import fps_cuda._ext as _ext
except ImportError:if not getattr(builtins, "__POINTNET2_SETUP__", False):raise ImportError("Could not import _ext module.\n""Please see the setup instructions in the README: ""https://github.com/erikwijmans/Pointnet2_PyTorch/blob/master/README.rst")class FurthestPointSampling(Function):@staticmethoddef forward(ctx, xyz, npoint):# type: (Any, torch.Tensor, int) -> torch.Tensorr"""Uses iterative furthest point sampling to select a set of npoint features that have the largestminimum distanceParameters----------xyz : torch.Tensor(B, N, 3) tensor where N > npointnpoint : int32number of features in the sampled setReturns-------torch.Tensor(B, npoint) tensor containing the set"""fps_inds = _ext.furthest_point_sampling(xyz, npoint)ctx.mark_non_differentiable(fps_inds)return fps_inds@staticmethoddef backward(xyz, a=None):return None, Nonefurthest_point_sample = FurthestPointSampling.apply    xyz = torch.randn(5,1024,3)
npoint=512
fps_inds = furthest_point_sample(xyz, npoint)
# ctx.mark_non_differentiable(fps_inds)
print(fps_inds)

RuntimeError: Unknown layout in MultiScaleDeformableAttnFunction · Issue #284 · IDEA-Research/GroundingDINO · GitHub

报错解决方法:

pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118

 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词