Skip to content

Commit cd9dc3a

Browse files
committed
improve the case the remove the broken files
1 parent 8c12c31 commit cd9dc3a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

download_imagenet.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def download_image(download_str, save_dir):
2525
img_size_bytes = os.path.getsize(save_img)
2626
img_size_KB = img_size_bytes / 1024
2727

28-
if width < 500 or height < 500 or img_size_KB < 100:
28+
if width < 500 or height < 500 or img_size_KB < 200:
2929
os.remove(save_img)
3030
print("Remove downloaded images (w:{}, h:{}, s:{}KB)".format(width, height, img_size_KB))
3131
else:
@@ -34,9 +34,11 @@ def download_image(download_str, save_dir):
3434
if not downloaded:
3535
print("Cannot download.")
3636
else:
37-
os.remove(save_img)
3837
print("Remove failed, downloaded images.")
3938

39+
if os.path.isfile(save_img):
40+
os.remove(save_img)
41+
4042

4143
def main():
4244
parser = argparse.ArgumentParser()

0 commit comments

Comments
 (0)