Unverified 提交 1e8ab3f5 authored 作者: zzttqu's avatar zzttqu 提交者: GitHub

Add tqdm pbar.close() (#2644)

When using tqdm, sometimes it can't print in one line and roll to next line.
上级 2bf34f50
...@@ -443,6 +443,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing ...@@ -443,6 +443,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
self.imgs[i], self.img_hw0[i], self.img_hw[i] = x # img, hw_original, hw_resized = load_image(self, i) self.imgs[i], self.img_hw0[i], self.img_hw[i] = x # img, hw_original, hw_resized = load_image(self, i)
gb += self.imgs[i].nbytes gb += self.imgs[i].nbytes
pbar.desc = f'{prefix}Caching images ({gb / 1E9:.1f}GB)' pbar.desc = f'{prefix}Caching images ({gb / 1E9:.1f}GB)'
pbar.close()
def cache_labels(self, path=Path('./labels.cache'), prefix=''): def cache_labels(self, path=Path('./labels.cache'), prefix=''):
# Cache dataset labels, check images and read shapes # Cache dataset labels, check images and read shapes
...@@ -487,6 +488,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing ...@@ -487,6 +488,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
pbar.desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels... " \ pbar.desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels... " \
f"{nf} found, {nm} missing, {ne} empty, {nc} corrupted" f"{nf} found, {nm} missing, {ne} empty, {nc} corrupted"
pbar.close()
if nf == 0: if nf == 0:
print(f'{prefix}WARNING: No labels found in {path}. See {help_url}') print(f'{prefix}WARNING: No labels found in {path}. See {help_url}')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论