Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -1,213 +1,228 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import fns
|
3 |
-
import generate
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
with gr.Group():
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
with gr.Group():
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import fns
|
3 |
+
import generate
|
4 |
+
|
5 |
+
js_func = """
|
6 |
+
function refresh() {
|
7 |
+
const url = new URL(window.location);
|
8 |
+
|
9 |
+
if (url.searchParams.get('__theme') !== 'dark') {
|
10 |
+
url.searchParams.set('__theme', 'dark');
|
11 |
+
window.location.href = url.href;
|
12 |
+
}
|
13 |
+
}
|
14 |
+
"""
|
15 |
+
|
16 |
+
with gr.Blocks(theme=gr.themes.Soft(), js=js_func) as demo:
|
17 |
+
with gr.Row():
|
18 |
+
gr.Markdown(
|
19 |
+
"""
|
20 |
+
# Objektify
|
21 |
+
### custom objekt
|
22 |
+
## Join official objektify Discord!!!
|
23 |
+
### [Click here and Join](https://discord.gg/K44Ka83BYT)
|
24 |
+
""")
|
25 |
+
|
26 |
+
with gr.Tab("Front"):
|
27 |
+
with gr.Row():
|
28 |
+
with gr.Column(): #1
|
29 |
+
img_type = gr.Radio(["Image", "Gif"], value="Image", scale=1, label="type")
|
30 |
+
img_static = gr.Image(label="Image", interactive=True, sources=['upload', 'clipboard'], type="pil", visible=True, scale=10)
|
31 |
+
img_dynamic_file = gr.File(file_types=[".gif"], visible=False, scale=1, interactive=True, label="Gif File", type="filepath")
|
32 |
+
img_dynamic_show = gr.Image(label="Gif", interactive=False, sources=['upload', 'clipboard'], type="pil", visible=False, scale=10)
|
33 |
+
|
34 |
+
|
35 |
+
img_type.change(fn=fns.change_img_type, inputs=[img_type], outputs=[img_static, img_dynamic_file, img_dynamic_show])
|
36 |
+
img_static.upload(fn=fns.img2cache_resize, inputs=img_static, outputs=img_static)
|
37 |
+
img_dynamic_file.upload(fn=fns.gif2cache, inputs=img_dynamic_file, outputs=img_dynamic_show)
|
38 |
+
img_dynamic_file.clear(fn=fns.gif_clear, outputs=img_dynamic_show)
|
39 |
+
|
40 |
+
|
41 |
+
with gr.Column(): #2
|
42 |
+
with gr.Group(): #objekt color
|
43 |
+
obj_color = gr.Radio(["Atom01", "Binary01", "Cream01", "Divine01", "Special", "Other color", "AI Color"], label="Objekt Color", value="Cream01")
|
44 |
+
|
45 |
+
with gr.Row():
|
46 |
+
ai_num = gr.Slider(1, 1000, 500, label="AI Serial", visible=False, step=1)
|
47 |
+
change_ai = gr.Button(value="Change AI", visible=False)
|
48 |
+
obj_color_picker = gr.ColorPicker(label="Other Objekt Color", visible=False, interactive=True, value="#ffffff")
|
49 |
+
|
50 |
+
|
51 |
+
obj_color.change(fn=fns.obj_color_update, inputs=obj_color, outputs=[obj_color_picker, ai_num, change_ai])
|
52 |
+
|
53 |
+
|
54 |
+
with gr.Group():
|
55 |
+
txt_color = gr.Radio(["White", "Black", "Other"], label="Text Color", value="Black")
|
56 |
+
txt_color_picker = gr.ColorPicker(label="Other Text Color", value="#ffffff", visible=False, interactive=True)
|
57 |
+
txt_color.change(fns.txt_color_update, txt_color, txt_color_picker)
|
58 |
+
with gr.Group():
|
59 |
+
group_name_radio = gr.Radio(["tripleS", "ARTMS", "Other"], label="Group Name")
|
60 |
+
group_name_txt = gr.Textbox(label="Other Group name", placeholder="CLASSY", visible=False, interactive=True)
|
61 |
+
|
62 |
+
with gr.Group():
|
63 |
+
member_name_dropdown = gr.Dropdown(
|
64 |
+
["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede",
|
65 |
+
"DaHyun", "Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon",
|
66 |
+
"ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon"], label="Member Name", allow_custom_value=True)
|
67 |
+
|
68 |
+
group_name_radio.change(fns.group_member_name_update, group_name_radio, [group_name_txt, member_name_dropdown])
|
69 |
+
|
70 |
+
|
71 |
+
with gr.Accordion("Add Objekt Number", open=False):
|
72 |
+
with gr.Row():
|
73 |
+
obj_num = gr.Textbox(label="Objekt Number", placeholder="100", interactive=True, visible=True, scale=1)
|
74 |
+
obj_alphabet = gr.Radio(["Z", "A", "Other"], label="Z or A", interactive=True, visible=True, scale=1)
|
75 |
+
obj_alphabet_txt = gr.Textbox(label="Alphabet", placeholder="S", interactive=True, visible=False, scale=1)
|
76 |
+
|
77 |
+
obj_alphabet.change(fns.alphabet_txt_update, obj_alphabet, obj_alphabet_txt)
|
78 |
+
|
79 |
+
|
80 |
+
with gr.Row():
|
81 |
+
obj_serial = gr.Textbox(label="Objekt Serial", placeholder="00001", interactive=True, visible=True, scale=1)
|
82 |
+
obj_serial_random = gr.Button(value="Random Serial", interactive=True, visible=True, scale=1)
|
83 |
+
|
84 |
+
|
85 |
+
obj_serial_random.click(fn=fns.serial_random, outputs=obj_serial)
|
86 |
+
|
87 |
+
|
88 |
+
with gr.Group():
|
89 |
+
rounded = gr.Checkbox(label="Rounded", value=True, interactive=True)
|
90 |
+
with gr.Group():
|
91 |
+
generate_btn = gr.Button(value="Generate")
|
92 |
+
|
93 |
+
with gr.Column():
|
94 |
+
edited_img = gr.Image(label="Edited Image", scale=10)
|
95 |
+
|
96 |
+
|
97 |
+
with gr.Tab("Back") as back_tab:
|
98 |
+
with gr.Row():
|
99 |
+
preview = gr.Image(label="Image", interactive=False)
|
100 |
+
with gr.Column():
|
101 |
+
with gr.Group():
|
102 |
+
obj_outline_color = gr.Radio(["White", "Black", "Other"], label="Frame color", value="White")
|
103 |
+
obj_outline_color_picker = gr.ColorPicker(label="Other Outline Color", value="#ffffff", visible=False, interactive=True)
|
104 |
+
|
105 |
+
obj_outline_color.change(fns.frame_color_update, obj_outline_color, obj_outline_color_picker)
|
106 |
+
|
107 |
+
with gr.Group():
|
108 |
+
logo_radio = gr.Radio(["tripleS", "ARTMS", "None"], label="Add Logo", interactive=True, value="None")
|
109 |
+
|
110 |
+
|
111 |
+
with gr.Group():
|
112 |
+
class_radio = gr.Radio(["Zero", "First", "Double", "Special", "Other"], label="CLASS", visible=True)
|
113 |
+
class_txt = gr.Textbox(label="Other class", placeholder="Third", visible=False)
|
114 |
+
|
115 |
+
class_radio.change(fns.txt_class_visibility, class_radio, class_txt)
|
116 |
+
|
117 |
+
with gr.Group():
|
118 |
+
season_radio = gr.Radio(["Atom01", "Binary01", "Cream01", "Divine01", "Other"], label="SEASON", type="value")
|
119 |
+
|
120 |
+
with gr.Row():
|
121 |
+
season_txt = gr.Textbox(label="Other SEASON", interactive=True, visible=False)
|
122 |
+
season_txt_outline = gr.Textbox(label="Other SEASON Outline", interactive=True, visible=False)
|
123 |
+
|
124 |
+
season_radio.change(fns.txt_season_visibility, season_radio, [season_txt, season_txt_outline])
|
125 |
+
|
126 |
+
with gr.Group():
|
127 |
+
sign = gr.Dropdown(
|
128 |
+
["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede",
|
129 |
+
"DaHyun", "Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon",
|
130 |
+
"ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon", "HeeJin", "KimLip", "JinSoul", "Choerry", "HaSeul"], label="Sign", type='index')
|
131 |
+
with gr.Group():
|
132 |
+
qr_url_dropdown = gr.Dropdown(["tripleS website", "tripleS youtube", "tripleS 𝕏", "tripleS discord"],
|
133 |
+
label="qr url", info="Can write any url", allow_custom_value=True)
|
134 |
+
with gr.Row():
|
135 |
+
qr_Logo_radio = gr.Radio(["tripleS", "None"], label="tripleS Logo", value="None",
|
136 |
+
interactive=True)
|
137 |
+
with gr.Group():
|
138 |
+
right_btn = gr.Checkbox(label="Add Rights", value=False, interactive=True)
|
139 |
+
with gr.Group():
|
140 |
+
rounded_back = gr.Checkbox(label="Rounded", value=True, interactive=True)
|
141 |
+
with gr.Group():
|
142 |
+
generate_btn_back = gr.Button(value="Generate")
|
143 |
+
|
144 |
+
with gr.Column():
|
145 |
+
outputs2 = gr.Image(label="Edited Image", scale=10)
|
146 |
+
|
147 |
+
with gr.Tab("Export") as ex:
|
148 |
+
with gr.Row():
|
149 |
+
ex_img_f = gr.Image(label="Front", type="pil", interactive=False)
|
150 |
+
ex_file_f = gr.File(render=True, visible=False)
|
151 |
+
ex_img_b = gr.Image(label="Back", type="pil", interactive=False)
|
152 |
+
with gr.Column():
|
153 |
+
with gr.Group():
|
154 |
+
with gr.Row():
|
155 |
+
ex_hide_blur = gr.Checkbox(label="Blur")
|
156 |
+
ex_hide_blur_range = gr.Slider(1, 20, 5, label="Blur Range", step=1, interactive=False, scale=10)
|
157 |
+
|
158 |
+
ex_hide_blur.select(fns.ex_blur, ex_hide_blur, ex_hide_blur_range)
|
159 |
+
|
160 |
+
with gr.Group():
|
161 |
+
watermark = gr.Textbox(label="Add watermark")
|
162 |
+
|
163 |
+
ex_gen_file_count = gr.Radio(["One File", "Two Files"], label="Export Type", value="One File")
|
164 |
+
ex_btn = gr.Button(value="Export")
|
165 |
+
with gr.Row():
|
166 |
+
ex_img_f_out = gr.Image(label="Front", interactive=False)
|
167 |
+
ex_img_b_out = gr.Image(label="Back", visible=False, interactive=False)
|
168 |
+
|
169 |
+
|
170 |
+
|
171 |
+
with gr.Tab("Dev"):
|
172 |
+
dev_txt = gr.Textbox(label="Developer Key", visible=True, interactive=True)
|
173 |
+
dev_btn = gr.Button(value="Do and refresh", visible=True, interactive=True)
|
174 |
+
dev_out = gr.Textbox()
|
175 |
+
dev_drop = gr.Dropdown(visible=False, interactive=False)
|
176 |
+
dev_file = gr.File(visible=False, interactive=False)
|
177 |
+
dev_btn2 = gr.Button(visible=False, interactive=False, value="move")
|
178 |
+
dev_btn3 = gr.Button(visible=False, interactive=False, value="zip")
|
179 |
+
dev_btn4 = gr.Button(visible=False, interactive=False, value="download")
|
180 |
+
dev_btn5 = gr.Button(visible=False, interactive=False, value="remove")
|
181 |
+
|
182 |
+
dev_btn2.click(fn=fns.dev2, outputs=dev_out)
|
183 |
+
dev_btn3.click(fn=fns.dev3, inputs=dev_drop, outputs=dev_out)
|
184 |
+
dev_btn4.click(fn=fns.dev4, inputs=dev_drop, outputs=dev_file)
|
185 |
+
dev_btn5.click(fn=fns.dev5, inputs=dev_drop, outputs=dev_out)
|
186 |
+
dev_btn.click(fns.dev, dev_txt, [dev_out, dev_drop, dev_file, dev_btn2, dev_btn3, dev_btn4, dev_btn5])
|
187 |
+
gr.Markdown(
|
188 |
+
"""
|
189 |
+
## Made by
|
190 |
+
# Discord : hj_sss
|
191 |
+
## official discord
|
192 |
+
### [Click here and Join](https://discord.gg/K44Ka83BYT)
|
193 |
+
|
194 |
+
### Members or group presets can be added and advertised. Check the official discord.
|
195 |
+
#### Check the objektify official discord for licensing and other data processing policies.
|
196 |
+
""")
|
197 |
+
|
198 |
+
generate_btn.click(fn=generate.sorting,
|
199 |
+
inputs=[img_type, img_static, img_dynamic_file, obj_color, obj_color_picker, ai_num, txt_color,
|
200 |
+
txt_color_picker, member_name_dropdown, group_name_radio, group_name_txt, obj_num,
|
201 |
+
obj_alphabet, obj_alphabet_txt, obj_serial, rounded], outputs=[edited_img, ex_img_f, ex_file_f])
|
202 |
+
|
203 |
+
ex_gen_file_count.change(fns.ex_gen_count, ex_gen_file_count, ex_img_b_out)
|
204 |
+
rounded.change(fns.rounded_sync, rounded, rounded_back)
|
205 |
+
rounded_back.change(fns.rounded_sync, rounded_back, rounded)
|
206 |
+
|
207 |
+
change_ai.click(fns.change_ran, obj_color, ai_num)
|
208 |
+
|
209 |
+
generate_btn_back.click(fn=generate.back,
|
210 |
+
inputs=[obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group_name_radio,
|
211 |
+
group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt,
|
212 |
+
obj_serial, obj_outline_color, obj_outline_color_picker, logo_radio, class_radio,
|
213 |
+
class_txt, season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown,
|
214 |
+
qr_Logo_radio, right_btn, rounded_back], outputs=[outputs2, ex_img_b])
|
215 |
+
|
216 |
+
back_tab.select(fn=generate.back,
|
217 |
+
inputs=[obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group_name_radio,
|
218 |
+
group_name_txt, member_name_dropdown, obj_num, obj_alphabet, obj_alphabet_txt, obj_serial,
|
219 |
+
obj_outline_color, obj_outline_color_picker, logo_radio, class_radio, class_txt,
|
220 |
+
season_radio, season_txt, season_txt_outline, sign, qr_url_dropdown, qr_Logo_radio,
|
221 |
+
right_btn, rounded_back], outputs=[preview, ex_img_b])
|
222 |
+
|
223 |
+
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])
|
224 |
+
|
225 |
+
if __name__ == "__main__":
|
226 |
+
print("http://localhost:7860")
|
227 |
+
demo.launch(server_name="0.0.0.0")
|
228 |
+
|