Remove usage of pathlib.Path.unlink(missing_ok=...) (#9227)

remove usage of pathlib.Path.unlink(missing_ok=...)

Co-authored-by: Yannick Merkli <ymerkli@latticeflow.ai>
This commit is contained in:
Yannick MerkliandYannick Merkli authored and GitHub committed 2022-08-30 21:57:36 +02:00
1 parent 4a37381ee8
commit 5f1000a499
2 files changed
+15 -7

No files matched your search

+3 -1
View File
@@ -917,7 +917,9 @@ def autosplit(path=DATASETS_DIR / 'coco128/images', weights=(0.9, 0.1, 0.0), ann
indices = random.choices([0, 1, 2], weights=weights, k=n) # assign each image to a split
txt = ['autosplit_train.txt', 'autosplit_val.txt', 'autosplit_test.txt'] # 3 txt files
[(path.parent / x).unlink(missing_ok=True) for x in txt] # remove existing
for x in txt:
if (path.parent / x).exists():
(path.parent / x).unlink() # remove existing
print(f'Autosplitting images from {path}' + ', using *.txt labeled images only' * annotated_only)
for i, img in tqdm(zip(indices, files), total=n):