Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for sdxl_gen_img.py unable to load in Google Colab Env and Distributed Inference Version (accel_sdxl_gen_img.py) #1901

Open
wants to merge 222 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
222 commits
Select commit Hold shift + click to select a range
fd3a14c
Update sdxl_train_util.py
DKnight54 Jan 23, 2025
75a225d
Update sdxl_gen_img.py
DKnight54 Jan 23, 2025
68c65e0
Update sdxl_gen_img.py
DKnight54 Jan 23, 2025
8daa8b3
Update sdxl_train_util.py
DKnight54 Jan 23, 2025
6231883
Update sdxl_gen_img.py
DKnight54 Jan 23, 2025
3ca8dc5
Update sdxl_gen_img.py
DKnight54 Jan 23, 2025
8f85024
Create accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
8b241c4
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
0770c7b
Update sdxl_gen_img.py
DKnight54 Jan 24, 2025
e5cf6b6
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
a15d8f7
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
66d4a62
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
d1e3650
Update sdxl_gen_img.py
DKnight54 Jan 24, 2025
0933ee9
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
f7fde60
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
2c8cf94
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
f1fc65e
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
8a3548a
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
3534842
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
319a25c
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
e9cb466
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
ba91cce
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
7cfae3d
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
0a16ab6
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
1181460
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
9131e2f
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
be36070
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
c0d3abd
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
e45db09
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
a5e3715
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
85ae527
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
cad34c5
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
0c08de4
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
9550106
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
b927a7d
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
77ca871
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
0ed9bbf
Update accel_sdxl_gen_img.py
DKnight54 Jan 24, 2025
ce9dfda
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
c710432
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
6955fb8
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
9027fe9
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
9a89208
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
56e6956
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
bd2dd6b
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
b369058
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
fd5b11c
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
b7781f9
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
04739d7
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
70ffc73
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
86d572c
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
8e56429
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
8340fdc
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
e7f7ade
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
2b5a95e
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
25321e1
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
0670968
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
251e9a7
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
7d04dcb
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
0806954
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
df9936e
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
a832925
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
2328128
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
ebcca55
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
9f47400
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
d310bc9
Update accel_sdxl_gen_img.py
DKnight54 Jan 25, 2025
fecaa7d
Update accel_sdxl_gen_img.py
DKnight54 Jan 26, 2025
ce620f5
Create accel_sdxl_gen_img_v2.py
DKnight54 Jan 26, 2025
dd2a1f2
Update accel_sdxl_gen_img_v2.py
DKnight54 Jan 26, 2025
884ea48
Update accel_sdxl_gen_img_v2.py
DKnight54 Jan 26, 2025
29ac223
Update accel_sdxl_gen_img.py
DKnight54 Jan 26, 2025
13a40bd
Update accel_sdxl_gen_img_v2.py
DKnight54 Jan 26, 2025
c0b771b
Update accel_sdxl_gen_img_v2.py
DKnight54 Jan 26, 2025
dba2f03
Delete accel_sdxl_gen_img.py
DKnight54 Jan 26, 2025
099cea2
Rename accel_sdxl_gen_img_v2.py to accel_sdxl_gen_img.py
DKnight54 Jan 26, 2025
2528300
Update accel_sdxl_gen_img.py
DKnight54 Jan 27, 2025
e96ea1b
Update accel_sdxl_gen_img.py
DKnight54 Jan 27, 2025
4c7a7c8
Setting seeds to random after exhausted
DKnight54 Jan 27, 2025
7dfc5c9
Update gen_img.py
DKnight54 Jan 27, 2025
b1ca9d9
Update accel_sdxl_gen_img.py
DKnight54 Jan 27, 2025
78a64b0
Update accel_sdxl_gen_img.py
DKnight54 Jan 27, 2025
8d8e7e4
Update accel_sdxl_gen_img.py
DKnight54 Jan 27, 2025
009d07a
Update accel_sdxl_gen_img.py
DKnight54 Jan 27, 2025
54ca042
Update accel_sdxl_gen_img.py
DKnight54 Jan 27, 2025
41b181c
Update accel_sdxl_gen_img.py
DKnight54 Jan 27, 2025
c7caa88
Update accel_sdxl_gen_img.py
DKnight54 Jan 27, 2025
b1b1c19
Update accel_sdxl_gen_img.py
DKnight54 Jan 28, 2025
39a3751
adding example generation
DKnight54 Jan 29, 2025
158af8d
Update train_util.py
DKnight54 Jan 29, 2025
96ab0cc
Modify list of seed for dynamic prompt and add checks for filename to…
DKnight54 Jan 29, 2025
f95952c
Merge pull request #5 from DKnight54/fix_stuck_seed
DKnight54 Jan 29, 2025
9ae34ac
Update gen_img.py
DKnight54 Jan 29, 2025
0bb8a2c
Test logging fix
DKnight54 Jan 29, 2025
99bc4b6
Update train_util.py
DKnight54 Jan 29, 2025
0d26359
Update gen_img.py
DKnight54 Jan 29, 2025
a602fde
Update utils.py
DKnight54 Jan 29, 2025
1a1496c
Update gen_img.py
DKnight54 Jan 29, 2025
8db164b
Update gen_img.py
DKnight54 Jan 29, 2025
ec6ca91
Update gen_img.py
DKnight54 Jan 29, 2025
06f1180
Update gen_img.py
DKnight54 Jan 29, 2025
fa444fa
Update gen_img.py
DKnight54 Jan 29, 2025
6a65396
Update gen_img.py
DKnight54 Jan 29, 2025
c70ce28
Update gen_img.py
DKnight54 Jan 30, 2025
3decab5
Update train_util.py
DKnight54 Jan 30, 2025
198aea9
Update train_util.py
DKnight54 Jan 30, 2025
c86739b
Update train_util.py
DKnight54 Jan 30, 2025
dee3c48
Update train_util.py
DKnight54 Jan 30, 2025
7e8daad
Update train_util.py
DKnight54 Jan 30, 2025
a049c85
Update train_util.py
DKnight54 Jan 30, 2025
12dd9f6
Update train_util.py
DKnight54 Jan 30, 2025
5559d1b
Update train_network.py
DKnight54 Jan 30, 2025
a130bb4
Update train_util.py
DKnight54 Jan 30, 2025
f73db40
Update train_network.py
DKnight54 Jan 30, 2025
7f0ae28
Update train_util.py
DKnight54 Jan 30, 2025
307099c
Update train_util.py
DKnight54 Jan 30, 2025
a8ea5a6
Update train_util.py
DKnight54 Jan 30, 2025
793616f
Update train_util.py
DKnight54 Jan 31, 2025
e723e45
Update train_util.py
DKnight54 Jan 31, 2025
6de0051
Update train_network.py
DKnight54 Jan 31, 2025
a979ea5
Update accel_sdxl_gen_img.py
DKnight54 Jan 31, 2025
3bb1d9d
Update train_util.py
DKnight54 Jan 31, 2025
2165967
Update train_util.py
DKnight54 Jan 31, 2025
2cdaa33
Update train_network.py
DKnight54 Jan 31, 2025
d179a48
Update accel_sdxl_gen_img.py
DKnight54 Jan 31, 2025
00234a0
Update train_util.py
DKnight54 Jan 31, 2025
f7a77b6
Update train_util.py
DKnight54 Jan 31, 2025
938ff56
Update accel_sdxl_gen_img.py
DKnight54 Jan 31, 2025
ba8dd4d
Update train_util.py
DKnight54 Jan 31, 2025
c14aa5b
Update accel_sdxl_gen_img.py
DKnight54 Jan 31, 2025
13f764d
Update train_network.py
DKnight54 Jan 31, 2025
b524520
Update accel_sdxl_gen_img.py
DKnight54 Jan 31, 2025
56f0805
Update accel_sdxl_gen_img.py
DKnight54 Jan 31, 2025
5308a0b
Update train_util.py
DKnight54 Jan 31, 2025
086e90d
Update accel_sdxl_gen_img.py
DKnight54 Jan 31, 2025
e10eabf
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
eb7c0b5
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
e607dc4
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
aafcac6
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
b6ba987
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
5305038
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
91986ec
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
3733126
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
0e334ae
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
efb3722
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
03232a6
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
ff77d3a
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
cba5437
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
11404c1
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
107625b
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
6350816
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
eaf4a9a
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
cc6266d
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
4ff521e
Update train_util.py
DKnight54 Feb 1, 2025
75859a6
Update train_util.py
DKnight54 Feb 1, 2025
8967e2f
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
01430d0
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
4594ef9
Update accel_sdxl_gen_img.py
DKnight54 Feb 1, 2025
6eabaf3
Update train_util.py
DKnight54 Feb 1, 2025
6fc3847
Update train_network.py
DKnight54 Feb 1, 2025
896ade6
Update train_network.py
DKnight54 Feb 1, 2025
aea7cad
Update train_network.py
DKnight54 Feb 1, 2025
83a171d
Update train_network.py
DKnight54 Feb 1, 2025
06681ce
Update train_util.py
DKnight54 Feb 1, 2025
55179ad
Update accel_sdxl_gen_img.py
DKnight54 Feb 2, 2025
df365c5
Update train_util.py
DKnight54 Feb 2, 2025
b3b8563
Update train_network.py
DKnight54 Feb 2, 2025
639a60d
Update train_network.py
DKnight54 Feb 2, 2025
9d5c051
Update train_util.py
DKnight54 Feb 2, 2025
07a2e35
Update accel_sdxl_gen_img.py
DKnight54 Feb 2, 2025
e250e7a
Update train_network.py
DKnight54 Feb 2, 2025
4c5ec69
Update train_network.py
DKnight54 Feb 2, 2025
e6433ec
Update train_network.py
DKnight54 Feb 3, 2025
6cd468a
Update train_util.py
DKnight54 Feb 3, 2025
e8faf4f
Update accel_sdxl_gen_img.py
DKnight54 Feb 3, 2025
debf4af
Update accel_sdxl_gen_img.py
DKnight54 Feb 3, 2025
f36b545
Update train_network.py
DKnight54 Feb 6, 2025
c1e387f
Update train_network.py
DKnight54 Feb 6, 2025
8d14893
Update train_network.py
DKnight54 Feb 6, 2025
984441c
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
94c5704
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
a53aa0a
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
0361121
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
b566340
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
c126db9
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
6e30e57
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
68a039f
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
79962b8
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
1738b7f
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
0105b92
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
f06d23c
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
c0c17a1
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
fcb046b
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
3be7042
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
8af7ab1
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
19e6bf0
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
c4dd712
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
4a744c3
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
0ee1083
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
7aa3337
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
22ed684
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
375971d
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
36617e9
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
5a01f06
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
95dd367
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
de8620f
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
d865824
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
13150c7
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
213faba
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
dfdfb6d
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
8cc503f
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
a5b8c0b
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
84934b3
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
a215e3f
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
ebbe949
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
58d6434
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
0a74083
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
c6e6643
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
d69619c
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
b640c39
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
70fd06d
Update accel_sdxl_gen_img.py
DKnight54 Feb 8, 2025
586e89a
Update accel_sdxl_gen_img.py
DKnight54 Feb 10, 2025
b8d3c68
Update accel_sdxl_gen_img.py
DKnight54 Feb 12, 2025
9b9d205
Update accel_sdxl_gen_img.py
DKnight54 Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,363 changes: 3,363 additions & 0 deletions accel_sdxl_gen_img.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions fine_tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,14 @@ def fn_recursive_set_mem_eff(module: torch.nn.Module):
optimizer.step()
lr_scheduler.step()
optimizer.zero_grad(set_to_none=True)

example_tuple = (latents, batch["captions"])
# Checks if the accelerator has performed an optimization step behind the scenes
if accelerator.sync_gradients:
progress_bar.update(1)
global_step += 1

train_util.sample_images(
accelerator, args, None, global_step, accelerator.device, vae, tokenizer, text_encoder, unet
accelerator, args, None, global_step, accelerator.device, vae, tokenizer, text_encoder, unet, example_tuple
)

# 指定ステップごとにモデルを保存
Expand Down Expand Up @@ -474,7 +474,7 @@ def fn_recursive_set_mem_eff(module: torch.nn.Module):
vae,
)

train_util.sample_images(accelerator, args, epoch + 1, global_step, accelerator.device, vae, tokenizer, text_encoder, unet)
train_util.sample_images(accelerator, args, epoch + 1, global_step, accelerator.device, vae, tokenizer, text_encoder, unet, example_tuple)

is_main_process = accelerator.is_main_process
if is_main_process:
Expand Down
73 changes: 64 additions & 9 deletions gen_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,13 +1485,16 @@ def __call__(self, *args, **kwargs):


def main(args):

if args.fp16:
dtype = torch.float16
elif args.bf16:
dtype = torch.bfloat16
else:
dtype = torch.float32

device = get_preferred_device()

highres_fix = args.highres_fix_scale is not None
# assert not highres_fix or args.image_path is None, f"highres_fix doesn't work with img2img / highres_fixはimg2imgと同時に使えません"

Expand Down Expand Up @@ -1521,9 +1524,10 @@ def main(args):
if is_sdxl:
if args.clip_skip is None:
args.clip_skip = 2


model_dtype = sdxl_train_util.match_mixed_precision(args, dtype)
(_, text_encoder1, text_encoder2, vae, unet, _, _) = sdxl_train_util._load_target_model(
args.ckpt, args.vae, sdxl_model_util.MODEL_VERSION_SDXL_BASE_V1_0, dtype
args.ckpt, args.vae, sdxl_model_util.MODEL_VERSION_SDXL_BASE_V1_0, dtype, device, model_dtype
)
unet: InferSdxlUNet2DConditionModel = InferSdxlUNet2DConditionModel(unet)
text_encoders = [text_encoder1, text_encoder2]
Expand Down Expand Up @@ -1748,7 +1752,7 @@ def __getattr__(self, item):
logger.info(f"network_merge: {network_merge}")

for i, network_module in enumerate(args.network_module):
logger.info("import network module: {network_module}")
logger.info(f"import network module: {network_module}")
imported_module = importlib.import_module(network_module)

network_mul = 1.0 if args.network_mul is None or len(args.network_mul) <= i else args.network_mul[i]
Expand Down Expand Up @@ -2508,7 +2512,7 @@ def scale_and_round(x):
metadata.add_text("crop-left", str(crop_left))

if filename is not None:
fln = filename
fln = first_available_filename(args.outdir, filename) #Checks to make sure is not existing file, else returns first available sequential filename
else:
if args.use_original_file_name and init_images is not None:
if type(init_images) is list:
Expand Down Expand Up @@ -2586,7 +2590,8 @@ def scale_and_round(x):
negative_scale = args.negative_scale
steps = args.steps
seed = None
seeds = None
if pi == 0:
seeds = None
strength = 0.8 if args.strength is None else args.strength
negative_prompt = ""
clip_prompt = None
Expand Down Expand Up @@ -2670,7 +2675,11 @@ def scale_and_round(x):

m = re.match(r"d ([\d,]+)", parg, re.IGNORECASE)
if m: # seed
seeds = [int(d) for d in m.group(1).split(",")]
if pi > 0 and len(raw_prompts) > 1: #Bypass od 2nd loop for dynamic prompts
continue
logger.info(f"{m}")
seeds = m.group(1).split(",")
seeds = [int(d.strip()) for d in seeds]
logger.info(f"seeds: {seeds}")
continue

Expand Down Expand Up @@ -2795,14 +2804,19 @@ def scale_and_round(x):
m = re.match(r"f (.+)", parg, re.IGNORECASE)
if m: # filename
filename = m.group(1)
logger.info(f"filename: {filename}")
continue

except ValueError as ex:
logger.error(f"Exception in parsing / 解析エラー: {parg}")
logger.error(f"{ex}")

# override Deep Shrink
# override filename to add index number if more than one image per prompt
if filename is not None and (args.images_per_prompt > 1 or len(raw_prompts) > 1):
fileext = os.path.splitext(filename)
filename = fileext[0] + "_%s" % pi + fileext[1]
logger.info(f"filename: {filename}")

# override Deep Shrink
if ds_depth_1 is not None:
if ds_depth_1 < 0:
ds_depth_1 = args.ds_depth_1 or 3
Expand Down Expand Up @@ -2835,8 +2849,16 @@ def scale_and_round(x):
# prepare seed
if seeds is not None: # given in prompt
# num_images_per_promptが多い場合は足りなくなるので、足りない分は前のを使う
if len(seeds) > 0:
# Previous implementation may result in unexpected behaviour when number of seeds is lesss than number of repeats. Last seed is taken for rest of repeated prompts. Add condition if last element is -1, to start randomizing seed.
if len(seeds) > 1:
seed = seeds.pop(0)
elif len(seeds) == 1:
if seeds[0] == -1:
seeds = None
else:
seed = seeds.pop(0)


else:
if args.iter_same_seed:
seed = iter_seed
Expand All @@ -2847,6 +2869,7 @@ def scale_and_round(x):
seed = seed_random.randint(0, 2**32 - 1)
if args.interactive:
logger.info(f"seed: {seed}")
# logger.info(f"seed: {seed}") #debugging logger. Uncomment to verify if expected seed is added correctly.

# prepare init image, guide image and mask
init_image = mask_image = guide_image = None
Expand Down Expand Up @@ -2935,7 +2958,35 @@ def scale_and_round(x):

logger.info("done!")

def first_available_filename(path, filename):
"""
Checks if filename is in use.
if filename is in use, appends a running number
e.g. filename = 'file.png':

file.png
file_1.png
file_2.png

Runs in log(n) time where n is the number of existing files in sequence
"""
i = 1
if not os.path.exists(os.path.join(path, filename)):
return filename
fileext = os.path.splitext(filename)
filename = fileext[0] + "_%s" + fileext[1]
# First do an exponential search
while os.path.exists(os.path.join(path,filename % i)):
i = i * 2

# Result lies somewhere in the interval (i/2..i]
# We call this interval (a..b] and narrow it down until a + 1 = b
a, b = (i // 2, i)
while a + 1 < b:
c = (a + b) // 2 # interval midpoint
a, b = (c, b) if os.path.exists(os.path.join(path,filename % c)) else (a, c)

return filename % b
def setup_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser()

Expand Down Expand Up @@ -3343,6 +3394,10 @@ def setup_parser() -> argparse.ArgumentParser:
help="unsharp mask parameters for Gradual Latent: ksize, sigma, strength, target-x (1 means True). `3,0.5,0.5,1` or `3,1.0,1.0,0` is recommended /"
+ " Gradual Latentのunsharp maskのパラメータ: ksize, sigma, strength, target-x. `3,0.5,0.5,1` または `3,1.0,1.0,0` が推奨",
)
parser.add_argument("--full_fp16", action="store_true", help="Loading model in fp16")
parser.add_argument(
"--full_bf16", action="store_true", help="Loading model in bf16"
)

# # parser.add_argument(
# "--control_net_image_path", type=str, default=None, nargs="*", help="image for ControlNet guidance / ControlNetでガイドに使う画像"
Expand Down
Loading