Spaces:
Runtime error
Runtime error
Update waifuc_gui/interface.py
Browse files- waifuc_gui/interface.py +29 -13
waifuc_gui/interface.py
CHANGED
@@ -40,7 +40,10 @@ class Interface:
|
|
40 |
"config_status": "配置状态",
|
41 |
"view_logs": "查看日志",
|
42 |
"download_log": "下载日志",
|
43 |
-
"local_source_info": "上传包含图片的zip文件用于LocalSource"
|
|
|
|
|
|
|
44 |
},
|
45 |
"en": {
|
46 |
"title": "Waifuc Data Collection Tool",
|
@@ -66,7 +69,10 @@ class Interface:
|
|
66 |
"config_status": "Configuration Status",
|
67 |
"view_logs": "View Logs",
|
68 |
"download_log": "Download Log",
|
69 |
-
"local_source_info": "Upload a ZIP file containing images for LocalSource"
|
|
|
|
|
|
|
70 |
}
|
71 |
}
|
72 |
|
@@ -100,6 +106,16 @@ class Interface:
|
|
100 |
self, selected_source, params, selected_actions, action_params, dataset_name, selected_exporter,
|
101 |
source_manager, action_manager, exporter_manager, file_handler
|
102 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
output_dir = f"/tmp/user_{source_manager.config_manager.session_id}/{dataset_name}"
|
104 |
try:
|
105 |
logger = logging.getLogger("waifuc_gui")
|
@@ -214,17 +230,17 @@ class Interface:
|
|
214 |
self.config_manager.set_config("language", language)
|
215 |
updates = {
|
216 |
language_dropdown: gr.update(label=self.get_text("language")),
|
217 |
-
source_dropdown: gr.update(label=self.get_text("select_source"), info=
|
218 |
-
action_checkboxes: gr.update(label=self.get_text("select_actions"), info=
|
219 |
-
dataset_name_input: gr.update(label=self.get_text("dataset_name"), info=
|
220 |
-
exporter_dropdown: gr.update(label=self.get_text("select_exporter"), info=
|
221 |
start_btn: gr.update(value=self.get_text("start_collection")),
|
222 |
status: gr.update(label=self.get_text("status")),
|
223 |
output_file: gr.update(label=self.get_text("download_data")),
|
224 |
-
pixiv_token_input: gr.update(label=self.get_text("pixiv_token"), info=
|
225 |
-
output_dir_input: gr.update(label=self.get_text("output_dir"), info=
|
226 |
-
num_items_input: gr.update(label=self.get_text("num_items"), info=
|
227 |
-
resize_size_input: gr.update(label=self.get_text("resize_size"), info=
|
228 |
config_export_btn: gr.update(value=self.get_text("export_config")),
|
229 |
config_import_file: gr.update(label=self.get_text("import_config")),
|
230 |
save_config_btn: gr.update(value=self.get_text("save_config")),
|
@@ -313,8 +329,8 @@ class Interface:
|
|
313 |
outputs=log_download_file
|
314 |
)
|
315 |
|
316 |
-
cleanup_btn = gr.Button(
|
317 |
-
cleanup_status = gr.Textbox(label=
|
318 |
|
319 |
cleanup_btn.click(
|
320 |
fn=self.cleanup_session,
|
@@ -339,4 +355,4 @@ class Interface:
|
|
339 |
"log_download_file": log_download_file,
|
340 |
"cleanup_btn": cleanup_btn,
|
341 |
"cleanup_status": cleanup_status
|
342 |
-
}
|
|
|
40 |
"config_status": "配置状态",
|
41 |
"view_logs": "查看日志",
|
42 |
"download_log": "下载日志",
|
43 |
+
"local_source_info": "上传包含图片的zip文件用于LocalSource",
|
44 |
+
"pixiv_word": "搜索关键词(Pixiv)",
|
45 |
+
"missing_params": "请填写所有必填参数(如搜索关键词)",
|
46 |
+
"invalid_source": "无效的数据源配置"
|
47 |
},
|
48 |
"en": {
|
49 |
"title": "Waifuc Data Collection Tool",
|
|
|
69 |
"config_status": "Configuration Status",
|
70 |
"view_logs": "View Logs",
|
71 |
"download_log": "Download Log",
|
72 |
+
"local_source_info": "Upload a ZIP file containing images for LocalSource",
|
73 |
+
"pixiv_word": "Search Keyword (Pixiv)",
|
74 |
+
"missing_params": "Please fill in all required parameters (e.g., search keyword)",
|
75 |
+
"invalid_source": "Invalid data source configuration"
|
76 |
}
|
77 |
}
|
78 |
|
|
|
106 |
self, selected_source, params, selected_actions, action_params, dataset_name, selected_exporter,
|
107 |
source_manager, action_manager, exporter_manager, file_handler
|
108 |
):
|
109 |
+
if not selected_source or not dataset_name or not selected_exporter:
|
110 |
+
return (
|
111 |
+
self.get_text("missing_params"),
|
112 |
+
None, ""
|
113 |
+
)
|
114 |
+
if selected_source == "PixivSearchSource" and (not params.get("word") or not params.get("refresh_token")):
|
115 |
+
return (
|
116 |
+
self.get_text("missing_params"),
|
117 |
+
None, ""
|
118 |
+
)
|
119 |
output_dir = f"/tmp/user_{source_manager.config_manager.session_id}/{dataset_name}"
|
120 |
try:
|
121 |
logger = logging.getLogger("waifuc_gui")
|
|
|
230 |
self.config_manager.set_config("language", language)
|
231 |
updates = {
|
232 |
language_dropdown: gr.update(label=self.get_text("language")),
|
233 |
+
source_dropdown: gr.update(label=self.get_text("select_source"), info=self.get_text("select_source_info")),
|
234 |
+
action_checkboxes: gr.update(label=self.get_text("select_actions"), info=self.get_text("select_actions_info")),
|
235 |
+
dataset_name_input: gr.update(label=self.get_text("dataset_name"), info=self.get_text("dataset_name_info")),
|
236 |
+
exporter_dropdown: gr.update(label=self.get_text("select_exporter"), info=self.get_text("select_exporter_info")),
|
237 |
start_btn: gr.update(value=self.get_text("start_collection")),
|
238 |
status: gr.update(label=self.get_text("status")),
|
239 |
output_file: gr.update(label=self.get_text("download_data")),
|
240 |
+
pixiv_token_input: gr.update(label=self.get_text("pixiv_token"), info=self.get_text("pixiv_token_info")),
|
241 |
+
output_dir_input: gr.update(label=self.get_text("output_dir"), info=self.get_text("output_dir_info")),
|
242 |
+
num_items_input: gr.update(label=self.get_text("num_items"), info=self.get_text("num_items_info")),
|
243 |
+
resize_size_input: gr.update(label=self.get_text("resize_size"), info=self.get_text("resize_size_info")),
|
244 |
config_export_btn: gr.update(value=self.get_text("export_config")),
|
245 |
config_import_file: gr.update(label=self.get_text("import_config")),
|
246 |
save_config_btn: gr.update(value=self.get_text("save_config")),
|
|
|
329 |
outputs=log_download_file
|
330 |
)
|
331 |
|
332 |
+
cleanup_btn = gr.Button(self.get_text("cleanup_session"))
|
333 |
+
cleanup_status = gr.Textbox(label=self.get_text("cleanup_status"), interactive=False)
|
334 |
|
335 |
cleanup_btn.click(
|
336 |
fn=self.cleanup_session,
|
|
|
355 |
"log_download_file": log_download_file,
|
356 |
"cleanup_btn": cleanup_btn,
|
357 |
"cleanup_status": cleanup_status
|
358 |
+
}
|