Skip to content

Commit

Permalink
Ignore non-files in the input directory
Browse files Browse the repository at this point in the history
  • Loading branch information
samiraguiar committed Oct 19, 2020
1 parent 43e5cb7 commit 9686071
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Global/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ def main(config):
print("processing", image_name)

results = []
scratch_image = Image.open(os.path.join(config.test_path, image_name)).convert("RGB")
scratch_file = os.path.join(config.test_path, image_name)
if not os.path.isfile(scratch_file):
print("Skipping non-file %s" % image_name)
continue
scratch_image = Image.open(scratch_file).convert("RGB")

w, h = scratch_image.size

Expand Down
8 changes: 6 additions & 2 deletions Global/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def parameter_set(opt):
dataset_size = 0

input_loader = os.listdir(opt.test_input)
dataset_size = len(os.listdir(opt.test_input))
dataset_size = len(input_loader)
input_loader.sort()

if opt.test_mask != "":
Expand All @@ -124,7 +124,11 @@ def parameter_set(opt):
for i in range(dataset_size):

input_name = input_loader[i]
input = Image.open(os.path.join(opt.test_input, input_name)).convert("RGB")
input_file = os.path.join(opt.test_input, input_name)
if not os.path.isfile(input_file):
print("Skipping non-file %s" % input_name)
continue
input = Image.open(input_file).convert("RGB")

print("Now you are processing %s" % (input_name))

Expand Down

0 comments on commit 9686071

Please sign in to comment.