neuroama commited on
Commit
8489786
·
1 Parent(s): bec374d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -17
app.py CHANGED
@@ -1,24 +1,21 @@
1
  import gradio as gr
2
- import subprocess
3
- import os
4
 
5
- def download_model():
6
- # 创建目录 ./trained/wdlm/,如果不存在的话
7
- subprocess.run(["mkdir", "-p", "./trained/wdlm/"])
 
 
 
 
 
8
 
9
- # 切换到目录 ./trained/wdlm/
10
- os.chdir("./trained/wdlm/")
 
 
11
 
12
- # 下载模型文件
13
- subprocess.run(["wget", "-O", "G_38400.pth", "https://github.com/00000000002/render/releases/download/ddd/G_38400.pth"])
14
 
15
- print("模型下载完成!")
16
-
17
- iface = gr.Interface(fn=download_model, inputs="None", outputs="None", live=True)
18
- download_button = gr.Button(download_model, "下载模型")
19
- download_button.style.justify_content = "center" # 垂直居中
20
- download_button.style.width = "200px" # 设置按钮宽度
21
- iface.add_element(download_button)
22
- iface.launch()
23
 
24
 
 
1
  import gradio as gr
2
+ import requests
 
3
 
4
+ def download_file(download_url, save_path):
5
+ try:
6
+ response = requests.get(download_url)
7
+ with open(save_path, 'wb') as f:
8
+ f.write(response.content)
9
+ return f"File downloaded successfully to {save_path}"
10
+ except Exception as e:
11
+ return f"Error downloading file: {str(e)}"
12
 
13
+ iface = gr.Interface(fn=download_file, inputs=["text", "text"], outputs="text",
14
+ inputs_label=["Download URL", "Save Path"],
15
+ outputs_label="Download Status")
16
+ iface.launch(share=True)
17
 
18
+ # subprocess.run(["wget", "-O", "G_38400.pth", "https://github.com/00000000002/render/releases/download/ddd/G_38400.pth"])
 
19
 
 
 
 
 
 
 
 
 
20
 
21