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:99a1fa3d70fb86abd05f3b1ab6b731597d1e81ff3a2c0e3e8668db60d81aa7b2
|
| 3 |
+
size 150866140
|
Danbooru Prompt Selector/TEST2024/prompt_selector_auto_1212_testv8.py
CHANGED
|
@@ -150,13 +150,14 @@ def generate(width, height, positive, negative, button):
|
|
| 150 |
with open(f"error_log.txt", "a") as file:
|
| 151 |
file.write(error_message)
|
| 152 |
|
| 153 |
-
global access_token, error_count
|
| 154 |
while (running_flag):
|
| 155 |
time.sleep(1)
|
| 156 |
try:
|
| 157 |
running_flag = True
|
| 158 |
tprint("Running : NAI request received")
|
| 159 |
-
zipped_bytes = generate_image(access_token, positive, "nai-diffusion-3", "generate", params)
|
|
|
|
| 160 |
d = Path(f"output_NAI/{start_time}/txt2img")
|
| 161 |
d.mkdir(parents=True, exist_ok=True)
|
| 162 |
zipped = zipfile.ZipFile(io.BytesIO(zipped_bytes))
|
|
@@ -172,19 +173,23 @@ def generate(width, height, positive, negative, button):
|
|
| 172 |
globals()['tk_image'] = None
|
| 173 |
tk_image = ImageTk.PhotoImage(i_resized)
|
| 174 |
image_label.config(image=tk_image)
|
|
|
|
| 175 |
image_label.image = tk_image # μ°Έμ‘° μ μ§
|
| 176 |
output_file_path = "output_image.jpg"
|
| 177 |
i.save(output_file_path)
|
| 178 |
error_count = 0
|
| 179 |
except Exception as e:
|
| 180 |
#text_output.insert(tk.END, f"Error: {e}", fg='red')
|
| 181 |
-
log_error(
|
| 182 |
time.sleep(random.uniform(1.0, 2.5))
|
| 183 |
error_count += 1
|
| 184 |
if error_count > 5:
|
| 185 |
mac_var.set(0)
|
| 186 |
button.config(state=tk.NORMAL)
|
| 187 |
|
|
|
|
|
|
|
|
|
|
| 188 |
running_flag = False
|
| 189 |
last_generation_seed = params['seed']
|
| 190 |
entry_seed_value.set(last_generation_seed)
|
|
@@ -582,6 +587,11 @@ def turbo_stop(button):
|
|
| 582 |
tprint("Stopping pipelines ... ")
|
| 583 |
|
| 584 |
def exit_program():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 585 |
window.destroy()
|
| 586 |
|
| 587 |
def save_settings():
|
|
@@ -694,8 +704,7 @@ def exit_program():
|
|
| 694 |
window.destroy()
|
| 695 |
|
| 696 |
def on_ctrl_enter(event):
|
| 697 |
-
|
| 698 |
-
pass
|
| 699 |
|
| 700 |
def on_shift_enter(event):
|
| 701 |
random_function()
|
|
@@ -737,11 +746,61 @@ def export_csv_search():
|
|
| 737 |
def for_canonical(f):
|
| 738 |
return lambda k: f(listener.canonical(k))
|
| 739 |
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 745 |
|
| 746 |
def character_search_thread():
|
| 747 |
search_thread = threading.Thread(target=character_search, daemon=True)
|
|
@@ -970,132 +1029,14 @@ def character_search():
|
|
| 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()
|
| 977 |
-
pyautogui.click(prompt_position)
|
| 978 |
-
time.sleep(0.5)
|
| 979 |
-
random_function()
|
| 980 |
-
pyautogui.hotkey('ctrl', 'a', 'v','Right','Right','Enter')
|
| 981 |
-
time.sleep(0.5)
|
| 982 |
-
pyautogui.click(save_position)
|
| 983 |
-
|
| 984 |
-
def start_automation(save_position, prompt_position, label, window_to_close, automation_event):
|
| 985 |
-
def automation_task():
|
| 986 |
-
while automation_event.is_set():
|
| 987 |
-
random_delay = random.uniform(17.5, 23.5)
|
| 988 |
-
next_click_time = time.time() + random_delay
|
| 989 |
-
while time.time() < next_click_time and automation_event.is_set():
|
| 990 |
-
time_remaining = max(next_click_time - time.time(), 0)
|
| 991 |
-
label.config(text=f"λ€μ ν΄λ¦κΉμ§: {time_remaining:.2f}μ΄")
|
| 992 |
-
time.sleep(0.1)
|
| 993 |
-
if automation_event.is_set():
|
| 994 |
-
v_automatic(save_position, prompt_position)
|
| 995 |
-
|
| 996 |
-
automation_thread = threading.Thread(target=automation_task, daemon=True)
|
| 997 |
-
automation_thread.start()
|
| 998 |
-
random_function()
|
| 999 |
-
|
| 1000 |
-
def stop_automation():
|
| 1001 |
-
automation_event.clear()
|
| 1002 |
-
window_to_close.destroy()
|
| 1003 |
-
|
| 1004 |
-
window_to_close.protocol("WM_DELETE_WINDOW", stop_automation)
|
| 1005 |
-
|
| 1006 |
-
def stop_automation(window_to_close, automation_event, start_button, stop_button):
|
| 1007 |
-
automation_event.clear() # Stop the automation task
|
| 1008 |
-
start_button['state'] = 'normal' # Enable the start button
|
| 1009 |
-
stop_button['state'] = 'disabled' # Disable the stop button
|
| 1010 |
-
window_to_close.destroy() # Close the automation window
|
| 1011 |
-
window.deiconify()
|
| 1012 |
-
|
| 1013 |
-
# λΌλ²¨μ μ
λ°μ΄νΈνλ ν¨μ
|
| 1014 |
-
def update_label(label, text):
|
| 1015 |
-
def task():
|
| 1016 |
-
label.config(text=text)
|
| 1017 |
-
label.after(1000, task) # λ©μΈ μ€λ λμμ UI μ
λ°μ΄νΈ
|
| 1018 |
-
|
| 1019 |
-
def open_automation_window():
|
| 1020 |
-
window.iconify()
|
| 1021 |
-
automation_event = threading.Event()
|
| 1022 |
-
automation_event.set() # Enable the automation event
|
| 1023 |
-
auto_window = tk.Toplevel(window)
|
| 1024 |
-
auto_window.title("μλν μ€μ ")
|
| 1025 |
-
auto_window.geometry("300x200") # μ°½ ν¬κΈ° μ‘°μ
|
| 1026 |
-
auto_window.attributes('-topmost', True) # μ°½μ νμ 맨 μμ μμΉ
|
| 1027 |
-
auto_window.focus_force() # μ°½ μ΄λ¦΄ λ ν¬μ»€μ€ κ°μ μ΄λ
|
| 1028 |
-
|
| 1029 |
-
save_position = None
|
| 1030 |
-
prompt_position = None
|
| 1031 |
-
automation_running = threading.Event()
|
| 1032 |
-
|
| 1033 |
-
def get_mouse_position(event=None):
|
| 1034 |
-
nonlocal save_position, prompt_position
|
| 1035 |
-
x, y = pyautogui.position()
|
| 1036 |
-
if not save_position:
|
| 1037 |
-
save_position = (x, y)
|
| 1038 |
-
position_label.config(text=f"μ μ₯ λ²νΌμ μ’ν: {x}, {y}\nν둬ννΈ μ°½μ μ’ν: ")
|
| 1039 |
-
elif not prompt_position:
|
| 1040 |
-
prompt_position = (x, y)
|
| 1041 |
-
position_label.config(text=f"μ μ₯ λ²νΌμ μ’ν: {save_position[0]}, {save_position[1]}\nν둬ννΈ μ°½μ μ’ν: {x}, {y}")
|
| 1042 |
-
start_button.config(state="normal")
|
| 1043 |
-
if save_position and prompt_position:
|
| 1044 |
-
start_button.config(state="normal")
|
| 1045 |
-
stop_button.config(state="normal")
|
| 1046 |
-
|
| 1047 |
-
|
| 1048 |
-
position_label = tk.Label(auto_window, text="μν°λ₯Ό λλ¬ λ§μ°μ€ μ’νλ₯Ό μ μ₯νμΈμ\n(ν΄λ¦ X, 1.μ μ₯->2.ν둬ννΈμ°½ μμ)", justify=tk.LEFT)
|
| 1049 |
-
position_label.pack(pady=10)
|
| 1050 |
-
|
| 1051 |
-
start_button = tk.Button(auto_window, text="μμ", state="disabled",
|
| 1052 |
-
command=lambda: start_automation(save_position, prompt_position, countdown_label, auto_window, automation_event))
|
| 1053 |
-
start_button.pack(side=tk.LEFT, fill='x', expand=True)
|
| 1054 |
-
|
| 1055 |
-
stop_button = tk.Button(auto_window, text="μ€μ§", state="disabled",
|
| 1056 |
-
command=lambda: stop_automation(auto_window, automation_event, start_button, stop_button))
|
| 1057 |
-
stop_button.pack(side=tk.RIGHT, fill='x', expand=True)
|
| 1058 |
-
|
| 1059 |
-
countdown_label = tk.Label(auto_window, text="")
|
| 1060 |
-
countdown_label.pack(pady=10)
|
| 1061 |
-
|
| 1062 |
-
auto_window.bind('<Return>', get_mouse_position)
|
| 1063 |
-
|
| 1064 |
-
def NAI_generation(width, height, button):
|
| 1065 |
-
global access_token_multi, NAI_width, NAI_height
|
| 1066 |
-
global button_stop, running_flag
|
| 1067 |
-
|
| 1068 |
-
pretest = text_output.get("1.0", tk.END).split(', ')
|
| 1069 |
-
if (turbo_var.get() == 1):
|
| 1070 |
-
if ( 'sex' not in pretest or '1girl' not in pretest or '1boy' not in pretest):
|
| 1071 |
-
tprint('νμ¬ λΆμ€νΈ κΈ°λ₯μ 1girl, 1boy, sex μΈκ°μ§ ν€μλκ° μμ΄μΌ λμν©λλ€.')
|
| 1072 |
-
return
|
| 1073 |
-
|
| 1074 |
-
if(rand_resolution_var.get() == 1):
|
| 1075 |
-
resolutions = ["1024 x 1024", "960 x 1088", "896 x 1152", "832 x 1216", "1088 x 960", "1152 x 896", "1216 x 832"]
|
| 1076 |
-
random_resolution = random.choice(resolutions)
|
| 1077 |
-
selected_resolution.set(random_resolution)
|
| 1078 |
-
|
| 1079 |
-
if(turbo_var.get() == 1 and access_token):
|
| 1080 |
-
button_stop.config(state='normal')
|
| 1081 |
-
NAI_generation_turbo(NAI_width, NAI_height, button)
|
| 1082 |
-
else:
|
| 1083 |
-
if not (running_flag):
|
| 1084 |
-
NAI_generation_normal(NAI_width, NAI_height, button)
|
| 1085 |
-
|
| 1086 |
-
def Auto_login_check():
|
| 1087 |
-
global access_token, access_token_multi
|
| 1088 |
-
if os.path.exists('token.txt'):
|
| 1089 |
-
with open('token.txt', 'r', encoding='utf-8') as f:
|
| 1090 |
-
tokens = f.readlines()
|
| 1091 |
-
if(tokens[0]): access_token = tokens[0].strip()
|
| 1092 |
-
if(access_token): button_setting.config(state='disabled')
|
| 1093 |
-
if(access_token): button_generate.config(state='normal')
|
| 1094 |
|
| 1095 |
def NAI_generation_normal(width, height, button):
|
| 1096 |
button.config(state=tk.DISABLED)
|
| 1097 |
positive = text_output.get("1.0", tk.END)
|
| 1098 |
negative = negative_text.get("1.0", "end-1c").strip()
|
|
|
|
|
|
|
|
|
|
| 1099 |
thread = threading.Thread(target=generate, args=(width, height, positive, negative, button))
|
| 1100 |
thread.start()
|
| 1101 |
|
|
@@ -1104,7 +1045,6 @@ def NAI_generation_turbo(width, height, button):
|
|
| 1104 |
button.config(state=tk.DISABLED)
|
| 1105 |
positive = text_output.get("1.0", tk.END)
|
| 1106 |
negative = negative_text.get("1.0", "end-1c").strip()
|
| 1107 |
-
|
| 1108 |
|
| 1109 |
def SELECT(positive):
|
| 1110 |
lines = positive[:25]
|
|
@@ -1286,6 +1226,9 @@ def NAI_generation_turbo(width, height, button):
|
|
| 1286 |
sleep2 = sleep1 + random.uniform(13.5,19.5)
|
| 1287 |
sleep3 = sleep2 + random.uniform(13.5,19.5)
|
| 1288 |
|
|
|
|
|
|
|
|
|
|
| 1289 |
thread_init = threading.Thread(target=generate_turbo, args=(seed,turbo_count, access_token, width, height, positive, negative, button, 0, 0))
|
| 1290 |
thread_init.start()
|
| 1291 |
thread0 = threading.Thread(target=generate_turbo, args=(seed,turbo_count, access_token, width, height, positive0, negative, button, 1, sleep0))
|
|
@@ -1371,7 +1314,7 @@ def generate_turbo(_seed, turbo_count, tb_access_token,width, height, positive,
|
|
| 1371 |
|
| 1372 |
return new_image
|
| 1373 |
|
| 1374 |
-
def insert_queue(i, _number):
|
| 1375 |
global image_queue, temp_clipboard_image
|
| 1376 |
while len(image_queue) < 4: image_queue.append(None)
|
| 1377 |
if _number <= 4:
|
|
@@ -1387,17 +1330,23 @@ def generate_turbo(_seed, turbo_count, tb_access_token,width, height, positive,
|
|
| 1387 |
globals()['tk_image'] = None
|
| 1388 |
tk_image = ImageTk.PhotoImage(i_resized)
|
| 1389 |
image_label.config(image=tk_image)
|
|
|
|
| 1390 |
image_label.image = tk_image # μ°Έμ‘° μ μ§
|
| 1391 |
if all(img is not None for img in image_queue):
|
| 1392 |
time.sleep(5)
|
| 1393 |
merged_image = merge_images(image_queue)
|
| 1394 |
temp_clipboard_image = merged_image.copy()
|
| 1395 |
if merged_image is not None:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1396 |
i_resized = resize_and_fill(merged_image)
|
| 1397 |
if 'tk_image' in globals():
|
| 1398 |
globals()['tk_image'] = None
|
| 1399 |
tk_image = ImageTk.PhotoImage(i_resized)
|
| 1400 |
image_label.config(image=tk_image)
|
|
|
|
| 1401 |
image_label.image = tk_image # μ°Έμ‘° μ μ§
|
| 1402 |
output_file_path = "output_image.jpg"
|
| 1403 |
merged_image.save(output_file_path)
|
|
@@ -1445,7 +1394,7 @@ def generate_turbo(_seed, turbo_count, tb_access_token,width, height, positive,
|
|
| 1445 |
print('containing : ',pipe_number)
|
| 1446 |
|
| 1447 |
running_flag = True
|
| 1448 |
-
tprint("Running : request received, pipeline :"
|
| 1449 |
global error_count
|
| 1450 |
try:
|
| 1451 |
zipped_bytes = generate_image(tb_access_token, positive, "nai-diffusion-3", "generate", params)
|
|
@@ -1466,8 +1415,8 @@ def generate_turbo(_seed, turbo_count, tb_access_token,width, height, positive,
|
|
| 1466 |
temp_clipboard_image.close()
|
| 1467 |
if(pipe_number == 1 and len(image_queue) < 4): image_queue.clear()
|
| 1468 |
temp_clipboard_image = i
|
| 1469 |
-
insert_queue(i, pipe_number)
|
| 1470 |
-
tprint("image inserted, pipe number : "
|
| 1471 |
else:
|
| 1472 |
if temp_clipboard_image is not None:
|
| 1473 |
temp_clipboard_image.close()
|
|
@@ -1477,15 +1426,16 @@ def generate_turbo(_seed, turbo_count, tb_access_token,width, height, positive,
|
|
| 1477 |
globals()['tk_image'] = None
|
| 1478 |
tk_image = ImageTk.PhotoImage(i_resized)
|
| 1479 |
image_label.config(image=tk_image)
|
|
|
|
| 1480 |
image_label.image = tk_image # μ°Έμ‘° μ μ§
|
| 1481 |
except Exception as e:
|
| 1482 |
#text_output.insert(tk.END, f"Error: {e}", fg='red')
|
| 1483 |
-
log_error(
|
| 1484 |
error_count += 1
|
| 1485 |
if error_count > 5:
|
| 1486 |
mac_var.set(0)
|
| 1487 |
time.sleep(random.uniform(3.0, 9.0))
|
| 1488 |
-
insert_queue(temp_clipboard_image, pipe_number)
|
| 1489 |
|
| 1490 |
task_finished += 1 #ν°λ³΄ κΈ°λ₯μ μμ μ₯μΉμ
λλ€.
|
| 1491 |
|
|
@@ -1496,6 +1446,9 @@ def generate_turbo(_seed, turbo_count, tb_access_token,width, height, positive,
|
|
| 1496 |
last_generation_seed = params['seed']
|
| 1497 |
entry_seed_value.set(last_generation_seed)
|
| 1498 |
|
|
|
|
|
|
|
|
|
|
| 1499 |
stopped = False
|
| 1500 |
if (turbo_stop_bit):
|
| 1501 |
time.sleep(1.5)
|
|
@@ -1503,7 +1456,7 @@ def generate_turbo(_seed, turbo_count, tb_access_token,width, height, positive,
|
|
| 1503 |
button.config(state=tk.NORMAL)
|
| 1504 |
stopped = True
|
| 1505 |
if (pipe_number != 4):
|
| 1506 |
-
tprint("Stopped : request stopped before assign pipeline :"
|
| 1507 |
|
| 1508 |
if pipe_number == 4 and mac_var.get():
|
| 1509 |
wait_limit = 0
|
|
@@ -1823,7 +1776,6 @@ def apply_wildcard(artist_text, character_text, window):
|
|
| 1823 |
|
| 1824 |
window.destroy()
|
| 1825 |
|
| 1826 |
-
|
| 1827 |
def load_wildcard(text_widget, window, _type):
|
| 1828 |
global artist_wildcard_saved, character_wildcard_saved
|
| 1829 |
window.iconify()
|
|
@@ -1870,13 +1822,236 @@ def get_random_keyword(req_keyword):
|
|
| 1870 |
|
| 1871 |
def tprint(*args):
|
| 1872 |
ctext = ""
|
|
|
|
| 1873 |
for t in args:
|
| 1874 |
-
|
| 1875 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1876 |
|
| 1877 |
def on_hold_seed_button_click():
|
| 1878 |
global last_generation_seed
|
| 1879 |
-
last_generation_seed = entry_seed_value.get()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1880 |
|
| 1881 |
start_time = datetime.now().strftime('%Y%m%d_%H%M')
|
| 1882 |
thread_controller = False
|
|
@@ -1912,6 +2087,7 @@ last_generation_seed = random.randint(0,9999999999)
|
|
| 1912 |
turbo_stop_bit = False
|
| 1913 |
task_finished = 0
|
| 1914 |
error_count = 0
|
|
|
|
| 1915 |
|
| 1916 |
whitelist = wlist.whitelist
|
| 1917 |
bag_of_tags = tagbag.bag_of_tags
|
|
@@ -2033,16 +2209,12 @@ button_stop.grid(row=0, column=5, sticky='ew')
|
|
| 2033 |
button_stop.config(state='disabled')
|
| 2034 |
|
| 2035 |
# "μ€μ " λ²νΌ
|
| 2036 |
-
button_setting = tk.Button(button_frame, text="NAI
|
| 2037 |
button_setting.grid(row=0, column=6, sticky='ew')
|
| 2038 |
|
| 2039 |
-
# "ν°λ³΄" λ²νΌ
|
| 2040 |
-
#button_turbo = tk.Button(button_frame, text="ν°λ³΄", command=lambda: NAI_setting_multi(button_turbo))
|
| 2041 |
-
#button_turbo.grid(row=0, column=7, sticky='ew')
|
| 2042 |
-
|
| 2043 |
# 'μλν'μ 'ν°λ³΄on'μ ν¬ν¨ν μλΈ νλ μ μμ±
|
| 2044 |
sub_frame = tk.Frame(button_frame)
|
| 2045 |
-
sub_frame.grid(row=0, column=
|
| 2046 |
|
| 2047 |
# 'μλν' 체ν¬λ°μ€λ₯Ό μλΈ νλ μμ λ°°μΉ
|
| 2048 |
mac_var = tk.IntVar()
|
|
@@ -2054,6 +2226,10 @@ turbo_var = tk.IntVar()
|
|
| 2054 |
turbo_button = tk.Checkbutton(sub_frame, text="ν°λ³΄on", variable=turbo_var)
|
| 2055 |
turbo_button.grid(row=1, column=0, sticky='ew') # λ λ²μ§Έ νμ λ°°μΉ
|
| 2056 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2057 |
# ν
μ€νΈ λ° κ³ μ ν둬ννΈ λ€κ±°ν°λΈ λ± ν둬ννΈ μ°½
|
| 2058 |
text_frame = tk.Frame(left_frame)
|
| 2059 |
text_frame.grid(row=6, column=0, padx=5, pady=5, sticky='w')
|
|
@@ -2112,7 +2288,7 @@ character_search_button.grid(row=0, column=1, padx=2, pady=5, sticky='e')
|
|
| 2112 |
recommend_prompt_button = tk.Button(auto_hide_frame, text="μΆμ² ν둬ννΈ", command=open_prompt_window)
|
| 2113 |
recommend_prompt_button.grid(row=0, column=2, padx=2, pady=5, sticky='e') # sticky μ΅μ
μ 'e'λ‘ λ³κ²½νμ¬ μ€λ₯Έμͺ½ μ λ ¬
|
| 2114 |
|
| 2115 |
-
|
| 2116 |
|
| 2117 |
# 체ν¬λ°μ€λ€μ ν¬ν¨ν νλ μ μμ±
|
| 2118 |
checkbox_frame = tk.Frame(left_frame)
|
|
@@ -2225,6 +2401,10 @@ resolution3_frame.columnconfigure(2, weight=1)
|
|
| 2225 |
|
| 2226 |
running_state = tk.Label(resolution3_frame, text="state : idle")
|
| 2227 |
running_state.grid(row = 0, column= 0, sticky='w')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2228 |
entry_rescale_value = tk.StringVar()
|
| 2229 |
entry_rescale_label = tk.Label(resolution3_frame, text=" Prompt Guidance Rescale : ", justify=tk.LEFT)
|
| 2230 |
entry_rescale_label.grid(row=0, column=1, sticky='e')
|
|
@@ -2250,6 +2430,9 @@ hold_seed_button.grid(row=0, column=2, sticky='ew')
|
|
| 2250 |
btn_add_low_freq = tk.Button(right_frame_area16, text="μ΄λ―Έμ§λ₯Ό ν΄λ¦½λ³΄λμ 볡μ¬", fg="blue", command=copy_image_to_clipboard)
|
| 2251 |
btn_add_low_freq.grid(row=0, column=3, padx=5, pady=5, sticky='ew')
|
| 2252 |
|
|
|
|
|
|
|
|
|
|
| 2253 |
# νμμ μ΄λ―Έμ§ μμ±
|
| 2254 |
white_image = Image.new('RGB', (_size, _size), 'white')
|
| 2255 |
white_photo = ImageTk.PhotoImage(white_image)
|
|
@@ -2260,4 +2443,5 @@ image_label.image = white_photo
|
|
| 2260 |
|
| 2261 |
Auto_login_check()
|
| 2262 |
|
| 2263 |
-
window.
|
|
|
|
|
|
| 150 |
with open(f"error_log.txt", "a") as file:
|
| 151 |
file.write(error_message)
|
| 152 |
|
| 153 |
+
global access_token, access_token_multi, error_count, multi_token_enable
|
| 154 |
while (running_flag):
|
| 155 |
time.sleep(1)
|
| 156 |
try:
|
| 157 |
running_flag = True
|
| 158 |
tprint("Running : NAI request received")
|
| 159 |
+
if not (multi_token_enable): zipped_bytes = generate_image(access_token, positive, "nai-diffusion-3", "generate", params)
|
| 160 |
+
else: zipped_bytes = generate_image(access_token_multi, positive, "nai-diffusion-3", "generate", params)
|
| 161 |
d = Path(f"output_NAI/{start_time}/txt2img")
|
| 162 |
d.mkdir(parents=True, exist_ok=True)
|
| 163 |
zipped = zipfile.ZipFile(io.BytesIO(zipped_bytes))
|
|
|
|
| 173 |
globals()['tk_image'] = None
|
| 174 |
tk_image = ImageTk.PhotoImage(i_resized)
|
| 175 |
image_label.config(image=tk_image)
|
| 176 |
+
image_label.original_image = i.copy()
|
| 177 |
image_label.image = tk_image # μ°Έμ‘° μ μ§
|
| 178 |
output_file_path = "output_image.jpg"
|
| 179 |
i.save(output_file_path)
|
| 180 |
error_count = 0
|
| 181 |
except Exception as e:
|
| 182 |
#text_output.insert(tk.END, f"Error: {e}", fg='red')
|
| 183 |
+
log_error(zipped_bytes.decode('utf-8')[2:-2], "path_to_output_folder")
|
| 184 |
time.sleep(random.uniform(1.0, 2.5))
|
| 185 |
error_count += 1
|
| 186 |
if error_count > 5:
|
| 187 |
mac_var.set(0)
|
| 188 |
button.config(state=tk.NORMAL)
|
| 189 |
|
| 190 |
+
global delay_offset
|
| 191 |
+
time.sleep(delay_offset)
|
| 192 |
+
|
| 193 |
running_flag = False
|
| 194 |
last_generation_seed = params['seed']
|
| 195 |
entry_seed_value.set(last_generation_seed)
|
|
|
|
| 587 |
tprint("Stopping pipelines ... ")
|
| 588 |
|
| 589 |
def exit_program():
|
| 590 |
+
global stop_event, auto_thread
|
| 591 |
+
if stop_event is not None:
|
| 592 |
+
stop_event.set()
|
| 593 |
+
if auto_thread is not None and auto_thread.is_alive():
|
| 594 |
+
auto_thread.join() # μ€λ λκ° μ’
λ£λ λκΉμ§ κΈ°λ€λ¦Ό
|
| 595 |
window.destroy()
|
| 596 |
|
| 597 |
def save_settings():
|
|
|
|
| 704 |
window.destroy()
|
| 705 |
|
| 706 |
def on_ctrl_enter(event):
|
| 707 |
+
random_function()
|
|
|
|
| 708 |
|
| 709 |
def on_shift_enter(event):
|
| 710 |
random_function()
|
|
|
|
| 746 |
def for_canonical(f):
|
| 747 |
return lambda k: f(listener.canonical(k))
|
| 748 |
|
| 749 |
+
# λΌλ²¨μ μ
λ°μ΄νΈνλ ν¨μ
|
| 750 |
+
def update_label(label, text):
|
| 751 |
+
def task():
|
| 752 |
+
label.config(text=text)
|
| 753 |
+
label.after(1000, task) # λ©μΈ μ€λ λμμ UI μ
λ°μ΄νΈ
|
| 754 |
+
|
| 755 |
+
def NAI_generation(width, height, button):
|
| 756 |
+
global access_token_multi, NAI_width, NAI_height
|
| 757 |
+
global button_stop, running_flag
|
| 758 |
+
|
| 759 |
+
def run_function():
|
| 760 |
+
time.sleep(1)
|
| 761 |
+
random_function()
|
| 762 |
+
time.sleep(2)
|
| 763 |
+
window.event_generate(GENERATE_EVENT, when="tail")
|
| 764 |
+
|
| 765 |
+
pretest = text_output.get("1.0", tk.END).split(', ')
|
| 766 |
+
if (turbo_var.get() == 1):
|
| 767 |
+
if ( 'sex' not in pretest or '1girl' not in pretest or '1boy' not in pretest):
|
| 768 |
+
tprint('λΆμ€νΈ κΈ°λ₯μ 1girl, 1boy, sex μΈκ°μ§ ν€μλκ° μμ΄μΌ λμν©λλ€.','color=red')
|
| 769 |
+
if not mac_var.get():
|
| 770 |
+
button.config(state='normal')
|
| 771 |
+
return
|
| 772 |
+
else:
|
| 773 |
+
thread = threading.Thread(target=run_function)
|
| 774 |
+
thread.start()
|
| 775 |
+
return
|
| 776 |
+
|
| 777 |
+
if(rand_resolution_var.get() == 1):
|
| 778 |
+
resolutions = ["1024 x 1024", "960 x 1088", "896 x 1152", "832 x 1216", "1088 x 960", "1152 x 896", "1216 x 832"]
|
| 779 |
+
random_resolution = random.choice(resolutions)
|
| 780 |
+
selected_resolution.set(random_resolution)
|
| 781 |
+
|
| 782 |
+
if(turbo_var.get() == 1 and access_token):
|
| 783 |
+
button_stop.config(state='normal')
|
| 784 |
+
NAI_generation_turbo(NAI_width, NAI_height, button)
|
| 785 |
+
else:
|
| 786 |
+
if not (running_flag):
|
| 787 |
+
NAI_generation_normal(NAI_width, NAI_height, button)
|
| 788 |
+
|
| 789 |
+
def Auto_login_check():
|
| 790 |
+
global access_token, access_token_multi
|
| 791 |
+
if os.path.exists('token.txt'):
|
| 792 |
+
with open('token.txt', 'r', encoding='utf-8') as f:
|
| 793 |
+
tokens = f.readlines()
|
| 794 |
+
if(tokens[0]):
|
| 795 |
+
access_token = tokens[0].strip()
|
| 796 |
+
tprint("1 Account automatically loaded : ",access_token[-5:])
|
| 797 |
+
try:
|
| 798 |
+
if(len(tokens)>=2):
|
| 799 |
+
access_token_multi = tokens[1].strip()
|
| 800 |
+
tprint("2 Account automatically loaded : ",access_token[-5:]+", "+access_token_multi[-5:])
|
| 801 |
+
except:
|
| 802 |
+
access_token_multi = None
|
| 803 |
+
if(access_token): button_generate.config(state='normal')
|
| 804 |
|
| 805 |
def character_search_thread():
|
| 806 |
search_thread = threading.Thread(target=character_search, daemon=True)
|
|
|
|
| 1029 |
all_keywords = sorted(cd.character_dictionary.items(), key=lambda item: item[1], reverse=True)
|
| 1030 |
for keyword, count in all_keywords:
|
| 1031 |
listbox.insert(tk.END, f"{keyword} - {count}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1032 |
|
| 1033 |
def NAI_generation_normal(width, height, button):
|
| 1034 |
button.config(state=tk.DISABLED)
|
| 1035 |
positive = text_output.get("1.0", tk.END)
|
| 1036 |
negative = negative_text.get("1.0", "end-1c").strip()
|
| 1037 |
+
global auto_count_left_flag, auto_count_left
|
| 1038 |
+
if(auto_count_left_flag and auto_count_left > 0):
|
| 1039 |
+
auto_count_left -= 1
|
| 1040 |
thread = threading.Thread(target=generate, args=(width, height, positive, negative, button))
|
| 1041 |
thread.start()
|
| 1042 |
|
|
|
|
| 1045 |
button.config(state=tk.DISABLED)
|
| 1046 |
positive = text_output.get("1.0", tk.END)
|
| 1047 |
negative = negative_text.get("1.0", "end-1c").strip()
|
|
|
|
| 1048 |
|
| 1049 |
def SELECT(positive):
|
| 1050 |
lines = positive[:25]
|
|
|
|
| 1226 |
sleep2 = sleep1 + random.uniform(13.5,19.5)
|
| 1227 |
sleep3 = sleep2 + random.uniform(13.5,19.5)
|
| 1228 |
|
| 1229 |
+
global auto_count_left_flag, auto_count_left, turbo_stop_bit
|
| 1230 |
+
if(auto_count_left_flag and auto_count_left > 0):
|
| 1231 |
+
auto_count_left -= 5
|
| 1232 |
thread_init = threading.Thread(target=generate_turbo, args=(seed,turbo_count, access_token, width, height, positive, negative, button, 0, 0))
|
| 1233 |
thread_init.start()
|
| 1234 |
thread0 = threading.Thread(target=generate_turbo, args=(seed,turbo_count, access_token, width, height, positive0, negative, button, 1, sleep0))
|
|
|
|
| 1314 |
|
| 1315 |
return new_image
|
| 1316 |
|
| 1317 |
+
def insert_queue(i, _number, turbo_count):
|
| 1318 |
global image_queue, temp_clipboard_image
|
| 1319 |
while len(image_queue) < 4: image_queue.append(None)
|
| 1320 |
if _number <= 4:
|
|
|
|
| 1330 |
globals()['tk_image'] = None
|
| 1331 |
tk_image = ImageTk.PhotoImage(i_resized)
|
| 1332 |
image_label.config(image=tk_image)
|
| 1333 |
+
image_label.original_image = i.copy()
|
| 1334 |
image_label.image = tk_image # μ°Έμ‘° μ μ§
|
| 1335 |
if all(img is not None for img in image_queue):
|
| 1336 |
time.sleep(5)
|
| 1337 |
merged_image = merge_images(image_queue)
|
| 1338 |
temp_clipboard_image = merged_image.copy()
|
| 1339 |
if merged_image is not None:
|
| 1340 |
+
output_directory = Path(f"output_NAI/{start_time}/turbo/grid")
|
| 1341 |
+
output_directory.mkdir(parents=True, exist_ok=True)
|
| 1342 |
+
file_path = output_directory / f"{turbo_count:05}.png"
|
| 1343 |
+
merged_image.save(file_path)
|
| 1344 |
i_resized = resize_and_fill(merged_image)
|
| 1345 |
if 'tk_image' in globals():
|
| 1346 |
globals()['tk_image'] = None
|
| 1347 |
tk_image = ImageTk.PhotoImage(i_resized)
|
| 1348 |
image_label.config(image=tk_image)
|
| 1349 |
+
image_label.original_image = i_resized.copy()
|
| 1350 |
image_label.image = tk_image # μ°Έμ‘° μ μ§
|
| 1351 |
output_file_path = "output_image.jpg"
|
| 1352 |
merged_image.save(output_file_path)
|
|
|
|
| 1394 |
print('containing : ',pipe_number)
|
| 1395 |
|
| 1396 |
running_flag = True
|
| 1397 |
+
tprint("Running : request received, pipeline : "+str(pipe_number))
|
| 1398 |
global error_count
|
| 1399 |
try:
|
| 1400 |
zipped_bytes = generate_image(tb_access_token, positive, "nai-diffusion-3", "generate", params)
|
|
|
|
| 1415 |
temp_clipboard_image.close()
|
| 1416 |
if(pipe_number == 1 and len(image_queue) < 4): image_queue.clear()
|
| 1417 |
temp_clipboard_image = i
|
| 1418 |
+
insert_queue(i, pipe_number, turbo_count)
|
| 1419 |
+
tprint("image inserted, pipe number : "+str(pipe_number))
|
| 1420 |
else:
|
| 1421 |
if temp_clipboard_image is not None:
|
| 1422 |
temp_clipboard_image.close()
|
|
|
|
| 1426 |
globals()['tk_image'] = None
|
| 1427 |
tk_image = ImageTk.PhotoImage(i_resized)
|
| 1428 |
image_label.config(image=tk_image)
|
| 1429 |
+
image_label.original_image = i.copy()
|
| 1430 |
image_label.image = tk_image # μ°Έμ‘° μ μ§
|
| 1431 |
except Exception as e:
|
| 1432 |
#text_output.insert(tk.END, f"Error: {e}", fg='red')
|
| 1433 |
+
log_error(zipped_bytes.decode('utf-8')[2:-2], "path_to_output_folder")
|
| 1434 |
error_count += 1
|
| 1435 |
if error_count > 5:
|
| 1436 |
mac_var.set(0)
|
| 1437 |
time.sleep(random.uniform(3.0, 9.0))
|
| 1438 |
+
insert_queue(temp_clipboard_image, pipe_number, turbo_count)
|
| 1439 |
|
| 1440 |
task_finished += 1 #ν°λ³΄ κΈ°λ₯μ μμ μ₯μΉμ
λλ€.
|
| 1441 |
|
|
|
|
| 1446 |
last_generation_seed = params['seed']
|
| 1447 |
entry_seed_value.set(last_generation_seed)
|
| 1448 |
|
| 1449 |
+
global delay_offset
|
| 1450 |
+
time.sleep(delay_offset)
|
| 1451 |
+
|
| 1452 |
stopped = False
|
| 1453 |
if (turbo_stop_bit):
|
| 1454 |
time.sleep(1.5)
|
|
|
|
| 1456 |
button.config(state=tk.NORMAL)
|
| 1457 |
stopped = True
|
| 1458 |
if (pipe_number != 4):
|
| 1459 |
+
tprint("Stopped : request stopped before assign pipeline :"+str(pipe_number+1))
|
| 1460 |
|
| 1461 |
if pipe_number == 4 and mac_var.get():
|
| 1462 |
wait_limit = 0
|
|
|
|
| 1776 |
|
| 1777 |
window.destroy()
|
| 1778 |
|
|
|
|
| 1779 |
def load_wildcard(text_widget, window, _type):
|
| 1780 |
global artist_wildcard_saved, character_wildcard_saved
|
| 1781 |
window.iconify()
|
|
|
|
| 1822 |
|
| 1823 |
def tprint(*args):
|
| 1824 |
ctext = ""
|
| 1825 |
+
color = None
|
| 1826 |
for t in args:
|
| 1827 |
+
if(type(t) is str and 'color=' in t):
|
| 1828 |
+
color = t[6:]
|
| 1829 |
+
else:
|
| 1830 |
+
ctext += str(t)
|
| 1831 |
+
if not color: running_state.config(text=ctext, fg='black')
|
| 1832 |
+
else: running_state.config(text=ctext, fg='red')
|
| 1833 |
+
|
| 1834 |
+
|
| 1835 |
+
def show_automation_option():
|
| 1836 |
+
global auto_thread, stop_event
|
| 1837 |
+
top = tk.Toplevel(window)
|
| 1838 |
+
top.title("Automation Stop Condition")
|
| 1839 |
+
|
| 1840 |
+
global var, timer_label, timer_entry, count_label, count_entry
|
| 1841 |
+
var = tk.StringVar(value="unlimited")
|
| 1842 |
+
|
| 1843 |
+
def show_option():
|
| 1844 |
+
if var.get() == 'timer':
|
| 1845 |
+
timer_label.grid(row=4, column=0)
|
| 1846 |
+
timer_entry.grid(row=4, column=1)
|
| 1847 |
+
count_label.grid_forget()
|
| 1848 |
+
count_entry.grid_forget()
|
| 1849 |
+
elif var.get() == 'count':
|
| 1850 |
+
count_label.grid(row=4, column=0)
|
| 1851 |
+
count_entry.grid(row=4, column=1)
|
| 1852 |
+
timer_label.grid_forget()
|
| 1853 |
+
timer_entry.grid_forget()
|
| 1854 |
+
else:
|
| 1855 |
+
timer_label.grid_forget()
|
| 1856 |
+
timer_entry.grid_forget()
|
| 1857 |
+
count_label.grid_forget()
|
| 1858 |
+
count_entry.grid_forget()
|
| 1859 |
+
|
| 1860 |
+
label_time = tk.Label(top, text="μ΄λ―Έμ§ μμ±λΉ μ§μ°μκ° μΆκ° (μ΄)")
|
| 1861 |
+
label_time.grid(row=0, column=0, columnspan=3)
|
| 1862 |
+
|
| 1863 |
+
delay_entry = tk.Entry(top)
|
| 1864 |
+
delay_entry.grid(row=1, column=0, columnspan=3)
|
| 1865 |
+
|
| 1866 |
+
label = tk.Label(top, text="μλν μ’
λ£ μ‘°κ±΄")
|
| 1867 |
+
label.grid(row=2, column=0, columnspan=3)
|
| 1868 |
+
|
| 1869 |
+
radio1 = tk.Radiobutton(top, text="무μ ν", variable=var, value="unlimited", command=show_option)
|
| 1870 |
+
radio1.grid(row=3, column=0)
|
| 1871 |
+
|
| 1872 |
+
radio2 = tk.Radiobutton(top, text="νμ΄λ¨Έ", variable=var, value="timer", command=show_option)
|
| 1873 |
+
radio2.grid(row=3, column=1)
|
| 1874 |
+
|
| 1875 |
+
radio3 = tk.Radiobutton(top, text="μμ± μΉ΄μ΄νΈ", variable=var, value="count", command=show_option)
|
| 1876 |
+
radio3.grid(row=3, column=2)
|
| 1877 |
+
|
| 1878 |
+
timer_label = tk.Label(top, text="μλν λμ μκ°(λΆ) :")
|
| 1879 |
+
timer_entry = tk.Entry(top)
|
| 1880 |
+
|
| 1881 |
+
count_label = tk.Label(top, text="μλ μμ± νμ:")
|
| 1882 |
+
count_entry = tk.Entry(top)
|
| 1883 |
+
|
| 1884 |
+
# "A.μ€μ " μ°½μμ λ²νΌ ν΄λ¦ μ΄λ²€νΈ μ²λ¦¬
|
| 1885 |
+
def on_apply(top):
|
| 1886 |
+
global auto_time_left_flag, auto_time_left, auto_count_left_flag, auto_count_left, delay_offset, delay_offset_label
|
| 1887 |
+
|
| 1888 |
+
selected_option = var.get()
|
| 1889 |
+
if delay_entry.get():
|
| 1890 |
+
try:
|
| 1891 |
+
delay_offset = round(float(delay_entry.get()), 1)
|
| 1892 |
+
delay_offset_label.config(text="Dealy offset : "+str(delay_offset))
|
| 1893 |
+
except ValueError as e:
|
| 1894 |
+
print(e)
|
| 1895 |
+
delay_offset = 0
|
| 1896 |
+
else:
|
| 1897 |
+
delay_offset = 0
|
| 1898 |
+
delay_offset_label.config(text="")
|
| 1899 |
+
if selected_option == "timer":
|
| 1900 |
+
auto_time_left_flag = True
|
| 1901 |
+
auto_count_left_flag = False
|
| 1902 |
+
try:
|
| 1903 |
+
# μνΈλ¦¬μμ μ
λ ₯λ μκ°μ λΆ λ¨μμμ μ΄ λ¨μλ‘ λ³ν
|
| 1904 |
+
auto_time_left = int(timer_entry.get()) * 60
|
| 1905 |
+
except ValueError:
|
| 1906 |
+
# μλͺ»λ μ
λ ₯ μ²λ¦¬
|
| 1907 |
+
print("Invalid input for timer. Please enter a number.")
|
| 1908 |
+
return
|
| 1909 |
+
elif selected_option == "count":
|
| 1910 |
+
auto_count_left_flag = True
|
| 1911 |
+
auto_time_left_flag = False
|
| 1912 |
+
try:
|
| 1913 |
+
auto_count_left = int(count_entry.get())
|
| 1914 |
+
except ValueError:
|
| 1915 |
+
# μλͺ»λ μ
λ ₯ μ²λ¦¬
|
| 1916 |
+
print("Invalid input for count. Please enter a number.")
|
| 1917 |
+
return
|
| 1918 |
+
else:
|
| 1919 |
+
auto_time_left_flag = False
|
| 1920 |
+
auto_count_left_flag = False
|
| 1921 |
+
stop_auto_thread() # μ΄μ μ€λ λ μ’
λ£
|
| 1922 |
+
start_auto_thread() # μ μ€λ λ μμ
|
| 1923 |
+
mac_var.set(1)
|
| 1924 |
+
top.destroy()
|
| 1925 |
+
|
| 1926 |
+
apply_button = tk.Button(top, text="μ μ©", command=lambda: on_apply(top))
|
| 1927 |
+
stop_button = tk.Button(top, text="μ€λ¨", command=on_stop)
|
| 1928 |
+
close_button = tk.Button(top, text="λ«κΈ°", command=top.destroy)
|
| 1929 |
+
|
| 1930 |
+
apply_button.grid(row=5, column=0, pady=5)
|
| 1931 |
+
stop_button.grid(row=5, column=1, pady=5)
|
| 1932 |
+
close_button.grid(row=5, column=2, pady=5)
|
| 1933 |
+
|
| 1934 |
+
def auto_time_thread(stop_event):
|
| 1935 |
+
global auto_time_left, auto_time_left_flag
|
| 1936 |
+
|
| 1937 |
+
def seconds_to_hms(seconds):
|
| 1938 |
+
h = seconds // 3600
|
| 1939 |
+
m = (seconds % 3600) // 60
|
| 1940 |
+
s = seconds % 60
|
| 1941 |
+
return f"{h:02d}:{m:02d}:{s:02d}"
|
| 1942 |
+
|
| 1943 |
+
def update_label_for_time_finished():
|
| 1944 |
+
automation_state.config(text="μ§μ ν μκ°μ΄ λͺ¨λ μμ§λμ΄ μλνκ° μ’
λ£λμμ΅λλ€.")
|
| 1945 |
+
auto_time_left_flag = False
|
| 1946 |
+
mac_var.set(0)
|
| 1947 |
+
|
| 1948 |
+
while not stop_event.is_set() and auto_time_left > 0:
|
| 1949 |
+
time.sleep(1)
|
| 1950 |
+
auto_time_left -= 1
|
| 1951 |
+
remaining_time = seconds_to_hms(auto_time_left)
|
| 1952 |
+
window.after(0, lambda: automation_state.config(text=f"μλν λ¨μμκ° : {remaining_time}"))
|
| 1953 |
+
|
| 1954 |
+
if auto_time_left <= 0:
|
| 1955 |
+
window.after(0, update_label_for_time_finished)
|
| 1956 |
+
|
| 1957 |
+
if stop_event.is_set():
|
| 1958 |
+
window.after(0, lambda: automation_state.config(text="Conditional automation not set (A.μ€μ )"))
|
| 1959 |
+
auto_time_left_flag = False
|
| 1960 |
+
|
| 1961 |
+
def auto_count_thread(stop_event):
|
| 1962 |
+
global auto_count_left, auto_count_left_flag
|
| 1963 |
+
|
| 1964 |
+
def update_label_for_count_finished():
|
| 1965 |
+
mac_var.set(0) # μλν μ’
λ£ μ‘°κ±΄ μΆ©μ‘±
|
| 1966 |
+
auto_count_left_flag = False
|
| 1967 |
+
automation_state.config(text="μ§μ ν νμκ° λͺ¨λ μμ§λμ΄ μλνκ° μ’
λ£λμμ΅λλ€.")
|
| 1968 |
+
|
| 1969 |
+
while not stop_event.is_set():
|
| 1970 |
+
time.sleep(1) # μ£ΌκΈ°μ μΌλ‘ νμΈ
|
| 1971 |
+
window.after(0, lambda: automation_state.config(text=f"μλν λ¨μνμ : {auto_count_left}"))
|
| 1972 |
+
if auto_count_left <= 0:
|
| 1973 |
+
window.after(0, update_label_for_count_finished)
|
| 1974 |
+
break # 루ν νμΆ
|
| 1975 |
+
if stop_event.is_set():
|
| 1976 |
+
window.after(0, lambda: automation_state.config(text="Conditional automation not set (A.μ€μ )"))
|
| 1977 |
+
mac_var.set(0)
|
| 1978 |
+
auto_count_left_flag = False
|
| 1979 |
+
|
| 1980 |
+
# μ€λ λ μμ λ° μ’
λ£ ν¨μ
|
| 1981 |
+
def start_auto_thread():
|
| 1982 |
+
global auto_thread, stop_event
|
| 1983 |
+
stop_event = threading.Event()
|
| 1984 |
+
auto_thread = None
|
| 1985 |
+
|
| 1986 |
+
if auto_time_left_flag:
|
| 1987 |
+
auto_thread = threading.Thread(target=auto_time_thread, args=(stop_event,))
|
| 1988 |
+
elif auto_count_left_flag:
|
| 1989 |
+
auto_thread = threading.Thread(target=auto_count_thread, args=(stop_event,))
|
| 1990 |
+
|
| 1991 |
+
if auto_thread is not None:
|
| 1992 |
+
auto_thread.start()
|
| 1993 |
+
|
| 1994 |
+
def stop_auto_thread():
|
| 1995 |
+
global stop_event, auto_thread
|
| 1996 |
+
if stop_event is not None:
|
| 1997 |
+
stop_event.set()
|
| 1998 |
+
#if auto_thread is not None and auto_thread.is_alive():
|
| 1999 |
+
# auto_thread.join()
|
| 2000 |
+
|
| 2001 |
+
def on_stop():
|
| 2002 |
+
global auto_thread, stop_event
|
| 2003 |
+
stop_auto_thread() # μ€λ λ μ’
λ£
|
| 2004 |
|
| 2005 |
def on_hold_seed_button_click():
|
| 2006 |
global last_generation_seed
|
| 2007 |
+
last_generation_seed = entry_seed_value.get()
|
| 2008 |
+
|
| 2009 |
+
def update_fullscreen_image(new_window, new_image_label):
|
| 2010 |
+
last_updated_image = None
|
| 2011 |
+
while True:
|
| 2012 |
+
time.sleep(1)
|
| 2013 |
+
if not new_window.winfo_exists():
|
| 2014 |
+
break
|
| 2015 |
+
try:
|
| 2016 |
+
current_image = getattr(image_label, 'original_image', None)
|
| 2017 |
+
if current_image and current_image != last_updated_image:
|
| 2018 |
+
resized_image = resize_image_to_fit(current_image, new_window.winfo_height())
|
| 2019 |
+
tk_image = ImageTk.PhotoImage(resized_image)
|
| 2020 |
+
new_window.after(0, lambda img=tk_image: new_image_label.config(image=img))
|
| 2021 |
+
new_image_label.image = tk_image
|
| 2022 |
+
last_updated_image = current_image
|
| 2023 |
+
except ValueError:
|
| 2024 |
+
print(ValueError)
|
| 2025 |
+
|
| 2026 |
+
def show_fullscreen_image():
|
| 2027 |
+
new_window = tk.Toplevel()
|
| 2028 |
+
new_window.attributes('-fullscreen', True)
|
| 2029 |
+
new_window.configure(bg='black')
|
| 2030 |
+
|
| 2031 |
+
new_image_label = tk.Label(new_window, relief='solid', borderwidth=1, bg='black')
|
| 2032 |
+
new_image_label.pack(expand=True, fill='both')
|
| 2033 |
+
new_window.bind("<Escape>", lambda e: new_window.destroy())
|
| 2034 |
+
|
| 2035 |
+
update_thread = threading.Thread(target=update_fullscreen_image, args=(new_window, new_image_label))
|
| 2036 |
+
update_thread.daemon = True
|
| 2037 |
+
update_thread.start()
|
| 2038 |
+
|
| 2039 |
+
def resize_image_to_fit(image, target_height):
|
| 2040 |
+
original_width, original_height = image.size
|
| 2041 |
+
|
| 2042 |
+
ratio = target_height / float(original_height)
|
| 2043 |
+
new_width = int(original_width * ratio)
|
| 2044 |
+
|
| 2045 |
+
resized_image = image.resize((new_width, target_height), Image.Resampling.LANCZOS)
|
| 2046 |
+
return resized_image
|
| 2047 |
+
|
| 2048 |
+
auto_time_left_flag = False
|
| 2049 |
+
auto_time_left = 0
|
| 2050 |
+
auto_count_left_flag = False
|
| 2051 |
+
auto_count_left = 0
|
| 2052 |
+
stop_event = None
|
| 2053 |
+
auto_thread = None
|
| 2054 |
+
delay_offset = 0
|
| 2055 |
|
| 2056 |
start_time = datetime.now().strftime('%Y%m%d_%H%M')
|
| 2057 |
thread_controller = False
|
|
|
|
| 2087 |
turbo_stop_bit = False
|
| 2088 |
task_finished = 0
|
| 2089 |
error_count = 0
|
| 2090 |
+
multi_token_enable = False
|
| 2091 |
|
| 2092 |
whitelist = wlist.whitelist
|
| 2093 |
bag_of_tags = tagbag.bag_of_tags
|
|
|
|
| 2209 |
button_stop.config(state='disabled')
|
| 2210 |
|
| 2211 |
# "μ€μ " λ²νΌ
|
| 2212 |
+
button_setting = tk.Button(button_frame, text="NAI μ€μ ", command=lambda: NAI_setting(button_setting, button_generate))
|
| 2213 |
button_setting.grid(row=0, column=6, sticky='ew')
|
| 2214 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2215 |
# 'μλν'μ 'ν°λ³΄on'μ ν¬ν¨ν μλΈ νλ μ μμ±
|
| 2216 |
sub_frame = tk.Frame(button_frame)
|
| 2217 |
+
sub_frame.grid(row=0, column=7, sticky='ns') # μλΈ νλ μμ μ΄ 8μ λ°°μΉ
|
| 2218 |
|
| 2219 |
# 'μλν' 체ν¬λ°μ€λ₯Ό μλΈ νλ μμ λ°°μΉ
|
| 2220 |
mac_var = tk.IntVar()
|
|
|
|
| 2226 |
turbo_button = tk.Checkbutton(sub_frame, text="ν°λ³΄on", variable=turbo_var)
|
| 2227 |
turbo_button.grid(row=1, column=0, sticky='ew') # λ λ²μ§Έ νμ λ°°μΉ
|
| 2228 |
|
| 2229 |
+
# "A.μ€μ " λ²νΌ
|
| 2230 |
+
button_auto_setting = tk.Button(button_frame, text="A.μ€μ ", command=show_automation_option)
|
| 2231 |
+
button_auto_setting.grid(row=0, column=8, sticky='ew')
|
| 2232 |
+
|
| 2233 |
# ν
μ€νΈ λ° κ³ μ ν둬ννΈ λ€κ±°ν°λΈ λ± ν둬ννΈ μ°½
|
| 2234 |
text_frame = tk.Frame(left_frame)
|
| 2235 |
text_frame.grid(row=6, column=0, padx=5, pady=5, sticky='w')
|
|
|
|
| 2288 |
recommend_prompt_button = tk.Button(auto_hide_frame, text="μΆμ² ν둬ννΈ", command=open_prompt_window)
|
| 2289 |
recommend_prompt_button.grid(row=0, column=2, padx=2, pady=5, sticky='e') # sticky μ΅μ
μ 'e'λ‘ λ³κ²½νμ¬ μ€λ₯Έμͺ½ μ λ ¬
|
| 2290 |
|
| 2291 |
+
|
| 2292 |
|
| 2293 |
# 체ν¬λ°μ€λ€μ ν¬ν¨ν νλ μ μμ±
|
| 2294 |
checkbox_frame = tk.Frame(left_frame)
|
|
|
|
| 2401 |
|
| 2402 |
running_state = tk.Label(resolution3_frame, text="state : idle")
|
| 2403 |
running_state.grid(row = 0, column= 0, sticky='w')
|
| 2404 |
+
automation_state = tk.Label(resolution3_frame, text="Conditional automation not set (A.μ€μ )")
|
| 2405 |
+
automation_state.grid(row = 1, column= 0, sticky='w')
|
| 2406 |
+
delay_offset_label = tk.Label(resolution3_frame, text="Dealy offset : "+str(delay_offset))
|
| 2407 |
+
delay_offset_label.grid(row = 1, column= 1, sticky='e')
|
| 2408 |
entry_rescale_value = tk.StringVar()
|
| 2409 |
entry_rescale_label = tk.Label(resolution3_frame, text=" Prompt Guidance Rescale : ", justify=tk.LEFT)
|
| 2410 |
entry_rescale_label.grid(row=0, column=1, sticky='e')
|
|
|
|
| 2430 |
btn_add_low_freq = tk.Button(right_frame_area16, text="μ΄λ―Έμ§λ₯Ό ν΄λ¦½λ³΄λμ 볡μ¬", fg="blue", command=copy_image_to_clipboard)
|
| 2431 |
btn_add_low_freq.grid(row=0, column=3, padx=5, pady=5, sticky='ew')
|
| 2432 |
|
| 2433 |
+
show_fullscreen_btn = tk.Button(right_frame_area16, text="μ 체νλ©΄ 보기 (ESCλ‘ λ«κΈ°)", command=show_fullscreen_image)
|
| 2434 |
+
show_fullscreen_btn.grid(row=0, column=4, padx=5, pady=5, sticky='ew')
|
| 2435 |
+
|
| 2436 |
# νμμ μ΄λ―Έμ§ μμ±
|
| 2437 |
white_image = Image.new('RGB', (_size, _size), 'white')
|
| 2438 |
white_photo = ImageTk.PhotoImage(white_image)
|
|
|
|
| 2443 |
|
| 2444 |
Auto_login_check()
|
| 2445 |
|
| 2446 |
+
window.protocol("WM_DELETE_WINDOW", exit_program)
|
| 2447 |
+
window.mainloop()
|