laichaoyi commited on
Commit
5a5897a
·
verified ·
1 Parent(s): 3a7c74e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import pyperclip
2
  import os
 
3
  from PIL import Image
4
  from sd_parsers import ParserManager
5
  import gradio as gr
@@ -198,13 +199,14 @@ def save_metadata_to_file(image_input, prompt, neg_prompt, model, loras, seed, s
198
  f"Other Metadata:\n{metadata}\n"
199
  )
200
 
201
- # Tạo tệp tin tạm thời để người dùng tải xuống
202
- txt_filename = "metadata_info.txt"
203
- with open(txt_filename, "w", encoding="utf-8") as f:
204
- f.write(file_content)
 
 
 
205
 
206
- # Trả về đường dẫn tệp tin để tự động tải xuống
207
- return txt_filename, gr.Info(f"Đang tải file {txt_filename}...", duration=2)
208
 
209
  def check_image_size(image_input):
210
  try:
 
1
  import pyperclip
2
  import os
3
+ import io
4
  from PIL import Image
5
  from sd_parsers import ParserManager
6
  import gradio as gr
 
199
  f"Other Metadata:\n{metadata}\n"
200
  )
201
 
202
+ # Sử dụng io.BytesIO để tạo file tạm thời trong bộ nhớ
203
+ txt_file = io.BytesIO()
204
+ txt_file.write(file_content.encode('utf-8'))
205
+ txt_file.seek(0)
206
+
207
+ # Trả về file để tải xuống
208
+ return txt_file, gr.Info(f"Đang tải file metadata.txt...", duration=2)
209
 
 
 
210
 
211
  def check_image_size(image_input):
212
  try: