Update app.py
Browse files
app.py
CHANGED
@@ -23,9 +23,7 @@ import string
|
|
23 |
import random, time, math
|
24 |
import os
|
25 |
|
26 |
-
|
27 |
-
os.environ["NCCL_P2P_DISABLE"]="1"
|
28 |
-
os.environ["NCCL_IB_DISABLE"]="1"
|
29 |
|
30 |
import src.flux.generate
|
31 |
from src.flux.generate import generate_from_test_sample, seed_everything
|
@@ -118,7 +116,6 @@ model.config = config
|
|
118 |
|
119 |
run_mode = "mod_only"
|
120 |
store_attn_map = False
|
121 |
-
run_name = time.strftime("%m%d-%H%M")
|
122 |
|
123 |
num_inputs = 2
|
124 |
|
@@ -257,10 +254,10 @@ def generate_image(
|
|
257 |
|
258 |
src_inputs = []
|
259 |
use_words = []
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
print(f"Temporary directory created: {temp_dir}")
|
265 |
for i, (image_path, caption) in enumerate(zip(images, captions)):
|
266 |
if image_path:
|
@@ -273,7 +270,7 @@ def generate_image(
|
|
273 |
prompt = prompt.replace(f"ENT{i+1}", caption)
|
274 |
|
275 |
image = resize_keep_aspect_ratio(Image.open(image_path), 768)
|
276 |
-
save_path = f"{temp_dir}/
|
277 |
image.save(save_path)
|
278 |
|
279 |
input_image_path = save_path
|
@@ -311,7 +308,7 @@ def generate_image(
|
|
311 |
),
|
312 |
]
|
313 |
|
314 |
-
json_dump(test_sample, f"{temp_dir}/
|
315 |
assert single_attention == True
|
316 |
target_size = int(round((target_width * target_height) ** 0.5) // 16 * 16)
|
317 |
print(test_sample)
|
@@ -453,10 +450,8 @@ def cleanup(request: gr.Request):
|
|
453 |
"""
|
454 |
sid = request.session_hash
|
455 |
if sid:
|
456 |
-
d1 = os.path.join(os.environ["
|
457 |
-
d2 = os.path.join(os.environ["PIXEL3DMM_TRACKING_OUTPUT"], sid)
|
458 |
shutil.rmtree(d1, ignore_errors=True)
|
459 |
-
shutil.rmtree(d2, ignore_errors=True)
|
460 |
|
461 |
|
462 |
css = """
|
@@ -590,9 +585,9 @@ if __name__ == "__main__":
|
|
590 |
db_latent_lora_scale_str, sb_latent_lora_scale_str, vae_lora_scale_str,
|
591 |
indices_state,
|
592 |
session_state,
|
593 |
-
*images,
|
594 |
-
*captions,
|
595 |
-
*idip_checkboxes,
|
596 |
],
|
597 |
outputs=output
|
598 |
)
|
|
|
23 |
import random, time, math
|
24 |
import os
|
25 |
|
26 |
+
os.environ["XVERSE_OUTPUT_DATA"] = f"{os.getcwd()}/output_results"
|
|
|
|
|
27 |
|
28 |
import src.flux.generate
|
29 |
from src.flux.generate import generate_from_test_sample, seed_everything
|
|
|
116 |
|
117 |
run_mode = "mod_only"
|
118 |
store_attn_map = False
|
|
|
119 |
|
120 |
num_inputs = 2
|
121 |
|
|
|
254 |
|
255 |
src_inputs = []
|
256 |
use_words = []
|
257 |
+
|
258 |
+
temp_dir = os.path.join(os.environ["XVERSE_OUTPUT_DATA"], session_id)
|
259 |
+
os.makedirs(base_dir, exist_ok=True)
|
260 |
+
|
261 |
print(f"Temporary directory created: {temp_dir}")
|
262 |
for i, (image_path, caption) in enumerate(zip(images, captions)):
|
263 |
if image_path:
|
|
|
270 |
prompt = prompt.replace(f"ENT{i+1}", caption)
|
271 |
|
272 |
image = resize_keep_aspect_ratio(Image.open(image_path), 768)
|
273 |
+
save_path = f"{temp_dir}/tmp_resized_input_{i}.png"
|
274 |
image.save(save_path)
|
275 |
|
276 |
input_image_path = save_path
|
|
|
308 |
),
|
309 |
]
|
310 |
|
311 |
+
json_dump(test_sample, f"{temp_dir}/test_sample.json", 'utf-8')
|
312 |
assert single_attention == True
|
313 |
target_size = int(round((target_width * target_height) ** 0.5) // 16 * 16)
|
314 |
print(test_sample)
|
|
|
450 |
"""
|
451 |
sid = request.session_hash
|
452 |
if sid:
|
453 |
+
d1 = os.path.join(os.environ["XVERSE_OUTPUT_DATA"], sid)
|
|
|
454 |
shutil.rmtree(d1, ignore_errors=True)
|
|
|
455 |
|
456 |
|
457 |
css = """
|
|
|
585 |
db_latent_lora_scale_str, sb_latent_lora_scale_str, vae_lora_scale_str,
|
586 |
indices_state,
|
587 |
session_state,
|
588 |
+
[*images],
|
589 |
+
[*captions],
|
590 |
+
[*idip_checkboxes],
|
591 |
],
|
592 |
outputs=output
|
593 |
)
|