Spaces:
Running
Running
File size: 18,151 Bytes
438ebdf d10d21b 438ebdf 68f3e34 d10d21b eba98a5 d10d21b 438ebdf d10d21b e20294a a2c1cdb e20294a a2c1cdb e20294a 76f5da6 d10d21b a2c1cdb 68f3e34 e20294a d10d21b a5cbc50 27feafa 438ebdf 76f5da6 438ebdf 76f5da6 438ebdf d10d21b f553ae4 438ebdf d10d21b 438ebdf d10d21b 438ebdf d10d21b 438ebdf d10d21b 438ebdf d10d21b 438ebdf d10d21b 438ebdf d10d21b 438ebdf d10d21b 438ebdf d10d21b 438ebdf d10d21b dda97f6 d10d21b 62383cd d10d21b 438ebdf d10d21b a5cbc50 d10d21b eba98a5 d10d21b dda97f6 a5cbc50 dda97f6 d10d21b afe5a9d eba98a5 100d5f6 d10d21b eba98a5 438ebdf afe5a9d 68f3e34 438ebdf 68f3e34 438ebdf 68f3e34 438ebdf eba98a5 d10d21b eba98a5 cacd5ac 438ebdf d10d21b 438ebdf 7841a2b 438ebdf 5c09508 438ebdf 5c09508 438ebdf 5c09508 438ebdf d10d21b a2c1cdb 68f3e34 438ebdf |
1 2 3 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 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 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 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
import gradio as gr
import beta_fn
import fns
import generate
import login_discord
import preset_fn
import rekord
import pre
js_func = """
function refresh() {
const url = new URL(window.location);
if (url.searchParams.get('__theme') !== 'dark') {
url.searchParams.set('__theme', 'dark');
window.location.href = url.href;
}
}
"""
animation = """
function createGradioAnimation() {
var container = document.createElement('div');
container.id = 'gradio-animation';
container.style.fontSize = '2em';
container.style.fontWeight = 'bold';
container.style.textAlign = 'center';
container.style.marginTop = '0px';
container.style.marginBottom = '5px';
var text = 'Objektify';
for (var i = 0; i < text.length; i++) {
(function(i){
setTimeout(function(){
var letter = document.createElement('span');
letter.style.opacity = '0';
letter.style.transition = 'opacity 0.5s';
letter.innerText = text[i];
container.appendChild(letter);
setTimeout(function() {
letter.style.opacity = '1';
}, 50);
}, i * 250);
})(i);
}
var gradioContainer = document.querySelector('.gradio-container');
gradioContainer.insertBefore(container, gradioContainer.firstChild);
setTimeout(function() {
container.style.transition = 'all 2s';
container.style.fontSize = '1em';
container.style.letterSpacing = '0.1em';
}, 3000);
return 'Animation created';
}
"""
ga_script = """
<script async src="https://www.googletagmanager.com/gtag/js?id=G-J2J6MBSCQB"></script>
"""
ga_load = """
function() {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-J2J6MBSCQB');
}
"""
confirm_horizontal = "(x) => confirm('Apply horizontal mode?')"
def rst(a):
if a == None:
return False
return gr.Checkbox()
def tests():
print('tests')
def chk_size(img, dummy):
x, y = img.size
if x <= y:
return dummy
else:
return not dummy
theme = gr.themes.Soft(
secondary_hue="violet",
text_size="sm",
spacing_size="sm",
radius_size="lg",
).set(
block_background_fill='*secondary_50'
)
login_uri = pre.login_uri
with gr.Blocks(theme=theme, js=animation, head=ga_script) as demo: # , js=js_func
with gr.Column():
with gr.Row():
gr.Markdown(
"""
### [Join objektify official discord!](https://discord.com/invite/KAuTCUGXpH)
"""
)
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)
with gr.Row():
gr.Markdown(
"""
## Input image and Select Options
"""
)
preset = gr.Dropdown(scale=0, label='Preset', interactive=True, allow_custom_value=False, type='value', visible=True, info='Login to create preset')
with gr.Tab("Front"):
with gr.Row():
with gr.Column(): #1
img_type = gr.Radio(["Image", "Gif"], value="Image", scale=1, label="type")
img_static = gr.Image(label="Image", interactive=True, sources=['upload', 'clipboard'], type="pil", visible=True, scale=10)
img_dynamic_file = gr.File(file_types=[".gif"], visible=False, scale=1, interactive=True, label="Gif File", type="filepath")
img_dynamic_show = gr.Image(label="Gif", interactive=False, sources=['upload', 'clipboard'], type="pil", visible=False, scale=10)
horizontal = gr.Checkbox(visible=False, label='horizontal')
dummy = gr.Checkbox(visible=False, label='dummy')
img_type.change(fn=fns.change_img_type, inputs=[img_type], outputs=[img_static, img_dynamic_file, img_dynamic_show])
img_static.upload(fn=fns.img2cache_resize, inputs=[img_static, dummy], outputs=[img_static, dummy])
img_static.change(fn=rst, inputs=img_static, outputs=[horizontal])
dummy.change(fn=None, js=confirm_horizontal, outputs=horizontal)
horizontal.change(fn=fns.rotate, inputs=img_static, outputs=img_static)
img_dynamic_file.upload(fn=fns.gif2cache, inputs=img_dynamic_file, outputs=img_dynamic_show)
img_dynamic_file.clear(fn=fns.gif_clear, outputs=img_dynamic_show)
with gr.Column(): #2
with gr.Accordion(label='Colors'): #objekt color
obj_color = gr.Radio(["Atom01", "Binary01", "Cream01", "Divine01", "Special", "OMA1", "OMA2", "Other color", "AI Color"], value="Divine01", label='Objekt Color')
with gr.Row():
ai_num = gr.Slider(1, 1000, 500, label="AI Serial", visible=False, step=1)
change_ai = gr.Button(value="Change AI", visible=False)
obj_color_picker = gr.ColorPicker(label="Other Objekt Color", visible=False, interactive=True, value="#ffffff")
obj_color.change(fn=fns.obj_color_update, inputs=obj_color, outputs=[obj_color_picker, ai_num, change_ai])
txt_color = gr.Radio(["White", "Black", "Other"], label="Text Color", value="Black")
txt_color_picker = gr.ColorPicker(label="Other Text Color", value="#ffffff", visible=False, interactive=True)
txt_color.change(fns.txt_color_update, txt_color, txt_color_picker)
with gr.Accordion('Names'):
group_name_radio = gr.Radio(choices=pre.groups_Other, label="Group Name")
group_name_txt = gr.Textbox(label="Other Group name", placeholder="CLASSY", visible=False, interactive=True)
member_name_dropdown = gr.Dropdown(choices=pre.names, label="Member Name", allow_custom_value=True)
with gr.Accordion("Add Objekt Number", open=False):
with gr.Row():
obj_num = gr.Textbox(label="Objekt Number", placeholder="100", interactive=True, visible=True, scale=1)
obj_alphabet = gr.Radio(["Z", "A", "Other"], label="Z or A", interactive=True, visible=True, scale=1, value='Z')
obj_alphabet_txt = gr.Textbox(label="Alphabet", placeholder="S", interactive=True, visible=False, scale=1)
obj_alphabet.change(fns.alphabet_txt_update, obj_alphabet, obj_alphabet_txt)
with gr.Row():
obj_serial = gr.Textbox(label="Objekt Serial", placeholder="00001", interactive=True, visible=True, scale=1)
obj_serial_random = gr.Button(value="Random Serial", interactive=True, visible=True, scale=1)
obj_serial_random.click(fn=fns.serial_random, outputs=obj_serial)
with gr.Group():
generate_btn = gr.Button(value="Generate")
with gr.Column():
edited_img = gr.Image(label="Edited Image", scale=10)
with gr.Tab("Back") as back_tab:
with gr.Row():
preview = gr.Image(label="Image", interactive=False)
with gr.Column():
with gr.Accordion('Contents'):
obj_outline_color = gr.Radio(["White", "Black", "Other"], label="Frame color", value="White")
obj_outline_color_picker = gr.ColorPicker(label="Other Outline Color", value="#ffffff", visible=False, interactive=True)
obj_outline_color.change(fns.frame_color_update, obj_outline_color, obj_outline_color_picker)
logo_radio = gr.Radio(choices=pre.groups, label="Add Logo", interactive=True, value="None")
with gr.Accordion('Texts'):
class_radio = gr.Radio(["Zero", "First", "Double", "Special", "Other"], label="CLASS", visible=True)
class_txt = gr.Textbox(label="Other class", placeholder="Third", visible=False)
class_radio.change(fns.txt_class_visibility, class_radio, class_txt)
season_radio = gr.Radio(["Atom01", "Binary01", "Cream01", "Divine01", "Other"], label="SEASON", type="value")
with gr.Row():
season_txt = gr.Textbox(label="Other SEASON", interactive=True, visible=False)
season_txt_outline = gr.Textbox(label="Other SEASON Outline", interactive=True, visible=False)
season_radio.change(fns.txt_season_visibility, season_radio, [season_txt, season_txt_outline])
sign = gr.Dropdown(choices=pre.names, label="Sign", type='value')
with gr.Accordion('QR Options'):
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')
qr_Logo_radio = gr.Radio(["tripleS", "None"], label="QR Logo", value="None", interactive=True)
right_btn = gr.Checkbox(label="Add Rights", value=False, interactive=True)
generate_btn_back = gr.Button(value="Generate")
with gr.Column():
outputs2 = gr.Image(label="Edited Image", scale=10)
with gr.Tab("Export") as ex:
with gr.Row():
ex_img_f = gr.Image(label="Front", type="pil", interactive=False)
ex_file_f = gr.File(render=True, visible=False)
ex_img_b = gr.Image(label="Back", type="pil", interactive=False)
with gr.Column():
with gr.Group():
with gr.Row():
ex_hide_blur = gr.Checkbox(label="Blur")
ex_hide_blur_range = gr.Slider(1, 20, 5, label="Blur Range", step=1, interactive=False, scale=10)
ex_hide_blur.select(fns.ex_blur, ex_hide_blur, ex_hide_blur_range)
with gr.Group():
watermark = gr.Textbox(label="Add watermark")
ex_gen_file_count = gr.Radio(["One File", "Two Files"], label="Export Type", value="One File")
ex_btn = gr.Button(value="Export")
with gr.Row():
ex_img_f_out = gr.Image(label="Front", interactive=False)
ex_img_b_out = gr.Image(label="Back", visible=False, interactive=False)
with gr.Tab("Preset", visible=False) as beta:
gr.Markdown(
"""
## This is the beta channel for testing new features.
### Please join [here](https://discord.com/invite/KAuTCUGXpH) to report bugs and provide feedback.
"""
)
with gr.Row():
with gr.Column():
preset_name = gr.Textbox(label="Set preset name", placeholder="aespa winter")
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)
group_name = gr.Textbox(label="Group name", placeholder="aespa")
company_name = gr.Textbox(label="Company name", placeholder="SM ent")
top_logo_img = gr.Image(label="Top Logo", type='pil', image_mode='RGBA')
qr_logo_img = gr.Image(label="QR Logo", type='pil', image_mode='RGBA')
with gr.Accordion('Signs', open=True):
with gr.Column():
sign_img1 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
sign_img2 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
sign_img3 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
sign_img4 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
sign_img5 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
sign_img6 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
sign_img7 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
sign_img8 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
sign_img9 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
sign_img10 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
sign_img11 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
sign_img12 = gr.Image(label="Sign", visible=False, interactive=True, type='pil', image_mode='RGBA')
save = gr.Button(value="Save and Apply all")
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])
with gr.Tab("ReKord", visible=False):
rekord_img = gr.Image(type="filepath")
rekord_member = gr.Dropdown(choices=pre.names, label="Sign", type='index')
rekord_submit = gr.Button()
rekord_out = gr.Textbox()
rekord_submit.click(fn=rekord.upload, inputs=[rekord_img, rekord_member], outputs=rekord_out)
with gr.Tab(label='Dev_preset', visible=False) as rec:
preset_file = gr.File()
preset_file.upload(fn=preset_fn.unzip_file_to_directory, inputs=preset_file)
preset_zip = gr.Button()
preset_zip.click(fn=preset_fn.zip_directory)
with gr.Tab("Dev", visible=False) as dev:
dev_btn = gr.Button(value="refresh", visible=True, interactive=True)
dev_out = gr.Textbox()
dev_drop = gr.Dropdown()
dev_file = gr.File()
dev_btn2 = gr.Button(value="move")
dev_btn3 = gr.Button(value="zip")
dev_btn4 = gr.Button(value="download")
dev_btn5 = gr.Button(value="remove")
dev_btn2.click(fn=fns.dev2, outputs=dev_out)
dev_btn3.click(fn=fns.dev3, inputs=dev_drop, outputs=dev_out)
dev_btn4.click(fn=fns.dev4, inputs=dev_drop, outputs=dev_file)
dev_btn5.click(fn=fns.dev5, inputs=dev_drop, outputs=dev_out)
dev_btn.click(fns.dev, outputs=[dev_out, dev_drop])
gr.Markdown(
"""
## Made by
# Discord : hj_sss
## official discord
### [Click here and Join](https://discord.com/invite/KAuTCUGXpH)
#### Check the objektify official discord for licensing and other data processing policies.
### Members or group presets can be added and advertised. Check the official discord.
""")
userid = gr.Textbox(visible=False)
preset.change(fn=preset_fn.apply, inputs=preset,
outputs=[group_name_radio, member_name_dropdown, logo_radio, sign, qr_Logo_radio, preset])
group_name_radio.change(fns.group_member_name_update, [group_name_radio, artist_name, preset], [group_name_txt, member_name_dropdown])
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])
generate_btn.click(fn=generate.sorting,
inputs=[img_type, img_static, img_dynamic_file, obj_color, obj_color_picker, ai_num, txt_color,
txt_color_picker, member_name_dropdown, group_name_radio, group_name_txt, obj_num,
obj_alphabet, obj_alphabet_txt, obj_serial, horizontal], outputs=[edited_img, ex_img_f, ex_file_f])
ex_gen_file_count.change(fns.ex_gen_count, ex_gen_file_count, ex_img_b_out)
change_ai.click(fns.change_ran, obj_color, ai_num)
generate_btn_back.click(fn=generate.back,
inputs=[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, preset], outputs=[outputs2, ex_img_b])
back_tab.select(fn=generate.back,
inputs=[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, preset], outputs=[preview, ex_img_b])
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])
demo.load(fn=login_discord.id_check, outputs=[login, dev, rec, userid, beta, preset])
demo.load(fn=preset_fn.refresh, outputs=preset)
demo.load(None, js=ga_load)
if __name__ == "__main__":
print("http://localhost:7860")
demo.launch(server_name="0.0.0.0")
|