Open wsy-yjys opened 4 months ago
在具体实现上,引入标志self.test_speed
并将其设置为True
,实现只计算one2one
是否就可以?
class v10Detect(Detect):
max_det = 300
def __init__(self, nc=80, ch=()):
super().__init__(nc, ch)
c3 = max(ch[0], min(self.nc, 100)) # channels
self.cv3 = nn.ModuleList(nn.Sequential(nn.Sequential(Conv(x, x, 3, g=x), Conv(x, c3, 1)), \
nn.Sequential(Conv(c3, c3, 3, g=c3), Conv(c3, c3, 1)), \
nn.Conv2d(c3, self.nc, 1)) for i, x in enumerate(ch))
self.one2one_cv2 = copy.deepcopy(self.cv2)
self.one2one_cv3 = copy.deepcopy(self.cv3)
self.test_speed = True
def forward(self, x):
one2one = self.forward_feat([xi.detach() for xi in x], self.one2one_cv2, self.one2one_cv3)
if self.test_speed:
one2one = self.inference(one2one)
return {"one2one": one2one}
请问这个问题你解决了吗
请问不export模型,直接在PyTorch环境中进行测速,除了修改
v10Detect
删除one2many
之外,还需要注意什么吗?