当前位置:网站首页>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 !!!
边栏推荐
- Vipshop work practice: Jason's deserialization application
- 外部排序和大小堆相关知识
- 直播回顾 | smardaten李鸿飞解读中国低/无代码行业研究报告:风向变了
- Behavior tree XML file hot load
- [cloud primordial | kubernetes chapter] go deep into the foundation of all things - container (V)
- Efficiency thesis Reading 1
- [qnx hypervisor 2.2 user manual]12.2 terminology (II)
- [program compilation and pretreatment]
- Introduction to common classes on the runtime side
- Phpcms applet interface new universal interface get_ diy. php
猜你喜欢

phpcms小程序插件api接口升级到4.3(新增批量获取接口、搜索接口等)

How to convert wechat applet into Baidu applet

Fix the problem that the rich text component of the applet does not support the properties of video cover, autoplay, controls, etc

Regular Expression 正则表达式

Srv6---is-is extension

dedecms小程序插件正式上线,一键安装无需任何php或sql基础

The solution of positioning failure caused by framework jump

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

基于SSM的毕业论文管理系统

Yolov5进阶之一摄像头实时采集识别
随机推荐
Unity connects to Turing robot
行为树的基本概念及进阶
uniapp用uParse实现解析后台的富文本编辑器的内容及修改uParse样式
设置QCheckbox 样式的注意事项
Self taught neural network series - 4 learning of neural network
phpcms v9去掉phpsso模块
HDU - 6225 little boxes (\u int128)
20220623 getting started with Adobe Illustrator
Self taught neural network series - 3. First knowledge of neural network
Practice is the fastest way to become a network engineer
Yolov5 advanced zero environment rapid creation and testing
什么是乐观锁,什么是悲观锁
Phpcms V9 mall module (fix the Alipay interface Bug)
Autoregressive model of Lantern Festival
phpcms v9手机访问电脑站一对一跳转对应手机站页面插件
Programming training 7- date conversion problem
如何编译构建
Self taught neural network series - 1 Basic programming knowledge
Computer mall based on SSM
PD快充磁吸移動電源方案