chohj06ms commited on
Commit
8a6c79e
·
verified ·
1 Parent(s): 38914b3

Delete fns.py

Browse files
Files changed (1) hide show
  1. fns.py +0 -177
fns.py DELETED
@@ -1,177 +0,0 @@
1
- import gradio as gr
2
- import random
3
- import shutil
4
- import fn
5
- import edimg
6
- import os
7
-
8
-
9
- def change_img_type(a):
10
- if a == "Image":
11
- return gr.File(visible=True), gr.Image(visible=False), gr.Image(visible=False)
12
- else:
13
- return gr.File(visible=False), gr.Image(visible=True), gr.Image(visible=True)
14
-
15
-
16
-
17
- def gif2cache(a):
18
- krtime = fn.get_kr_time()
19
- shutil.copy2(a, f'/data/cache/original_{krtime}.gif')
20
- return a
21
-
22
- def gif_clear():
23
- return
24
- def img2cache_resize(a):
25
- krtime = fn.get_kr_time()
26
- a.save(f'/data/cache/original_{krtime}.jpg', quality=90)
27
- a = edimg.resize_img(a, 1164, 1800)
28
- return a
29
-
30
-
31
- def obj_color_update(obj_color):
32
- if obj_color == "Other color":
33
- return gr.ColorPicker(visible=True), gr.Slider(1, 1000, 0, visible=False), gr.Button(visible=False)
34
- elif obj_color == "AI Color":
35
- ran = random.randrange(1, 1000)
36
- return gr.ColorPicker(visible=False), gr.Slider(1, 1000, ran, visible=True), gr.Button(visible=True)
37
- else:
38
- return gr.ColorPicker(visible=False), gr.Slider(1, 1000, 0, visible=False), gr.Button(visible=False)
39
-
40
-
41
- def txt_color_update(txt_color_picker):
42
- if txt_color_picker == "Other":
43
- return gr.Image(visible=True)
44
- else:
45
- return gr.Image(visible=False)
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):
63
- if a == "Other":
64
- return gr.Textbox(visible=True)
65
- else:
66
- return gr.Textbox(visible=False)
67
-
68
-
69
- def serial_random():
70
- ran1 = random.randrange(0, 9)
71
- ran2 = random.randrange(0, 9)
72
- ran3 = random.randrange(0, 9)
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":
79
- return gr.ColorPicker(visible=True)
80
- else:
81
- return gr.ColorPicker(visible=False)
82
-
83
-
84
-
85
- def ex_gen_count(a):
86
- if a == "Two Files":
87
- return gr.Image(visible=True)
88
- else:
89
- return gr.Image(visible=False)
90
-
91
-
92
-
93
- def rounded_sync(a):
94
- return gr.Checkbox(value=a)
95
-
96
-
97
- def ex_blur(a):
98
- if a:
99
- return gr.Slider(interactive=True)
100
- else:
101
- return gr.Slider(interactive=False)
102
-
103
-
104
-
105
- def refresh():
106
- directory_path = "/data"
107
- # directory_path 내의 항목들을 리스트로 가져옴
108
- items = os.listdir(directory_path)
109
- # 해당 항목이 디렉토리인지 확인 후, 특정 폴더를 제외한 폴더 이름만 필터링
110
- folders = [item for item in items if os.path.isdir(os.path.join(directory_path, item))]
111
- folders_tuple = tuple(folders)
112
-
113
- # 현재 작업 디렉토리의 폴더 이름들을 튜플로 반환 (특정 폴더 제외)
114
- return folders_tuple
115
-
116
- key = os.getenv("key")
117
-
118
- def dev(a):
119
- if a == key:
120
- folders = refresh()
121
- return "Do", gr.Dropdown(folders, visible=True, interactive=True), gr.File(visible=True, interactive=True), gr.Button(visible=True, interactive=True), gr.Button(visible=True, interactive=True)
122
- elif a == key + "make":
123
- os.makedirs("/data/cache")
124
- return "make", gr.Dropdown(visible=False, interactive=False), gr.File(visible=False, interactive=False), gr.Button(visible=False, interactive=False), gr.Button(visible=False, interactive=False)
125
- else:
126
- return "Permission denied", gr.Dropdown(visible=False, interactive=False), gr.File(visible=False, interactive=False), gr.Button(visible=False, interactive=False), gr.Button(visible=False, interactive=False)
127
-
128
-
129
- def dev2():
130
- time = fn.get_kr_time()
131
- os.rename("/data/cache", f"/data/{time}")
132
- os.mkdir("/data/cache")
133
- return "Renamed"
134
-
135
- def dev3(a):
136
- import os
137
-
138
- # './data/' 디렉터리 경로 설정
139
- directory = '/data/'
140
-
141
- # 디렉터리 내의 모든 파일 및 폴더에 대해 반복
142
- for filename in os.listdir(directory):
143
- # 파일 경로 조합
144
- file_path = os.path.join(directory, filename)
145
- # 파일이 zip 파일인지 확인
146
- if filename.endswith('.zip'):
147
- # 파일 삭제
148
- os.remove(file_path)
149
-
150
- fn.storage(a)
151
- return f"/data/{a}.zip"
152
-
153
-
154
-
155
- def txt_season_visibility(a):
156
- if a == "Other":
157
- return gr.Textbox(visible=True), gr.Textbox(visible=True)
158
- else:
159
- return gr.Textbox(visible=False), gr.Textbox(visible=False)
160
-
161
-
162
-
163
- def change_ran(a):
164
- if a == "AI Color":
165
- ran = random.randrange(1, 1000)
166
- return ran
167
- else:
168
- return 0
169
-
170
-
171
-
172
- def txt_class_visibility(a):
173
- if a == "Other":
174
- return gr.Textbox(visible=True)
175
- else:
176
- return gr.Textbox(visible=False)
177
-