baqu2213 commited on
Commit
2a2e250
โ€ข
1 Parent(s): 08f125d

Upload 2 files

Browse files
Danbooru Prompt Selector/TEST2024/NAIA_0218_testv2.exe CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:bd60c7b1645e5c0a1c660bc91b68ad8ee97cb236b19bdccb2c15f7efbbae50e0
3
- size 888968069
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63425e67d5034488b7d3ec8105fe6a17be1afb7e4c37a2707bc86be72b8033f0
3
+ size 888968406
Danbooru Prompt Selector/TEST2024/NAIA_0218_testv2.py CHANGED
@@ -2275,6 +2275,56 @@ class App(customtkinter.CTk, TkinterDnD.DnDWrapper):
2275
  request_list = []
2276
  for i in range(self.image_generation_repeat):
2277
  if i != 0:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2278
  cvalue = random.randint(0,9999999999)
2279
  gen_request["seed"] = cvalue
2280
  pre_prompt = gen_request["prompt"]
@@ -2467,8 +2517,56 @@ class App(customtkinter.CTk, TkinterDnD.DnDWrapper):
2467
  request_list = []
2468
  for i in range(self.image_generation_repeat):
2469
  if i != 0:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2470
  cvalue = random.randint(0,9999999999)
2471
  gen_request["seed"] = cvalue
 
2472
  try:
2473
  treq_0, treq_1, treq_2, treq_3 = NAIA_generation.make_turbo_prompt(gen_request)
2474
  request_list.append(gen_request.copy())
@@ -2641,6 +2739,7 @@ class App(customtkinter.CTk, TkinterDnD.DnDWrapper):
2641
 
2642
  def turbo_process_request():
2643
  turbo_count = 0
 
2644
  while(request_list):
2645
  gen_request = request_list.pop(0) #length=5
2646
  generation_thread = threading.Thread(target=run_generation_turbo, args=(gen_request,), daemon=True)
@@ -2650,6 +2749,11 @@ class App(customtkinter.CTk, TkinterDnD.DnDWrapper):
2650
  if app.turbo_button.get() == 0:
2651
  app.state_label.configure(text =f"state : ์‚ฌ์šฉ์ž์— ์˜ํ•œ ํ„ฐ๋ณด์š”์ฒญ ์ค‘๋‹จ ({turbo_count})", text_color = "#FFFF97")
2652
  break
 
 
 
 
 
2653
  if self.automation_button.get() == 1:
2654
  if self.toggle_prompt_fix_button.get() == 0:
2655
  random_function()
@@ -4822,13 +4926,13 @@ class App(customtkinter.CTk, TkinterDnD.DnDWrapper):
4822
  import_frame2 = customtkinter.CTkFrame(import_window_right, width=586, fg_color="#2B2B2B")
4823
  import_frame2.grid(row=5, column=0, pady=5, padx=5, sticky="nsew")
4824
 
4825
- i_seed_label = customtkinter.CTkLabel(import_frame2, font=my_font, text="seed : ")
4826
  i_seed_label.grid(row=0, column=0, padx=5, sticky="nsew")
4827
  i_seed = customtkinter.CTkEntry(import_frame2, font=my_font, width=100)
4828
  i_seed.grid(row=0, column=1, padx=5, sticky="nsew")
4829
  i_seed.insert(0, str(contents['seed']))
4830
 
4831
- i_sampler_label = customtkinter.CTkLabel(import_frame2, font=my_font, text="sampler : ")
4832
  i_sampler_label.grid(row=0, column=2, padx=5, sticky="nsew")
4833
  i_sampler = customtkinter.CTkEntry(import_frame2, font=my_font, width=100)
4834
  i_sampler.grid(row=0, column=3, padx=5, sticky="nsew")
 
2275
  request_list = []
2276
  for i in range(self.image_generation_repeat):
2277
  if i != 0:
2278
+ if self.hold_wildcard == False:
2279
+ before_wildcard_turbo = self.text_input.get("0.0", "end-1c")
2280
+ before_wildcard = [item.strip() for item in before_wildcard_turbo.split(',')]
2281
+ if '<' in before_wildcard_turbo:
2282
+ wildcard_present = True
2283
+ itc = 0
2284
+ while (wildcard_present and itc < 10):
2285
+ wildcard_present = False
2286
+ #### ๋‹จ๊ณ„ 1 : ์ธ์Šคํ„ดํŠธ ์™€์ผ๋“œ์นด๋“œ ์ฒ˜๋ฆฌ ###
2287
+ for i, keyword in enumerate(before_wildcard):
2288
+ if keyword.startswith('<') and keyword.endswith('>'):
2289
+ wildcard_present = True
2290
+ vbar_check = keyword[1:-1]
2291
+ if '|' in vbar_check:
2292
+ choices = vbar_check.split('|') # '|'๋ฅผ ๊ธฐ์ค€์œผ๋กœ split
2293
+ choice_dic = {}
2294
+ for choice in choices:
2295
+ match = re.match(r'(\d*\.?\d+):(.+)', choice)
2296
+ if match:
2297
+ value, keyword = float(match.group(1)), match.group(2).strip()
2298
+ else:
2299
+ value, keyword = 1, choice.strip()
2300
+ choice_dic[keyword] = value
2301
+ keywords = list(choice_dic.keys())
2302
+ weights = list(choice_dic.values())
2303
+ selected_instant_wildcard = random.choices(keywords, weights=weights, k=1)[0]
2304
+ before_wildcard[i] = selected_instant_wildcard
2305
+ #### ๋‹จ๊ณ„ 2 : ๊ธ€๋กœ๋ฒŒ ์™€์ผ๋“œ์นด๋“œ ์ฒ˜๋ฆฌ ###
2306
+ for i, keyword in enumerate(before_wildcard):
2307
+ if "<" in keyword and ">" in keyword:
2308
+ wildcard_present = True
2309
+ input_str = keyword.strip('<>').strip()
2310
+ if("__" in input_str):
2311
+ adjectives = re.findall(r'__(.*?)__', input_str)
2312
+ last_keyword = re.split(r'__.*?__', input_str)[-1]
2313
+ adjective_string = ""
2314
+ for adjective in adjectives:
2315
+ adjective_string += (self.get_wildcard(adjective) + " ")
2316
+ before_wildcard[i] = adjective_string + self.get_wildcard(last_keyword)
2317
+ else:
2318
+ before_wildcard[i] = self.get_wildcard(input_str)
2319
+ itc += 1
2320
+ if not wildcard_present:
2321
+ break
2322
+ else:
2323
+ after_wildcard = self.text_input.get("0.0", "end-1c")
2324
+ after_wildcard = ', '.join(before_wildcard)
2325
+ cvalue = random.randint(0,9999999999)
2326
+ gen_request["seed"] = cvalue
2327
+ gen_request["prompt"] = after_wildcard
2328
  cvalue = random.randint(0,9999999999)
2329
  gen_request["seed"] = cvalue
2330
  pre_prompt = gen_request["prompt"]
 
2517
  request_list = []
2518
  for i in range(self.image_generation_repeat):
2519
  if i != 0:
2520
+ if self.hold_wildcard == False:
2521
+ before_wildcard_turbo = self.text_input.get("0.0", "end-1c")
2522
+ before_wildcard = [item.strip() for item in before_wildcard_turbo.split(',')]
2523
+ if '<' in before_wildcard_turbo:
2524
+ wildcard_present = True
2525
+ itc = 0
2526
+ while (wildcard_present and itc < 10):
2527
+ wildcard_present = False
2528
+ #### ๋‹จ๊ณ„ 1 : ์ธ์Šคํ„ดํŠธ ์™€์ผ๋“œ์นด๋“œ ์ฒ˜๋ฆฌ ###
2529
+ for i, keyword in enumerate(before_wildcard):
2530
+ if keyword.startswith('<') and keyword.endswith('>'):
2531
+ wildcard_present = True
2532
+ vbar_check = keyword[1:-1]
2533
+ if '|' in vbar_check:
2534
+ choices = vbar_check.split('|') # '|'๋ฅผ ๊ธฐ์ค€์œผ๋กœ split
2535
+ choice_dic = {}
2536
+ for choice in choices:
2537
+ match = re.match(r'(\d*\.?\d+):(.+)', choice)
2538
+ if match:
2539
+ value, keyword = float(match.group(1)), match.group(2).strip()
2540
+ else:
2541
+ value, keyword = 1, choice.strip()
2542
+ choice_dic[keyword] = value
2543
+ keywords = list(choice_dic.keys())
2544
+ weights = list(choice_dic.values())
2545
+ selected_instant_wildcard = random.choices(keywords, weights=weights, k=1)[0]
2546
+ before_wildcard[i] = selected_instant_wildcard
2547
+ #### ๋‹จ๊ณ„ 2 : ๊ธ€๋กœ๋ฒŒ ์™€์ผ๋“œ์นด๋“œ ์ฒ˜๋ฆฌ ###
2548
+ for i, keyword in enumerate(before_wildcard):
2549
+ if "<" in keyword and ">" in keyword:
2550
+ wildcard_present = True
2551
+ input_str = keyword.strip('<>').strip()
2552
+ if("__" in input_str):
2553
+ adjectives = re.findall(r'__(.*?)__', input_str)
2554
+ last_keyword = re.split(r'__.*?__', input_str)[-1]
2555
+ adjective_string = ""
2556
+ for adjective in adjectives:
2557
+ adjective_string += (self.get_wildcard(adjective) + " ")
2558
+ before_wildcard[i] = adjective_string + self.get_wildcard(last_keyword)
2559
+ else:
2560
+ before_wildcard[i] = self.get_wildcard(input_str)
2561
+ itc += 1
2562
+ if not wildcard_present:
2563
+ break
2564
+ else:
2565
+ after_wildcard = self.text_input.get("0.0", "end-1c")
2566
+ after_wildcard = ', '.join(before_wildcard)
2567
  cvalue = random.randint(0,9999999999)
2568
  gen_request["seed"] = cvalue
2569
+ gen_request["prompt"] = after_wildcard
2570
  try:
2571
  treq_0, treq_1, treq_2, treq_3 = NAIA_generation.make_turbo_prompt(gen_request)
2572
  request_list.append(gen_request.copy())
 
2739
 
2740
  def turbo_process_request():
2741
  turbo_count = 0
2742
+ last_gen_request_seed = request_list[0]['seed']
2743
  while(request_list):
2744
  gen_request = request_list.pop(0) #length=5
2745
  generation_thread = threading.Thread(target=run_generation_turbo, args=(gen_request,), daemon=True)
 
2749
  if app.turbo_button.get() == 0:
2750
  app.state_label.configure(text =f"state : ์‚ฌ์šฉ์ž์— ์˜ํ•œ ํ„ฐ๋ณด์š”์ฒญ ์ค‘๋‹จ ({turbo_count})", text_color = "#FFFF97")
2751
  break
2752
+ if self.automation_button.get() == 0:
2753
+ if request_list and request_list[0]['seed'] != last_gen_request_seed:
2754
+ app.state_label.configure(text =f"state : ์‚ฌ์šฉ์ž์— ์˜ํ•œ ํ„ฐ๋ณด์š”์ฒญ ์ค‘๋‹จ ({turbo_count})", text_color = "#FFFF97")
2755
+ break
2756
+ last_gen_request_seed = gen_request['seed']
2757
  if self.automation_button.get() == 1:
2758
  if self.toggle_prompt_fix_button.get() == 0:
2759
  random_function()
 
4926
  import_frame2 = customtkinter.CTkFrame(import_window_right, width=586, fg_color="#2B2B2B")
4927
  import_frame2.grid(row=5, column=0, pady=5, padx=5, sticky="nsew")
4928
 
4929
+ i_seed_label = customtkinter.CTkLabel(import_frame2, font=my_font, text="Seed : ")
4930
  i_seed_label.grid(row=0, column=0, padx=5, sticky="nsew")
4931
  i_seed = customtkinter.CTkEntry(import_frame2, font=my_font, width=100)
4932
  i_seed.grid(row=0, column=1, padx=5, sticky="nsew")
4933
  i_seed.insert(0, str(contents['seed']))
4934
 
4935
+ i_sampler_label = customtkinter.CTkLabel(import_frame2, font=my_font, text="Sampler : ")
4936
  i_sampler_label.grid(row=0, column=2, padx=5, sticky="nsew")
4937
  i_sampler = customtkinter.CTkEntry(import_frame2, font=my_font, width=100)
4938
  i_sampler.grid(row=0, column=3, padx=5, sticky="nsew")