Unverified 提交 d257c75c authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Update export.py (#7301)

* Update export.py Simplify code. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ciCo-authored-by: 's avatarpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
上级 741fac81
...@@ -480,15 +480,10 @@ def run( ...@@ -480,15 +480,10 @@ def run(
im, model = im.half(), model.half() # to FP16 im, model = im.half(), model.half() # to FP16
model.train() if train else model.eval() # training mode = no Detect() layer grid construction model.train() if train else model.eval() # training mode = no Detect() layer grid construction
for k, m in model.named_modules(): for k, m in model.named_modules():
# if isinstance(m, Conv): # assign export-friendly activations
# if isinstance(m.act, nn.SiLU):
# m.act = SiLU()
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 m.export = True
if hasattr(m, 'forward_export'):
m.forward = m.forward_export # assign custom forward (optional)
for _ in range(2): for _ in range(2):
y = model(im) # dry runs y = model(im) # dry runs
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论