bug描述 Describe the Bug
pytorch的这个算子torchvision.ops.roi_align可以支持batch!=1时的操作
paddle使用paddle.vision.ops.roi_align算子时,batch!=1时出现问题
paddle版本为2.3.1
如下代码中,batch==4,报错
import paddle
from paddle.vision.ops import roi_align
x=paddle.rand(shape=[4,3,512,512])
bbox=paddle.rand(shape=[8,4],dtype='float32')
num=paddle.to_tensor([2],dtype='int32')
print(roi_align(x,boxes=bbox,boxes_num=num,aligned=True,output_size=80))
报错为
Traceback (most recent call last):
File "c:\Users\Administrator\Desktop\GFPGAN-master\GFPGAN-master_paddle\gfpgan\data\a.py", line 14, in <module>
print(roi_align(x,boxes=bbox,boxes_num=num,aligned=True,output_size=80))
File "C:\ProgramData\Anaconda3\lib\site-packages\paddle\vision\ops.py", line 1252, in roi_align
align_out = _C_ops.roi_align(
ValueError: (InvalidArgument) The batch size of rois and the batch size of images must be the
same. But received the batch size of rois is 1, and the batch size of images is 4
[Hint: Expected boxes_batch_size == batch_size, but received boxes_batch_size:1 != batch_size:4.] (at C:\home\workspace\Paddle_release\paddle\phi\kernels\cpu\roi_align_kernel.cc:217)
[operator < roi_align > error]
batch等于1时不报错
import paddle
from paddle.vision.ops import roi_align
x=paddle.rand(shape=[1,3,512,512])
bbox=paddle.rand(shape=[2,4],dtype='float32')
num=paddle.to_tensor([2],dtype='int32')
print(roi_align(x,boxes=bbox,boxes_num=num,aligned=True,output_size=80))
其他补充信息 Additional Supplementary Information
No response
2条答案
按热度按时间6xfqseft1#
您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看 官网API文档 、 常见问题 、 历史Issue 、 AI社区 来寻求解答。祝您生活愉快~
Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the API , FAQ , Github Issue and AI community to get the answer.Have a nice day!
unguejic2#
num参数没给对。
每一张图片有多少个bbox选框是不知道的。所以num参数要告诉函数每一张图片各自有多少选框。
比如2张图片,8个选框。num可以是[3,5]。
告诉函数前3个选框属于第一张图片,接下俩5给选框属于第二张图片。