当前位置:网站首页>Pytorch 20 realizes corrosion expansion based on pytorch
Pytorch 20 realizes corrosion expansion based on pytorch
2022-07-03 00:16:00 【Ten thousand miles and a bright future arrived in an instant】
In some image processing projects , Sometimes it is necessary to carry out corrosion expansion and various value processing on the image , introduce opencv After processing , Data cannot be processed quickly , Value range interception 、 Use mask、where Operation etc. . therefore , have access to torch Achieve corrosion expansion , So as to avoid the modification of data structure , At the same time, it ensures that all operations can be realized in one model .( Of course ,opencv It is also very convenient to intercept the value range in , For details, please refer to section 7 in the following link c++ On opencv Common array operations _a486259 The blog of -CSDN Blog )
however , be based on torch Achieved corrosion expansion , There are certain assumptions : All structural elements are square operators . After implementation, it can act on C++ Under the libtorch in , however ksize The size of can only be fixed , Unable to change input . In practical use , Whether the image is a binary graph , It won't affect the result . Only the element with the largest value in the corresponding region of the operator will be selected for replacement .
Core code :
#ksize Must be odd , Otherwise, the size of the pool will change . Besides ,stride=1, padding=int((ksize-1)/ 2) It's a must
ksize=21
max_pool = torch.nn.MaxPool2d(kernel_size=ksize, stride=1, padding=int((ksize-1)/ 2)) # Adjustable kernel_size
Expansion operation
Inflation
边栏推荐
- What is the official website address of e-mail? Explanation of the login entry of the official website address of enterprise e-mail
- Slf4j + logback logging framework
- A single element in an ordered array -- Valentine's Day mental problems
- MFC gets the current time
- 67 page overall planning and construction plan for a new smart city (download attached)
- CADD course learning (4) -- obtaining proteins without crystal structure (Swiss model)
- Angled detection frame | calibrated depth feature for target detection (with implementation source code)
- Digital twin visualization solution digital twin visualization 3D platform
- 130 pages of PPT from the brick boss introduces the new features of Apache spark 3.2 & 3.3 in depth
- Slf4j + Logback日志框架
猜你喜欢
Monitor container runtime tool Falco
MySQL Foundation
Hit the industry directly! The propeller launched the industry's first model selection tool
What is the official website address of e-mail? Explanation of the login entry of the official website address of enterprise e-mail
基于OpenCV实现口罩识别
Mapper agent development
TypeError: Cannot read properties of undefined (reading ***)
CADD课程学习(4)-- 获取没有晶体结构的蛋白(SWISS-Model)
直击产业落地!飞桨重磅推出业界首个模型选型工具
How QT exports data to PDF files (qpdfwriter User Guide)
随机推荐
Where can I find the English literature of the thesis (except HowNet)?
Returns the maximum distance between two nodes of a binary tree
洛谷_P1149 [NOIP2008 提高组] 火柴棒等式_枚举打表
Sysdig analysis container system call
[shutter] shutter photo wall (center component | wrap component | clickrrect component | stack component | positioned component | button combination component)
130 pages of PPT from the brick boss introduces the new features of Apache spark 3.2 & 3.3 in depth
What website can you find English literature on?
Angled detection frame | calibrated depth feature for target detection (with implementation source code)
Open source | Wenxin big model Ernie tiny lightweight technology, which is accurate and fast, and the effect is fully open
TypeError: Cannot read properties of undefined (reading ***)
Realization of mask recognition based on OpenCV
Dishes launcher small green program and directory management (efficiency tool)
yolov5detect. Py comment
Sourcetree details
leetcode 650. 2 keys keyboard with only two keys (medium)
MFC 获取当前时间
Missing number
Is the multitasking loss in pytoch added up or backward separately?
What is the standard format of a 2000-3000 word essay for college students' classroom homework?
sysdig分析容器系统调用