Context manager open(file) as f fixes (#7289)

* Flask context manager `open()` fix

* Additional read context manager fixes
This commit is contained in:
Glenn Jocher authored and GitHub committed 2022-04-05 12:54:25 +02:00
1 parent 2181ef371e
commit 5f97001ed4
5 files changed
+17 -6

No files matched your search

+2 -1
View File
@@ -72,7 +72,8 @@ download: |
imgs_path.mkdir(exist_ok=True, parents=True)
lbs_path.mkdir(exist_ok=True, parents=True)
image_ids = open(path / f'VOC{year}/ImageSets/Main/{image_set}.txt').read().strip().split()
with open(path / f'VOC{year}/ImageSets/Main/{image_set}.txt') as f:
image_ids = f.read().strip().split()
for id in tqdm(image_ids, desc=f'{image_set}{year}'):
f = path / f'VOC{year}/JPEGImages/{id}.jpg' # old img path
lb_path = (lbs_path / f.name).with_suffix('.txt') # new label path