Fabrice-TIERCELIN commited on
Commit
5b56c89
·
verified ·
1 Parent(s): 4168328

zf.write(image_path, arcname=os.path.basename(image_path))

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -225,7 +225,7 @@ def export_images_to_zip(gallery) -> str:
225
  with zipfile.ZipFile(tmp_zip.name, "w", compression=zipfile.ZIP_DEFLATED) as zf:
226
  for i in range(len(gallery)):
227
  image_path = gallery[i]
228
- zf.write(image_path, arcname=str(i) + "_" + os.path.basename(image_path))
229
 
230
  print(str(len(gallery)) + " images zipped")
231
  return tmp_zip.name
@@ -265,7 +265,7 @@ def infer_example(prompt, input_images=None, mode_choice="Base (50 steps)", seed
265
  except:
266
  print("Error")
267
  zip_path = export_images_to_zip(gallery)
268
- return [seed, zip_path]
269
 
270
 
271
  examples = [
@@ -424,7 +424,7 @@ FLUX.2 [klein] is a fast, unified image generation and editing model designed fo
424
 
425
  with gr.Row(visible=False):
426
  download_button = gr.DownloadButton(elem_id="download_btn", interactive = True)
427
- result_gallery = gr.Gallery(interactive = False, elem_id = "gallery1")
428
  prompt_debug = gr.Text(
429
  max_lines=2,
430
  container=False,
@@ -442,7 +442,7 @@ FLUX.2 [klein] is a fast, unified image generation and editing model designed fo
442
  ],
443
  fn=infer_example,
444
  inputs=[prompt, input_image],
445
- outputs=[seed, download_button],
446
  run_on_click=True,
447
  cache_examples=True,
448
  cache_mode='lazy'
 
225
  with zipfile.ZipFile(tmp_zip.name, "w", compression=zipfile.ZIP_DEFLATED) as zf:
226
  for i in range(len(gallery)):
227
  image_path = gallery[i]
228
+ zf.write(image_path, arcname=os.path.basename(image_path))
229
 
230
  print(str(len(gallery)) + " images zipped")
231
  return tmp_zip.name
 
265
  except:
266
  print("Error")
267
  zip_path = export_images_to_zip(gallery)
268
+ return [seed, zip_path, "Done!"]
269
 
270
 
271
  examples = [
 
424
 
425
  with gr.Row(visible=False):
426
  download_button = gr.DownloadButton(elem_id="download_btn", interactive = True)
427
+ info_debug = gr.HTML(value = "")
428
  prompt_debug = gr.Text(
429
  max_lines=2,
430
  container=False,
 
442
  ],
443
  fn=infer_example,
444
  inputs=[prompt, input_image],
445
+ outputs=[seed, download_button, info_debug],
446
  run_on_click=True,
447
  cache_examples=True,
448
  cache_mode='lazy'