Spaces:
Running
Running
File size: 6,492 Bytes
d10d21b 9793ed6 3e8ff37 9793ed6 d10d21b 9793ed6 76f5da6 3e8ff37 76f5da6 9793ed6 76f5da6 3e8ff37 76f5da6 9793ed6 d10d21b 9793ed6 d10d21b 9793ed6 d10d21b 9793ed6 d10d21b 9793ed6 d10d21b 9793ed6 d10d21b 68f3e34 9793ed6 d10d21b |
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 |
import pickle
import gradio as gr
import random
import shutil
import fn
import edimg
import os
from PIL import Image, ImageDraw, ImageFont, ImageColor, ImageFilter, ImageSequence, PngImagePlugin
import pre
def change_img_type(a):
if a == "Image":
return gr.File(visible=True), gr.Image(visible=False), gr.Image(visible=False)
else:
return gr.File(visible=False), gr.Image(visible=True), gr.Image(visible=True)
def gif2cache(a):
krtime = fn.get_kr_time()
shutil.copy2(a, f'/data/cache/original_{krtime}.gif')
return a
def gif_clear():
return
def img2cache_resize(a, dummy):
a = Image.open(a).convert('RGB')
x, y = a.size
krtime = fn.get_kr_time()
a.save(f'/data/cache/original_{krtime}.jpg', quality=90)
if x <= y:
a = edimg.resize_img(a, 1164, 1800)
return a, dummy
else:
return a, not dummy
def rotate(a):
if a == None:
return None
a = Image.open(a)
a = a.rotate(270, expand=True)
print('rotated')
a = edimg.resize_img(a, 1164, 1800)
return a
def obj_color_update(obj_color):
if obj_color == "Other color":
return gr.ColorPicker(visible=True), gr.Slider(1, 1000, 0, visible=False), gr.Button(visible=False)
elif obj_color == "AI Color":
ran = random.randrange(1, 1000)
return gr.ColorPicker(visible=False), gr.Slider(1, 1000, ran, visible=True), gr.Button(visible=True)
else:
return gr.ColorPicker(visible=False), gr.Slider(1, 1000, 0, visible=False), gr.Button(visible=False)
def txt_color_update(txt_color_picker):
if txt_color_picker == "Other":
return gr.Image(visible=True)
else:
return gr.Image(visible=False)
def group_member_name_update(a, artist_name, folder):
if a == "Other":
return gr.Textbox(visible=True), gr.Dropdown([], label="Member Name", allow_custom_value=True)
elif a == "tripleS":
return gr.Textbox(visible=False), 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)
elif a == "ARTMS":
return gr.Textbox(visible=False), gr.Dropdown(["HeeJin", "JinSoul", "Kim Lip", "Choerry", "HaSeul"],
label="Member Name", allow_custom_value=True)
else:
directory_path = f"/data/presets/{folder}"
with open(f'{directory_path}/data.pkl', 'rb') as f:
data = pickle.load(f)
group_name = data['group']
artist_name = data['artist']
member_name_dropdown = gr.Dropdown(choices=artist_name, label="Member Name", allow_custom_value=True,
value=artist_name[0])
return gr.Textbox(visible=False), member_name_dropdown
def alphabet_txt_update(a):
if a == "Other":
return gr.Textbox(visible=True)
else:
return gr.Textbox(visible=False)
def serial_random():
random_number = random.randint(0, 99999)
formatted_number = f"{random_number:05}"
return gr.Textbox(value=formatted_number)
def frame_color_update(a):
if a == "Other":
return gr.ColorPicker(visible=True)
else:
return gr.ColorPicker(visible=False)
def ex_gen_count(a):
if a == "Two Files":
return gr.Image(visible=True)
else:
return gr.Image(visible=False)
def rounded_sync(a):
return gr.Checkbox(value=a)
def ex_blur(a):
if a:
return gr.Slider(interactive=True)
else:
return gr.Slider(interactive=False)
def refresh():
directory_path = "/data"
# directory_path ๋ด์ ํญ๋ชฉ๋ค์ ๋ฆฌ์คํธ๋ก ๊ฐ์ ธ์ด
items = os.listdir(directory_path)
# ํด๋น ํญ๋ชฉ์ด ๋๋ ํ ๋ฆฌ์ธ์ง ํ์ธ ํ, ํน์ ํด๋๋ฅผ ์ ์ธํ ํด๋ ์ด๋ฆ๋ง ํํฐ๋ง
folders = [item for item in items]
folders_tuple = tuple(folders)
# ํ์ฌ ์์
๋๋ ํ ๋ฆฌ์ ํด๋ ์ด๋ฆ๋ค์ ํํ๋ก ๋ฐํ (ํน์ ํด๋ ์ ์ธ)
return folders_tuple
def dev():
folders = refresh()
return "Do", gr.Dropdown(folders, visible=True, interactive=True)
def dev2():
time = fn.get_kr_time()
os.rename("/data/cache", f"/data/{time}")
os.mkdir("/data/cache")
return "Moved"
def dev3(a):
fn.zip(a)
return f"/data/{a}"
def dev4(a):
return f"/data/{a}"
def dev5(a):
fn.remove(a)
return "Deleted"
def txt_season_visibility(a):
if a == "Other":
return gr.Textbox(visible=True), gr.Textbox(visible=True)
else:
return gr.Textbox(visible=False), gr.Textbox(visible=False)
def change_ran(a):
if a == "AI Color":
ran = random.randrange(1, 1000)
return ran
else:
return 0
def txt_class_visibility(a):
if a == "Other":
return gr.Textbox(visible=True)
else:
return gr.Textbox(visible=False)
def custom_name(count):
visibilities = [True] * len(count) + [False] * (12 - len(count))
return (
gr.Image(label=count[0] if len(count) > 0 else 'Sign', visible=visibilities[0]),
gr.Image(label=count[1] if len(count) > 1 else 'Sign', visible=visibilities[1]),
gr.Image(label=count[2] if len(count) > 2 else 'Sign', visible=visibilities[2]),
gr.Image(label=count[3] if len(count) > 3 else 'Sign', visible=visibilities[3]),
gr.Image(label=count[4] if len(count) > 4 else 'Sign', visible=visibilities[4]),
gr.Image(label=count[5] if len(count) > 5 else 'Sign', visible=visibilities[5]),
gr.Image(label=count[6] if len(count) > 6 else 'Sign', visible=visibilities[6]),
gr.Image(label=count[7] if len(count) > 7 else 'Sign', visible=visibilities[7]),
gr.Image(label=count[8] if len(count) > 8 else 'Sign', visible=visibilities[8]),
gr.Image(label=count[9] if len(count) > 9 else 'Sign', visible=visibilities[9]),
gr.Image(label=count[10] if len(count) > 10 else 'Sign', visible=visibilities[10]),
gr.Image(label=count[11] if len(count) > 11 else 'Sign', visible=visibilities[11])
)
|