当前位置:网站首页>Fasterrcnn sample code test 1: make anchor_ generator = None
Fasterrcnn sample code test 1: make anchor_ generator = None
2022-07-24 02:32:00 【Eden_ mm】
Focus on RPN One column :
import torch
import torchvision
from torchvision.models.detection import FasterRCNN
from torchvision.models.detection.rpn import AnchorGenerator
# Definition backbone
backbone = torchvision.models.mobilenet_v2().features
backbone.out_channels = 1280
##!!!! RPN, Pay attention here
#anchor_generator = AnchorGenerator(sizes=((32, 64, 128, 256, 512),), aspect_ratios=((0.5, 1, 2),))
anchor_generator = None
# Define which feature Will be used for RoIAlign
roi_pooler = torchvision.ops.MultiScaleRoIAlign(featmap_names=['0'],
output_size=7,
sampling_ratio=2)
# Integrate into the model
model = FasterRCNN(backbone=backbone, num_classes=10, rpn_anchor_generator=anchor_generator,
box_roi_pool=roi_pooler)
model.eval()
# Compile a data
x = [torch.rand(3, 500, 689), torch.rand(3, 400, 654)]
a = model(x)
print(a)
——————————————————————————————————————————
##!!!! RPN, Pay attention here
#anchor_generator = AnchorGenerator(sizes=((32, 64, 128, 256, 512),), aspect_ratios=((0.5, 1, 2),))
anchor_generator = None
Generally, you can set it yourself anchor_generator, You can also use the system default , Reference resources fast-rcnn Source code
def _default_anchorgen():
anchor_sizes = ((32,), (64,), (128,), (256,), (512,))
aspect_ratios = ((0.5, 1.0, 2.0),) * len(anchor_sizes)
return AnchorGenerator(anchor_sizes, aspect_ratios)
if rpn_anchor_generator is None:
rpn_anchor_generator = _default_anchorgen()
——————————————————————————————————————————————
But I use the default , An error occurred
assert condition, message
AssertionError: Anchors should be Tuple[Tuple[int]] because each feature map could potentially have different sizes and aspect ratios.
There needs to be a match between the number of feature maps passed and the number of sizes / aspect ratios specified.
speculation : default def _default_anchorgen(), This is FPN Of , Multiscale generation .
anchor_sizes = ((32,), (64,), (128,), (256,), (512,))
aspect_ratios = ((0.5, 1.0, 2.0),) * len(anchor_sizes)
(32,), (64,), (128,), (256,), (512,) Each represents five feature_map Upper value size ;
aspect_ratios =((0.5, 1.0, 2.0), (0.5, 1.0, 2.0), (0.5, 1.0, 2.0), (0.5, 1.0, 2.0), (0.5, 1.0, 2.0))
This is what I guess ........ Haven't seen the anchor box generation , provisional
边栏推荐
- Data conversion problem in Qt development serial communication software: when reading_ Qbytearray to string; When sending_ Data format; Int to hexadecimal format string; Intercept characters in string
- What is naked SQL? What middleware or plug-in is good for express to operate MySQL?
- 关于缺少编程基础的朋友想转行 ABAP 开发岗提出的一些咨询问题和解答
- Jina AI and datawhale jointly launched a learning project!
- [diary of supplementary questions] [2022 Niuke summer school 1] j-serval and essay
- Ggplot2 displays png
- Use the pagoda panel to plan tasks and automatically push the website to Baidu for inclusion
- 关于 SAP 电商云 Spartacus UI Transfer State 冗余 API 请求发送的讨论
- Async await details & Promise
- 【补题日记】[2022牛客暑期多校1]J-Serval and Essay
猜你喜欢

Doodle Icons - 一组免费商用的涂鸦风格图标库,可爱轻快又独特

Live800: there is nothing trivial about customer service. Don't let service destroy the reputation of the enterprise
![[Luogu] p1318 ponding area](/img/94/ed0c27c0be3759f83c0290d4b7801b.jpg)
[Luogu] p1318 ponding area

Discussion on sending redundant API requests for Spartacus UI transfer state of SAP e-commerce cloud

Network protocol details: UDP

Reading notes: self cultivation of programmers - Chapter 3

响应式布局一个网页在不同设备显示不同效果)meta:vp

1000 okaleido tiger launched binance NFT, triggering a rush to buy

ggplot2显示png

网络协议详解:TCP Part1
随机推荐
canvas-绘图(鼠标按下 绘制 抬起 结束)
微信小程序实现折线面积图-玫瑰图-立体柱状图
BPG笔记(三)
Use the pagoda panel to plan tasks and automatically push the website to Baidu for inclusion
Idea's gradle project Chinese garbled
I'm a novice. I heard that there is a breakeven financial product in opening an account. What is it?
22 -- 二叉搜索树的范围和
Some consulting questions and answers raised by friends who lack programming foundation and want to change careers in ABAP development post
[FPGA tutorial case 39] communication case 9 - interleaving deinterleaving data transmission based on FPGA
1000个Okaleido Tiger首发上线Binance NFT,引发抢购热潮
JDBC tool class
No coding is required, and the "asynchronous request reply" mode is automatically implemented
Qml- use listview to build a three-level treeview architecture
【补题日记】[2022杭电暑期多校1]B-Dragon slayer
【数据集】——flyingthings3d光流部分数据集下载
Loadrunner12 installation, recording the first script and the proxy server did not respond to the solution
Async await details & Promise
[FPGA tutorial case 38] communication case 8 - serial parallel serial data transmission based on FPGA
【补题日记】[2022牛客暑期多校2]K-Link with Bracket Sequence I
Share two interesting special effects