Spaces:
Running
Running
update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,20 @@ def start_process(input1, input2, shape0_str, shape1_str, input_suffix=".pth"):
|
|
31 |
log = "转换过程非常慢,请耐心等待。显示文件列表不代表转换完成。如果未发生错误,转换结束会显示”任务完成“\n"
|
32 |
yield [], log
|
33 |
if input2 == None or input2.strip() == "":
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
if input2 == "":
|
36 |
input2 = str(task_id)
|
37 |
log += f"未提供文件名,使用{input2}\n"
|
@@ -245,7 +258,7 @@ with gr.Blocks() as demo:
|
|
245 |
with gr.Row():
|
246 |
input1 = gr.Textbox(label="粘贴地址")
|
247 |
# 新增文件上传组件
|
248 |
-
input1_file = gr.File(label="上传文件")
|
249 |
input2 = gr.Textbox(label="自定义文件名")
|
250 |
# 修改为字符串输入控件
|
251 |
shape0_str = gr.Textbox(label="shape0 (逗号分隔的整数)", value="1,3,128,128")
|
@@ -275,13 +288,13 @@ with gr.Blocks() as demo:
|
|
275 |
|
276 |
# 添加范例
|
277 |
examples = [
|
278 |
-
["https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth",
|
279 |
-
["https://github.com/Phhofm/models/releases/download/4xNomos8kSC/4xNomos8kSC.pth",
|
280 |
-
["https://github.com/Phhofm/models/releases/download/1xDeJPG/1xDeJPG_SRFormer_light.pth",
|
281 |
]
|
282 |
gr.Examples(
|
283 |
examples=examples,
|
284 |
-
inputs=[input1,
|
285 |
outputs=[output, log_textbox],
|
286 |
fn=start_process
|
287 |
)
|
|
|
31 |
log = "转换过程非常慢,请耐心等待。显示文件列表不代表转换完成。如果未发生错误,转换结束会显示”任务完成“\n"
|
32 |
yield [], log
|
33 |
if input2 == None or input2.strip() == "":
|
34 |
+
split_input = os.path.splitext(os.path.basename(input1))
|
35 |
+
if len(split_input) > 1:
|
36 |
+
suffix = split_input[1].split('?')[0].lower()
|
37 |
+
if suffix not in [".pth" , ".safetensors" , ".ckpt"]:
|
38 |
+
print_log(task_id, input2, "不支持此文件的格式 suffix="+suffix, "错误")
|
39 |
+
log += f"不支持此文件的格式\n"
|
40 |
+
return [] , log
|
41 |
+
print_log(task_id, input2, "检查文件名", "开始")
|
42 |
+
log += f"检查文件名…\n"
|
43 |
+
yield [], log
|
44 |
+
if input2 == None or input2.strip() == "":
|
45 |
+
input2 = str(task_id)
|
46 |
+
|
47 |
+
input1 = split_input[0]
|
48 |
if input2 == "":
|
49 |
input2 = str(task_id)
|
50 |
log += f"未提供文件名,使用{input2}\n"
|
|
|
258 |
with gr.Row():
|
259 |
input1 = gr.Textbox(label="粘贴地址")
|
260 |
# 新增文件上传组件
|
261 |
+
input1_file = gr.File(label="上传文件", file_types=[".pth", ".safetensors", ".ckpt"])
|
262 |
input2 = gr.Textbox(label="自定义文件名")
|
263 |
# 修改为字符串输入控件
|
264 |
shape0_str = gr.Textbox(label="shape0 (逗号分隔的整数)", value="1,3,128,128")
|
|
|
288 |
|
289 |
# 添加范例
|
290 |
examples = [
|
291 |
+
["https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth", "", "1,3,128,128", "0,0,0,0"],
|
292 |
+
["https://github.com/Phhofm/models/releases/download/4xNomos8kSC/4xNomos8kSC.pth", "", "1,3,128,128", "0,0,0,0"],
|
293 |
+
["https://github.com/Phhofm/models/releases/download/1xDeJPG/1xDeJPG_SRFormer_light.pth", "", "1,3,128,128", "0,0,0,0"]
|
294 |
]
|
295 |
gr.Examples(
|
296 |
examples=examples,
|
297 |
+
inputs=[input1, input2, shape0_str, shape1_str],
|
298 |
outputs=[output, log_textbox],
|
299 |
fn=start_process
|
300 |
)
|