TzuShianYang commited on
Commit
a31010b
·
1 Parent(s): d9e620f

Fix image file name with datetime

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -13,14 +13,15 @@ def add_image(camera, gallery):
13
 
14
 
15
  def zip_gallery(gallery):
16
- new_zip_name = f'{datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")}.zip'
 
17
  count = 0
18
  if not gallery:
19
  return gr.DownloadButton("Download", visible=False)
20
  zf = zipfile.ZipFile(new_zip_name, mode="w")
21
  try:
22
  for path, _ in gallery:
23
- zf.write(path, f'image_{count}.png',
24
  compress_type=zipfile.ZIP_DEFLATED)
25
  count = count + 1
26
  except FileNotFoundError:
 
13
 
14
 
15
  def zip_gallery(gallery):
16
+ current_time = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
17
+ new_zip_name = f'{current_time}.zip'
18
  count = 0
19
  if not gallery:
20
  return gr.DownloadButton("Download", visible=False)
21
  zf = zipfile.ZipFile(new_zip_name, mode="w")
22
  try:
23
  for path, _ in gallery:
24
+ zf.write(path, f'{current_time}_{count}.png',
25
  compress_type=zipfile.ZIP_DEFLATED)
26
  count = count + 1
27
  except FileNotFoundError: