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:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:297fdc6f69a9dae7741ccc9027eaf3e732557715b97cf37ceee89ad359f7ed05
|
| 3 |
+
size 150864130
|
Danbooru Prompt Selector/TEST2024/prompt_selector_auto_1212_testv8.py
CHANGED
|
@@ -312,8 +312,6 @@ def random_function():
|
|
| 312 |
include_keywords = [kw for kw in remaining_keywords if not kw.startswith('~') and not kw.startswith('*')]
|
| 313 |
|
| 314 |
if current_deep_search_keywords != last_deep_search_keywords or not cached_rows:
|
| 315 |
-
entry_auto_hide.delete(0, tk.END)
|
| 316 |
-
entry_auto_hide.insert(tk.END, 'monochrome, doujin cover, bad source, censored, bar censor, photoshop (medium)')
|
| 317 |
with open('txt2img_temp_prompt.csv', 'r', newline='', encoding='utf-8') as f:
|
| 318 |
reader = csv.reader(f)
|
| 319 |
rows = []
|
|
@@ -436,21 +434,41 @@ def random_function():
|
|
| 436 |
if kw in random_row_keywords:
|
| 437 |
random_row_keywords.remove(kw)
|
| 438 |
|
| 439 |
-
|
| 440 |
# temp_first_keywords์ boy์ girl ํค์๋๋ฅผ ์ ์ ํ ์์น์ ์ถ๊ฐ
|
| 441 |
if(girl_keywords and 'girl' in temp_first_keywords[0]): temp_first_keywords.pop(0)
|
| 442 |
#print(wildcard_var.get())
|
|
|
|
| 443 |
if(wildcard_var2.get() == 1):
|
| 444 |
temp_len = len(girl_keywords)
|
| 445 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 446 |
if(wildcard_var.get() == 1):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 447 |
if(wildcard_var2.get() == 1):
|
| 448 |
-
girl_keywords.insert(temp_len+1,
|
| 449 |
else:
|
| 450 |
-
girl_keywords.append(
|
| 451 |
-
print(boy_keywords)
|
| 452 |
-
print(girl_keywords)
|
| 453 |
-
print(temp_first_keywords)
|
| 454 |
if temp_first_keywords and 'girl' in temp_first_keywords[0]:
|
| 455 |
girl_in_gkey = False
|
| 456 |
for gkey in girl_keywords:
|
|
@@ -815,7 +833,7 @@ def character_search():
|
|
| 815 |
|
| 816 |
for k, v in keyword_count_dict1.items():
|
| 817 |
if '|' in k: continue
|
| 818 |
-
if v >=
|
| 819 |
result_list1.append(k)
|
| 820 |
|
| 821 |
result_list1.insert(0, keyword)
|
|
@@ -839,6 +857,11 @@ def character_search():
|
|
| 839 |
# Insert the matching keywords into the listbox
|
| 840 |
for keyword, count in matching_keywords:
|
| 841 |
listbox.insert(tk.END, f"{keyword} - {count}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 842 |
|
| 843 |
# ๋ฉ์ธ ์๋์ฐ ์์ฑ
|
| 844 |
ch_search_window = tk.Toplevel(window)
|
|
@@ -869,15 +892,62 @@ def character_search():
|
|
| 869 |
# center_frame ๋ด๋ถ ๊ตฌ์ฑ
|
| 870 |
search_button = tk.Button(center_frame, text="๊ฒ์", command=on_search)
|
| 871 |
search_button.grid(row=2, column=0, rowspan=4, padx=10, pady=175)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 872 |
|
| 873 |
# right_frame ๋ด๋ถ ๊ตฌ์ฑ
|
| 874 |
-
|
|
|
|
|
|
|
| 875 |
prompt_label.grid(row=0, column=0, padx=10, pady=5, sticky="ew")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 876 |
character_prompt = tk.Text(right_frame, height=10)
|
| 877 |
character_prompt.grid(row=1, column=0, padx=10, pady=5, sticky="nsew")
|
| 878 |
#row=3, column=0, padx=10, pady=5, sticky="nsew"
|
| 879 |
-
|
| 880 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 881 |
cosplay_prompt = tk.Text(right_frame, height=10)
|
| 882 |
cosplay_prompt.grid(row=3, column=0, padx=10, pady=5, sticky="ew")
|
| 883 |
|
|
@@ -897,6 +967,10 @@ def character_search():
|
|
| 897 |
ch_search_window.grid_columnconfigure(1, weight=1) # center_frame
|
| 898 |
ch_search_window.grid_columnconfigure(2, weight=6) # right_frame
|
| 899 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 900 |
def v_automatic(save_position, prompt_position):
|
| 901 |
# ํ๋กฌํํธ ์ฐฝ ํด๋ฆญ
|
| 902 |
copy_to_clipboard()
|
|
@@ -1846,6 +1920,9 @@ afilter_30000 = arti_list.afilter_30000
|
|
| 1846 |
current_wildcard_artist = []
|
| 1847 |
current_wildcard_character = []
|
| 1848 |
|
|
|
|
|
|
|
|
|
|
| 1849 |
GENERATE_EVENT = "<<GenerateEvent>>"
|
| 1850 |
window.bind(GENERATE_EVENT, on_generate_event)
|
| 1851 |
|
|
|
|
| 312 |
include_keywords = [kw for kw in remaining_keywords if not kw.startswith('~') and not kw.startswith('*')]
|
| 313 |
|
| 314 |
if current_deep_search_keywords != last_deep_search_keywords or not cached_rows:
|
|
|
|
|
|
|
| 315 |
with open('txt2img_temp_prompt.csv', 'r', newline='', encoding='utf-8') as f:
|
| 316 |
reader = csv.reader(f)
|
| 317 |
rows = []
|
|
|
|
| 434 |
if kw in random_row_keywords:
|
| 435 |
random_row_keywords.remove(kw)
|
| 436 |
|
| 437 |
+
global previous_wildcard_artist, previous_wildcard_character
|
| 438 |
# temp_first_keywords์ boy์ girl ํค์๋๋ฅผ ์ ์ ํ ์์น์ ์ถ๊ฐ
|
| 439 |
if(girl_keywords and 'girl' in temp_first_keywords[0]): temp_first_keywords.pop(0)
|
| 440 |
#print(wildcard_var.get())
|
| 441 |
+
print(random_row_keywords)
|
| 442 |
if(wildcard_var2.get() == 1):
|
| 443 |
temp_len = len(girl_keywords)
|
| 444 |
+
print('previous : ',previous_wildcard_character, 'type : ', type(previous_wildcard_character))
|
| 445 |
+
if previous_wildcard_character in random_row_keywords:
|
| 446 |
+
random_row_keywords.remove(previous_wildcard_character)
|
| 447 |
+
elif(previous_wildcard_character is not None):
|
| 448 |
+
split_previous_wildcard_character = previous_wildcard_character.split(',')
|
| 449 |
+
for _keyword in split_previous_wildcard_character:
|
| 450 |
+
if _keyword in random_row_keywords:
|
| 451 |
+
random_row_keywords.remove(_keyword)
|
| 452 |
+
previous_wildcard_character = get_random_keyword('character')
|
| 453 |
+
girl_keywords.append(previous_wildcard_character)
|
| 454 |
if(wildcard_var.get() == 1):
|
| 455 |
+
print('previous : ',previous_wildcard_artist, 'type : ', type(previous_wildcard_artist))
|
| 456 |
+
if previous_wildcard_artist is not None and " "+previous_wildcard_artist in random_row_keywords:
|
| 457 |
+
random_row_keywords.remove(" "+previous_wildcard_artist)
|
| 458 |
+
elif(previous_wildcard_artist is not None):
|
| 459 |
+
split_previous_wildcard_artist = previous_wildcard_artist.split(',')
|
| 460 |
+
split_previous_wildcard_artist[0] = " "+split_previous_wildcard_artist[0]
|
| 461 |
+
for _keyword in split_previous_wildcard_artist:
|
| 462 |
+
if _keyword in random_row_keywords:
|
| 463 |
+
random_row_keywords.remove(_keyword)
|
| 464 |
+
previous_wildcard_artist = get_random_keyword('artist')
|
| 465 |
if(wildcard_var2.get() == 1):
|
| 466 |
+
girl_keywords.insert(temp_len+1,previous_wildcard_artist)
|
| 467 |
else:
|
| 468 |
+
girl_keywords.append(previous_wildcard_artist)
|
| 469 |
+
#print(boy_keywords)
|
| 470 |
+
#print(girl_keywords)
|
| 471 |
+
#print(temp_first_keywords)
|
| 472 |
if temp_first_keywords and 'girl' in temp_first_keywords[0]:
|
| 473 |
girl_in_gkey = False
|
| 474 |
for gkey in girl_keywords:
|
|
|
|
| 833 |
|
| 834 |
for k, v in keyword_count_dict1.items():
|
| 835 |
if '|' in k: continue
|
| 836 |
+
if v >= highest_count1 * weight:
|
| 837 |
result_list1.append(k)
|
| 838 |
|
| 839 |
result_list1.insert(0, keyword)
|
|
|
|
| 857 |
# Insert the matching keywords into the listbox
|
| 858 |
for keyword, count in matching_keywords:
|
| 859 |
listbox.insert(tk.END, f"{keyword} - {count}")
|
| 860 |
+
else:
|
| 861 |
+
# Sort all keywords by count in descending order
|
| 862 |
+
all_keywords = sorted(cd.character_dictionary.items(), key=lambda item: item[1], reverse=True)
|
| 863 |
+
for keyword, count in all_keywords:
|
| 864 |
+
listbox.insert(tk.END, f"{keyword} - {count}")
|
| 865 |
|
| 866 |
# ๋ฉ์ธ ์๋์ฐ ์์ฑ
|
| 867 |
ch_search_window = tk.Toplevel(window)
|
|
|
|
| 892 |
# center_frame ๋ด๋ถ ๊ตฌ์ฑ
|
| 893 |
search_button = tk.Button(center_frame, text="๊ฒ์", command=on_search)
|
| 894 |
search_button.grid(row=2, column=0, rowspan=4, padx=10, pady=175)
|
| 895 |
+
|
| 896 |
+
def character_prompt_auto_insert():
|
| 897 |
+
selected_indices = listbox.curselection()
|
| 898 |
+
if not selected_indices: # If there is no selection
|
| 899 |
+
print("No selection made.")
|
| 900 |
+
return
|
| 901 |
+
# Assuming the first selected index (single selection mode)
|
| 902 |
+
selected_index = selected_indices[0]
|
| 903 |
+
# Get the keyword from the listbox, split by '-', and trim whitespace
|
| 904 |
+
keyword_with_count = listbox.get(selected_index).strip()
|
| 905 |
+
keyword = keyword_with_count.split('-')[0].strip()
|
| 906 |
+
prompt = character_prompt.get("1.0", tk.END).replace(keyword+',','')
|
| 907 |
+
if(len(prompt) > 8):
|
| 908 |
+
text_output.delete('1.0', tk.END)
|
| 909 |
+
entry_prompt = entry_fixed_prompt.get().replace('1girl', f'1girl, {keyword}')
|
| 910 |
+
result_text = entry_prompt+", "+prompt[:-2]+", "+entry_fixed_prompt_after.get()
|
| 911 |
+
text_output.insert(tk.END, result_text)
|
| 912 |
+
return (len(prompt) > 8)
|
| 913 |
+
|
| 914 |
+
def character_prompt_auto_generate():
|
| 915 |
+
global running_flag
|
| 916 |
+
if(character_prompt_auto_insert() and not running_flag):
|
| 917 |
+
window.event_generate(GENERATE_EVENT, when="tail")
|
| 918 |
+
|
| 919 |
+
def character_cosplay_auto_insert():
|
| 920 |
+
prompt = cosplay_prompt.get("1.0", tk.END)
|
| 921 |
+
if(len(prompt) > 8):
|
| 922 |
+
text_output.delete('1.0', tk.END)
|
| 923 |
+
result_text = entry_fixed_prompt.get()+", "+prompt[:-2]+", "+entry_fixed_prompt_after.get()
|
| 924 |
+
text_output.insert(tk.END, result_text)
|
| 925 |
+
return (len(prompt) > 8)
|
| 926 |
+
|
| 927 |
+
def character_cosplay_auto_generate():
|
| 928 |
+
if(character_cosplay_auto_insert() and not running_flag):
|
| 929 |
+
window.event_generate(GENERATE_EVENT, when="tail")
|
| 930 |
|
| 931 |
# right_frame ๋ด๋ถ ๊ตฌ์ฑ
|
| 932 |
+
character_prompt_frame = tk.Frame(right_frame)
|
| 933 |
+
character_prompt_frame.grid(row=0, column=0, padx=10, pady=5, sticky="ew")
|
| 934 |
+
prompt_label = tk.Label(character_prompt_frame, text="์บ๋ฆญํฐ ํ๋กฌํํธ:")
|
| 935 |
prompt_label.grid(row=0, column=0, padx=10, pady=5, sticky="ew")
|
| 936 |
+
character_prompt_insert = tk.Button(character_prompt_frame, text="์๋์
๋ ฅ", command=character_prompt_auto_insert)
|
| 937 |
+
character_prompt_insert.grid(row=0, column=1, padx=10, pady=5, sticky="ew")
|
| 938 |
+
character_prompt_generate = tk.Button(character_prompt_frame, text="์ฆ์์์ฑ", command=character_prompt_auto_generate)
|
| 939 |
+
character_prompt_generate.grid(row=0, column=2, padx=10, pady=5, sticky="ew")
|
| 940 |
character_prompt = tk.Text(right_frame, height=10)
|
| 941 |
character_prompt.grid(row=1, column=0, padx=10, pady=5, sticky="nsew")
|
| 942 |
#row=3, column=0, padx=10, pady=5, sticky="nsew"
|
| 943 |
+
character_cosplay_frame = tk.Frame(right_frame)
|
| 944 |
+
character_cosplay_frame.grid(row=2, column=0, padx=10, pady=5, sticky="ew")
|
| 945 |
+
cosplay_label = tk.Label(character_cosplay_frame, text="์บ๋ฆญํฐ (Cosplay):")
|
| 946 |
+
cosplay_label.grid(row=0, column=0, padx=10, pady=5, sticky="ew")
|
| 947 |
+
character_cosplay_insert = tk.Button(character_cosplay_frame, text="์๋์
๋ ฅ", command=character_cosplay_auto_insert)
|
| 948 |
+
character_cosplay_insert.grid(row=0, column=1, padx=10, pady=5, sticky="ew")
|
| 949 |
+
character_prompt_generate = tk.Button(character_cosplay_frame, text="์ฆ์์์ฑ", command=character_cosplay_auto_generate)
|
| 950 |
+
character_prompt_generate.grid(row=0, column=2, padx=10, pady=5, sticky="ew")
|
| 951 |
cosplay_prompt = tk.Text(right_frame, height=10)
|
| 952 |
cosplay_prompt.grid(row=3, column=0, padx=10, pady=5, sticky="ew")
|
| 953 |
|
|
|
|
| 967 |
ch_search_window.grid_columnconfigure(1, weight=1) # center_frame
|
| 968 |
ch_search_window.grid_columnconfigure(2, weight=6) # right_frame
|
| 969 |
|
| 970 |
+
all_keywords = sorted(cd.character_dictionary.items(), key=lambda item: item[1], reverse=True)
|
| 971 |
+
for keyword, count in all_keywords:
|
| 972 |
+
listbox.insert(tk.END, f"{keyword} - {count}")
|
| 973 |
+
|
| 974 |
def v_automatic(save_position, prompt_position):
|
| 975 |
# ํ๋กฌํํธ ์ฐฝ ํด๋ฆญ
|
| 976 |
copy_to_clipboard()
|
|
|
|
| 1920 |
current_wildcard_artist = []
|
| 1921 |
current_wildcard_character = []
|
| 1922 |
|
| 1923 |
+
previous_wildcard_artist = None
|
| 1924 |
+
previous_wildcard_character = None
|
| 1925 |
+
|
| 1926 |
GENERATE_EVENT = "<<GenerateEvent>>"
|
| 1927 |
window.bind(GENERATE_EVENT, on_generate_event)
|
| 1928 |
|