ModuleNotFoundError: No Module named nms.gpu_nms

Manasa Noolu(Mortha)
1 min readJan 28, 2021

--

ModuleNotFoundError statement

If your program nms_wrapper is unable to find nms.gpu_nms or nms.cpu_nms then we need to do a few modifications in the nms.wrapper.py file in the fast_rcnn folder.

do the following steps to overcome the error:

  1. comment the following import statement in the nms_wrapper.py file
# from nms.gpu_nms import gpu_nms
#from nms.cpu_nms import cpu_nms

2. then add this line

from nms.py_cpu_nms import py_cpu_nms

3. modify the below def module

def nms(dets, thresh, force_cpu=False):
"""Dispatch to either CPU or GPU NMS implementations."""

if dets.shape[0] == 0:
return []
if cfg.USE_GPU_NMS and not force_cpu:
return gpu_nms(dets, thresh, device_id=cfg.GPU_ID)
else:
return cpu_nms(dets, thresh)

by

def nms(dets, thresh, force_cpu=False):
"""Dispatch to either CPU or GPU NMS implementations."""

if dets.shape[0] == 0:
return []
else:
return py_cpu_nms(dets, thresh)

This will remove the error. However, the names of the project name, libraries, functions would be different. I have taken from the original file, for more information on Python Faster RCNN you can refer to https://github.com/rbgirshick/py-faster-rcnn

The reference for the above error statement can be found in the below link

--

--