Update app.py
Browse files
app.py
CHANGED
@@ -261,7 +261,7 @@ def generate_image(
|
|
261 |
use_words = []
|
262 |
cur_run_time = time.strftime("%m%d-%H%M%S")
|
263 |
tmp_dir_root = f"tmp/gradio_demo/{run_name}"
|
264 |
-
temp_dir = f"{tmp_dir_root}/{cur_run_time}_{generate_random_string(4)}"
|
265 |
os.makedirs(temp_dir, exist_ok=True)
|
266 |
print(f"Temporary directory created: {temp_dir}")
|
267 |
for i, (image_path, caption) in enumerate(zip(images, captions)):
|
@@ -275,7 +275,7 @@ def generate_image(
|
|
275 |
prompt = prompt.replace(f"ENT{i+1}", caption)
|
276 |
|
277 |
image = resize_keep_aspect_ratio(Image.open(image_path), 768)
|
278 |
-
save_path = f"{temp_dir}/
|
279 |
image.save(save_path)
|
280 |
|
281 |
input_image_path = save_path
|
@@ -313,7 +313,7 @@ def generate_image(
|
|
313 |
),
|
314 |
]
|
315 |
|
316 |
-
json_dump(test_sample, f"{temp_dir}/
|
317 |
assert single_attention == True
|
318 |
target_size = int(round((target_width * target_height) ** 0.5) // 16 * 16)
|
319 |
print(test_sample)
|
|
|
261 |
use_words = []
|
262 |
cur_run_time = time.strftime("%m%d-%H%M%S")
|
263 |
tmp_dir_root = f"tmp/gradio_demo/{run_name}"
|
264 |
+
temp_dir = f"{tmp_dir_root}/{session_id}/{cur_run_time}_{generate_random_string(4)}"
|
265 |
os.makedirs(temp_dir, exist_ok=True)
|
266 |
print(f"Temporary directory created: {temp_dir}")
|
267 |
for i, (image_path, caption) in enumerate(zip(images, captions)):
|
|
|
275 |
prompt = prompt.replace(f"ENT{i+1}", caption)
|
276 |
|
277 |
image = resize_keep_aspect_ratio(Image.open(image_path), 768)
|
278 |
+
save_path = f"{temp_dir}/tmp_resized_input_{i}.png"
|
279 |
image.save(save_path)
|
280 |
|
281 |
input_image_path = save_path
|
|
|
313 |
),
|
314 |
]
|
315 |
|
316 |
+
json_dump(test_sample, f"{temp_dir}/test_sample.json", 'utf-8')
|
317 |
assert single_attention == True
|
318 |
target_size = int(round((target_width * target_height) ** 0.5) // 16 * 16)
|
319 |
print(test_sample)
|