objektify2 / main.py
chohj06ms's picture
Upload 61 files
624937a verified
raw
history blame
11.9 kB
import gradio as gr
import fns
import generate
import os
with gr.Blocks(theme=gr.themes.Soft()) as demo:
with gr.Row():
gr.Markdown(
"""
# Custom Objekt
## Input image and Select Options
""")
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)
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, 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.Group(): #objekt color
obj_color = gr.Radio(["Atom01", "Binary01", "Cream01", "Divine01", "Special", "Other color", "AI Color"], label="Objekt Color", value="Cream01")
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])
with gr.Group():
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.Group():
group_name_radio = gr.Radio(["tripleS", "ARTMS", "Other"], label="Group Name")
group_name_txt = gr.Textbox(label="Other Group name", placeholder="CLASSY", visible=False, interactive=True)
with gr.Group():
member_name_dropdown = gr.Dropdown(
["SeoYeon", "HyeRin", "JiWoo", "ChaeYeon", "YooYeon", "SooMin", "NaKyoung", "YuBin", "Kaede",
"DaHyun", "Kotone", "YeonJi", "Nien", "SoHyun", "Xinyu", "Mayu", "Lynn", "JooBin", "HaYeon",
"ShiOn", "ChaeWon", "Sullin", "SeoAh", "JiYeon"], label="Member Name", allow_custom_value=True)
group_name_radio.change(fns.group_member_name_update, group_name_radio, [group_name_txt, member_name_dropdown])
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)
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():
rounded = gr.Checkbox(label="Rounded", value=True, interactive=True)
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.Group():
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)
with gr.Group():
logo_radio = gr.Radio(["tripleS", "ARTMS", "None"], label="Add Logo", interactive=True, value="None")
with gr.Group():
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)
with gr.Group():
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])
with gr.Group():
sign = gr.Dropdown(
["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"], label="Sign", type='index')
with gr.Group():
qr_url_dropdown = gr.Dropdown(["tripleS website", "tripleS youtube", "tripleS 𝕏", "tripleS discord"],
label="qr url", info="Can write any url", allow_custom_value=True)
with gr.Row():
qr_Logo_radio = gr.Radio(["tripleS", "None"], label="tripleS Logo", value="None",
interactive=True)
with gr.Group():
right_btn = gr.Checkbox(label="Add Rights", value=False, interactive=True)
with gr.Group():
rounded_back = gr.Checkbox(label="Rounded", value=True, interactive=True)
with gr.Group():
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("Dev"):
dev_txt = gr.Textbox(label="Developer Key", visible=True, interactive=True)
dev_btn = gr.Button(value="Do", visible=True, interactive=True)
dev_out = gr.Textbox()
dev_drop = gr.Dropdown(visible=False, interactive=False)
dev_file = gr.File(visible=False, interactive=False)
dev_btn2 = gr.Button(visible=False, interactive=False)
dev_btn3 = gr.Button(visible=False, interactive=False)
dev_btn2.click(fn=fns.dev2, outputs=dev_out)
dev_btn3.click(fn=fns.dev3, inputs=dev_drop, outputs=dev_file)
dev_btn.click(fns.dev, dev_txt, [dev_out, dev_drop, dev_file, dev_btn2, dev_btn3])
gr.Markdown(
"""
## Made by
# Discord : hj_sss (Can DM)
# Cosmo : ILoveYouyeon
### this site is free But I hope anyone can support the objekt to my Cosmo
""")
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, rounded], 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)
rounded.change(fns.rounded_sync, rounded, rounded_back)
rounded_back.change(fns.rounded_sync, rounded_back, rounded)
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, rounded_back], 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, rounded_back], 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])
if __name__ == "__main__":
print("http://localhost:7860")
demo.launch(server_name="0.0.0.0")