yoloV7出现Results do not correspond to current coco set。
因为我想让yoloV7输出大中小目标的mAP,所以我把test.py中的test函数的参数save_json设置成True。然而 anno = COCO(anno_json)这行报错了。
if save_json and len(jdict):
w = Path(weights[0] if isinstance(weights, list) else weights).stem if weights is not None else '' # weights
anno_json = r'C:\datasets\nmpw\annotations\instances_val2017.json' # annotations json
pred_json = str(save_dir / f"{w}_predictions.json") # predictions json
print('\nEvaluating pycocotools mAP... saving %s...' % pred_json)
with open(pred_json, 'w') as f:
json.dump(jdict, f)
try: # https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval
anno = COCO(anno_json) # init annotations api
pred = anno.loadRes(pred_json) # init predictions api
eval = COCOeval(anno, pred, 'bbox')
if is_coco:
eval.params.imgIds = [int(Path(x).stem) for x in dataloader.dataset.img_files] # image IDs to evaluate
eval.evaluate()
eval.accumulate()
eval.summarize()
map, map50 = eval.stats[:2] # update results (mAP@0.5:0.95, mAP@0.5)
print(*print_label,sep='\t')
print(*eval.stats,sep='\t')
except Exception as e:
print(f'pycocotools unable to run: {e}')
.你让别人看代码,别人都不知道这个报错的函数厘米干了沙,起码把github链接放这里把