tripleS-Dev commited on
Commit
afe5a9d
·
1 Parent(s): 331cc37

update V1.3.1L Beta

Browse files
Files changed (3) hide show
  1. generate.py +1 -1
  2. main.py +6 -1
  3. preset_fn.py +35 -1
generate.py CHANGED
@@ -337,7 +337,7 @@ def back(obj_color, obj_color_picker, ai_num, txt_color, txt_color_picker, group
337
  pass
338
  case _:
339
  img_qr_icon = Image.open(f'/data/presets/{preset}/qr_logo.png')
340
- colored_icon = edimg.color(img_qr_icon, '#000000')
341
 
342
  original_width, original_height = colored_icon.size
343
  ratio = min(84 / original_width, 84 / original_height)
 
337
  pass
338
  case _:
339
  img_qr_icon = Image.open(f'/data/presets/{preset}/qr_logo.png')
340
+ colored_icon = img_qr_icon
341
 
342
  original_width, original_height = colored_icon.size
343
  ratio = min(84 / original_width, 84 / original_height)
main.py CHANGED
@@ -229,7 +229,7 @@ with gr.Blocks(theme=theme) as demo: # , js=js_func
229
 
230
  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])
231
 
232
- with gr.Tab("ReKord", visible=False) as rec:
233
  rekord_img = gr.Image(type="filepath")
234
 
235
  rekord_member = gr.Dropdown(choices=pre.names, label="Sign", type='index')
@@ -237,6 +237,11 @@ with gr.Blocks(theme=theme) as demo: # , js=js_func
237
  rekord_out = gr.Textbox()
238
  rekord_submit.click(fn=rekord.upload, inputs=[rekord_img, rekord_member], outputs=rekord_out)
239
 
 
 
 
 
 
240
  with gr.Tab("Dev", visible=False) as dev:
241
 
242
  dev_btn = gr.Button(value="refresh", visible=True, interactive=True)
 
229
 
230
  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])
231
 
232
+ with gr.Tab("ReKord", visible=False):
233
  rekord_img = gr.Image(type="filepath")
234
 
235
  rekord_member = gr.Dropdown(choices=pre.names, label="Sign", type='index')
 
237
  rekord_out = gr.Textbox()
238
  rekord_submit.click(fn=rekord.upload, inputs=[rekord_img, rekord_member], outputs=rekord_out)
239
 
240
+ with gr.Tab(label='Dev_preset', visible=False) as rec:
241
+ preset_file = gr.File()
242
+ preset_file.upload(fn=preset_fn.unzip_file_to_directory, inputs=preset_file)
243
+ preset_zip = gr.Button()
244
+ preset_zip.click(fn=preset_fn.zip_directory)
245
  with gr.Tab("Dev", visible=False) as dev:
246
 
247
  dev_btn = gr.Button(value="refresh", visible=True, interactive=True)
preset_fn.py CHANGED
@@ -103,4 +103,38 @@ def apply(folder):
103
 
104
  preset = gr.Dropdown()
105
 
106
- return group_name_radio, member_name_dropdown, logo_radio, sign, qr_Logo_radio, preset
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
  preset = gr.Dropdown()
105
 
106
+ return group_name_radio, member_name_dropdown, logo_radio, sign, qr_Logo_radio, preset
107
+
108
+
109
+ import zipfile
110
+ import os
111
+
112
+
113
+ def unzip_file_to_directory(zip_file_path):
114
+ output_directory = '/data/presets/'
115
+ # Ensure the output directory exists
116
+ os.makedirs(output_directory, exist_ok=True)
117
+
118
+ # Unzip the file
119
+ with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
120
+ zip_ref.extractall(output_directory)
121
+ print(f"Unzipped {zip_file_path} to {output_directory}")
122
+
123
+
124
+ import zipfile
125
+ import os
126
+
127
+ def zip_directory():
128
+ # Example usage
129
+ directory_path = '/data/presets/'
130
+ zip_file_path = '/data/presets.zip'
131
+ # Create a zip file
132
+ with zipfile.ZipFile(zip_file_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
133
+ # Walk through the directory
134
+ for root, dirs, files in os.walk(directory_path):
135
+ for file in files:
136
+ # Create the full filepath
137
+ full_path = os.path.join(root, file)
138
+ # Add the file to the zip file
139
+ zipf.write(full_path, os.path.relpath(full_path, directory_path))
140
+ print(f"Compressed {directory_path} to {zip_file_path}")