Skip to content

Commit

Permalink
change filename scheme of saved images
Browse files Browse the repository at this point in the history
  • Loading branch information
seruva19 committed May 17, 2023
1 parent f739872 commit 468e113
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/utils/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ def save_output(output_dir, task_type, images, seed):
for img in images:
path = f'{output_dir}/{task_type}'
if not os.path.exists(path): os.makedirs(path)

name = f'{path}/{seed}-{uuid.uuid4()}.png'
img.save(name, 'PNG')
output.append(name)

current_datetime = datetime.now()
format_string = "%Y%m%d%H%M%S"
formatted_datetime = current_datetime.strftime(format_string)

# name = f'{path}/{seed}-{uuid.uuid4()}.png'
filename = f'{path}/{formatted_datetime}.png'
while os.path.exists(filename):
unique_id = current_datetime.microsecond
filename = f'{formatted_datetime}_{unique_id}.jpg'

img.save(filename, 'PNG')
output.append(filename)

return output

0 comments on commit 468e113

Please sign in to comment.