Ryouko65777 commited on
Commit
605b44a
·
verified ·
1 Parent(s): fb44ed3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from civitai_downloader import download_file
3
+
4
+ def download_model(url, token, output_path='/content'):
5
+ try:
6
+ # Download the file
7
+ downloaded_file_path = download_file(url, output_path, token)
8
+ return downloaded_file_path # Return the path to the downloaded file
9
+ except Exception as e:
10
+ return str(e) # Return error message if an exception occurs
11
+
12
+ with gr.Blocks() as demo:
13
+ gr.Markdown("# Civitai Model Downloader")
14
+
15
+ with gr.Row():
16
+ url_input = gr.Textbox(label="Model URL", placeholder="Enter the Civitai model download URL here")
17
+ token_input = gr.Textbox(label="Token", placeholder="Enter your Civitai token here", type="password")
18
+
19
+ output_path = gr.Textbox(label="Output Path", value="/content", interactive=True)
20
+ download_button = gr.Button("Download Model")
21
+ result_file = gr.File(label="Downloaded File", interactive=False) # For file output
22
+
23
+ download_button.click(
24
+ download_model,
25
+ inputs=[url_input, token_input, output_path],
26
+ outputs=result_file # Update to output the downloaded file
27
+ )
28
+
29
+ demo.launch()
30
+