Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yuedongli1 committed Oct 18, 2024
1 parent ccbf594 commit 9da3d85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions configs/yolov8/yolov8-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ img_size: 640
iou_thres: 0.7
conf_free: True
sync_bn: True
anchor_base: False
opencv_threads_num: 0 # opencv: disable threading optimizations

network:
Expand Down
9 changes: 6 additions & 3 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def get_parser_train(parents=None):
parser.add_argument("--ms_amp_level", type=str, default="O0", help="amp level, O0/O1/O2/O3")
parser.add_argument("--keep_loss_fp32", type=ast.literal_eval, default=True,
help="Whether to maintain loss using fp32/O0-level calculation")
parser.add_argument("--anchor_base", type=ast.literal_eval, default=True, help="Anchor-base")
parser.add_argument("--ms_loss_scaler", type=str, default="static", help="train loss scaler, static/dynamic/none")
parser.add_argument("--ms_loss_scaler_value", type=float, default=1024.0, help="static loss scale value")
parser.add_argument("--ms_jit", type=ast.literal_eval, default=True, help="use jit or not")
Expand Down Expand Up @@ -189,9 +190,11 @@ def train(args):
eval_dataset, eval_dataloader = None, None

# Scale loss hyps
args.loss.cls *= args.data.nc / 80 # scale to classes
if hasattr(args.loss, "obj"):
args.loss.obj *= (args.img_size / 640) ** 2 # scale to image size
nl = network.model.model[-1].nl
args.loss.box *= 3 / nl # scale to layers
args.loss.cls *= args.data.nc / 80 * 3 / nl # scale to classes and layers
if args.anchor_base:
args.loss.obj *= (args.img_size / 640) ** 2 * 3 / nl # scale to image size and layers

# Create Loss
loss_fn = create_loss(
Expand Down

0 comments on commit 9da3d85

Please sign in to comment.