Upload 2 files
Browse filesFiles changed (2)
123version https://git-lfs.github.com/spec/v1oid sha256:297fdc6f69a9dae7741ccc9027eaf3e732557715b97cf37ceee89ad359f7ed05size 150864130123version https://git-lfs.github.com/spec/v1oid sha256:99a1fa3d70fb86abd05f3b1ab6b731597d1e81ff3a2c0e3e8668db60d81aa7b2size 150866140
149 unmodified lines1501511521531541551561571581591601611629 unmodified lines172173174175176177178179180181182183184185186187188189190391 unmodified lines582583584585586587106 unmodified lines69469569669769869970070135 unmodified lines737738739740741742743744745746747222 unmodified lines9709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011012 unmodified lines1104110511061107110811091110175 unmodified lines12861287128812891290129179 unmodified lines13711372137313741375137613779 unmodified lines1387138813891390139113921393139413951396139713981399140014011402140341 unmodified lines144514461447144814491450145114 unmodified lines146614671468146914701471147214733 unmodified lines1477147814791480148114821483148414851486148714881489149014914 unmodified lines1496149714981499150015011 unmodified line1503150415051506150715081509313 unmodified lines182318241825182618271828182940 unmodified lines187018711872187318741875187618771878187918801881188229 unmodified lines191219131914191519161917115 unmodified lines20332034203520362037203820392040204120422043204420452046204720485 unmodified lines20542055205620572058205952 unmodified lines2112211321142115211621172118106 unmodified lines22252226222722282229223019 unmodified lines2250225122522253225422554 unmodified lines2260226122622263149 unmodified lineswith open(f"error_log.txt", "a") as file:file.write(error_message)global access_token, error_countwhile (running_flag):time.sleep(1)try:running_flag = Truetprint("Running : NAI request received")zipped_bytes = generate_image(access_token, positive, "nai-diffusion-3", "generate", params)d = Path(f"output_NAI/{start_time}/txt2img")d.mkdir(parents=True, exist_ok=True)zipped = zipfile.ZipFile(io.BytesIO(zipped_bytes))9 unmodified linesglobals()['tk_image'] = Nonetk_image = ImageTk.PhotoImage(i_resized)image_label.config(image=tk_image)image_label.image = tk_image # ์ฐธ์กฐ ์ ์งoutput_file_path = "output_image.jpg"i.save(output_file_path)error_count = 0except Exception as e:#text_output.insert(tk.END, f"Error: {e}", fg='red')log_error(e, "path_to_output_folder")time.sleep(random.uniform(1.0, 2.5))error_count += 1if error_count > 5:mac_var.set(0)button.config(state=tk.NORMAL)running_flag = Falselast_generation_seed = params['seed']entry_seed_value.set(last_generation_seed)391 unmodified linestprint("Stopping pipelines ... ")def exit_program():window.destroy()def save_settings():106 unmodified lineswindow.destroy()def on_ctrl_enter(event):#NAI_generation(NAI_width, NAI_height, button_generate)passdef on_shift_enter(event):random_function()35 unmodified linesdef for_canonical(f):return lambda k: f(listener.canonical(k))def on_release(key):try:current_keys.remove(key)except KeyError:passdef character_search_thread():search_thread = threading.Thread(target=character_search, daemon=True)222 unmodified linesall_keywords = sorted(cd.character_dictionary.items(), key=lambda item: item[1], reverse=True)for keyword, count in all_keywords:listbox.insert(tk.END, f"{keyword} - {count}")def v_automatic(save_position, prompt_position):# ํ๋กฌํํธ ์ฐฝ ํด๋ฆญcopy_to_clipboard()pyautogui.click(prompt_position)time.sleep(0.5)random_function()pyautogui.hotkey('ctrl', 'a', 'v','Right','Right','Enter')time.sleep(0.5)pyautogui.click(save_position)def start_automation(save_position, prompt_position, label, window_to_close, automation_event):def automation_task():while automation_event.is_set():random_delay = random.uniform(17.5, 23.5)next_click_time = time.time() + random_delaywhile time.time() < next_click_time and automation_event.is_set():time_remaining = max(next_click_time - time.time(), 0)label.config(text=f"๋ค์ ํด๋ฆญ๊น์ง: {time_remaining:.2f}์ด")time.sleep(0.1)if automation_event.is_set():v_automatic(save_position, prompt_position)automation_thread = threading.Thread(target=automation_task, daemon=True)automation_thread.start()random_function()def stop_automation():automation_event.clear()window_to_close.destroy()window_to_close.protocol("WM_DELETE_WINDOW", stop_automation)def stop_automation(window_to_close, automation_event, start_button, stop_button):automation_event.clear() # Stop the automation taskstart_button['state'] = 'normal' # Enable the start buttonstop_button['state'] = 'disabled' # Disable the stop buttonwindow_to_close.destroy() # Close the automation windowwindow.deiconify()# ๋ผ๋ฒจ์ ์ ๋ฐ์ดํธํ๋ ํจ์def update_label(label, text):def task():label.config(text=text)label.after(1000, task) # ๋ฉ์ธ ์ค๋ ๋์์ UI ์ ๋ฐ์ดํธdef open_automation_window():window.iconify()automation_event = threading.Event()automation_event.set() # Enable the automation eventauto_window = tk.Toplevel(window)auto_window.title("์๋ํ ์ค์ ")auto_window.geometry("300x200") # ์ฐฝ ํฌ๊ธฐ ์กฐ์ auto_window.attributes('-topmost', True) # ์ฐฝ์ ํญ์ ๋งจ ์์ ์์นauto_window.focus_force() # ์ฐฝ ์ด๋ฆด ๋ ํฌ์ปค์ค ๊ฐ์ ์ด๋save_position = Noneprompt_position = Noneautomation_running = threading.Event()def get_mouse_position(event=None):nonlocal save_position, prompt_positionx, y = pyautogui.position()if not save_position:save_position = (x, y)position_label.config(text=f"์ ์ฅ ๋ฒํผ์ ์ขํ: {x}, {y}\nํ๋กฌํํธ ์ฐฝ์ ์ขํ: ")elif not prompt_position:prompt_position = (x, y)position_label.config(text=f"์ ์ฅ ๋ฒํผ์ ์ขํ: {save_position[0]}, {save_position[1]}\nํ๋กฌํํธ ์ฐฝ์ ์ขํ: {x}, {y}")start_button.config(state="normal")if save_position and prompt_position:start_button.config(state="normal")stop_button.config(state="normal")position_label = tk.Label(auto_window, text="์ํฐ๋ฅผ ๋๋ฌ ๋ง์ฐ์ค ์ขํ๋ฅผ ์ ์ฅํ์ธ์\n(ํด๋ฆญ X, 1.์ ์ฅ->2.ํ๋กฌํํธ์ฐฝ ์์)", justify=tk.LEFT)position_label.pack(pady=10)start_button = tk.Button(auto_window, text="์์", state="disabled",command=lambda: start_automation(save_position, prompt_position, countdown_label, auto_window, automation_event))start_button.pack(side=tk.LEFT, fill='x', expand=True)stop_button = tk.Button(auto_window, text="์ค์ง", state="disabled",command=lambda: stop_automation(auto_window, automation_event, start_button, stop_button))stop_button.pack(side=tk.RIGHT, fill='x', expand=True)countdown_label = tk.Label(auto_window, text="")countdown_label.pack(pady=10)auto_window.bind('<Return>', get_mouse_position)def NAI_generation(width, height, button):global access_token_multi, NAI_width, NAI_heightglobal button_stop, running_flagpretest = text_output.get("1.0", tk.END).split(', ')if (turbo_var.get() == 1):if ( 'sex' not in pretest or '1girl' not in pretest or '1boy' not in pretest):tprint('ํ์ฌ ๋ถ์คํธ ๊ธฐ๋ฅ์ 1girl, 1boy, sex ์ธ๊ฐ์ง ํค์๋๊ฐ ์์ด์ผ ๋์ํฉ๋๋ค.')returnif(rand_resolution_var.get() == 1):resolutions = ["1024 x 1024", "960 x 1088", "896 x 1152", "832 x 1216", "1088 x 960", "1152 x 896", "1216 x 832"]random_resolution = random.choice(resolutions)selected_resolution.set(random_resolution)if(turbo_var.get() == 1 and access_token):button_stop.config(state='normal')NAI_generation_turbo(NAI_width, NAI_height, button)else:if not (running_flag):NAI_generation_normal(NAI_width, NAI_height, button)def Auto_login_check():global access_token, access_token_multiif os.path.exists('token.txt'):with open('token.txt', 'r', encoding='utf-8') as f:tokens = f.readlines()if(tokens[0]): access_token = tokens[0].strip()if(access_token): button_setting.config(state='disabled')if(access_token): button_generate.config(state='normal')def NAI_generation_normal(width, height, button):button.config(state=tk.DISABLED)positive = text_output.get("1.0", tk.END)negative = negative_text.get("1.0", "end-1c").strip()thread = threading.Thread(target=generate, args=(width, height, positive, negative, button))thread.start()2 unmodified linesbutton.config(state=tk.DISABLED)positive = text_output.get("1.0", tk.END)negative = negative_text.get("1.0", "end-1c").strip()def SELECT(positive):lines = positive[:25]175 unmodified linessleep2 = sleep1 + random.uniform(13.5,19.5)sleep3 = sleep2 + random.uniform(13.5,19.5)thread_init = threading.Thread(target=generate_turbo, args=(seed,turbo_count, access_token, width, height, positive, negative, button, 0, 0))thread_init.start()thread0 = threading.Thread(target=generate_turbo, args=(seed,turbo_count, access_token, width, height, positive0, negative, button, 1, sleep0))79 unmodified linesreturn new_imagedef insert_queue(i, _number):global image_queue, temp_clipboard_imagewhile len(image_queue) < 4: image_queue.append(None)if _number <= 4:9 unmodified linesglobals()['tk_image'] = Nonetk_image = ImageTk.PhotoImage(i_resized)image_label.config(image=tk_image)image_label.image = tk_image # ์ฐธ์กฐ ์ ์งif all(img is not None for img in image_queue):time.sleep(5)merged_image = merge_images(image_queue)temp_clipboard_image = merged_image.copy()if merged_image is not None:i_resized = resize_and_fill(merged_image)if 'tk_image' in globals():globals()['tk_image'] = Nonetk_image = ImageTk.PhotoImage(i_resized)image_label.config(image=tk_image)image_label.image = tk_image # ์ฐธ์กฐ ์ ์งoutput_file_path = "output_image.jpg"merged_image.save(output_file_path)41 unmodified linesprint('containing : ',pipe_number)running_flag = Truetprint("Running : request received, pipeline :",pipe_number)global error_counttry:zipped_bytes = generate_image(tb_access_token, positive, "nai-diffusion-3", "generate", params)14 unmodified linestemp_clipboard_image.close()if(pipe_number == 1 and len(image_queue) < 4): image_queue.clear()temp_clipboard_image = iinsert_queue(i, pipe_number)tprint("image inserted, pipe number : ",pipe_number)else:if temp_clipboard_image is not None:temp_clipboard_image.close()3 unmodified linesglobals()['tk_image'] = Nonetk_image = ImageTk.PhotoImage(i_resized)image_label.config(image=tk_image)image_label.image = tk_image # ์ฐธ์กฐ ์ ์งexcept Exception as e:#text_output.insert(tk.END, f"Error: {e}", fg='red')log_error(e, "path_to_output_folder")error_count += 1if error_count > 5:mac_var.set(0)time.sleep(random.uniform(3.0, 9.0))insert_queue(temp_clipboard_image, pipe_number)task_finished += 1 #ํฐ๋ณด ๊ธฐ๋ฅ์ ์์ ์ฅ์น์ ๋๋ค.4 unmodified lineslast_generation_seed = params['seed']entry_seed_value.set(last_generation_seed)stopped = Falseif (turbo_stop_bit):time.sleep(1.5)1 unmodified linebutton.config(state=tk.NORMAL)stopped = Trueif (pipe_number != 4):tprint("Stopped : request stopped before assign pipeline :",pipe_number+1)if pipe_number == 4 and mac_var.get():wait_limit = 0313 unmodified lineswindow.destroy()def load_wildcard(text_widget, window, _type):global artist_wildcard_saved, character_wildcard_savedwindow.iconify()40 unmodified linesdef tprint(*args):ctext = ""for t in args:ctext += str(t)running_state.config(text=ctext)def on_hold_seed_button_click():global last_generation_seedlast_generation_seed = entry_seed_value.get() # entry_seed_value์์ ๊ฐ์ ๊ฐ์ ธ์ last_generation_seed์ ์ ์ฅstart_time = datetime.now().strftime('%Y%m%d_%H%M')thread_controller = False29 unmodified linesturbo_stop_bit = Falsetask_finished = 0error_count = 0whitelist = wlist.whitelistbag_of_tags = tagbag.bag_of_tags115 unmodified linesbutton_stop.config(state='disabled')# "์ค์ " ๋ฒํผbutton_setting = tk.Button(button_frame, text="NAI ๋ก๊ทธ์ธ ์ค์ ", command=lambda: NAI_setting(button_setting, button_generate))button_setting.grid(row=0, column=6, sticky='ew')# "ํฐ๋ณด" ๋ฒํผ#button_turbo = tk.Button(button_frame, text="ํฐ๋ณด", command=lambda: NAI_setting_multi(button_turbo))#button_turbo.grid(row=0, column=7, sticky='ew')# '์๋ํ'์ 'ํฐ๋ณดon'์ ํฌํจํ ์๋ธ ํ๋ ์ ์์ฑsub_frame = tk.Frame(button_frame)sub_frame.grid(row=0, column=8, sticky='ns') # ์๋ธ ํ๋ ์์ ์ด 8์ ๋ฐฐ์น# '์๋ํ' ์ฒดํฌ๋ฐ์ค๋ฅผ ์๋ธ ํ๋ ์์ ๋ฐฐ์นmac_var = tk.IntVar()5 unmodified linesturbo_button = tk.Checkbutton(sub_frame, text="ํฐ๋ณดon", variable=turbo_var)turbo_button.grid(row=1, column=0, sticky='ew') # ๋ ๋ฒ์งธ ํ์ ๋ฐฐ์น# ํ ์คํธ ๋ฐ ๊ณ ์ ํ๋กฌํํธ ๋ค๊ฑฐํฐ๋ธ ๋ฑ ํ๋กฌํํธ ์ฐฝtext_frame = tk.Frame(left_frame)text_frame.grid(row=6, column=0, padx=5, pady=5, sticky='w')52 unmodified linesrecommend_prompt_button = tk.Button(auto_hide_frame, text="์ถ์ฒ ํ๋กฌํํธ", command=open_prompt_window)recommend_prompt_button.grid(row=0, column=2, padx=2, pady=5, sticky='e') # sticky ์ต์ ์ 'e'๋ก ๋ณ๊ฒฝํ์ฌ ์ค๋ฅธ์ชฝ ์ ๋ ฌ#character_search_button# ์ฒดํฌ๋ฐ์ค๋ค์ ํฌํจํ ํ๋ ์ ์์ฑcheckbox_frame = tk.Frame(left_frame)106 unmodified linesrunning_state = tk.Label(resolution3_frame, text="state : idle")running_state.grid(row = 0, column= 0, sticky='w')entry_rescale_value = tk.StringVar()entry_rescale_label = tk.Label(resolution3_frame, text=" Prompt Guidance Rescale : ", justify=tk.LEFT)entry_rescale_label.grid(row=0, column=1, sticky='e')19 unmodified linesbtn_add_low_freq = tk.Button(right_frame_area16, text="์ด๋ฏธ์ง๋ฅผ ํด๋ฆฝ๋ณด๋์ ๋ณต์ฌ", fg="blue", command=copy_image_to_clipboard)btn_add_low_freq.grid(row=0, column=3, padx=5, pady=5, sticky='ew')# ํ์์ ์ด๋ฏธ์ง ์์ฑwhite_image = Image.new('RGB', (_size, _size), 'white')white_photo = ImageTk.PhotoImage(white_image)4 unmodified linesAuto_login_check()window.mainloop()149 unmodified lines1501511521531541551561571581591601611621639 unmodified lines173174175176177178179180181182183184185186187188189190191192193194195391 unmodified lines587588589590591592593594595596597106 unmodified lines70470570670770870971035 unmodified lines746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806222 unmodified lines102910301031103210331034103510361037103810391040104110422 unmodified lines104510461047104810491050175 unmodified lines12261227122812291230123112321233123479 unmodified lines13141315131613171318131913209 unmodified lines1330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135241 unmodified lines139413951396139713981399140014 unmodified lines141514161417141814191420142114223 unmodified lines14261427142814291430143114321433143414351436143714381439144014414 unmodified lines1446144714481449145014511452145314541 unmodified line1456145714581459146014611462313 unmodified lines17761777177817791780178140 unmodified lines1822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205729 unmodified lines2087208820892090209120922093115 unmodified lines2209221022112212221322142215221622172218221922205 unmodified lines222622272228222922302231223222332234223552 unmodified lines2288228922902291229222932294106 unmodified lines240124022403240424052406240724082409241019 unmodified lines2430243124322433243424352436243724384 unmodified lines24432444244524462447149 unmodified lineswith open(f"error_log.txt", "a") as file:file.write(error_message)global access_token, access_token_multi, error_count, multi_token_enablewhile (running_flag):time.sleep(1)try:running_flag = Truetprint("Running : NAI request received")if not (multi_token_enable): zipped_bytes = generate_image(access_token, positive, "nai-diffusion-3", "generate", params)else: zipped_bytes = generate_image(access_token_multi, positive, "nai-diffusion-3", "generate", params)d = Path(f"output_NAI/{start_time}/txt2img")d.mkdir(parents=True, exist_ok=True)zipped = zipfile.ZipFile(io.BytesIO(zipped_bytes))9 unmodified linesglobals()['tk_image'] = Nonetk_image = ImageTk.PhotoImage(i_resized)image_label.config(image=tk_image)image_label.original_image = i.copy()image_label.image = tk_image # ์ฐธ์กฐ ์ ์งoutput_file_path = "output_image.jpg"i.save(output_file_path)error_count = 0except Exception as e:#text_output.insert(tk.END, f"Error: {e}", fg='red')log_error(zipped_bytes.decode('utf-8')[2:-2], "path_to_output_folder")time.sleep(random.uniform(1.0, 2.5))error_count += 1if error_count > 5:mac_var.set(0)button.config(state=tk.NORMAL)global delay_offsettime.sleep(delay_offset)running_flag = Falselast_generation_seed = params['seed']entry_seed_value.set(last_generation_seed)391 unmodified linestprint("Stopping pipelines ... ")def exit_program():global stop_event, auto_threadif stop_event is not None:stop_event.set()if auto_thread is not None and auto_thread.is_alive():auto_thread.join() # ์ค๋ ๋๊ฐ ์ข ๋ฃ๋ ๋๊น์ง ๊ธฐ๋ค๋ฆผwindow.destroy()def save_settings():106 unmodified lineswindow.destroy()def on_ctrl_enter(event):random_function()def on_shift_enter(event):random_function()35 unmodified linesdef for_canonical(f):return lambda k: f(listener.canonical(k))# ๋ผ๋ฒจ์ ์ ๋ฐ์ดํธํ๋ ํจ์def update_label(label, text):def task():label.config(text=text)label.after(1000, task) # ๋ฉ์ธ ์ค๋ ๋์์ UI ์ ๋ฐ์ดํธdef NAI_generation(width, height, button):global access_token_multi, NAI_width, NAI_heightglobal button_stop, running_flagdef run_function():time.sleep(1)random_function()time.sleep(2)window.event_generate(GENERATE_EVENT, when="tail")pretest = text_output.get("1.0", tk.END).split(', ')if (turbo_var.get() == 1):if ( 'sex' not in pretest or '1girl' not in pretest or '1boy' not in pretest):tprint('๋ถ์คํธ ๊ธฐ๋ฅ์ 1girl, 1boy, sex ์ธ๊ฐ์ง ํค์๋๊ฐ ์์ด์ผ ๋์ํฉ๋๋ค.','color=red')if not mac_var.get():button.config(state='normal')returnelse:thread = threading.Thread(target=run_function)thread.start()returnif(rand_resolution_var.get() == 1):resolutions = ["1024 x 1024", "960 x 1088", "896 x 1152", "832 x 1216", "1088 x 960", "1152 x 896", "1216 x 832"]random_resolution = random.choice(resolutions)selected_resolution.set(random_resolution)if(turbo_var.get() == 1 and access_token):button_stop.config(state='normal')NAI_generation_turbo(NAI_width, NAI_height, button)else:if not (running_flag):NAI_generation_normal(NAI_width, NAI_height, button)def Auto_login_check():global access_token, access_token_multiif os.path.exists('token.txt'):with open('token.txt', 'r', encoding='utf-8') as f:tokens = f.readlines()if(tokens[0]):access_token = tokens[0].strip()tprint("1 Account automatically loaded : ",access_token[-5:])try:if(len(tokens)>=2):access_token_multi = tokens[1].strip()tprint("2 Account automatically loaded : ",access_token[-5:]+", "+access_token_multi[-5:])except:access_token_multi = Noneif(access_token): button_generate.config(state='normal')def character_search_thread():search_thread = threading.Thread(target=character_search, daemon=True)222 unmodified linesall_keywords = sorted(cd.character_dictionary.items(), key=lambda item: item[1], reverse=True)for keyword, count in all_keywords:listbox.insert(tk.END, f"{keyword} - {count}")def NAI_generation_normal(width, height, button):button.config(state=tk.DISABLED)positive = text_output.get("1.0", tk.END)negative = negative_text.get("1.0", "end-1c").strip()global auto_count_left_flag, auto_count_leftif(auto_count_left_flag and auto_count_left > 0):auto_count_left -= 1thread = threading.Thread(target=generate, args=(width, height, positive, negative, button))thread.start()2 unmodified linesbutton.config(state=tk.DISABLED)positive = text_output.get("1.0", tk.END)negative = negative_text.get("1.0", "end-1c").strip()def SELECT(positive):lines = positive[:25]175 unmodified linessleep2 = sleep1 + random.uniform(13.5,19.5)sleep3 = sleep2 + random.uniform(13.5,19.5)global auto_count_left_flag, auto_count_left, turbo_stop_bitif(auto_count_left_flag and auto_count_left > 0):auto_count_left -= 5thread_init = threading.Thread(target=generate_turbo, args=(seed,turbo_count, access_token, width, height, positive, negative, button, 0, 0))thread_init.start()thread0 = threading.Thread(target=generate_turbo, args=(seed,turbo_count, access_token, width, height, positive0, negative, button, 1, sleep0))79 unmodified linesreturn new_imagedef insert_queue(i, _number, turbo_count):global image_queue, temp_clipboard_imagewhile len(image_queue) < 4: image_queue.append(None)if _number <= 4:9 unmodified linesglobals()['tk_image'] = Nonetk_image = ImageTk.PhotoImage(i_resized)image_label.config(image=tk_image)image_label.original_image = i.copy()image_label.image = tk_image # ์ฐธ์กฐ ์ ์งif all(img is not None for img in image_queue):time.sleep(5)merged_image = merge_images(image_queue)temp_clipboard_image = merged_image.copy()if merged_image is not None:output_directory = Path(f"output_NAI/{start_time}/turbo/grid")output_directory.mkdir(parents=True, exist_ok=True)file_path = output_directory / f"{turbo_count:05}.png"merged_image.save(file_path)i_resized = resize_and_fill(merged_image)if 'tk_image' in globals():globals()['tk_image'] = Nonetk_image = ImageTk.PhotoImage(i_resized)image_label.config(image=tk_image)image_label.original_image = i_resized.copy()image_label.image = tk_image # ์ฐธ์กฐ ์ ์งoutput_file_path = "output_image.jpg"merged_image.save(output_file_path)41 unmodified linesprint('containing : ',pipe_number)running_flag = Truetprint("Running : request received, pipeline : "+str(pipe_number))global error_counttry:zipped_bytes = generate_image(tb_access_token, positive, "nai-diffusion-3", "generate", params)14 unmodified linestemp_clipboard_image.close()if(pipe_number == 1 and len(image_queue) < 4): image_queue.clear()temp_clipboard_image = iinsert_queue(i, pipe_number, turbo_count)tprint("image inserted, pipe number : "+str(pipe_number))else:if temp_clipboard_image is not None:temp_clipboard_image.close()3 unmodified linesglobals()['tk_image'] = Nonetk_image = ImageTk.PhotoImage(i_resized)image_label.config(image=tk_image)image_label.original_image = i.copy()image_label.image = tk_image # ์ฐธ์กฐ ์ ์งexcept Exception as e:#text_output.insert(tk.END, f"Error: {e}", fg='red')log_error(zipped_bytes.decode('utf-8')[2:-2], "path_to_output_folder")error_count += 1if error_count > 5:mac_var.set(0)time.sleep(random.uniform(3.0, 9.0))insert_queue(temp_clipboard_image, pipe_number, turbo_count)task_finished += 1 #ํฐ๋ณด ๊ธฐ๋ฅ์ ์์ ์ฅ์น์ ๋๋ค.4 unmodified lineslast_generation_seed = params['seed']entry_seed_value.set(last_generation_seed)global delay_offsettime.sleep(delay_offset)stopped = Falseif (turbo_stop_bit):time.sleep(1.5)1 unmodified linebutton.config(state=tk.NORMAL)stopped = Trueif (pipe_number != 4):tprint("Stopped : request stopped before assign pipeline :"+str(pipe_number+1))if pipe_number == 4 and mac_var.get():wait_limit = 0313 unmodified lineswindow.destroy()def load_wildcard(text_widget, window, _type):global artist_wildcard_saved, character_wildcard_savedwindow.iconify()40 unmodified linesdef tprint(*args):ctext = ""color = Nonefor t in args:if(type(t) is str and 'color=' in t):color = t[6:]else:ctext += str(t)if not color: running_state.config(text=ctext, fg='black')else: running_state.config(text=ctext, fg='red')def show_automation_option():global auto_thread, stop_eventtop = tk.Toplevel(window)top.title("Automation Stop Condition")global var, timer_label, timer_entry, count_label, count_entryvar = tk.StringVar(value="unlimited")def show_option():if var.get() == 'timer':timer_label.grid(row=4, column=0)timer_entry.grid(row=4, column=1)count_label.grid_forget()count_entry.grid_forget()elif var.get() == 'count':count_label.grid(row=4, column=0)count_entry.grid(row=4, column=1)timer_label.grid_forget()timer_entry.grid_forget()else:timer_label.grid_forget()timer_entry.grid_forget()count_label.grid_forget()count_entry.grid_forget()label_time = tk.Label(top, text="์ด๋ฏธ์ง ์์ฑ๋น ์ง์ฐ์๊ฐ ์ถ๊ฐ (์ด)")label_time.grid(row=0, column=0, columnspan=3)delay_entry = tk.Entry(top)delay_entry.grid(row=1, column=0, columnspan=3)label = tk.Label(top, text="์๋ํ ์ข ๋ฃ ์กฐ๊ฑด")label.grid(row=2, column=0, columnspan=3)radio1 = tk.Radiobutton(top, text="๋ฌด์ ํ", variable=var, value="unlimited", command=show_option)radio1.grid(row=3, column=0)radio2 = tk.Radiobutton(top, text="ํ์ด๋จธ", variable=var, value="timer", command=show_option)radio2.grid(row=3, column=1)radio3 = tk.Radiobutton(top, text="์์ฑ ์นด์ดํธ", variable=var, value="count", command=show_option)radio3.grid(row=3, column=2)timer_label = tk.Label(top, text="์๋ํ ๋์ ์๊ฐ(๋ถ) :")timer_entry = tk.Entry(top)count_label = tk.Label(top, text="์๋ ์์ฑ ํ์:")count_entry = tk.Entry(top)# "A.์ค์ " ์ฐฝ์์ ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ ์ฒ๋ฆฌdef on_apply(top):global auto_time_left_flag, auto_time_left, auto_count_left_flag, auto_count_left, delay_offset, delay_offset_labelselected_option = var.get()if delay_entry.get():try:delay_offset = round(float(delay_entry.get()), 1)delay_offset_label.config(text="Dealy offset : "+str(delay_offset))except ValueError as e:print(e)delay_offset = 0else:delay_offset = 0delay_offset_label.config(text="")if selected_option == "timer":auto_time_left_flag = Trueauto_count_left_flag = Falsetry:# ์ํธ๋ฆฌ์์ ์ ๋ ฅ๋ ์๊ฐ์ ๋ถ ๋จ์์์ ์ด ๋จ์๋ก ๋ณํauto_time_left = int(timer_entry.get()) * 60except ValueError:# ์๋ชป๋ ์ ๋ ฅ ์ฒ๋ฆฌprint("Invalid input for timer. Please enter a number.")returnelif selected_option == "count":auto_count_left_flag = Trueauto_time_left_flag = Falsetry:auto_count_left = int(count_entry.get())except ValueError:# ์๋ชป๋ ์ ๋ ฅ ์ฒ๋ฆฌprint("Invalid input for count. Please enter a number.")returnelse:auto_time_left_flag = Falseauto_count_left_flag = Falsestop_auto_thread() # ์ด์ ์ค๋ ๋ ์ข ๋ฃstart_auto_thread() # ์ ์ค๋ ๋ ์์mac_var.set(1)top.destroy()apply_button = tk.Button(top, text="์ ์ฉ", command=lambda: on_apply(top))stop_button = tk.Button(top, text="์ค๋จ", command=on_stop)close_button = tk.Button(top, text="๋ซ๊ธฐ", command=top.destroy)apply_button.grid(row=5, column=0, pady=5)stop_button.grid(row=5, column=1, pady=5)close_button.grid(row=5, column=2, pady=5)def auto_time_thread(stop_event):global auto_time_left, auto_time_left_flagdef seconds_to_hms(seconds):h = seconds // 3600m = (seconds % 3600) // 60s = seconds % 60return f"{h:02d}:{m:02d}:{s:02d}"def update_label_for_time_finished():automation_state.config(text="์ง์ ํ ์๊ฐ์ด ๋ชจ๋ ์์ง๋์ด ์๋ํ๊ฐ ์ข ๋ฃ๋์์ต๋๋ค.")auto_time_left_flag = Falsemac_var.set(0)while not stop_event.is_set() and auto_time_left > 0:time.sleep(1)auto_time_left -= 1remaining_time = seconds_to_hms(auto_time_left)window.after(0, lambda: automation_state.config(text=f"์๋ํ ๋จ์์๊ฐ : {remaining_time}"))if auto_time_left <= 0:window.after(0, update_label_for_time_finished)if stop_event.is_set():window.after(0, lambda: automation_state.config(text="Conditional automation not set (A.์ค์ )"))auto_time_left_flag = Falsedef auto_count_thread(stop_event):global auto_count_left, auto_count_left_flagdef update_label_for_count_finished():mac_var.set(0) # ์๋ํ ์ข ๋ฃ ์กฐ๊ฑด ์ถฉ์กฑauto_count_left_flag = Falseautomation_state.config(text="์ง์ ํ ํ์๊ฐ ๋ชจ๋ ์์ง๋์ด ์๋ํ๊ฐ ์ข ๋ฃ๋์์ต๋๋ค.")while not stop_event.is_set():time.sleep(1) # ์ฃผ๊ธฐ์ ์ผ๋ก ํ์ธwindow.after(0, lambda: automation_state.config(text=f"์๋ํ ๋จ์ํ์ : {auto_count_left}"))if auto_count_left <= 0:window.after(0, update_label_for_count_finished)break # ๋ฃจํ ํ์ถif stop_event.is_set():window.after(0, lambda: automation_state.config(text="Conditional automation not set (A.์ค์ )"))mac_var.set(0)auto_count_left_flag = False# ์ค๋ ๋ ์์ ๋ฐ ์ข ๋ฃ ํจ์def start_auto_thread():global auto_thread, stop_eventstop_event = threading.Event()auto_thread = Noneif auto_time_left_flag:auto_thread = threading.Thread(target=auto_time_thread, args=(stop_event,))elif auto_count_left_flag:auto_thread = threading.Thread(target=auto_count_thread, args=(stop_event,))if auto_thread is not None:auto_thread.start()def stop_auto_thread():global stop_event, auto_threadif stop_event is not None:stop_event.set()#if auto_thread is not None and auto_thread.is_alive():# auto_thread.join()def on_stop():global auto_thread, stop_eventstop_auto_thread() # ์ค๋ ๋ ์ข ๋ฃdef on_hold_seed_button_click():global last_generation_seedlast_generation_seed = entry_seed_value.get()def update_fullscreen_image(new_window, new_image_label):last_updated_image = Nonewhile True:time.sleep(1)if not new_window.winfo_exists():breaktry:current_image = getattr(image_label, 'original_image', None)if current_image and current_image != last_updated_image:resized_image = resize_image_to_fit(current_image, new_window.winfo_height())tk_image = ImageTk.PhotoImage(resized_image)new_window.after(0, lambda img=tk_image: new_image_label.config(image=img))new_image_label.image = tk_imagelast_updated_image = current_imageexcept ValueError:print(ValueError)def show_fullscreen_image():new_window = tk.Toplevel()new_window.attributes('-fullscreen', True)new_window.configure(bg='black')new_image_label = tk.Label(new_window, relief='solid', borderwidth=1, bg='black')new_image_label.pack(expand=True, fill='both')new_window.bind("<Escape>", lambda e: new_window.destroy())update_thread = threading.Thread(target=update_fullscreen_image, args=(new_window, new_image_label))update_thread.daemon = Trueupdate_thread.start()def resize_image_to_fit(image, target_height):original_width, original_height = image.sizeratio = target_height / float(original_height)new_width = int(original_width * ratio)resized_image = image.resize((new_width, target_height), Image.Resampling.LANCZOS)return resized_imageauto_time_left_flag = Falseauto_time_left = 0auto_count_left_flag = Falseauto_count_left = 0stop_event = Noneauto_thread = Nonedelay_offset = 0start_time = datetime.now().strftime('%Y%m%d_%H%M')thread_controller = False29 unmodified linesturbo_stop_bit = Falsetask_finished = 0error_count = 0multi_token_enable = Falsewhitelist = wlist.whitelistbag_of_tags = tagbag.bag_of_tags115 unmodified linesbutton_stop.config(state='disabled')# "์ค์ " ๋ฒํผbutton_setting = tk.Button(button_frame, text="NAI ์ค์ ", command=lambda: NAI_setting(button_setting, button_generate))button_setting.grid(row=0, column=6, sticky='ew')# '์๋ํ'์ 'ํฐ๋ณดon'์ ํฌํจํ ์๋ธ ํ๋ ์ ์์ฑsub_frame = tk.Frame(button_frame)sub_frame.grid(row=0, column=7, sticky='ns') # ์๋ธ ํ๋ ์์ ์ด 8์ ๋ฐฐ์น# '์๋ํ' ์ฒดํฌ๋ฐ์ค๋ฅผ ์๋ธ ํ๋ ์์ ๋ฐฐ์นmac_var = tk.IntVar()5 unmodified linesturbo_button = tk.Checkbutton(sub_frame, text="ํฐ๋ณดon", variable=turbo_var)turbo_button.grid(row=1, column=0, sticky='ew') # ๋ ๋ฒ์งธ ํ์ ๋ฐฐ์น# "A.์ค์ " ๋ฒํผbutton_auto_setting = tk.Button(button_frame, text="A.์ค์ ", command=show_automation_option)button_auto_setting.grid(row=0, column=8, sticky='ew')# ํ ์คํธ ๋ฐ ๊ณ ์ ํ๋กฌํํธ ๋ค๊ฑฐํฐ๋ธ ๋ฑ ํ๋กฌํํธ ์ฐฝtext_frame = tk.Frame(left_frame)text_frame.grid(row=6, column=0, padx=5, pady=5, sticky='w')52 unmodified linesrecommend_prompt_button = tk.Button(auto_hide_frame, text="์ถ์ฒ ํ๋กฌํํธ", command=open_prompt_window)recommend_prompt_button.grid(row=0, column=2, padx=2, pady=5, sticky='e') # sticky ์ต์ ์ 'e'๋ก ๋ณ๊ฒฝํ์ฌ ์ค๋ฅธ์ชฝ ์ ๋ ฌ# ์ฒดํฌ๋ฐ์ค๋ค์ ํฌํจํ ํ๋ ์ ์์ฑcheckbox_frame = tk.Frame(left_frame)106 unmodified linesrunning_state = tk.Label(resolution3_frame, text="state : idle")running_state.grid(row = 0, column= 0, sticky='w')automation_state = tk.Label(resolution3_frame, text="Conditional automation not set (A.์ค์ )")automation_state.grid(row = 1, column= 0, sticky='w')delay_offset_label = tk.Label(resolution3_frame, text="Dealy offset : "+str(delay_offset))delay_offset_label.grid(row = 1, column= 1, sticky='e')entry_rescale_value = tk.StringVar()entry_rescale_label = tk.Label(resolution3_frame, text=" Prompt Guidance Rescale : ", justify=tk.LEFT)entry_rescale_label.grid(row=0, column=1, sticky='e')19 unmodified linesbtn_add_low_freq = tk.Button(right_frame_area16, text="์ด๋ฏธ์ง๋ฅผ ํด๋ฆฝ๋ณด๋์ ๋ณต์ฌ", fg="blue", command=copy_image_to_clipboard)btn_add_low_freq.grid(row=0, column=3, padx=5, pady=5, sticky='ew')show_fullscreen_btn = tk.Button(right_frame_area16, text="์ ์ฒดํ๋ฉด ๋ณด๊ธฐ (ESC๋ก ๋ซ๊ธฐ)", command=show_fullscreen_image)show_fullscreen_btn.grid(row=0, column=4, padx=5, pady=5, sticky='ew')# ํ์์ ์ด๋ฏธ์ง ์์ฑwhite_image = Image.new('RGB', (_size, _size), 'white')white_photo = ImageTk.PhotoImage(white_image)4 unmodified linesAuto_login_check()window.protocol("WM_DELETE_WINDOW", exit_program)window.mainloop()
Danbooru Prompt Selector/TEST2024/prompt_selector_auto_1212_testv8.exe+2-2
Danbooru Prompt Selector/TEST2024/prompt_selector_auto_1212_testv8.py+335-151