Upload 2 files
Browse filesFiles changed (2)
123version https://git-lfs.github.com/spec/v1oid sha256:e359edfa85abd142301b02cc3ebcc59d1040f2effeeb0443b02f6ccae56ccf88size 81784429123version https://git-lfs.github.com/spec/v1oid sha256:2e4593d4f9fc5c8aaf0b3e291f874f76e1718d6c83cdfaca02dcc77d7e6e98e4size 84497981
147 unmodified lines1481491501511521531541551561571581591609 unmodified lines170171172173174175176177178179180181182183184295 unmodified lines48048148248348448572 unmodified lines558559560561562563279 unmodified lines84384484584684784884985085185285312 unmodified lines8668678688698708718728738748758768778788792 unmodified lines882883884885886887888175 unmodified lines10641065106610671068106979 unmodified lines11491150115111521153115411559 unmodified lines1165116611671168116911701171117211731174117511761177117811791180118141 unmodified lines12231224122512261227122812297 unmodified lines12371238123912401241124212431244124512461247124812493 unmodified lines1253125412551256125712581259126012611262126312644 unmodified lines1269127012711272127312741 unmodified line1276127712781279128012811282313 unmodified lines159615971598159916001601160240 unmodified lines164316441645164616471648164916501651165216531654165528 unmodified lines168416851686168716881689112 unmodified lines18021803180418051806180718081809181018111812181318141815181618175 unmodified lines182318241825182618271828162 unmodified lines19911992199319941995199619 unmodified lines20162017201820192020202112 unmodified lines2034203520362037147 unmodified lineswith open(f"error_log.txt", "a") as file:file.write(error_message)global access_tokenwhile (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)except 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))button.config(state=tk.NORMAL)running_flag = Falselast_generation_seed = params['seed']entry_seed_value.set(last_generation_seed)295 unmodified linesif " (" in keyword:temp_first_keywords.append(keyword)random_row_keywords.remove(keyword)#last_selected_row_keywords =boy_keywords + girl_keywords[:0] + random_row_keywords#print("3 :", temp_first_keywords)72 unmodified linestprint("Stopping pipelines ... ")def exit_program():window.destroy()def save_settings():279 unmodified linesglobal 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"]12 unmodified linesif 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)try:zipped_bytes = generate_image(tb_access_token, positive, "nai-diffusion-3", "generate", params)if(pipe_number != 0):7 unmodified lines(d / f"{turbo_count:05}_{pipe_number}.png" ).write_bytes(image_bytes)i = Image.open(io.BytesIO(image_bytes))i = ImageOps.exif_transpose(i).convert("RGB")if(pipe_number != 0):if temp_clipboard_image is not None:temp_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")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 = False28 unmodified lineslast_generation_seed = random.randint(0,9999999999)turbo_stop_bit = Falsetask_finished = 0whitelist = wlist.whitelistbag_of_tags = tagbag.bag_of_tags112 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')162 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)12 unmodified linesAuto_login_check()window.mainloop()147 unmodified lines1481491501511521531541551561571581591601619 unmodified lines171172173174175176177178179180181182183184185186187188189190191192193295 unmodified lines48949049149249349449549649749849950050150250350450550650750850951051151272 unmodified lines585586587588589590591592593594595279 unmodified lines87587687787887988088188288388488588688788888989089189289389489589689712 unmodified lines9109119129139149159169179189199209219229239249259269279289299309319329332 unmodified lines936937938939940941175 unmodified lines11171118111911201121112211231124112579 unmodified lines12051206120712081209121012119 unmodified lines1221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124341 unmodified lines128512861287128812891290129112927 unmodified lines130013011302130313041305130613071308130913101311131213133 unmodified lines13171318131913201321132213231324132513261327132813291330133113324 unmodified lines1337133813391340134113421343134413451 unmodified line1347134813491350135113521353313 unmodified lines16671668166916701671167240 unmodified lines1713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194828 unmodified lines19771978197919801981198219831984112 unmodified lines2097209820992100210121022103210421052106210721085 unmodified lines2114211521162117211821192120212121222123162 unmodified lines228622872288228922902291229222932294229519 unmodified lines23152316231723182319232023212322232312 unmodified lines23362337233823392340147 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)295 unmodified linesif " (" in keyword:temp_first_keywords.append(keyword)random_row_keywords.remove(keyword)# ํ์จ ๊ฐ์ ํ๋กฌํํธvalid_keywords = []for keyword in temp_first_keywords:if "(" in keyword and "(artist)" not in keyword and "(style)" not in keyword:start = keyword.find("(") + 1end = keyword.find(")")if start < end and keyword[start:end] in current_deep_search_keywords:valid_keywords.append(keyword)for keyword in valid_keywords:if keyword in temp_first_keywords:temp_first_keywords.remove(keyword)girl_index = next((i for i, k in enumerate(temp_first_keywords) if 'girl' in k), None)if girl_index is not None:for keyword in valid_keywords:temp_first_keywords.insert(girl_index + 1, keyword)girl_index += 1# ๊ฒฐ๊ณผ ์ถ๋ ฅprint(temp_first_keywords)#last_selected_row_keywords =boy_keywords + girl_keywords[:0] + random_row_keywords#print("3 :", temp_first_keywords)72 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():279 unmodified linesglobal 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"]12 unmodified linesif 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 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)if(pipe_number != 0):7 unmodified lines(d / f"{turbo_count:05}_{pipe_number}.png" ).write_bytes(image_bytes)i = Image.open(io.BytesIO(image_bytes))i = ImageOps.exif_transpose(i).convert("RGB")error_count = 0if(pipe_number != 0):if temp_clipboard_image is not None:temp_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 = False28 unmodified lineslast_generation_seed = random.randint(0,9999999999)turbo_stop_bit = Falsetask_finished = 0error_count = 0multi_token_enable = Falsewhitelist = wlist.whitelistbag_of_tags = tagbag.bag_of_tags112 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')162 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)12 unmodified linesAuto_login_check()window.protocol("WM_DELETE_WINDOW", exit_program)window.mainloop()
Danbooru Prompt Selector/TEST/prompt_selector_auto_1208_testv6.exe+2-2
Danbooru Prompt Selector/TEST/prompt_selector_auto_1208_testv6.py+328-25