Spaces:
Running
Running
tripleS-Dev
commited on
Commit
·
d10d21b
1
Parent(s):
b818488
update V1.3.0L Beta
Browse files- beta_fn.py +46 -0
- event/1.ttf +0 -0
- event/2.ttf +0 -0
- event/3.ttf +0 -0
- event/4.ttf +0 -0
- event/Black.png +0 -0
- event/White.png +0 -0
- event/dddd/2.ttf +0 -0
- event/dddd/5.ttf +0 -0
- event/under.png +0 -0
- fns.py +44 -10
- generate.py +37 -93
- login_discord.py +12 -8
- main.py +111 -63
- pre.py +5 -0
- preset_fn.py +113 -0
- requirements.txt +2 -1
- resource/oma_frame.png +0 -0
- resource/outline_oma.png +0 -0
beta_fn.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pre
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
import preset_fn
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
def save(preset_name, artist_name, group_name, company_name, top_logo_img, qr_logo_img, sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12, userid, user_name):
|
12 |
+
|
13 |
+
|
14 |
+
group_name_radio = gr.Radio(choices=pre.groups, label="Group Name")
|
15 |
+
member_name_dropdown = gr.Dropdown(choices=pre.names, label="Member Name", allow_custom_value=True)
|
16 |
+
logo_radio = gr.Radio(choices=pre.groups, label="Add Logo", interactive=True, value="None")
|
17 |
+
sign = gr.Dropdown(choices=pre.names, label="Sign", type='index')
|
18 |
+
qr_Logo_radio = gr.Radio(["tripleS", "None"], label="QR Logo", value="None", interactive=True)
|
19 |
+
|
20 |
+
|
21 |
+
signs = [sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12]
|
22 |
+
|
23 |
+
if any(arg is None for arg in (preset_name, artist_name, group_name, company_name, top_logo_img, qr_logo_img)):
|
24 |
+
gr.Warning("Fill all blank")
|
25 |
+
return group_name_radio, member_name_dropdown, logo_radio, sign, qr_Logo_radio, sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12
|
26 |
+
|
27 |
+
for i in range(len(artist_name)):
|
28 |
+
if signs[i] is None:
|
29 |
+
gr.Warning("Fill all blank")
|
30 |
+
return group_name_radio, member_name_dropdown, logo_radio, sign, qr_Logo_radio, sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
group_name_radio = gr.Radio(choices=[group_name] + pre.groups_Other, label="Group Name", value=group_name)
|
36 |
+
member_name_dropdown = gr.Dropdown(choices=artist_name, label="Member Name", allow_custom_value=True, value=artist_name[0])
|
37 |
+
logo_radio = gr.Radio(choices=[group_name] + pre.groups, label="Add Logo", interactive=True, value=group_name)
|
38 |
+
sign = gr.Dropdown(choices=artist_name + pre.names, label="Sign", type='index', value=artist_name[0])
|
39 |
+
qr_Logo_radio = gr.Radio([group_name] + ["tripleS", "None"], label="QR Logo", value=group_name, interactive=True)
|
40 |
+
|
41 |
+
preset_id = preset_fn.create(userid, user_name, preset_name, group_name, artist_name, company_name, top_logo_img, qr_logo_img, sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12)
|
42 |
+
|
43 |
+
folders = preset_fn.refresh_folder()
|
44 |
+
preset = gr.Dropdown(choices=folders, value=preset_id)
|
45 |
+
|
46 |
+
return group_name_radio, member_name_dropdown, logo_radio, sign, qr_Logo_radio, preset
|
event/1.ttf
DELETED
Binary file (93 kB)
|
|
event/2.ttf
DELETED
Binary file (136 kB)
|
|
event/3.ttf
DELETED
Binary file (214 kB)
|
|
event/4.ttf
DELETED
Binary file (73.6 kB)
|
|
event/Black.png
DELETED
Binary file (22.4 kB)
|
|
event/White.png
DELETED
Binary file (24.8 kB)
|
|
event/dddd/2.ttf
DELETED
Binary file (21.4 kB)
|
|
event/dddd/5.ttf
DELETED
Binary file (83.6 kB)
|
|
event/under.png
DELETED
Binary file (114 Bytes)
|
|
fns.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import random
|
3 |
import shutil
|
@@ -5,6 +7,8 @@ import fn
|
|
5 |
import edimg
|
6 |
import os
|
7 |
|
|
|
|
|
8 |
|
9 |
def change_img_type(a):
|
10 |
if a == "Image":
|
@@ -46,17 +50,30 @@ def txt_color_update(txt_color_picker):
|
|
46 |
|
47 |
|
48 |
|
49 |
-
def group_member_name_update(a):
|
50 |
if a == "Other":
|
51 |
-
return gr.Textbox(visible=True), gr.Dropdown([], label="Name", allow_custom_value=True)
|
52 |
elif a == "tripleS":
|
53 |
return gr.Textbox(visible=False), gr.Dropdown(
|
54 |
["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede", "DaHyun",
|
55 |
-
"Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon", "ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon"], label="Name",
|
56 |
allow_custom_value=True)
|
57 |
elif a == "ARTMS":
|
58 |
return gr.Textbox(visible=False), gr.Dropdown(["HeeJin", "JinSoul", "Kim Lip", "Choerry", "HaSeul"],
|
59 |
-
label="Name", allow_custom_value=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
|
62 |
def alphabet_txt_update(a):
|
@@ -67,12 +84,9 @@ def alphabet_txt_update(a):
|
|
67 |
|
68 |
|
69 |
def serial_random():
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
ran4 = random.randrange(0, 9)
|
74 |
-
ran5 = random.randrange(0, 9)
|
75 |
-
return gr.Textbox(value=f"{ran1}{ran2}{ran3}{ran4}{ran5}")
|
76 |
|
77 |
def frame_color_update(a):
|
78 |
if a == "Other":
|
@@ -113,6 +127,10 @@ def refresh():
|
|
113 |
# 현재 작업 디렉토리의 폴더 이름들을 튜플로 반환 (특정 폴더 제외)
|
114 |
return folders_tuple
|
115 |
|
|
|
|
|
|
|
|
|
116 |
def dev():
|
117 |
folders = refresh()
|
118 |
return "Do", gr.Dropdown(folders, visible=True, interactive=True)
|
@@ -161,3 +179,19 @@ def txt_class_visibility(a):
|
|
161 |
else:
|
162 |
return gr.Textbox(visible=False)
|
163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pickle
|
2 |
+
|
3 |
import gradio as gr
|
4 |
import random
|
5 |
import shutil
|
|
|
7 |
import edimg
|
8 |
import os
|
9 |
|
10 |
+
import pre
|
11 |
+
|
12 |
|
13 |
def change_img_type(a):
|
14 |
if a == "Image":
|
|
|
50 |
|
51 |
|
52 |
|
53 |
+
def group_member_name_update(a, artist_name, folder):
|
54 |
if a == "Other":
|
55 |
+
return gr.Textbox(visible=True), gr.Dropdown([], label="Member Name", allow_custom_value=True)
|
56 |
elif a == "tripleS":
|
57 |
return gr.Textbox(visible=False), gr.Dropdown(
|
58 |
["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede", "DaHyun",
|
59 |
+
"Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon", "ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon"], label="Member Name",
|
60 |
allow_custom_value=True)
|
61 |
elif a == "ARTMS":
|
62 |
return gr.Textbox(visible=False), gr.Dropdown(["HeeJin", "JinSoul", "Kim Lip", "Choerry", "HaSeul"],
|
63 |
+
label="Member Name", allow_custom_value=True)
|
64 |
+
else:
|
65 |
+
|
66 |
+
directory_path = f"/data/presets/{folder}"
|
67 |
+
|
68 |
+
with open(f'{directory_path}/data.pkl', 'rb') as f:
|
69 |
+
data = pickle.load(f)
|
70 |
+
|
71 |
+
group_name = data['group']
|
72 |
+
artist_name = data['artist']
|
73 |
+
|
74 |
+
member_name_dropdown = gr.Dropdown(choices=artist_name, label="Member Name", allow_custom_value=True,
|
75 |
+
value=artist_name[0])
|
76 |
+
return gr.Textbox(visible=False), member_name_dropdown
|
77 |
|
78 |
|
79 |
def alphabet_txt_update(a):
|
|
|
84 |
|
85 |
|
86 |
def serial_random():
|
87 |
+
random_number = random.randint(0, 99999)
|
88 |
+
formatted_number = f"{random_number:05}"
|
89 |
+
return gr.Textbox(value=formatted_number)
|
|
|
|
|
|
|
90 |
|
91 |
def frame_color_update(a):
|
92 |
if a == "Other":
|
|
|
127 |
# 현재 작업 디렉토리의 폴더 이름들을 튜플로 반환 (특정 폴더 제외)
|
128 |
return folders_tuple
|
129 |
|
130 |
+
|
131 |
+
|
132 |
+
|
133 |
+
|
134 |
def dev():
|
135 |
folders = refresh()
|
136 |
return "Do", gr.Dropdown(folders, visible=True, interactive=True)
|
|
|
179 |
else:
|
180 |
return gr.Textbox(visible=False)
|
181 |
|
182 |
+
def custom_name(count):
|
183 |
+
visibilities = [True] * len(count) + [False] * (12 - len(count))
|
184 |
+
return (
|
185 |
+
gr.Image(label=count[0] if len(count) > 0 else 'Sign', visible=visibilities[0]),
|
186 |
+
gr.Image(label=count[1] if len(count) > 1 else 'Sign', visible=visibilities[1]),
|
187 |
+
gr.Image(label=count[2] if len(count) > 2 else 'Sign', visible=visibilities[2]),
|
188 |
+
gr.Image(label=count[3] if len(count) > 3 else 'Sign', visible=visibilities[3]),
|
189 |
+
gr.Image(label=count[4] if len(count) > 4 else 'Sign', visible=visibilities[4]),
|
190 |
+
gr.Image(label=count[5] if len(count) > 5 else 'Sign', visible=visibilities[5]),
|
191 |
+
gr.Image(label=count[6] if len(count) > 6 else 'Sign', visible=visibilities[6]),
|
192 |
+
gr.Image(label=count[7] if len(count) > 7 else 'Sign', visible=visibilities[7]),
|
193 |
+
gr.Image(label=count[8] if len(count) > 8 else 'Sign', visible=visibilities[8]),
|
194 |
+
gr.Image(label=count[9] if len(count) > 9 else 'Sign', visible=visibilities[9]),
|
195 |
+
gr.Image(label=count[10] if len(count) > 10 else 'Sign', visible=visibilities[10]),
|
196 |
+
gr.Image(label=count[11] if len(count) > 11 else 'Sign', visible=visibilities[11])
|
197 |
+
)
|
generate.py
CHANGED
@@ -89,10 +89,14 @@ def front_static(img, obj_color, obj_color_picker, ai_num, txt_color, txt_color_
|
|
89 |
case "ARTMS":
|
90 |
img_artms_side = edimg.color("resource/artms_side.png", txt_color_hex)
|
91 |
img.paste(img_artms_side, (1081, 1371), img_artms_side)
|
92 |
-
|
93 |
case "Other":
|
94 |
img_group_name = edimg.txt(group_name_txt, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
|
95 |
img.paste(img_group_name, (1050, 1240), img_group_name)
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
if obj_num != "" and obj_alphabet != "":
|
98 |
if obj_alphabet == "Other":
|
@@ -113,6 +117,7 @@ def front_static(img, obj_color, obj_color_picker, ai_num, txt_color, txt_color_
|
|
113 |
|
114 |
back_ui = Image.open("resource/back_ui.png")
|
115 |
outline_ui = Image.open("resource/outline.png")
|
|
|
116 |
|
117 |
|
118 |
sign_positions = {
|
@@ -152,18 +157,22 @@ cream01 = Image.open("resource/cream01.png")
|
|
152 |
atom01 = Image.open("resource/atom01.png")
|
153 |
binary01 = Image.open("resource/binary01.png")
|
154 |
divine01 = Image.open("resource/divine01.png")
|
155 |
-
oma_frame = Image.open("resource/oma_frame.png")
|
156 |
|
157 |
right_modhaus = Image.open("resource/right_modhaus.png")
|
158 |
img_qr_white_space = Image.new("RGB", (335, 335), 'white')
|
159 |
-
def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group_name_radio, group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial, obj_outline_color, obj_outline_color_picker, logo_radio, class_radio, class_txt, season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown, qr_Logo_radio, right_btn, rounded_back):
|
|
|
|
|
|
|
|
|
|
|
160 |
match obj_outline_color:
|
161 |
case "White":
|
162 |
-
outline = edimg.color(
|
163 |
case "Black":
|
164 |
-
outline = edimg.color(
|
165 |
case _:
|
166 |
-
outline = edimg.color(
|
167 |
|
168 |
|
169 |
|
@@ -192,6 +201,7 @@ def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group
|
|
192 |
case _:
|
193 |
img = Image.new("RGB", (1164, 1800), "#FFFFFF")
|
194 |
|
|
|
195 |
img.paste(outline, (0,0), outline)
|
196 |
|
197 |
match txt_color:
|
@@ -220,6 +230,20 @@ def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group
|
|
220 |
case "ARTMS":
|
221 |
logo = edimg.color('resource/artms_logo.png', txt_color_hex)
|
222 |
img.paste(logo, (61, 162), logo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
|
224 |
|
225 |
if member_name_dropdown:
|
@@ -239,7 +263,6 @@ def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group
|
|
239 |
if obj_serial:
|
240 |
img_obj_serial_side = edimg.serial(obj_serial, txt_color_r,txt_color_g,txt_color_b, 75)
|
241 |
img.paste(img_obj_serial_side, (943, 867), img_obj_serial_side)
|
242 |
-
|
243 |
match group_name_radio:
|
244 |
case "tripleS":
|
245 |
img_group_name_side = edimg.txt("tripleS", txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
|
@@ -251,6 +274,12 @@ def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group
|
|
251 |
img_group_name_side = edimg.txt(group_name_txt, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
|
252 |
img.paste(img_group_name_side, (943, 1238), img_group_name_side)
|
253 |
group_name_radio = group_name_txt
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
|
255 |
match class_radio:
|
256 |
case "Zero" | "First" | "Double" | "Special":
|
@@ -307,8 +336,7 @@ def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group
|
|
307 |
if right_btn:
|
308 |
img_right_modhaus = edimg.color(right_modhaus, txt_color_hex)
|
309 |
img.paste(img_right_modhaus, (61,1604), img_right_modhaus)
|
310 |
-
|
311 |
-
img.paste(oma_frame, (0, 0), oma_frame)
|
312 |
if rounded_back:
|
313 |
img = edimg.rounded(img)
|
314 |
|
@@ -363,89 +391,5 @@ def ex_gen(img_front, file_front_path, img_back, count, blur, blur_strength, wat
|
|
363 |
|
364 |
|
365 |
|
366 |
-
underbar = Image.open("event/under.png")
|
367 |
-
|
368 |
-
def event(event_img, event_radio, event_txt, position):
|
369 |
-
if event_img == None:
|
370 |
-
gr.Warning("Upload the image first")
|
371 |
-
return "resource/upload_first.png"
|
372 |
-
|
373 |
-
img_jpeg = event_img.convert('RGB')
|
374 |
-
krtime = fn.get_kr_time()
|
375 |
-
img_jpeg.save(
|
376 |
-
f'/data/cache/event_original_{krtime}.jpg',
|
377 |
-
quality=90)
|
378 |
-
|
379 |
-
#txt가 x700 넘을때 경우 나누기
|
380 |
-
|
381 |
-
images_list = []
|
382 |
-
|
383 |
-
# 반복문을 사용하여 이미지 생성 및 추가
|
384 |
-
for i in range(4):
|
385 |
-
|
386 |
-
event_img_s = event_img.copy()
|
387 |
-
event_black = Image.open("event/Black.png")
|
388 |
-
event_white = Image.open("event/White.png")
|
389 |
-
match event_radio:
|
390 |
-
case "White":
|
391 |
-
r = 255
|
392 |
-
g = 255
|
393 |
-
b = 255
|
394 |
-
hex = "#FFFFFF"
|
395 |
-
event_img_gnd = event_white
|
396 |
-
case "Black":
|
397 |
-
r = 0
|
398 |
-
g = 0
|
399 |
-
b = 0
|
400 |
-
hex = "#000"
|
401 |
-
event_img_gnd = event_black
|
402 |
-
case _:
|
403 |
-
r = 0
|
404 |
-
g = 0
|
405 |
-
b = 0
|
406 |
-
hex = "#000"
|
407 |
-
event_img_gnd = event_black
|
408 |
-
|
409 |
-
i1 = i + 1
|
410 |
-
x = edimg.calculate_size(event_txt, 260, f"event/{i1}.ttf")
|
411 |
-
match i:
|
412 |
-
case 0:
|
413 |
-
offset_x = -30
|
414 |
-
offset_y = 0
|
415 |
-
case 1:
|
416 |
-
offset_x = 80
|
417 |
-
offset_y = 0
|
418 |
-
case 2:
|
419 |
-
offset_x = 0
|
420 |
-
offset_y = 0
|
421 |
-
case 3:
|
422 |
-
offset_x = 70
|
423 |
-
offset_y = 20
|
424 |
-
case _:
|
425 |
-
offset_x = 0
|
426 |
-
offset_y = 0
|
427 |
-
img_txt = edimg.txt(event_txt, r, g, b, 260, 0, "l", f"event/{i1}.ttf", (3000, 370 - offset_y))
|
428 |
-
x_half = x / 2
|
429 |
-
event_img_gnd.paste(img_txt, (2434 - int(x_half), 0), img_txt)
|
430 |
-
x, y = event_img_s.size
|
431 |
-
x1, y1 = event_img_gnd.size
|
432 |
-
y2 = x * y1 / x1
|
433 |
-
event_img_gnd = edimg.resize_img(event_img_gnd, int(x), int(y2))
|
434 |
-
y3 = find_value(y - y2, position)
|
435 |
-
event_img_s.paste(event_img_gnd, (0, int(y3)), event_img_gnd)
|
436 |
-
img_jpeg = event_img_s.convert('RGB')
|
437 |
-
krtime = fn.get_kr_time()
|
438 |
-
img_jpeg.save(
|
439 |
-
f'/data/cache/event_{krtime}_{i1}.jpg',
|
440 |
-
quality=70)
|
441 |
-
# 이미지 리스트에 추가
|
442 |
-
|
443 |
-
images_list.append(event_img_s)
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
return images_list
|
448 |
-
|
449 |
-
|
450 |
def find_value(n, percent):
|
451 |
return n * (percent / 100.0)
|
|
|
89 |
case "ARTMS":
|
90 |
img_artms_side = edimg.color("resource/artms_side.png", txt_color_hex)
|
91 |
img.paste(img_artms_side, (1081, 1371), img_artms_side)
|
|
|
92 |
case "Other":
|
93 |
img_group_name = edimg.txt(group_name_txt, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
|
94 |
img.paste(img_group_name, (1050, 1240), img_group_name)
|
95 |
+
case None:
|
96 |
+
pass
|
97 |
+
case _:
|
98 |
+
img_group_name = edimg.txt(group_name_radio, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
|
99 |
+
img.paste(img_group_name, (1050, 1240), img_group_name)
|
100 |
|
101 |
if obj_num != "" and obj_alphabet != "":
|
102 |
if obj_alphabet == "Other":
|
|
|
117 |
|
118 |
back_ui = Image.open("resource/back_ui.png")
|
119 |
outline_ui = Image.open("resource/outline.png")
|
120 |
+
outline_ui_oma = Image.open("resource/outline_oma.png")
|
121 |
|
122 |
|
123 |
sign_positions = {
|
|
|
157 |
atom01 = Image.open("resource/atom01.png")
|
158 |
binary01 = Image.open("resource/binary01.png")
|
159 |
divine01 = Image.open("resource/divine01.png")
|
|
|
160 |
|
161 |
right_modhaus = Image.open("resource/right_modhaus.png")
|
162 |
img_qr_white_space = Image.new("RGB", (335, 335), 'white')
|
163 |
+
def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group_name_radio, group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial, obj_outline_color, obj_outline_color_picker, logo_radio, class_radio, class_txt, season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown, qr_Logo_radio, right_btn, rounded_back, preset):
|
164 |
+
if obj_color == 'OMA':
|
165 |
+
frame = outline_ui_oma
|
166 |
+
else:
|
167 |
+
frame = outline_ui
|
168 |
+
|
169 |
match obj_outline_color:
|
170 |
case "White":
|
171 |
+
outline = edimg.color(frame, "#FFFFFF")
|
172 |
case "Black":
|
173 |
+
outline = edimg.color(frame, "#000000")
|
174 |
case _:
|
175 |
+
outline = edimg.color(frame, obj_outline_color_picker)
|
176 |
|
177 |
|
178 |
|
|
|
201 |
case _:
|
202 |
img = Image.new("RGB", (1164, 1800), "#FFFFFF")
|
203 |
|
204 |
+
|
205 |
img.paste(outline, (0,0), outline)
|
206 |
|
207 |
match txt_color:
|
|
|
230 |
case "ARTMS":
|
231 |
logo = edimg.color('resource/artms_logo.png', txt_color_hex)
|
232 |
img.paste(logo, (61, 162), logo)
|
233 |
+
case 'None':
|
234 |
+
pass
|
235 |
+
case _:
|
236 |
+
logo = edimg.color(f'/data/presets/{preset}/top_logo.png', txt_color_hex)
|
237 |
+
width, height = logo.size
|
238 |
+
|
239 |
+
# Calculate the new width to maintain the aspect ratio
|
240 |
+
new_height = 117
|
241 |
+
aspect_ratio = width / height
|
242 |
+
new_width = int(new_height * aspect_ratio)
|
243 |
+
|
244 |
+
# Resize the image
|
245 |
+
logo = logo.resize((new_width, new_height), Image.Resampling.LANCZOS)
|
246 |
+
img.paste(logo, (57, 151), logo)
|
247 |
|
248 |
|
249 |
if member_name_dropdown:
|
|
|
263 |
if obj_serial:
|
264 |
img_obj_serial_side = edimg.serial(obj_serial, txt_color_r,txt_color_g,txt_color_b, 75)
|
265 |
img.paste(img_obj_serial_side, (943, 867), img_obj_serial_side)
|
|
|
266 |
match group_name_radio:
|
267 |
case "tripleS":
|
268 |
img_group_name_side = edimg.txt("tripleS", txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
|
|
|
274 |
img_group_name_side = edimg.txt(group_name_txt, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
|
275 |
img.paste(img_group_name_side, (943, 1238), img_group_name_side)
|
276 |
group_name_radio = group_name_txt
|
277 |
+
case None:
|
278 |
+
pass
|
279 |
+
case _:
|
280 |
+
img_group_name_side = edimg.txt(group_name_radio, txt_color_r, txt_color_g, txt_color_b, 61, 270, "r")
|
281 |
+
img.paste(img_group_name_side, (943, 1238), img_group_name_side)
|
282 |
+
group_name_radio = group_name_txt
|
283 |
|
284 |
match class_radio:
|
285 |
case "Zero" | "First" | "Double" | "Special":
|
|
|
336 |
if right_btn:
|
337 |
img_right_modhaus = edimg.color(right_modhaus, txt_color_hex)
|
338 |
img.paste(img_right_modhaus, (61,1604), img_right_modhaus)
|
339 |
+
|
|
|
340 |
if rounded_back:
|
341 |
img = edimg.rounded(img)
|
342 |
|
|
|
391 |
|
392 |
|
393 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
def find_value(n, percent):
|
395 |
return n * (percent / 100.0)
|
login_discord.py
CHANGED
@@ -2,23 +2,25 @@ import requests
|
|
2 |
import gradio as gr
|
3 |
from urllib.parse import urlparse, parse_qs
|
4 |
|
|
|
|
|
|
|
5 |
def id_check(request: gr.Request):
|
6 |
param = str(request.query_params)
|
7 |
if not "code=" in param:
|
8 |
-
return "Login to Discord", gr.Tab(visible=False), gr.
|
9 |
|
10 |
code = param.split('code=')
|
11 |
print(code[1])
|
12 |
|
13 |
user_id, username, avatar_url = get_discord_user_profile(str(code[1]))
|
14 |
if user_id == None:
|
15 |
-
return "Login to Discord", gr.Tab(visible=False)
|
16 |
if user_id == "412827396027187211":
|
17 |
-
return gr.Button(value=username, icon=avatar_url, link=redirect_uri), gr.Tab(visible=True), gr.
|
18 |
-
|
19 |
-
return gr.Button(value=username, icon=avatar_url, link=redirect_uri), gr.Tab(visible=False), gr.Radio(["Atom01", "Binary01", "Cream01", "Divine01", "Special", "OMA", "Other color", "AI Color"],label="Objekt Color", value="Divine01"), gr.Tab(visible=True)
|
20 |
print(user_id)
|
21 |
-
return gr.Button(value=username, icon=avatar_url, link=redirect_uri), gr.Tab(visible=False), gr.
|
22 |
#1
|
23 |
|
24 |
def get_discord_user_profile(code):
|
@@ -62,11 +64,13 @@ def get_discord_user_profile(code):
|
|
62 |
except requests.exceptions.RequestException as e:
|
63 |
print("Error to login")
|
64 |
# print(str(e)) # 오류 내용 출력을 원한다면 주석 해제
|
65 |
-
return
|
66 |
|
67 |
# 사용 예:
|
68 |
client_id = "1239473790732472370"
|
69 |
client_secret = "C7RLdB4YArSM9jVk8tsznQnKOzwGKwsO"
|
70 |
# code = "THE_CODE_FROM_REDIRECT_URI"
|
71 |
-
redirect_uri = "https://chohj06ms-objektify2.hf.space/"
|
|
|
|
|
72 |
|
|
|
2 |
import gradio as gr
|
3 |
from urllib.parse import urlparse, parse_qs
|
4 |
|
5 |
+
import pre
|
6 |
+
|
7 |
+
|
8 |
def id_check(request: gr.Request):
|
9 |
param = str(request.query_params)
|
10 |
if not "code=" in param:
|
11 |
+
return "Login to Discord", gr.Tab(visible=False), gr.Tab(visible=False), '', gr.Tab(visible=False), gr.Dropdown(visible=False)
|
12 |
|
13 |
code = param.split('code=')
|
14 |
print(code[1])
|
15 |
|
16 |
user_id, username, avatar_url = get_discord_user_profile(str(code[1]))
|
17 |
if user_id == None:
|
18 |
+
return "Login to Discord", gr.Tab(visible=False), gr.Tab(visible=False), '', gr.Tab(visible=False), gr.Dropdown(visible=False)
|
19 |
if user_id == "412827396027187211":
|
20 |
+
return gr.Button(value=username, icon=avatar_url, link=redirect_uri), gr.Tab(visible=True), gr.Tab(visible=True), user_id, gr.Tab(visible=True), gr.Dropdown(visible=True)
|
21 |
+
|
|
|
22 |
print(user_id)
|
23 |
+
return gr.Button(value=username, icon=avatar_url, link=redirect_uri), gr.Tab(visible=False), gr.Tab(visible=False), user_id, gr.Tab(visible=True), gr.Dropdown(visible=True)
|
24 |
#1
|
25 |
|
26 |
def get_discord_user_profile(code):
|
|
|
64 |
except requests.exceptions.RequestException as e:
|
65 |
print("Error to login")
|
66 |
# print(str(e)) # 오류 내용 출력을 원한다면 주석 해제
|
67 |
+
return None, None, None
|
68 |
|
69 |
# 사용 예:
|
70 |
client_id = "1239473790732472370"
|
71 |
client_secret = "C7RLdB4YArSM9jVk8tsznQnKOzwGKwsO"
|
72 |
# code = "THE_CODE_FROM_REDIRECT_URI"
|
73 |
+
#redirect_uri = "https://chohj06ms-objektify2.hf.space/"
|
74 |
+
redirect_uri = pre.login_uri
|
75 |
+
|
76 |
|
main.py
CHANGED
@@ -1,8 +1,12 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
import fns
|
3 |
import generate
|
4 |
import login_discord
|
|
|
5 |
import rekord
|
|
|
6 |
|
7 |
js_func = """
|
8 |
function refresh() {
|
@@ -14,23 +18,37 @@ function refresh() {
|
|
14 |
}
|
15 |
}
|
16 |
"""
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
with gr.Column():
|
19 |
with gr.Row():
|
20 |
gr.Markdown(
|
21 |
"""
|
22 |
# Objektify
|
23 |
""")
|
24 |
-
login = gr.Button(size="sm", value="Login to Discord", link="https://discord.com/oauth2/authorize?client_id=1239473790732472370&response_type=code&redirect_uri=
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
|
35 |
|
36 |
with gr.Tab("Front"):
|
@@ -49,8 +67,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo: # , js=js_func
|
|
49 |
|
50 |
|
51 |
with gr.Column(): #2
|
52 |
-
with gr.
|
53 |
-
obj_color = gr.Radio(["Atom01", "Binary01", "Cream01", "Divine01", "Special", "Other color", "AI Color"],
|
54 |
|
55 |
with gr.Row():
|
56 |
ai_num = gr.Slider(1, 1000, 500, label="AI Serial", visible=False, step=1)
|
@@ -61,27 +79,25 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo: # , js=js_func
|
|
61 |
obj_color.change(fn=fns.obj_color_update, inputs=obj_color, outputs=[obj_color_picker, ai_num, change_ai])
|
62 |
|
63 |
|
64 |
-
|
65 |
txt_color = gr.Radio(["White", "Black", "Other"], label="Text Color", value="Black")
|
66 |
txt_color_picker = gr.ColorPicker(label="Other Text Color", value="#ffffff", visible=False, interactive=True)
|
67 |
txt_color.change(fns.txt_color_update, txt_color, txt_color_picker)
|
68 |
-
|
69 |
-
|
|
|
|
|
70 |
group_name_txt = gr.Textbox(label="Other Group name", placeholder="CLASSY", visible=False, interactive=True)
|
71 |
|
72 |
-
with gr.Group():
|
73 |
-
member_name_dropdown = gr.Dropdown(
|
74 |
-
["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede",
|
75 |
-
"DaHyun", "Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon",
|
76 |
-
"ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon"], label="Member Name", allow_custom_value=True)
|
77 |
|
78 |
-
|
|
|
79 |
|
80 |
|
81 |
with gr.Accordion("Add Objekt Number", open=False):
|
82 |
with gr.Row():
|
83 |
obj_num = gr.Textbox(label="Objekt Number", placeholder="100", interactive=True, visible=True, scale=1)
|
84 |
-
obj_alphabet = gr.Radio(["Z", "A", "Other"], label="Z or A", interactive=True, visible=True, scale=1)
|
85 |
obj_alphabet_txt = gr.Textbox(label="Alphabet", placeholder="S", interactive=True, visible=False, scale=1)
|
86 |
|
87 |
obj_alphabet.change(fns.alphabet_txt_update, obj_alphabet, obj_alphabet_txt)
|
@@ -107,24 +123,24 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo: # , js=js_func
|
|
107 |
with gr.Tab("Back") as back_tab:
|
108 |
with gr.Row():
|
109 |
preview = gr.Image(label="Image", interactive=False)
|
|
|
110 |
with gr.Column():
|
111 |
-
with gr.
|
112 |
obj_outline_color = gr.Radio(["White", "Black", "Other"], label="Frame color", value="White")
|
113 |
obj_outline_color_picker = gr.ColorPicker(label="Other Outline Color", value="#ffffff", visible=False, interactive=True)
|
114 |
|
115 |
obj_outline_color.change(fns.frame_color_update, obj_outline_color, obj_outline_color_picker)
|
116 |
|
117 |
-
|
118 |
-
logo_radio = gr.Radio(["tripleS", "ARTMS", "None"], label="Add Logo", interactive=True, value="None")
|
119 |
|
120 |
|
121 |
-
with gr.
|
122 |
class_radio = gr.Radio(["Zero", "First", "Double", "Special", "Other"], label="CLASS", visible=True)
|
123 |
class_txt = gr.Textbox(label="Other class", placeholder="Third", visible=False)
|
124 |
|
125 |
class_radio.change(fns.txt_class_visibility, class_radio, class_txt)
|
126 |
|
127 |
-
|
128 |
season_radio = gr.Radio(["Atom01", "Binary01", "Cream01", "Divine01", "Other"], label="SEASON", type="value")
|
129 |
|
130 |
with gr.Row():
|
@@ -133,23 +149,19 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo: # , js=js_func
|
|
133 |
|
134 |
season_radio.change(fns.txt_season_visibility, season_radio, [season_txt, season_txt_outline])
|
135 |
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
with gr.Group():
|
150 |
-
rounded_back = gr.Checkbox(label="Rounded", value=True, interactive=True)
|
151 |
-
with gr.Group():
|
152 |
-
generate_btn_back = gr.Button(value="Generate")
|
153 |
|
154 |
with gr.Column():
|
155 |
outputs2 = gr.Image(label="Edited Image", scale=10)
|
@@ -175,25 +187,51 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo: # , js=js_func
|
|
175 |
with gr.Row():
|
176 |
ex_img_f_out = gr.Image(label="Front", interactive=False)
|
177 |
ex_img_b_out = gr.Image(label="Back", visible=False, interactive=False)
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
with gr.Row():
|
180 |
with gr.Column():
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
with gr.Tab("ReKord", visible=False) as rec:
|
191 |
rekord_img = gr.Image(type="filepath")
|
192 |
|
193 |
-
rekord_member = gr.Dropdown(
|
194 |
-
["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede",
|
195 |
-
"DaHyun", "Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon",
|
196 |
-
"ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon", "HeeJin", "KimLip", "JinSoul", "Choerry", "HaSeul"], label="Sign", type='index')
|
197 |
rekord_submit = gr.Button()
|
198 |
rekord_out = gr.Textbox()
|
199 |
rekord_submit.click(fn=rekord.upload, inputs=[rekord_img, rekord_member], outputs=rekord_out)
|
@@ -219,11 +257,20 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo: # , js=js_func
|
|
219 |
## Made by
|
220 |
# Discord : hj_sss
|
221 |
## official discord
|
222 |
-
### [Click here and Join](https://discord.
|
223 |
|
224 |
### Members or group presets can be added and advertised. Check the official discord.
|
225 |
#### Check the objektify official discord for licensing and other data processing policies.
|
226 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
|
228 |
generate_btn.click(fn=generate.sorting,
|
229 |
inputs=[img_type, img_static, img_dynamic_file, obj_color, obj_color_picker, ai_num, txt_color,
|
@@ -241,17 +288,18 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo: # , js=js_func
|
|
241 |
group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt,
|
242 |
obj_serial, obj_outline_color, obj_outline_color_picker, logo_radio, class_radio,
|
243 |
class_txt, season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown,
|
244 |
-
qr_Logo_radio, right_btn, rounded_back], outputs=[outputs2, ex_img_b])
|
245 |
|
246 |
back_tab.select(fn=generate.back,
|
247 |
inputs=[obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group_name_radio,
|
248 |
group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial,
|
249 |
obj_outline_color, obj_outline_color_picker, logo_radio, class_radio, class_txt,
|
250 |
season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown, qr_Logo_radio,
|
251 |
-
right_btn, rounded_back], outputs=[preview, ex_img_b])
|
252 |
|
253 |
ex_btn.click(fn=generate.ex_gen, inputs=[ex_img_f, ex_file_f, ex_img_b, ex_gen_file_count, ex_hide_blur, ex_hide_blur_range, watermark], outputs=[ex_img_f_out, ex_img_b_out])
|
254 |
-
demo.load(fn=login_discord.id_check, outputs=[login, dev,
|
|
|
255 |
|
256 |
|
257 |
|
|
|
1 |
import gradio as gr
|
2 |
+
|
3 |
+
import beta_fn
|
4 |
import fns
|
5 |
import generate
|
6 |
import login_discord
|
7 |
+
import preset_fn
|
8 |
import rekord
|
9 |
+
import pre
|
10 |
|
11 |
js_func = """
|
12 |
function refresh() {
|
|
|
18 |
}
|
19 |
}
|
20 |
"""
|
21 |
+
|
22 |
+
|
23 |
+
theme = gr.themes.Soft(
|
24 |
+
secondary_hue="violet",
|
25 |
+
text_size="sm",
|
26 |
+
spacing_size="sm",
|
27 |
+
radius_size="lg",
|
28 |
+
).set(
|
29 |
+
block_background_fill='*secondary_50'
|
30 |
+
)
|
31 |
+
|
32 |
+
|
33 |
+
login_uri = pre.login_uri
|
34 |
+
|
35 |
+
|
36 |
+
with gr.Blocks(theme=theme) as demo: # , js=js_func
|
37 |
with gr.Column():
|
38 |
with gr.Row():
|
39 |
gr.Markdown(
|
40 |
"""
|
41 |
# Objektify
|
42 |
""")
|
43 |
+
login = gr.Button(size="sm", value="Login to Discord", link=f"https://discord.com/oauth2/authorize?client_id=1239473790732472370&response_type=code&redirect_uri={login_uri}&scope=identify", scale=0)
|
44 |
+
with gr.Row():
|
45 |
+
gr.Markdown(
|
46 |
+
"""
|
47 |
+
### [Join objektify official discord!](https://discord.com/invite/KAuTCUGXpH)
|
48 |
+
## Input image and Select Options
|
49 |
+
"""
|
50 |
+
)
|
51 |
+
preset = gr.Dropdown(scale=0, label='Preset', interactive=True, allow_custom_value=False, type='value', visible=False)
|
|
|
52 |
|
53 |
|
54 |
with gr.Tab("Front"):
|
|
|
67 |
|
68 |
|
69 |
with gr.Column(): #2
|
70 |
+
with gr.Accordion(label='Colors'): #objekt color
|
71 |
+
obj_color = gr.Radio(["Atom01", "Binary01", "Cream01", "Divine01", "Special", "OMA","Other color", "AI Color"], value="Cream01", label='Objekt Color')
|
72 |
|
73 |
with gr.Row():
|
74 |
ai_num = gr.Slider(1, 1000, 500, label="AI Serial", visible=False, step=1)
|
|
|
79 |
obj_color.change(fn=fns.obj_color_update, inputs=obj_color, outputs=[obj_color_picker, ai_num, change_ai])
|
80 |
|
81 |
|
82 |
+
|
83 |
txt_color = gr.Radio(["White", "Black", "Other"], label="Text Color", value="Black")
|
84 |
txt_color_picker = gr.ColorPicker(label="Other Text Color", value="#ffffff", visible=False, interactive=True)
|
85 |
txt_color.change(fns.txt_color_update, txt_color, txt_color_picker)
|
86 |
+
|
87 |
+
|
88 |
+
with gr.Accordion('Names'):
|
89 |
+
group_name_radio = gr.Radio(choices=pre.groups_Other, label="Group Name")
|
90 |
group_name_txt = gr.Textbox(label="Other Group name", placeholder="CLASSY", visible=False, interactive=True)
|
91 |
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
+
member_name_dropdown = gr.Dropdown(choices=pre.names, label="Member Name", allow_custom_value=True)
|
94 |
+
|
95 |
|
96 |
|
97 |
with gr.Accordion("Add Objekt Number", open=False):
|
98 |
with gr.Row():
|
99 |
obj_num = gr.Textbox(label="Objekt Number", placeholder="100", interactive=True, visible=True, scale=1)
|
100 |
+
obj_alphabet = gr.Radio(["Z", "A", "Other"], label="Z or A", interactive=True, visible=True, scale=1, value='Z')
|
101 |
obj_alphabet_txt = gr.Textbox(label="Alphabet", placeholder="S", interactive=True, visible=False, scale=1)
|
102 |
|
103 |
obj_alphabet.change(fns.alphabet_txt_update, obj_alphabet, obj_alphabet_txt)
|
|
|
123 |
with gr.Tab("Back") as back_tab:
|
124 |
with gr.Row():
|
125 |
preview = gr.Image(label="Image", interactive=False)
|
126 |
+
|
127 |
with gr.Column():
|
128 |
+
with gr.Accordion('Contents'):
|
129 |
obj_outline_color = gr.Radio(["White", "Black", "Other"], label="Frame color", value="White")
|
130 |
obj_outline_color_picker = gr.ColorPicker(label="Other Outline Color", value="#ffffff", visible=False, interactive=True)
|
131 |
|
132 |
obj_outline_color.change(fns.frame_color_update, obj_outline_color, obj_outline_color_picker)
|
133 |
|
134 |
+
logo_radio = gr.Radio(choices=pre.groups, label="Add Logo", interactive=True, value="None")
|
|
|
135 |
|
136 |
|
137 |
+
with gr.Accordion('Texts'):
|
138 |
class_radio = gr.Radio(["Zero", "First", "Double", "Special", "Other"], label="CLASS", visible=True)
|
139 |
class_txt = gr.Textbox(label="Other class", placeholder="Third", visible=False)
|
140 |
|
141 |
class_radio.change(fns.txt_class_visibility, class_radio, class_txt)
|
142 |
|
143 |
+
|
144 |
season_radio = gr.Radio(["Atom01", "Binary01", "Cream01", "Divine01", "Other"], label="SEASON", type="value")
|
145 |
|
146 |
with gr.Row():
|
|
|
149 |
|
150 |
season_radio.change(fns.txt_season_visibility, season_radio, [season_txt, season_txt_outline])
|
151 |
|
152 |
+
|
153 |
+
sign = gr.Dropdown(choices=pre.names, label="Sign", type='index')
|
154 |
+
|
155 |
+
|
156 |
+
with gr.Accordion('QR Options'):
|
157 |
+
qr_url_dropdown = gr.Dropdown(["tripleS website", "tripleS youtube", "tripleS 𝕏", "tripleS discord"], label="QR url", info="Can write any url", allow_custom_value=True, value='https://objektify.wav.haus')
|
158 |
+
|
159 |
+
qr_Logo_radio = gr.Radio(["tripleS", "None"], label="QR Logo", value="None", interactive=True)
|
160 |
+
|
161 |
+
|
162 |
+
right_btn = gr.Checkbox(label="Add Rights", value=False, interactive=True)
|
163 |
+
rounded_back = gr.Checkbox(label="Rounded", value=True, interactive=True)
|
164 |
+
generate_btn_back = gr.Button(value="Generate")
|
|
|
|
|
|
|
|
|
165 |
|
166 |
with gr.Column():
|
167 |
outputs2 = gr.Image(label="Edited Image", scale=10)
|
|
|
187 |
with gr.Row():
|
188 |
ex_img_f_out = gr.Image(label="Front", interactive=False)
|
189 |
ex_img_b_out = gr.Image(label="Back", visible=False, interactive=False)
|
190 |
+
|
191 |
+
|
192 |
+
with gr.Tab("Beta", visible=True) as beta:
|
193 |
+
gr.Markdown(
|
194 |
+
"""
|
195 |
+
## This is the beta channel for testing new features.
|
196 |
+
### Please join [here](https://discord.com/invite/KAuTCUGXpH) to report bugs and provide feedback.
|
197 |
+
"""
|
198 |
+
)
|
199 |
with gr.Row():
|
200 |
with gr.Column():
|
201 |
+
preset_name = gr.Textbox(label="Set preset name", placeholder="aespa winter")
|
202 |
+
artist_name = gr.Dropdown(label="Artist name", multiselect=True, allow_custom_value=True, info="Press Enter to add more than 1 people (Max 12)", max_choices=12)
|
203 |
+
group_name = gr.Textbox(label="Group name", placeholder="aespa")
|
204 |
+
company_name = gr.Textbox(label="Company name", placeholder="SM ent")
|
205 |
+
|
206 |
+
top_logo_img = gr.Image(label="Top Logo", type='pil')
|
207 |
+
qr_logo_img = gr.Image(label="QR Logo", type='pil')
|
208 |
+
|
209 |
+
with gr.Accordion('Signs', open=True):
|
210 |
+
with gr.Row():
|
211 |
+
sign_img1 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
|
212 |
+
sign_img2 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
|
213 |
+
sign_img3 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
|
214 |
+
sign_img4 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
|
215 |
+
with gr.Row():
|
216 |
+
sign_img5 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
|
217 |
+
sign_img6 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
|
218 |
+
sign_img7 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
|
219 |
+
sign_img8 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
|
220 |
+
with gr.Row():
|
221 |
+
sign_img9 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
|
222 |
+
sign_img10 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
|
223 |
+
sign_img11 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
|
224 |
+
sign_img12 = gr.Image(label="Sign", visible=False, interactive=True, type='pil')
|
225 |
+
|
226 |
+
save = gr.Button(value="Save and Apply all")
|
227 |
+
|
228 |
+
|
229 |
+
artist_name.change(fn=fns.custom_name, inputs=artist_name, outputs=[sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12])
|
230 |
+
|
231 |
with gr.Tab("ReKord", visible=False) as rec:
|
232 |
rekord_img = gr.Image(type="filepath")
|
233 |
|
234 |
+
rekord_member = gr.Dropdown(choices=pre.names, label="Sign", type='index')
|
|
|
|
|
|
|
235 |
rekord_submit = gr.Button()
|
236 |
rekord_out = gr.Textbox()
|
237 |
rekord_submit.click(fn=rekord.upload, inputs=[rekord_img, rekord_member], outputs=rekord_out)
|
|
|
257 |
## Made by
|
258 |
# Discord : hj_sss
|
259 |
## official discord
|
260 |
+
### [Click here and Join](https://discord.com/invite/KAuTCUGXpH)
|
261 |
|
262 |
### Members or group presets can be added and advertised. Check the official discord.
|
263 |
#### Check the objektify official discord for licensing and other data processing policies.
|
264 |
""")
|
265 |
+
userid = gr.Textbox(visible=False)
|
266 |
+
|
267 |
+
preset.change(fn=preset_fn.apply, inputs=preset,
|
268 |
+
outputs=[group_name_radio, member_name_dropdown, logo_radio, sign, qr_Logo_radio, preset])
|
269 |
+
|
270 |
+
group_name_radio.change(fns.group_member_name_update, [group_name_radio, artist_name, preset], [group_name_txt, member_name_dropdown])
|
271 |
+
|
272 |
+
save.click(fn=beta_fn.save, inputs=[preset_name, artist_name, group_name, company_name, top_logo_img, qr_logo_img, sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12, userid, login], outputs=[group_name_radio, member_name_dropdown, logo_radio, sign, qr_Logo_radio, preset])
|
273 |
+
|
274 |
|
275 |
generate_btn.click(fn=generate.sorting,
|
276 |
inputs=[img_type, img_static, img_dynamic_file, obj_color, obj_color_picker, ai_num, txt_color,
|
|
|
288 |
group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt,
|
289 |
obj_serial, obj_outline_color, obj_outline_color_picker, logo_radio, class_radio,
|
290 |
class_txt, season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown,
|
291 |
+
qr_Logo_radio, right_btn, rounded_back, preset], outputs=[outputs2, ex_img_b])
|
292 |
|
293 |
back_tab.select(fn=generate.back,
|
294 |
inputs=[obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group_name_radio,
|
295 |
group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial,
|
296 |
obj_outline_color, obj_outline_color_picker, logo_radio, class_radio, class_txt,
|
297 |
season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown, qr_Logo_radio,
|
298 |
+
right_btn, rounded_back, preset], outputs=[preview, ex_img_b])
|
299 |
|
300 |
ex_btn.click(fn=generate.ex_gen, inputs=[ex_img_f, ex_file_f, ex_img_b, ex_gen_file_count, ex_hide_blur, ex_hide_blur_range, watermark], outputs=[ex_img_f_out, ex_img_b_out])
|
301 |
+
demo.load(fn=login_discord.id_check, outputs=[login, dev, rec, userid, beta, preset])
|
302 |
+
demo.load(fn=preset_fn.refresh, outputs=preset)
|
303 |
|
304 |
|
305 |
|
pre.py
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
groups = ["tripleS", "ARTMS", "None"]
|
2 |
+
groups_Other = ["tripleS", "ARTMS", "Other"]
|
3 |
+
names = ["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede", "DaHyun", "Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon", "ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon", "HeeJin", "KimLip", "JinSoul", "Choerry", "HaSeul"]
|
4 |
+
login_uri = 'http://localhost:7860/'
|
5 |
+
#login_uri = 'http://localhost:7860'
|
preset_fn.py
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cairosvg
|
2 |
+
import gradio as gr
|
3 |
+
import random
|
4 |
+
import shutil
|
5 |
+
import fn
|
6 |
+
import edimg
|
7 |
+
import os
|
8 |
+
from PIL import Image, ImageDraw, ImageFont, ImageColor, ImageFilter, ImageSequence
|
9 |
+
import pickle
|
10 |
+
|
11 |
+
import pre
|
12 |
+
from wand.image import Image
|
13 |
+
from wand.color import Color
|
14 |
+
|
15 |
+
def convert_svg_to_image(svg_path, output_path):
|
16 |
+
with Image(filename=svg_path, background=Color('white')) as img:
|
17 |
+
img.format = 'png'
|
18 |
+
img.save(filename=output_path)
|
19 |
+
|
20 |
+
def refresh():
|
21 |
+
|
22 |
+
directory_path = "/data/presets"
|
23 |
+
|
24 |
+
if not os.path.exists(directory_path):
|
25 |
+
os.makedirs(directory_path)
|
26 |
+
else:
|
27 |
+
print(f"폴더 '{directory_path}'가 이미 존재합니다.")
|
28 |
+
|
29 |
+
items = os.listdir(directory_path)
|
30 |
+
folders = [item for item in items]
|
31 |
+
|
32 |
+
return gr.Dropdown(folders)
|
33 |
+
|
34 |
+
def refresh_folder():
|
35 |
+
|
36 |
+
directory_path = "/data/presets"
|
37 |
+
|
38 |
+
if not os.path.exists(directory_path):
|
39 |
+
os.makedirs(directory_path)
|
40 |
+
else:
|
41 |
+
print(f"폴더 '{directory_path}'가 이미 존재합니다.")
|
42 |
+
|
43 |
+
items = os.listdir(directory_path)
|
44 |
+
folders = [item for item in items]
|
45 |
+
|
46 |
+
return folders
|
47 |
+
|
48 |
+
def create(userid, user_name, preset_name, group, artist, company, top_logo, qr_logo, sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12):
|
49 |
+
print(user_name)
|
50 |
+
|
51 |
+
path = f"/data/presets/{preset_name}_{user_name.split('#')[0]}"
|
52 |
+
if not os.path.exists(path):
|
53 |
+
os.makedirs(path)
|
54 |
+
else:
|
55 |
+
shutil.rmtree(path)
|
56 |
+
os.makedirs(path)
|
57 |
+
|
58 |
+
if isinstance(top_logo, str):
|
59 |
+
cairosvg.svg2png(url=top_logo, write_to=f"{path}/top_logo.png")
|
60 |
+
else:
|
61 |
+
top_logo.save(f"{path}/top_logo.png")
|
62 |
+
|
63 |
+
if isinstance(qr_logo, str):
|
64 |
+
cairosvg.svg2png(url=qr_logo, write_to=f"{path}/qr_logo.png")
|
65 |
+
else:
|
66 |
+
qr_logo.save(f"{path}/qr_logo.png")
|
67 |
+
|
68 |
+
|
69 |
+
signs = [sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12]
|
70 |
+
|
71 |
+
|
72 |
+
for i in range(len(artist)):
|
73 |
+
if isinstance(signs[i], str):
|
74 |
+
cairosvg.svg2png(url=signs[i], write_to=f"{path}/sign{i}.png")
|
75 |
+
else:
|
76 |
+
signs[i].save(f"{path}/sign{i}.png")
|
77 |
+
|
78 |
+
data = {}
|
79 |
+
data['userid'] = userid
|
80 |
+
data['preset_name'] = preset_name
|
81 |
+
data['group'] = group
|
82 |
+
data['artist'] = artist
|
83 |
+
data['company'] = company
|
84 |
+
|
85 |
+
with open(f'{path}/data.pkl', 'wb') as f:
|
86 |
+
pickle.dump(data, f)
|
87 |
+
|
88 |
+
f.close()
|
89 |
+
|
90 |
+
return f"{preset_name}_{user_name.split('#')[0]}"
|
91 |
+
|
92 |
+
|
93 |
+
def apply(folder):
|
94 |
+
if folder == None:
|
95 |
+
return
|
96 |
+
directory_path = f"/data/presets/{folder}"
|
97 |
+
|
98 |
+
with open(f'{directory_path}/data.pkl', 'rb') as f:
|
99 |
+
data = pickle.load(f)
|
100 |
+
|
101 |
+
group_name = data['group']
|
102 |
+
artist_name = data['artist']
|
103 |
+
|
104 |
+
group_name_radio = gr.Radio(choices=[group_name] + pre.groups_Other, label="Group Name", value=group_name)
|
105 |
+
member_name_dropdown = gr.Dropdown(choices=artist_name, label="Member Name", allow_custom_value=True,
|
106 |
+
value=artist_name[0])
|
107 |
+
logo_radio = gr.Radio(choices=[group_name] + pre.groups, label="Add Logo", interactive=True, value=group_name)
|
108 |
+
sign = gr.Dropdown(choices=artist_name + pre.names, label="Sign", type='index', value=artist_name[0])
|
109 |
+
qr_Logo_radio = gr.Radio([group_name] + ["tripleS", "None"], label="QR Logo", value=group_name, interactive=True)
|
110 |
+
|
111 |
+
preset = gr.Dropdown()
|
112 |
+
|
113 |
+
return group_name_radio, member_name_dropdown, logo_radio, sign, qr_Logo_radio, preset
|
requirements.txt
CHANGED
@@ -3,4 +3,5 @@ numpy
|
|
3 |
Pillow
|
4 |
qrcode
|
5 |
pytz
|
6 |
-
requests
|
|
|
|
3 |
Pillow
|
4 |
qrcode
|
5 |
pytz
|
6 |
+
requests
|
7 |
+
cairosvg
|
resource/oma_frame.png
DELETED
Binary file (120 kB)
|
|
resource/outline_oma.png
ADDED