Skip to content

Commit

Permalink
[Fix] config not found bug & output test file.
Browse files Browse the repository at this point in the history
  • Loading branch information
SakiRinn committed Apr 14, 2023
1 parent 29d33b5 commit 69c7cfd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion configs/locount/CLCNet_reg_s2d10_r50_fpn_1x_locount.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_base_ = [
'CLCNet_s2d10_r50_fpn_1x_locount.py'
'CLCNet_cls_s2d10_r50_fpn_1x_locount.py'
]
model = dict(
roi_head=dict(
Expand Down
2 changes: 1 addition & 1 deletion configs/locount/CLCNet_reg_s3d2_r50_fpn_1x_locount.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_base_ = [
'CLCNet_s3d2_r50_fpn_1x_locount.py'
'CLCNet_cls_s3d2_r50_fpn_1x_locount.py'
]
model = dict(
roi_head=dict(
Expand Down
2 changes: 1 addition & 1 deletion configs/locount/CLCNet_reg_s6d2_r50_fpn_1x_locount.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_base_ = [
'CLCNet_s6d2_r50_fpn_1x_locount.py'
'CLCNet_cls_s6d2_r50_fpn_1x_locount.py'
]
model = dict(
roi_head=dict(
Expand Down
2 changes: 1 addition & 1 deletion configs/locount/faster_rcnn_reg_r50_fpn_1x_locount.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_base_ = [
'faster_rcnn_r50_fpn_1x_locount.py'
'faster_rcnn_cls_r50_fpn_1x_locount.py'
]
model = dict(
roi_head=dict(
Expand Down
16 changes: 11 additions & 5 deletions mmdet/datasets/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

from mmdet.core import eval_recalls
from mmdet.core.evaluation import coco_classes
from .api_wrappers.cnt_coco_api import COCO, COCOeval # EDIT
# XXX: coco_api -> cnt_coco_api
from .api_wrappers.cnt_coco_api import COCO, COCOeval
from .builder import DATASETS
from .custom import CustomDataset

Expand Down Expand Up @@ -484,12 +485,15 @@ def evaluate_det_segm(self,
level=logging.ERROR)
break

cocoEval = COCOeval(coco_gt, coco_det, iou_type, counts=self.COUNTS)
try:
cocoEval = COCOeval(coco_gt, coco_det, iou_type, counts=self.COUNTS)
cocoEval.params.acThrs = ac_thrs
except TypeError as e:
cocoEval = COCOeval(coco_gt, coco_det, iou_type)
cocoEval.params.catIds = self.cat_ids
cocoEval.params.imgIds = self.img_ids
cocoEval.params.maxDets = list(proposal_nums)
cocoEval.params.iouThrs = iou_thrs
cocoEval.params.acThrs = ac_thrs
# mapping of cocoEval.stats
coco_metric_names = {
'mAP': 0,
Expand All @@ -513,7 +517,8 @@ def evaluate_det_segm(self,

if metric == 'proposal':
cocoEval.params.useCats = 0
cocoEval.params.useCnts = 0
if hasattr(cocoEval.params, 'useCnts'):
cocoEval.params.useCnts = 0
cocoEval.evaluate()
cocoEval.accumulate()

Expand Down Expand Up @@ -645,7 +650,8 @@ def evaluate(self,

coco_gt = self.coco
self.cat_ids = coco_gt.get_cat_ids(cat_names=self.CLASSES)
self.cnt_ids = coco_gt.get_cnt_ids(max_count=self.COUNTS)
if hasattr(coco_gt, 'get_cnt_ids'):
self.cnt_ids = coco_gt.get_cnt_ids(max_count=self.COUNTS)

result_files, tmp_dir = self.format_results(results, jsonfile_prefix)
eval_results = self.evaluate_det_segm(results, result_files, coco_gt,
Expand Down
5 changes: 4 additions & 1 deletion tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,10 @@ def main():
]:
eval_kwargs.pop(key, None)
eval_kwargs.update(dict(metric=args.eval, **kwargs))
metric = dataset.evaluate(outputs, **eval_kwargs)
outputs_prefix = osp.join(*osp.split(args.checkpoint)[:-1], 'outputs')
metric = dataset.evaluate(outputs,
jsonfile_prefix=outputs_prefix,
**eval_kwargs)
print(metric)
metric_dict = dict(config=args.config, metric=metric)
if args.work_dir is not None and rank == 0:
Expand Down

0 comments on commit 69c7cfd

Please sign in to comment.