Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
import os
|
4 |
|
5 |
-
def
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
|
|
|
|
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 |
|