当前位置:网站首页>Bug encountered in training detectron2: the test set cannot be evaluated during training
Bug encountered in training detectron2: the test set cannot be evaluated during training
2022-06-26 09:10:00 【G fruit】
Let me write it out front
Recently in use detectron2 When training the network , I want to see the test effect of the model on the test set during the training , I am here yaml The configuration file is set to 5000 Time Iteratively output the evaluation results of a test set , The setup code is as follows :
cfg.TEST.EVAL_PERIOD = 5000 # Printout
But when I trained to the th 5000 The evaluation results of the test set did not appear as I expected during the first iteration , It shows a warning , An error is as follows :
No evaluator found. Use DefaultTrainer.test(evaluators=), or implement its build_evaluator method.
resolvent
This report is wrong (warning) The source is detectron2/engine/defaults.py Official original build_evaluator function
Official primitive build_evaluator function
@classmethod
def build_evaluator(cls, cfg, dataset_name):
""" Returns: DatasetEvaluator or None It is not implemented by default. """
raise NotImplementedError(
""" If you want DefaultTrainer to automatically run evaluation, please implement `build_evaluator()` in subclasses (see train_net.py for example). Alternatively, you can call evaluation functions yourself (see Colab balloon tutorial for example). """
)
github The one above is right for this issue The discussion of the :
https://github.com/facebookresearch/detectron2/issues/951
Reference resources github The answer above :
See examples https://github.com/facebookresearch/detectron2/blob/master/tools/train_net.py
The main directory of the official source code has a train_net.py file , There are also build_evaluator function ,github The answer above means to refer to train_net.py Inside build_evaluator The contents of the function .
My method is simple and rough , I am too lazy to refer to , Put the original build_evaluator Function delete , And then put train_net.py Inside build_evaluator Function to copy and paste to the original location
The modified build_evaluator function ( Follow train_net.py Inside build_evaluator The function is the same )
@classmethod
def build_evaluator(cls, cfg, dataset_name, output_folder=None):
""" Create evaluator(s) for a given dataset. This uses the special metadata "evaluator_type" associated with each builtin dataset. For your own dataset, you can simply create an evaluator manually in your script and do not have to worry about the hacky if-else logic here. """
if output_folder is None:
output_folder = os.path.join(cfg.OUTPUT_DIR, "inference")
evaluator_list = []
evaluator_type = MetadataCatalog.get(dataset_name).evaluator_type
if evaluator_type in ["sem_seg", "coco_panoptic_seg"]:
evaluator_list.append(
SemSegEvaluator(
dataset_name,
distributed=True,
num_classes=cfg.MODEL.SEM_SEG_HEAD.NUM_CLASSES,
ignore_label=cfg.MODEL.SEM_SEG_HEAD.IGNORE_VALUE,
output_dir=output_folder,
)
)
if evaluator_type in ["coco", "coco_panoptic_seg"]:
evaluator_list.append(COCOEvaluator(dataset_name, cfg, True, output_folder))
if evaluator_type == "coco_panoptic_seg":
evaluator_list.append(COCOPanopticEvaluator(dataset_name, output_folder))
if evaluator_type == "cityscapes_instance":
assert (
torch.cuda.device_count() >= comm.get_rank()
), "CityscapesEvaluator currently do not work with multiple machines."
return CityscapesInstanceEvaluator(dataset_name)
if evaluator_type == "cityscapes_sem_seg":
assert (
torch.cuda.device_count() >= comm.get_rank()
), "CityscapesEvaluator currently do not work with multiple machines."
return CityscapesSemSegEvaluator(dataset_name)
elif evaluator_type == "pascal_voc":
return PascalVOCDetectionEvaluator(dataset_name)
elif evaluator_type == "lvis":
return LVISEvaluator(dataset_name, cfg, True, output_folder)
if len(evaluator_list) == 0:
raise NotImplementedError(
"no Evaluator for the dataset {} with the type {}".format(
dataset_name, evaluator_type
)
)
elif len(evaluator_list) == 1:
return evaluator_list[0]
return DatasetEvaluators(evaluator_list)
Be careful : Some of the called functions need import Come in
''' Remember to load functions !!!'''
from detectron2.evaluation import (
CityscapesInstanceEvaluator,
CityscapesSemSegEvaluator,
COCOEvaluator,
COCOPanopticEvaluator,
DatasetEvaluators,
LVISEvaluator,
PascalVOCDetectionEvaluator,
SemSegEvaluator,
verify_results,
)
After the modification is completed , The problems encountered are solved !!!
边栏推荐
- 小程序首页加载之前加载其他相关资源或配置(小程序的promise应用)
- Data warehouse (3) star model and dimension modeling of data warehouse modeling
- PD快充磁吸移動電源方案
- Which software is safer to open an account on
- XSS cross site scripting attack
- Yolov5进阶之五GPU环境搭建
- 直播回顾 | smardaten李鸿飞解读中国低/无代码行业研究报告:风向变了
- 【程序的编译和预处理】
- Introduction to common classes on the runtime side
- 行为树的基本概念及进阶
猜你喜欢
![[program compilation and pretreatment]](/img/c9/45353cf6578628ad44f149350873f5.png)
[program compilation and pretreatment]

【开源】使用PhenoCV-WeedCam进行更智能、更精确的杂草管理

PD快充磁吸移動電源方案

Slider verification - personal test (JD)

Uniapp uses uparse to parse the content of the background rich text editor and modify the uparse style

Yolov5进阶之四训练自己的数据集

Yolov5进阶之五GPU环境搭建

20220623 getting started with Adobe Illustrator

Data warehouse (3) star model and dimension modeling of data warehouse modeling

浅谈一下Type-C接口发展历程
随机推荐
Reverse crawling verification code identification login (OCR character recognition)
Yolov5进阶之五GPU环境搭建
Data warehouse (3) star model and dimension modeling of data warehouse modeling
什么是乐观锁,什么是悲观锁
如何利用最少的钱,快速打开淘宝流量入口?
Dedecms applet plug-in is officially launched, and one click installation does not require any PHP or SQL Foundation
What is optimistic lock and what is pessimistic lock
dedecms小程序插件正式上线,一键安装无需任何php或sql基础
Yolov5 advanced camera real-time acquisition and recognition
Graduation thesis management system based on SSM
Chargement à chaud du fichier XML de l'arbre de comportement
Which software is safer to open an account on
Particles and sound effect system in games104 music 12 game engine
[qnx hypervisor 2.2 user manual]12.1 terminology (I)
Backward usage
Implementation code of interceptor and filter
Yolov5进阶之三训练环境
Phpcms V9 adds the reading amount field in the background, and the reading amount can be modified at will
Mongodb分片环境搭建和验证(redis期末大作业)
Computer mall based on SSM