Browse Source

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>
modifyDataloader
Glenn Jocher GitHub 2 years ago
parent
commit
05cf0d1a44
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions
  1. +1
    -0
      export.py
  2. +2
    -1
      models/yolo.py

+ 1
- 0
export.py View File

@@ -477,6 +477,7 @@ def run(
if isinstance(m, Detect):
m.inplace = inplace
m.onnx_dynamic = dynamic
m.export = True
if hasattr(m, 'forward_export'):
m.forward = m.forward_export # assign custom forward (optional)


+ 2
- 1
models/yolo.py View File

@@ -37,6 +37,7 @@ except ImportError:
class Detect(nn.Module):
stride = None # strides computed during build
onnx_dynamic = False # ONNX export parameter
export = False # export mode

def __init__(self, nc=80, anchors=(), ch=(), inplace=True): # detection layer
super().__init__()
@@ -72,7 +73,7 @@ class Detect(nn.Module):
y = torch.cat((xy, wh, conf), 4)
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):
d = self.anchors[i].device

Loading…
Cancel
Save