mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-05-23 21:44:22 +08:00
Allocated updated pycocotools metrics fix (#101)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
441126a77e
commit
5c6d11bdb2
@ -40,7 +40,7 @@ ipython # interactive notebook
|
|||||||
psutil # system utilization
|
psutil # system utilization
|
||||||
thop>=0.1.1 # FLOPs computation
|
thop>=0.1.1 # FLOPs computation
|
||||||
# albumentations>=1.0.3
|
# albumentations>=1.0.3
|
||||||
# pycocotools>=2.0 # COCO mAP
|
# pycocotools>=2.0.6 # COCO mAP
|
||||||
# roboflow
|
# roboflow
|
||||||
|
|
||||||
# HUB -----------------------------------------
|
# HUB -----------------------------------------
|
||||||
|
@ -127,7 +127,7 @@ class BaseValidator:
|
|||||||
self.logger.info(f"Saving {f.name}...")
|
self.logger.info(f"Saving {f.name}...")
|
||||||
json.dump(self.jdict, f) # flatten and save
|
json.dump(self.jdict, f) # flatten and save
|
||||||
|
|
||||||
self.eval_json()
|
stats = self.eval_json(stats)
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
def get_dataloader(self, dataset_path, batch_size):
|
def get_dataloader(self, dataset_path, batch_size):
|
||||||
@ -171,5 +171,5 @@ class BaseValidator:
|
|||||||
def pred_to_json(self, preds, batch):
|
def pred_to_json(self, preds, batch):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def eval_json(self):
|
def eval_json(self, stats):
|
||||||
pass
|
pass
|
||||||
|
@ -210,13 +210,13 @@ class DetectionValidator(BaseValidator):
|
|||||||
'bbox': [round(x, 3) for x in b],
|
'bbox': [round(x, 3) for x in b],
|
||||||
'score': round(p[4], 5)})
|
'score': round(p[4], 5)})
|
||||||
|
|
||||||
def eval_json(self):
|
def eval_json(self, stats):
|
||||||
if self.args.save_json and self.is_coco and len(self.jdict):
|
if self.args.save_json and self.is_coco and len(self.jdict):
|
||||||
anno_json = self.data['path'] / "annotations/instances_val2017.json" # annotations
|
anno_json = self.data['path'] / "annotations/instances_val2017.json" # annotations
|
||||||
pred_json = self.save_dir / "predictions.json" # predictions
|
pred_json = self.save_dir / "predictions.json" # predictions
|
||||||
self.logger.info(f'\nEvaluating pycocotools mAP using {pred_json} and {anno_json}...')
|
self.logger.info(f'\nEvaluating pycocotools mAP using {pred_json} and {anno_json}...')
|
||||||
try: # https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
|
try: # https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
|
||||||
check_requirements('pycocotools')
|
check_requirements('pycocotools>=2.0.6')
|
||||||
from pycocotools.coco import COCO # noqa
|
from pycocotools.coco import COCO # noqa
|
||||||
from pycocotools.cocoeval import COCOeval # noqa
|
from pycocotools.cocoeval import COCOeval # noqa
|
||||||
|
|
||||||
@ -230,9 +230,10 @@ class DetectionValidator(BaseValidator):
|
|||||||
eval.evaluate()
|
eval.evaluate()
|
||||||
eval.accumulate()
|
eval.accumulate()
|
||||||
eval.summarize()
|
eval.summarize()
|
||||||
self.metrics.metric.map, self.metrics.metric.map50 = eval.stats[:2] # update mAP50-95 and mAP50
|
stats[self.metric_keys[-1]], stats[self.metric_keys[-2]] = eval.stats[:2] # update mAP50-95 and mAP50
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.warning(f'pycocotools unable to run: {e}')
|
self.logger.warning(f'pycocotools unable to run: {e}')
|
||||||
|
return stats
|
||||||
|
|
||||||
|
|
||||||
@hydra.main(version_base=None, config_path=str(DEFAULT_CONFIG.parent), config_name=DEFAULT_CONFIG.name)
|
@hydra.main(version_base=None, config_path=str(DEFAULT_CONFIG.parent), config_name=DEFAULT_CONFIG.name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user