Export single output only (#7259)
* Update * Update * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
779efbb9ca
commit
05cf0d1a44
2 files changed
+3
-1
No files matched your search
@@ -477,6 +477,7 @@ def run(
|
|||||||
if isinstance(m, Detect):
|
if isinstance(m, Detect):
|
||||||
m.inplace = inplace
|
m.inplace = inplace
|
||||||
m.onnx_dynamic = dynamic
|
m.onnx_dynamic = dynamic
|
||||||
|
m.export = True
|
||||||
if hasattr(m, 'forward_export'):
|
if hasattr(m, 'forward_export'):
|
||||||
m.forward = m.forward_export # assign custom forward (optional)
|
m.forward = m.forward_export # assign custom forward (optional)
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -37,6 +37,7 @@ except ImportError:
|
|||||||
class Detect(nn.Module):
|
class Detect(nn.Module):
|
||||||
stride = None # strides computed during build
|
stride = None # strides computed during build
|
||||||
onnx_dynamic = False # ONNX export parameter
|
onnx_dynamic = False # ONNX export parameter
|
||||||
|
export = False # export mode
|
||||||
|
|
||||||
def __init__(self, nc=80, anchors=(), ch=(), inplace=True): # detection layer
|
def __init__(self, nc=80, anchors=(), ch=(), inplace=True): # detection layer
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -72,7 +73,7 @@ class Detect(nn.Module):
|
|||||||
y = torch.cat((xy, wh, conf), 4)
|
y = torch.cat((xy, wh, conf), 4)
|
||||||
z.append(y.view(bs, -1, self.no))
|
z.append(y.view(bs, -1, self.no))
|
||||||
|
|
||||||
return x if self.training else (torch.cat(z, 1), x)
|
return x if self.training else (torch.cat(z, 1),) if self.export else (torch.cat(z, 1), x)
|
||||||
|
|
||||||
def _make_grid(self, nx=20, ny=20, i=0):
|
def _make_grid(self, nx=20, ny=20, i=0):
|
||||||
d = self.anchors[i].device
|
d = self.anchors[i].device
|
||||||
|
|||||||
Reference in new issue
Block a user