Use pathlib in DOTA ops (#7552)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-01-13 19:32:49 +01:00 committed by GitHub
parent f6309b8e70
commit 9d4ffa43bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 55 deletions

View file

@ -84,12 +84,8 @@ def benchmark(
emoji, filename = "", None # export defaults
try:
assert i != 9 or LINUX, "Edge TPU export only supported on Linux"
if i == 5:
assert MACOS or LINUX, "CoreML export only supported on macOS and Linux"
elif i == 10:
assert MACOS or LINUX, "TF.js export only supported on macOS and Linux"
# elif i == 11:
# assert sys.version_info < (3, 11), "PaddlePaddle export only supported on Python<=3.10"
if i in {5, 10}: # CoreML and TF.js
assert MACOS or LINUX, "export only supported on macOS and Linux"
if "cpu" in device.type:
assert cpu, "inference not supported on CPU"
if "cuda" in device.type:

View file

@ -105,12 +105,7 @@ def _fetch_trainer_metadata(trainer):
save_interval = curr_epoch % save_period == 0
save_assets = save and save_period > 0 and save_interval and not final_epoch
return dict(
curr_epoch=curr_epoch,
curr_step=curr_step,
save_assets=save_assets,
final_epoch=final_epoch,
)
return dict(curr_epoch=curr_epoch, curr_step=curr_step, save_assets=save_assets, final_epoch=final_epoch)
def _scale_bounding_box_to_original_image_shape(box, resized_image_shape, original_image_shape, ratio_pad):
@ -218,11 +213,7 @@ def _log_confusion_matrix(experiment, trainer, curr_step, curr_epoch):
conf_mat = trainer.validator.confusion_matrix.matrix
names = list(trainer.data["names"].values()) + ["background"]
experiment.log_confusion_matrix(
matrix=conf_mat,
labels=names,
max_categories=len(names),
epoch=curr_epoch,
step=curr_step,
matrix=conf_mat, labels=names, max_categories=len(names), epoch=curr_epoch, step=curr_step
)
@ -294,12 +285,7 @@ def _log_plots(experiment, trainer):
def _log_model(experiment, trainer):
"""Log the best-trained model to Comet.ml."""
model_name = _get_comet_model_name()
experiment.log_model(
model_name,
file_or_folder=str(trainer.best),
file_name="best.pt",
overwrite=True,
)
experiment.log_model(model_name, file_or_folder=str(trainer.best), file_name="best.pt", overwrite=True)
def on_pretrain_routine_start(trainer):
@ -320,11 +306,7 @@ def on_train_epoch_end(trainer):
curr_epoch = metadata["curr_epoch"]
curr_step = metadata["curr_step"]
experiment.log_metrics(
trainer.label_loss_items(trainer.tloss, prefix="train"),
step=curr_step,
epoch=curr_epoch,
)
experiment.log_metrics(trainer.label_loss_items(trainer.tloss, prefix="train"), step=curr_step, epoch=curr_epoch)
if curr_epoch == 1:
_log_images(experiment, trainer.save_dir.glob("train_batch*.jpg"), curr_step)

View file

@ -38,9 +38,7 @@ class VarifocalLoss(nn.Module):
class FocalLoss(nn.Module):
"""Wraps focal loss around existing loss_fcn(), i.e. criteria = FocalLoss(nn.BCEWithLogitsLoss(), gamma=1.5)."""
def __init__(
self,
):
def __init__(self):
"""Initializer for FocalLoss class with no parameters."""
super().__init__()