Apply ruff==0.9.0 formatting (#13486)
* Refactor code for speed and clarity * Auto-format by https://ultralytics.com/actions --------- Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
1 parent
6981c2742a
commit
86fd1ab270
20 files changed
+53
-84
No files matched your search
@@ -356,8 +356,7 @@ class LoadImages:
|
||||
else:
|
||||
self.cap = None
|
||||
assert self.nf > 0, (
|
||||
f"No images or videos found in {p}. "
|
||||
f"Supported formats are:\nimages: {IMG_FORMATS}\nvideos: {VID_FORMATS}"
|
||||
f"No images or videos found in {p}. Supported formats are:\nimages: {IMG_FORMATS}\nvideos: {VID_FORMATS}"
|
||||
)
|
||||
|
||||
def __iter__(self):
|
||||
@@ -713,8 +712,8 @@ class LoadImagesAndLabels(Dataset):
|
||||
cache = mem_required * (1 + safety_margin) < mem.available # to cache or not to cache, that is the question
|
||||
if not cache:
|
||||
LOGGER.info(
|
||||
f'{prefix}{mem_required / gb:.1f}GB RAM required, '
|
||||
f'{mem.available / gb:.1f}/{mem.total / gb:.1f}GB available, '
|
||||
f"{prefix}{mem_required / gb:.1f}GB RAM required, "
|
||||
f"{mem.available / gb:.1f}/{mem.total / gb:.1f}GB available, "
|
||||
f"{'caching images ✅' if cache else 'not caching images ⚠️'}"
|
||||
)
|
||||
return cache
|
||||
@@ -774,8 +773,7 @@ class LoadImagesAndLabels(Dataset):
|
||||
index = self.indices[index] # linear, shuffled, or image_weights
|
||||
|
||||
hyp = self.hyp
|
||||
mosaic = self.mosaic and random.random() < hyp["mosaic"]
|
||||
if mosaic:
|
||||
if mosaic := self.mosaic and random.random() < hyp["mosaic"]:
|
||||
# Load mosaic
|
||||
img, labels = self.load_mosaic(index)
|
||||
shapes = None
|
||||
@@ -1162,8 +1160,7 @@ def verify_image_label(args):
|
||||
segments = [np.array(x[1:], dtype=np.float32).reshape(-1, 2) for x in lb] # (cls, xy1...)
|
||||
lb = np.concatenate((classes.reshape(-1, 1), segments2boxes(segments)), 1) # (cls, xywh)
|
||||
lb = np.array(lb, dtype=np.float32)
|
||||
nl = len(lb)
|
||||
if nl:
|
||||
if nl := len(lb):
|
||||
assert lb.shape[1] == 5, f"labels require 5 columns, {lb.shape[1]} columns detected"
|
||||
assert (lb >= 0).all(), f"negative label values {lb[lb < 0]}"
|
||||
assert (lb[:, 1:] <= 1).all(), f"non-normalized or out of bounds coordinates {lb[:, 1:][lb[:, 1:] > 1]}"
|
||||
|
||||
Reference in new issue
Block a user