Pytorch 推理时,如何使用EfficientSet Pytork设置目标的参数?

Pytorch 推理时,如何使用EfficientSet Pytork设置目标的参数?,pytorch,object-detection,Pytorch,Object Detection,我第一次用高效的pytorch研究目标检测码 我使用预训练重量模型作为参考: 我试着检查EfficientSet模型的输出 从effdet导入获取\u efficientdet\u配置、efficientdet、DetBenchTrain 来自effdet.efficientdet导入头网 #加载样本效率设置代码 config=get\u efficientdet\u config('tf\u efficientdet\u d0') config.image_size=[512512]

我第一次用高效的pytorch研究目标检测码

我使用预训练重量模型作为参考:

我试着检查EfficientSet模型的输出


从effdet导入获取\u efficientdet\u配置、efficientdet、DetBenchTrain
来自effdet.efficientdet导入头网
#加载样本效率设置代码
config=get\u efficientdet\u config('tf\u efficientdet\u d0')
config.image_size=[512512]
config.norm_kwargs=dict(eps=0.001,动量=0.01)
net=效率ET(配置,预训练主干=假)
检查点=火炬荷载('efficientdet_d0-d92fd44f.pth')
net.load\u state\u dict(检查点)
#净重置头(num\u classes=1)
#net.class\u net=HeadNet(config,num\u outputs=config.num\u classes)
net=DetBenchTrain(net,config)
打印(“加载的预训练重量”)
#>>>加载预训练重量”
#图像形状:[3512512]
净增值()
使用手电筒。无梯度()
检测到=净(img.unsqueze(0))
#错误 目标值低于。
TypeError:forward()缺少1个必需的位置参数:“目标”
以及参考 我尝试了下面的代码


def作出预测(图像,分数阈值=0.22):
预测=[]
使用手电筒。无梯度()
det=net(images,torch.tensor([1]*images.shape[0]).float())
打印(det.shape)
对于范围内的i(images.shape[0]):
box=det[i].detach().cpu().numpy()[:,:4]
分数=det[i].detach().cpu().numpy()[:,4]
索引=np。其中(分数>分数\u阈值)[0]
框=框[索引]
盒子[:,2]=盒子[:,2]+盒子[:,0]
盒子[:,3]=盒子[:,3]+盒子[:,1]
预测。追加({
“框”:框[索引],
“分数”:分数[索引],
})
返回[预测]
输出=进行预测(img.unsqueze(0))
#错误如下。。。
---------------------------------------------------------------------------
索引器回溯(最后一次最近调用)
在里面
---->1输出=进行预测(img.unsqueze(0))
在make_预测中(图像、分数_阈值)
3预测=[]
4带火炬。无梯度()
---->5 det=net(图像,torch.tensor([1]*images.shape[0]).float())
6打印(详细形状)
7对于范围内的i(images.shape[0]):
/opt/anaconda3/envs/yohenv/lib/python3.7/site-packages/torch/nn/modules/modules.py in_call_impl(self,*输入,**kwargs)
720结果=self.\u slow\u forward(*输入,**kwargs)
721其他:
-->722结果=自转发(*输入,**kwargs)
723用于itertools.chain中的挂钩(
724 _全局_向前_hooks.values(),
/前进中的opt/anaconda3/envs/yohenv/lib/python3.7/site-packages/effdet/bench.py(self、x、target)
117其他:
118 cls_目标,方框_目标,正数值=self.anchor_labeler.batch_label_anchors(
-->119目标['bbox'],目标['cls'])
120
121损失,类别损失,方框损失=自身损失(类别损失,方框损失,cls目标,方框损失,正数值)
索引器:维度1的张量的索引太多
使用TestData进行推理时,如何设置目标的参数

很抱歉给您带来不便,您能给我一些建议吗