目录
报错解决:NameError: name ‘_C‘ is not defined
/GroundingDINO-main
pip install numpy==1.23.2
pip install matplotlib>=3.6.0
测试代码:
# from grounding_dino.groundingdino import _C
from groundingdino import _C
try:
from grounding_dino.groundingdino import _C
except:
print("Failed to load custom C++ ops. Running on CPU mode Only!")
import _C
报错解决:NameError: name ‘_C‘ is not defined
if torch.cuda.is_available() and value.is_cuda and 0:
halffloat = False
if value.dtype == torch.float16:
halffloat = True
value = value.float()
sampling_locations = sampling_locations.float()
attention_weights = attention_weights.float()
output = MultiScaleDeformableAttnFunction.apply(
value,
spatial_shapes,
level_start_index,
sampling_locations,
attention_weights,
self.im2col_step,
)
if halffloat:
output = output.half()
else:
output = multi_scale_deformable_attn_pytorch(
value, spatial_shapes, sampling_locations, attention_weights
)