当前位置:网站首页>[paddleseg source code reading] add boundary IOU calculation in paddleseg validation (1) -- val.py file details tips
[paddleseg source code reading] add boundary IOU calculation in paddleseg validation (1) -- val.py file details tips
2022-07-07 18:08:00 【Master Fuwen】
The last one was tossed boundary IoU
Calculation method of , This article talks about PaddleSeg How to add Boundary IoU do Val, Training and infer Almost. ,hxdm Step on the pit yourself
First of all, the whole thing PaddleSeg Lite version :
.travis.yml
.style.yapf
.pre-commit-config.yaml
.gitignore
.copyright.hook
LICENSE
README.md
README_CN.md
requirements.txt
export.py # Delete it or not , This is used to export static graph model files
setup.py # This is used to install PaddleSeg Of , Delete it
benchmark
deploy
docs
EISeg # An efficient and intelligent interactive segmentation and annotation software based on propeller
slim
test_tipc # Integrated certification of propeller training and propulsion (Training and Inference Pipeline Certification(TIPC)) Information and testing tools
tests
If it's just running training and reasoning , The above can be deleted directly
contrib Just some other functions , such as matting、PPHumanSeg And so on. , Can be deleted
configs Well , That's the pile of configuration files , Understand everything
tools, There are some commonly used tools , Label , Annotation format conversion and so on , After that, I don't want to write wheels , Just look here ( This is a treasure chest )
That's my PaddleSeg Lite version ,
val.py file
There's nothing to see , Just two sentences of code
# Directly here Data class Instantiation
val_dataset = cfg.val_dataset
# Directly here model Instantiation
model = cfg.model
Why instantiate directly here ? Obviously, it assigns an attribute , In fact, single-step debugging , You can see , He actually added a decorator to the attribute @property
@property
def val_dataset(self) -> paddle.io.Dataset:
_val_dataset = self.val_dataset_config
if not _val_dataset:
return None
return self._load_object(_val_dataset)
@property
def model(self) -> paddle.nn.Layer:
model_cfg = self.dic.get('model').copy()
if not model_cfg:
raise RuntimeError('No model specified in the configuration file.')
if not 'num_classes' in model_cfg:
......
if not self._model:
self._model = self._load_object(model_cfg)
return self._model
Did you see? , There is one self._load_object
function , All classes are loaded through this method ( Instantiation ) Of
Take a look at this method ( I hope the old irons can read it by themselves ):
def _load_object(self, cfg: dict) -> Any:
cfg = cfg.copy()
if 'type' not in cfg:
raise RuntimeError('No object information in {}.'.format(cfg))
component = self._load_component(cfg.pop('type'))
# The upper boundary is to get the class name
# ----------------- This is the dividing line -----------------
# Below the dividing line is the parameter dictionary
params = {
}
for key, val in cfg.items():
if self._is_meta_type(val):
params[key] = self._load_object(val)
elif isinstance(val, list):
params[key] = [
self._load_object(item)
if self._is_meta_type(item) else item for item in val
]
else:
params[key] = val
# take config After taking out the classes and parameters in , stay return This step returns the object
return component(**params)
There's another one inside _is_meta_type
Method , Guess the meaning , Is it Can be instantiated Judge
Click this method to see :
def _is_meta_type(self, item: Any) -> bool:
return isinstance(item, dict) and 'type' in item
If it's a dictionary , And there are type attribute , stay PaddleSeg Of Config In this architecture , Think that this class can be instantiated
OK, Now keep recursing to see the source code , Now let's jump back , have a look sellf._load_object
in self._load_component
How to get that kind of name
def _load_component(self, com_name: str) -> Any:
com_list = [
manager.MODELS, manager.BACKBONES, manager.DATASETS,
manager.TRANSFORMS, manager.LOSSES
]
for com in com_list:
if com_name in com.components_dict:
return com[com_name]
else:
raise RuntimeError(
'The specified component was not found {}.'.format(com_name))
See here , I believe if you have read my blog , Then there must be a feeling of sudden enlightenment
[PaddleSeg Source code reading ] PaddleSeg Custom data class
The end of this blog :
manager.MODELS
manager.BACKBONES
manager.DATASETS
manager.TRANSFORMS
manager.LOSSES
These components are shown , I think so ,PaddleSeg The commonly used components are abstracted , Directly abstracted as Model class ,Backbone Backbone network , Dataset class , picture Transform class and Loss function class
Abstract as a class , You need to add the corresponding decorator , For example, add custom classes , Need this decorator :
@manager.DATASETS.add_component
Look at that English .add_component
It means adding components , So in _load_component
In the source code ,
for com in com_list:
if com_name in com.components_dict:
return com[com_name]
Go and see com_name
Whether in manager.MODELS
、manager.BACKBONES
、manager.DATASETS
、manager.TRANSFORMS
and manager.LOSSES
Among these components
If none of them are in , be raise This is wrong :
raise RuntimeError(
'The specified component was not found {}.'.format(com_name))
“ This component was not found ”
Here's another line , image metrics Those indicators ( such as IoU, acc And so on. ), They're just functions , Not class , So you don't need to use it .add_component
To register
( This sentence is for later use Boundary IoU Pave the way )
Almost , This blog starts with these two sentences :
val_dataset = cfg.val_dataset
model = cfg.model
Led to so many
To sum up for yourselves , Send it to the comment area
边栏推荐
- Explain it in simple terms. CNN convolutional neural network
- USB通信协议深入理解
- What skills can you master to be a "master tester" when doing software testing?
- JS pull down the curtain JS special effect display layer
- Easy to understand [linear regression of machine learning]
- [answer] if the app is in the foreground, the activity will not be recycled?
- [principles and technologies of network attack and Defense] Chapter 3: network reconnaissance technology
- Self made dataset in pytoch for dataset rewriting
- 基于RGB图像阈值分割并利用滑动调节阈值
- 基于PyTorch利用CNN对自己的数据集进行分类
猜你喜欢
[4500 word summary] a complete set of skills that a software testing engineer needs to master
JS pull down the curtain JS special effect display layer
【4500字归纳总结】一名软件测试工程师需要掌握的技能大全
Mobile app takeout ordering personal center page
机器人工程终身学习和工作计划-2022-
什么是敏捷测试
Target detection 1 -- actual operation of Yolo data annotation and script for converting XML to TXT file
zdog.js火箭转向动画js特效
基于百度飞浆平台(EasyDL)设计的人脸识别考勤系统
Functions and usage of imageswitch
随机推荐
mui侧边导航锚点定位js特效
保证接口数据安全的10种方案
Five simple ways to troubleshoot with Stace
Notification is the notification displayed in the status bar of the phone
ICer知识点杂烩(后附大量题目,持续更新中)
zdog. JS rocket turn animation JS special effects
Automated testing: a practical skill that everyone wants to know about robot framework
【蓝桥杯集训100题】scratch从小到大排序 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第17题
数学分析_笔记_第11章:Fourier级数
Afghan interim government security forces launched military operations against a hideout of the extremist organization "Islamic state"
Yarn capacity scheduler (ultra detailed interpretation)
如何在软件研发阶段落地安全实践
debian10编译安装mysql
Dateticket and timeticket, functions and usage of date and time selectors
线上比赛相关规则补充说明
Create dialog style windows with popupwindow
Ansible learning summary (9) -- ansible loop, condition judgment, trigger, processing failure and other task control use summary
Sanxian Guidong JS game source code
Native JS verification code
带动画的列表选中js特效