1、ModuleNotFoundError: No module named 'yolox.layers.fast_cocoeval'
出现这个报错的原因应该是版本问题,需要将D:\anaconda\envs\realtime\Lib\site-packages\yolox\layers\jit_ops.py中的fast_cocoeval改为fast_coco_eval_api
具体为:
class FastCOCOEvalOp(JitOp):
# def __init__(self, name="fast_cocoeval"):
def __init__(self, name="fast_coco_eval_api"):
super().__init__(name=name)
def absolute_name(self):
return f'yolox.layers.{self.name}'
def sources(self):
sources = glob.glob(os.path.join("yolox", "layers", "cocoeval", "*.cpp"))
if not sources: # source will be empty list if the so file is removed after install
# use abosolute path to compile
import yolox
code_path = os.path.join(yolox.__path__[0], "layers", "cocoeval", "*.cpp")
sources = glob.glob(code_path)
return sources
def include_dirs(self):
return [os.path.join("yolox", "layers", "cocoeval")]
问题解决。
2、AttributeError: module 'yolox.layers.fast_cocoeval' has no attribute 'InstanceAnnotation'
问题的原因我也不知道,而且这个问题似乎在ubuntu中不会出现,但是在windows会出现。根据网上的思路,直接就不使用YOLOX定义的COCOeval_opt,而使用COCO的 COCOeval
代码所在路径D:\anaconda\envs\realtime\Lib\site-packages\yolox\evaluators\coco_evaluator.py
具体代码为:(276行)
try:
# from yolox.layers import COCOeval_opt as COCOeval
from pycocotools.cocoeval import COCOeval
except ImportError:
from pycocotools.cocoeval import COCOeval
logger.warning("Use standard COCOeval.")
问题解决