baqu2213 commited on
Commit
3e53406
Β·
1 Parent(s): a3b3ede

Upload 2 files

Browse files
Danbooru Prompt Selector/TEST2024/prompt_selector_auto_1212_testv8.exe CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:99a1fa3d70fb86abd05f3b1ab6b731597d1e81ff3a2c0e3e8668db60d81aa7b2
3
- size 150866140
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d955af933c28910c437d6166dcb3a8c68ed22773991b53a81bdb1f9bd6f384a
3
+ size 151425735
Danbooru Prompt Selector/TEST2024/prompt_selector_auto_1212_testv8.py CHANGED
@@ -27,11 +27,14 @@ from IPython.display import display
27
  import win32clipboard
28
  from io import BytesIO
29
  from datetime import datetime
30
- import arti_list, tagbag, wlist
31
  import character_dictionary as cd
32
  import pandas as pd
 
33
 
34
  BASE_URL="https://api.novelai.net"
 
 
35
 
36
  def argon_hash(email: str, password: str, size: int, domain: str) -> str:
37
  pre_salt = f"{password[:6]}{email}{domain}"
@@ -317,19 +320,48 @@ def random_function():
317
  include_keywords = [kw for kw in remaining_keywords if not kw.startswith('~') and not kw.startswith('*')]
318
 
319
  if current_deep_search_keywords != last_deep_search_keywords or not cached_rows:
320
- with open('txt2img_temp_prompt.csv', 'r', newline='', encoding='utf-8') as f:
321
- reader = csv.reader(f)
322
- rows = []
323
- for row in reader:
324
- if all(re.search(r'(?:^|, )' + re.escape(kw) + r'(?:,|$)', ', '.join(row)) for kw in perfect_match_keywords) \
325
- and not any(exclude in cell for exclude in exclude_keywords for cell in row) \
326
- and all(include in cell for include in include_keywords for cell in row):
327
- # '{}' μ•ˆμ˜ ν‚€μ›Œλ“œ 처리
328
- if all(any(re.search(r'(?:^|, )' + re.escape(kw) + r'(?:,|$)', ', '.join(cell)) for kw in perfect_group) or
329
- any(kw in cell for kw in regular_group) for perfect_group, regular_group in processed_keywords for cell in row):
330
- rows.append(row)
331
- cached_rows = rows
332
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  last_deep_search_keywords = current_deep_search_keywords
334
  if not toggle_prompt_var.get(): text_output.delete('1.0', tk.END)
335
 
@@ -439,7 +471,7 @@ def random_function():
439
  if kw in random_row_keywords:
440
  random_row_keywords.remove(kw)
441
 
442
- global previous_wildcard_artist, previous_wildcard_character
443
  # temp_first_keywords에 boy와 girl ν‚€μ›Œλ“œλ₯Ό μ μ ˆν•œ μœ„μΉ˜μ— μΆ”κ°€
444
  if(girl_keywords and 'girl' in temp_first_keywords[0]): temp_first_keywords.pop(0)
445
  #print(wildcard_var.get())
@@ -493,7 +525,7 @@ def random_function():
493
  temp_rm = []
494
  if rm_characteristic_var.get():
495
  for keyword in random_row_keywords:
496
- if keyword in bag_of_tags or "(" in keyword or "horns" in keyword:
497
  temp_rm.append(keyword)
498
  for keyword in temp_rm:
499
  random_row_keywords.remove(keyword)
@@ -538,6 +570,53 @@ def random_function():
538
 
539
  random_row_keywords = [keyword.strip(', ') for keyword in random_row_keywords]
540
  random_row_keywords = [keyword for keyword in random_row_keywords if keyword]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
541
  #print(random_row_keywords)
542
  text_output.insert(tk.END, f"{', '.join(random_row_keywords)}")
543
  if auto_copy_var.get():
@@ -2342,6 +2421,10 @@ widldcard_button.grid(row=1, column=2, sticky='ew')
2342
  folder_button = tk.Button(checkbox_frame, text="μ €μž₯ 폴더", command=open_file_explorer) #output_file_path
2343
  folder_button.grid(row=1, column=3, padx=5, sticky='ew')
2344
 
 
 
 
 
2345
 
2346
  window.bind('<Control-Return>', on_ctrl_enter)
2347
  window.bind('<Shift-Return>', on_shift_enter)
@@ -2352,10 +2435,12 @@ if not (entry_fixed_prompt.get()): entry_fixed_prompt.insert(0, '1girl,')
2352
  if not (entry_fixed_prompt_after.get()): entry_fixed_prompt_after.insert(0, 'great quality, aesthetic, absurdres')
2353
  if not (entry_auto_hide.get()): entry_auto_hide.insert(0, 'monochrome, doujin cover, bad source, censored, bar censor')
2354
 
 
 
2355
  resolution1_frame = tk.Frame(left_frame)
2356
- resolution1_frame.grid(row=15, column=0, padx=5, pady=5, sticky='ew')
2357
  resolution2_frame = tk.Frame(left_frame)
2358
- resolution2_frame.grid(row=16, column=0, padx=5, pady=5, sticky='ew')
2359
  selected_resolution = tk.StringVar(value="1024 x 1024")
2360
 
2361
  tk.Radiobutton(resolution1_frame, text="1024 x 1024", variable=selected_resolution, value="1024 x 1024").grid(row=0, column=0, sticky='w')
@@ -2394,7 +2479,7 @@ option_menu = tk.OptionMenu(resolution2_frame, selected_option, *options, comman
2394
  option_menu.grid(row=0, column=6, padx=5, sticky='ew')
2395
 
2396
  resolution3_frame = tk.Frame(left_frame)
2397
- resolution3_frame.grid(row=17, column=0, padx=5, pady=5, sticky='ew')
2398
  resolution3_frame.columnconfigure(0, weight=2)
2399
  resolution3_frame.columnconfigure(1, weight=1)
2400
  resolution3_frame.columnconfigure(2, weight=1)
 
27
  import win32clipboard
28
  from io import BytesIO
29
  from datetime import datetime
30
+ import arti_list, tagbag, wlist, copyright_dict
31
  import character_dictionary as cd
32
  import pandas as pd
33
+ import webbrowser
34
 
35
  BASE_URL="https://api.novelai.net"
36
+ copyright_keys = list(copyright_dict.copyright_dict.keys())
37
+ character_keys = list(cd.character_dictionary.keys())
38
 
39
  def argon_hash(email: str, password: str, size: int, domain: str) -> str:
40
  pre_salt = f"{password[:6]}{email}{domain}"
 
320
  include_keywords = [kw for kw in remaining_keywords if not kw.startswith('~') and not kw.startswith('*')]
321
 
322
  if current_deep_search_keywords != last_deep_search_keywords or not cached_rows:
323
+ if not os.path.exists('txt2img_temp_prompt.csv'):
324
+ text_output.delete('1.0', tk.END)
325
+ text_output.insert(tk.END, "txt2img_temp_prompt.csvκ°€ μ—†μ–΄ μž¬κ²€μƒ‰μ„ μˆ˜ν–‰ν•©λ‹ˆλ‹€. 이 μž‘μ—…μ—λŠ” 맀우 κΈ΄ μ‹œκ°„μ΄ μ†Œμš”λ©λ‹ˆλ‹€. tags.csv νŒŒμΌμ— λŒ€ν•΄ μ΄ˆκΈ°ν™” ν‚€μ›Œλ“œ 및 .csv 내보내기 κΈ°λŠ₯을 ν™œμš© ν•΄ μ£Όμ„Έμš”.")
326
+ try:
327
+ with open('txt2img_temp_prompt.csv', 'r', newline='', encoding='utf-8') as f:
328
+ reader = csv.reader(f)
329
+ rows = []
330
+ for row in reader:
331
+ if all(re.search(r'(?:^|, )' + re.escape(kw) + r'(?:,|$)', ', '.join(row)) for kw in perfect_match_keywords) \
332
+ and not any(exclude in cell for exclude in exclude_keywords for cell in row) \
333
+ and all(include in cell for include in include_keywords for cell in row):
334
+ # '{}' μ•ˆμ˜ ν‚€μ›Œλ“œ 처리
335
+ if all(any(re.search(r'(?:^|, )' + re.escape(kw) + r'(?:,|$)', ', '.join(cell)) for kw in perfect_group) or
336
+ any(kw in cell for kw in regular_group) for perfect_group, regular_group in processed_keywords for cell in row):
337
+ rows.append(row)
338
+ cached_rows = rows
339
+ except:
340
+ try:
341
+ search()
342
+ with open('txt2img_temp_prompt.csv', 'r', newline='', encoding='utf-8') as f:
343
+ reader = csv.reader(f)
344
+ rows = []
345
+ for row in reader:
346
+ if all(re.search(r'(?:^|, )' + re.escape(kw) + r'(?:,|$)', ', '.join(row)) for kw in perfect_match_keywords) \
347
+ and not any(exclude in cell for exclude in exclude_keywords for cell in row) \
348
+ and all(include in cell for include in include_keywords for cell in row):
349
+ # '{}' μ•ˆμ˜ ν‚€μ›Œλ“œ 처리
350
+ if all(any(re.search(r'(?:^|, )' + re.escape(kw) + r'(?:,|$)', ', '.join(cell)) for kw in perfect_group) or
351
+ any(kw in cell for kw in regular_group) for perfect_group, regular_group in processed_keywords for cell in row):
352
+ rows.append(row)
353
+ cached_rows = rows
354
+ except:
355
+ def open_link(url):
356
+ webbrowser.open_new(url)
357
+
358
+ text_output.delete('1.0', tk.END)
359
+ text_output.insert(tk.END, "tags.csv νŒŒμΌμ„ [파일 μ—΄κΈ°] λ²„νŠΌμ„ 눌러 νƒ‘μž¬ν•˜κ±°λ‚˜,")
360
+ text_output.insert(tk.END, "https://huggingface.co/baqu2213/PoemForSmallFThings/blob/main/Danbooru%20Prompt%20Selector/tags_2023.csv", "link")
361
+ text_output.insert(tk.END, " μ—μ„œ λ‹€μš΄λ‘œλ“œ ν•˜μ‹œκΈ° λ°”λžλ‹ˆλ‹€.")
362
+ text_output.tag_config("link", foreground="blue", underline=True)
363
+ text_output.tag_bind("link", "<Button-1>", lambda e: open_link("https://huggingface.co/baqu2213/PoemForSmallFThings/blob/main/Danbooru%20Prompt%20Selector/tags_2023.csv"))
364
+ return
365
  last_deep_search_keywords = current_deep_search_keywords
366
  if not toggle_prompt_var.get(): text_output.delete('1.0', tk.END)
367
 
 
471
  if kw in random_row_keywords:
472
  random_row_keywords.remove(kw)
473
 
474
+ global previous_wildcard_artist, previous_wildcard_character, character_keys
475
  # temp_first_keywords에 boy와 girl ν‚€μ›Œλ“œλ₯Ό μ μ ˆν•œ μœ„μΉ˜μ— μΆ”κ°€
476
  if(girl_keywords and 'girl' in temp_first_keywords[0]): temp_first_keywords.pop(0)
477
  #print(wildcard_var.get())
 
525
  temp_rm = []
526
  if rm_characteristic_var.get():
527
  for keyword in random_row_keywords:
528
+ if keyword in bag_of_tags or keyword in character_keys or "(" in keyword or "horns" in keyword:
529
  temp_rm.append(keyword)
530
  for keyword in temp_rm:
531
  random_row_keywords.remove(keyword)
 
570
 
571
  random_row_keywords = [keyword.strip(', ') for keyword in random_row_keywords]
572
  random_row_keywords = [keyword for keyword in random_row_keywords if keyword]
573
+
574
+ rm_copyright = []
575
+ global copyright_keys
576
+ if(rm_copyright_var.get() == 1):
577
+ for keyword in random_row_keywords:
578
+ if keyword in copyright_keys:
579
+ rm_copyright.append(keyword)
580
+ if rm_copyright is not None:
581
+ for keyword in rm_copyright:
582
+ random_row_keywords.remove(keyword)
583
+ else:
584
+ idx = 0
585
+ for keyword in random_row_keywords:
586
+ if keyword in copyright_keys:
587
+ random_row_keywords[idx] = keyword+" (copyright)"
588
+ idx += 1
589
+ pop_character = []
590
+ for keyword in random_row_keywords:
591
+ if keyword in character_keys:
592
+ pop_character.append(keyword)
593
+ if pop_character is not None:
594
+ found_index = 0
595
+ # Search for 'girl' in the first four elements
596
+ for i in range(min(10, len(random_row_keywords))):
597
+ if 'girl' in random_row_keywords[i]:
598
+ found_index = i
599
+ break
600
+ elif 'boy' in random_row_keywords[i]:
601
+ found_index = i
602
+ break
603
+ elif 'other' in random_row_keywords[i]:
604
+ found_index = i
605
+ break
606
+ for keyword in pop_character:
607
+ found_index += 1
608
+ random_row_keywords.remove(keyword)
609
+ random_row_keywords.insert(found_index,keyword)
610
+ pop_artist = []
611
+ for keyword in random_row_keywords:
612
+ if keyword in afilter_30000:
613
+ pop_artist.append(keyword)
614
+ if pop_artist is not None:
615
+ for keyword in pop_artist:
616
+ found_index += 1
617
+ random_row_keywords.remove(keyword)
618
+ random_row_keywords.insert(found_index,"artist:"+keyword)
619
+
620
  #print(random_row_keywords)
621
  text_output.insert(tk.END, f"{', '.join(random_row_keywords)}")
622
  if auto_copy_var.get():
 
2421
  folder_button = tk.Button(checkbox_frame, text="μ €μž₯ 폴더", command=open_file_explorer) #output_file_path
2422
  folder_button.grid(row=1, column=3, padx=5, sticky='ew')
2423
 
2424
+ # "μž‘ν’ˆλͺ… 제거" μ²΄ν¬λ°•μŠ€
2425
+ rm_copyright_var = tk.IntVar()
2426
+ rm_copyright_label = tk.Checkbutton(checkbox_frame, text="μž‘ν’ˆλͺ… 제거", variable=rm_copyright_var)
2427
+ rm_copyright_label.grid(row=2, column=0, pady=5, sticky='ew')
2428
 
2429
  window.bind('<Control-Return>', on_ctrl_enter)
2430
  window.bind('<Shift-Return>', on_shift_enter)
 
2435
  if not (entry_fixed_prompt_after.get()): entry_fixed_prompt_after.insert(0, 'great quality, aesthetic, absurdres')
2436
  if not (entry_auto_hide.get()): entry_auto_hide.insert(0, 'monochrome, doujin cover, bad source, censored, bar censor')
2437
 
2438
+
2439
+
2440
  resolution1_frame = tk.Frame(left_frame)
2441
+ resolution1_frame.grid(row=16, column=0, padx=5, pady=5, sticky='ew')
2442
  resolution2_frame = tk.Frame(left_frame)
2443
+ resolution2_frame.grid(row=17, column=0, padx=5, pady=5, sticky='ew')
2444
  selected_resolution = tk.StringVar(value="1024 x 1024")
2445
 
2446
  tk.Radiobutton(resolution1_frame, text="1024 x 1024", variable=selected_resolution, value="1024 x 1024").grid(row=0, column=0, sticky='w')
 
2479
  option_menu.grid(row=0, column=6, padx=5, sticky='ew')
2480
 
2481
  resolution3_frame = tk.Frame(left_frame)
2482
+ resolution3_frame.grid(row=18, column=0, padx=5, pady=5, sticky='ew')
2483
  resolution3_frame.columnconfigure(0, weight=2)
2484
  resolution3_frame.columnconfigure(1, weight=1)
2485
  resolution3_frame.columnconfigure(2, weight=1)