Skip to content

Commit ffcbd8c

Browse files
authored
Export with official nn.SiLU() (#7256)
* Update * Update time_limit
1 parent dda669a commit ffcbd8c

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

export.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454

5555
import pandas as pd
5656
import torch
57-
import torch.nn as nn
5857
from torch.utils.mobile_optimizer import optimize_for_mobile
5958

6059
FILE = Path(__file__).resolve()
@@ -64,10 +63,8 @@
6463
if platform.system() != 'Windows':
6564
ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
6665

67-
from models.common import Conv
6866
from models.experimental import attempt_load
6967
from models.yolo import Detect
70-
from utils.activations import SiLU
7168
from utils.datasets import LoadImages
7269
from utils.general import (LOGGER, check_dataset, check_img_size, check_requirements, check_version, colorstr,
7370
file_size, print_args, url2file)
@@ -474,10 +471,10 @@ def run(
474471
im, model = im.half(), model.half() # to FP16
475472
model.train() if train else model.eval() # training mode = no Detect() layer grid construction
476473
for k, m in model.named_modules():
477-
if isinstance(m, Conv): # assign export-friendly activations
478-
if isinstance(m.act, nn.SiLU):
479-
m.act = SiLU()
480-
elif isinstance(m, Detect):
474+
# if isinstance(m, Conv): # assign export-friendly activations
475+
# if isinstance(m.act, nn.SiLU):
476+
# m.act = SiLU()
477+
if isinstance(m, Detect):
481478
m.inplace = inplace
482479
m.onnx_dynamic = dynamic
483480
if hasattr(m, 'forward_export'):

utils/general.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ def non_max_suppression(prediction,
738738
# min_wh = 2 # (pixels) minimum box width and height
739739
max_wh = 7680 # (pixels) maximum box width and height
740740
max_nms = 30000 # maximum number of boxes into torchvision.ops.nms()
741-
time_limit = 0.030 * bs # seconds to quit after
741+
time_limit = 0.1 + 0.03 * bs # seconds to quit after
742742
redundant = True # require redundant detections
743743
multi_label &= nc > 1 # multiple labels per box (adds 0.5ms/img)
744744
merge = False # use merge-NMS

0 commit comments

Comments
 (0)