Ultralytics Code Refactor https://ultralytics.com/actions (#13152)
Refactor code for speed and clarity
This commit is contained in:
1 parent
05e59bdec1
commit
b9019671f4
13 files changed
+29
-5
No files matched your search
@@ -216,6 +216,7 @@ def train(hyp, opt, device, callbacks):
|
||||
else:
|
||||
|
||||
def lf(x):
|
||||
"""Linear learning rate scheduler decreasing from 1 to hyp['lrf'] over 'epochs'."""
|
||||
return (1 - x / epochs) * (1.0 - hyp["lrf"]) + hyp["lrf"] # linear
|
||||
|
||||
scheduler = lr_scheduler.LambdaLR(optimizer, lr_lambda=lf) # plot_lr_scheduler(optimizer, scheduler, epochs)
|
||||
|
||||
@@ -91,6 +91,7 @@ def save_one_json(predn, jdict, path, class_map, pred_masks):
|
||||
from pycocotools.mask import encode
|
||||
|
||||
def single_encode(x):
|
||||
"""Encodes binary mask arrays into RLE (Run-Length Encoding) format for JSON serialization."""
|
||||
rle = encode(np.asarray(x[:, :, None], order="F", dtype="uint8"))[0]
|
||||
rle["counts"] = rle["counts"].decode("utf-8")
|
||||
return rle
|
||||
|
||||
Reference in new issue
Block a user