Upload 2 files
Browse files
Danbooru Prompt Selector/TEST2024/prompt_selector_auto_1215_testv9.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:2de13ef437ae80bdf617829959f017d41cf55d8162935beac38a43ed370442c6
|
| 3 |
+
size 151554073
|
Danbooru Prompt Selector/TEST2024/prompt_selector_auto_1215_testv9.py
CHANGED
|
@@ -32,6 +32,10 @@ import character_dictionary as cd
|
|
| 32 |
import pandas as pd
|
| 33 |
import webbrowser
|
| 34 |
from collections import OrderedDict
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
BASE_URL="https://api.novelai.net"
|
| 37 |
copyright_keys = copyright_list_reformatted.copyright_list
|
|
@@ -85,21 +89,78 @@ def generate_image(access_token, prompt, model, action, parameters):
|
|
| 85 |
|
| 86 |
def history_queue(image, prompt, seed):
|
| 87 |
global history
|
|
|
|
| 88 |
history.append([image, prompt, seed])
|
| 89 |
-
if len(history) > 5:
|
| 90 |
-
history.pop(0)
|
| 91 |
|
| 92 |
def show_history():
|
| 93 |
global history
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
# ์๋ก์ด toplevel ์ฐฝ ์์ฑ
|
| 96 |
history_window = tk.Toplevel(window)
|
| 97 |
history_window.title("History")
|
| 98 |
|
| 99 |
# history_window์์ ์ธ๋ค์ผ๊ณผ ํ
์คํธ๋ฅผ ํ์ํ grid ์ค์
|
| 100 |
-
for index, (image, prompt, seed) in enumerate(history):
|
| 101 |
-
#
|
| 102 |
-
image.thumbnail((192, 192)) # ๊ฐ๋ก ์ธ๋ก 100ํฝ์
๋ก ์กฐ์
|
| 103 |
photo = ImageTk.PhotoImage(image)
|
| 104 |
|
| 105 |
# ์ธ๋ค์ผ ์ด๋ฏธ์ง ๋ผ๋ฒจ ์์ฑ
|
|
@@ -113,6 +174,9 @@ def show_history():
|
|
| 113 |
text_widget.insert('1.0', text_prompt)
|
| 114 |
text_widget.grid(row=index, column=1)
|
| 115 |
text_widget.config(state='disabled') # ํ
์คํธ ์์ ฏ์ ์ฝ๊ธฐ ์ ์ฉ์ผ๋ก ์ค์
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
def generate(width, height, positive, negative, button):
|
| 118 |
global temp_clipboard_image
|
|
@@ -227,7 +291,8 @@ def generate(width, height, positive, negative, button):
|
|
| 227 |
button.config(state=tk.NORMAL)
|
| 228 |
|
| 229 |
global delay_offset,cached_rows
|
| 230 |
-
|
|
|
|
| 231 |
|
| 232 |
running_flag = False
|
| 233 |
last_generation_seed = params['seed']
|
|
@@ -237,7 +302,12 @@ def generate(width, height, positive, negative, button):
|
|
| 237 |
random_function()
|
| 238 |
if len(cached_rows) == 0:
|
| 239 |
mac_var.set(0)
|
| 240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
button.config(state=tk.DISABLED)
|
| 242 |
window.event_generate(GENERATE_EVENT, when="tail")
|
| 243 |
else:
|
|
@@ -1899,7 +1969,8 @@ def generate_turbo(_seed, turbo_count, tb_access_token,width, height, positive,
|
|
| 1899 |
entry_seed_value.set(last_generation_seed)
|
| 1900 |
|
| 1901 |
global delay_offset
|
| 1902 |
-
|
|
|
|
| 1903 |
|
| 1904 |
stopped = False
|
| 1905 |
if (turbo_stop_bit):
|
|
@@ -2354,7 +2425,7 @@ def show_automation_option():
|
|
| 2354 |
if delay_entry.get():
|
| 2355 |
try:
|
| 2356 |
delay_offset = round(float(delay_entry.get()), 1)
|
| 2357 |
-
delay_offset_label.config(text="
|
| 2358 |
except ValueError as e:
|
| 2359 |
print(e)
|
| 2360 |
delay_offset = 0
|
|
|
|
| 32 |
import pandas as pd
|
| 33 |
import webbrowser
|
| 34 |
from collections import OrderedDict
|
| 35 |
+
import platform
|
| 36 |
+
from openpyxl import Workbook
|
| 37 |
+
from openpyxl.styles import Alignment
|
| 38 |
+
from openpyxl.drawing.image import Image as OpenpyxlImage
|
| 39 |
|
| 40 |
BASE_URL="https://api.novelai.net"
|
| 41 |
copyright_keys = copyright_list_reformatted.copyright_list
|
|
|
|
| 89 |
|
| 90 |
def history_queue(image, prompt, seed):
|
| 91 |
global history
|
| 92 |
+
#new_image = image.thumbnail((192, 192)) # ๊ฐ๋ก ์ธ๋ก 100ํฝ์
๋ก ์กฐ์
|
| 93 |
history.append([image, prompt, seed])
|
|
|
|
|
|
|
| 94 |
|
| 95 |
def show_history():
|
| 96 |
global history
|
| 97 |
|
| 98 |
+
def save_to_excel():
|
| 99 |
+
"""
|
| 100 |
+
contributor : highnoon1
|
| 101 |
+
function : ํ์คํ ๋ฆฌ ์์
๋ก ์ ์ฅ (๋ฌด์ ํ ๋ณด๊ธฐ๋ ์ฑ๋ฅ ์ด์๋ก ์ ์ธ)
|
| 102 |
+
"""
|
| 103 |
+
global start_time
|
| 104 |
+
workbook = Workbook()
|
| 105 |
+
sheet = workbook.active
|
| 106 |
+
|
| 107 |
+
alignment = Alignment(wrapText=True)
|
| 108 |
+
sheet['A1'].alignment = alignment
|
| 109 |
+
sheet['A1'] = 'Prompt'
|
| 110 |
+
sheet['B1'] = 'Seed'
|
| 111 |
+
sheet['C1'] = 'Image'
|
| 112 |
+
|
| 113 |
+
image_objects = [] # BytesIO ๊ฐ์ฒด๋ฅผ ์ถ์ ํ๊ธฐ ์ํ ๋ฆฌ์คํธ
|
| 114 |
+
|
| 115 |
+
# history ๋ฐ์ดํฐ๋ฅผ ๋ฐ๋ณตํ๋ฉฐ Excel์ ์ ์ฅ
|
| 116 |
+
for index, (pil_image, prompt, seed) in enumerate(history, start=1):
|
| 117 |
+
|
| 118 |
+
row_num = index + 1 # ํ ๋ฒํธ (Excel ํ์ 1๋ถํฐ ์์)
|
| 119 |
+
|
| 120 |
+
# ํ๋กฌํํธ์ ์๋ ์ฝ์
|
| 121 |
+
prompt_cell = sheet.cell(row=row_num, column=1, value=prompt)
|
| 122 |
+
sheet.cell(row=row_num, column=2, value=seed)
|
| 123 |
+
prompt_cell.alignment = Alignment(wrap_text=True)
|
| 124 |
+
|
| 125 |
+
# PIL ์ด๋ฏธ์ง๋ฅผ BytesIO ๊ฐ์ฒด์ PNG ํ์์ผ๋ก ์ ์ฅ
|
| 126 |
+
pil_image = resize_image_to_fit(pil_image,192)
|
| 127 |
+
output = io.BytesIO()
|
| 128 |
+
pil_image.save(output, format='PNG')
|
| 129 |
+
output.seek(0)
|
| 130 |
+
image_objects.append(output) # ๋ฆฌ์คํธ์ ์ถ๊ฐ
|
| 131 |
+
|
| 132 |
+
# Openpyxl ์ด๋ฏธ์ง ์์ฑ ๋ฐ ์ํธ์ ์ถ๊ฐ
|
| 133 |
+
img = OpenpyxlImage(output)
|
| 134 |
+
img.anchor = f'C{row_num}' # ์ด๋ฏธ์ง๋ฅผ C์ด์ ๊ณ ์
|
| 135 |
+
sheet.add_image(img)
|
| 136 |
+
|
| 137 |
+
# ์ด๋ฏธ์ง ํฌ๊ธฐ์ ๋ฐ๋ผ ํ ๋์ด ๋ฐ ์ด ๋๋น ์กฐ์
|
| 138 |
+
scale_factor = 0.75
|
| 139 |
+
sheet.row_dimensions[row_num].height = pil_image.height * scale_factor
|
| 140 |
+
sheet.column_dimensions['C'].width = pil_image.width * scale_factor / 7
|
| 141 |
+
|
| 142 |
+
# A์ด๊ณผ B์ด ํฌ๊ธฐ ์กฐ์
|
| 143 |
+
sheet.column_dimensions['A'].width = 50
|
| 144 |
+
sheet.column_dimensions['B'].width = 15
|
| 145 |
+
|
| 146 |
+
# ์ํฌ๋ถ ์ ์ฅ
|
| 147 |
+
workbook.save(f"history_with_images_{start_time}.xlsx")
|
| 148 |
+
|
| 149 |
+
# ๋ชจ๋ BytesIO ๊ฐ์ฒด ๋ซ๊ธฐ
|
| 150 |
+
for img_obj in image_objects:
|
| 151 |
+
img_obj.close()
|
| 152 |
+
if os.path.exists(f"history_with_images_{start_time}.xlsx"):
|
| 153 |
+
os.startfile(f"history_with_images_{start_time}.xlsx")
|
| 154 |
+
|
| 155 |
+
print("์์
ํ์ผ์ ์ ์ฅ๋จ")
|
| 156 |
+
|
| 157 |
# ์๋ก์ด toplevel ์ฐฝ ์์ฑ
|
| 158 |
history_window = tk.Toplevel(window)
|
| 159 |
history_window.title("History")
|
| 160 |
|
| 161 |
# history_window์์ ์ธ๋ค์ผ๊ณผ ํ
์คํธ๋ฅผ ํ์ํ grid ์ค์
|
| 162 |
+
for index, (image, prompt, seed) in enumerate(history[-5:]):
|
| 163 |
+
image.thumbnail((192, 192)) # ๊ฐ๋ก ์ธ๋ก 100ํฝ์
๋ก ์กฐ์
|
|
|
|
| 164 |
photo = ImageTk.PhotoImage(image)
|
| 165 |
|
| 166 |
# ์ธ๋ค์ผ ์ด๋ฏธ์ง ๋ผ๋ฒจ ์์ฑ
|
|
|
|
| 174 |
text_widget.insert('1.0', text_prompt)
|
| 175 |
text_widget.grid(row=index, column=1)
|
| 176 |
text_widget.config(state='disabled') # ํ
์คํธ ์์ ฏ์ ์ฝ๊ธฐ ์ ์ฉ์ผ๋ก ์ค์
|
| 177 |
+
|
| 178 |
+
save_button = tk.Button(history_window, text=f"Save to Excel ({len(history)})", command=save_to_excel)
|
| 179 |
+
save_button.grid(row=50)
|
| 180 |
|
| 181 |
def generate(width, height, positive, negative, button):
|
| 182 |
global temp_clipboard_image
|
|
|
|
| 291 |
button.config(state=tk.NORMAL)
|
| 292 |
|
| 293 |
global delay_offset,cached_rows
|
| 294 |
+
if delay_offset >= 0:
|
| 295 |
+
time.sleep(delay_offset)
|
| 296 |
|
| 297 |
running_flag = False
|
| 298 |
last_generation_seed = params['seed']
|
|
|
|
| 302 |
random_function()
|
| 303 |
if len(cached_rows) == 0:
|
| 304 |
mac_var.set(0)
|
| 305 |
+
sleep_time = random.uniform(5.1, 8.5)
|
| 306 |
+
if delay_offset < 0:
|
| 307 |
+
sleep_time += delay_offset
|
| 308 |
+
if sleep_time < 0.5:
|
| 309 |
+
sleep_time = 0.5
|
| 310 |
+
time.sleep(sleep_time)
|
| 311 |
button.config(state=tk.DISABLED)
|
| 312 |
window.event_generate(GENERATE_EVENT, when="tail")
|
| 313 |
else:
|
|
|
|
| 1969 |
entry_seed_value.set(last_generation_seed)
|
| 1970 |
|
| 1971 |
global delay_offset
|
| 1972 |
+
if delay_offset >= 0:
|
| 1973 |
+
time.sleep(delay_offset)
|
| 1974 |
|
| 1975 |
stopped = False
|
| 1976 |
if (turbo_stop_bit):
|
|
|
|
| 2425 |
if delay_entry.get():
|
| 2426 |
try:
|
| 2427 |
delay_offset = round(float(delay_entry.get()), 1)
|
| 2428 |
+
delay_offset_label.config(text="Delay offset : "+str(delay_offset))
|
| 2429 |
except ValueError as e:
|
| 2430 |
print(e)
|
| 2431 |
delay_offset = 0
|