Spaces:
Sleeping
Sleeping
_Noxty
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,11 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
from civitai_to_hf import (search_civitai, download_civitai, select_civitai_item, add_civitai_item, get_civitai_tag, select_civitai_all_item,
|
3 |
update_civitai_selection, update_civitai_checkbox, from_civitai_checkbox,
|
4 |
CIVITAI_TYPE, CIVITAI_BASEMODEL, CIVITAI_SORT, CIVITAI_PERIOD, CIVITAI_FILETYPE, download_file)
|
5 |
|
|
|
6 |
css = """
|
7 |
.title { font-size: 3em; align-items: center; text-align: center; }
|
8 |
.info { align-items: center; text-align: center; }
|
@@ -10,9 +13,31 @@ css = """
|
|
10 |
.desc [src$='#float'] { float: right; margin: 20px; }
|
11 |
"""
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
with gr.Column():
|
15 |
-
gr.Markdown("#
|
16 |
state = gr.State(value={})
|
17 |
with gr.Accordion("Search Civitai", open=True):
|
18 |
with gr.Row():
|
@@ -51,18 +76,39 @@ with gr.Blocks(theme="NoCrypt/miku@>=1.2.2", fill_width=True, css=css, delete_ca
|
|
51 |
civitai_key = gr.Textbox(label="Your Civitai Key", value="", max_lines=1)
|
52 |
gr.Markdown("Your Civitai API key is available at [https://civitai.com/user/account](https://civitai.com/user/account).", elem_classes="info")
|
53 |
|
54 |
-
|
|
|
|
|
55 |
output_but = gr.File(label="output")
|
56 |
uploaded_urls = gr.CheckboxGroup(visible=False, choices=[], value=None) # hidden
|
57 |
urls_md = gr.Markdown("<br><br>", elem_classes="result")
|
58 |
urls_remain = gr.Textbox("Remaining URLs", value="", show_copy_button=True, visible=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
|
61 |
gr.on(
|
62 |
-
triggers=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
fn=download_file,
|
64 |
inputs=[dl_url, civitai_key],
|
65 |
-
outputs=[
|
66 |
queue=True,
|
67 |
)
|
68 |
gr.on(
|
|
|
1 |
import gradio as gr
|
2 |
+
from stablepy import Model_Diffusers
|
3 |
+
|
4 |
from civitai_to_hf import (search_civitai, download_civitai, select_civitai_item, add_civitai_item, get_civitai_tag, select_civitai_all_item,
|
5 |
update_civitai_selection, update_civitai_checkbox, from_civitai_checkbox,
|
6 |
CIVITAI_TYPE, CIVITAI_BASEMODEL, CIVITAI_SORT, CIVITAI_PERIOD, CIVITAI_FILETYPE, download_file)
|
7 |
|
8 |
+
|
9 |
css = """
|
10 |
.title { font-size: 3em; align-items: center; text-align: center; }
|
11 |
.info { align-items: center; text-align: center; }
|
|
|
13 |
.desc [src$='#float'] { float: right; margin: 20px; }
|
14 |
"""
|
15 |
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
# Define the function to generate images
|
20 |
+
def generate_image(model_id, prompt, lora_A, num_steps, guidance_scale, sampler, img_width, img_height):
|
21 |
+
model = Model_Diffusers(
|
22 |
+
base_model_id=model_id,
|
23 |
+
task_name='txt2img',
|
24 |
+
)
|
25 |
+
|
26 |
+
image, info_image = model(
|
27 |
+
prompt=prompt,
|
28 |
+
lora_A=lora_A,
|
29 |
+
num_steps=num_steps,
|
30 |
+
guidance_scale=guidance_scale,
|
31 |
+
sampler=sampler,
|
32 |
+
img_width=img_width,
|
33 |
+
img_height=img_height,
|
34 |
+
)
|
35 |
+
return image[0]
|
36 |
+
|
37 |
+
|
38 |
+
with gr.Blocks(fill_width=True, css=css) as demo:
|
39 |
with gr.Column():
|
40 |
+
gr.Markdown("# StableGR", elem_classes="title")
|
41 |
state = gr.State(value={})
|
42 |
with gr.Accordion("Search Civitai", open=True):
|
43 |
with gr.Row():
|
|
|
76 |
civitai_key = gr.Textbox(label="Your Civitai Key", value="", max_lines=1)
|
77 |
gr.Markdown("Your Civitai API key is available at [https://civitai.com/user/account](https://civitai.com/user/account).", elem_classes="info")
|
78 |
|
79 |
+
with gr.Row():
|
80 |
+
run_base = gr.Button(value="Download Base Model", variant="primary")
|
81 |
+
run_lora = gr.Button(value="Download Lora", variant="primary")
|
82 |
output_but = gr.File(label="output")
|
83 |
uploaded_urls = gr.CheckboxGroup(visible=False, choices=[], value=None) # hidden
|
84 |
urls_md = gr.Markdown("<br><br>", elem_classes="result")
|
85 |
urls_remain = gr.Textbox("Remaining URLs", value="", show_copy_button=True, visible=False)
|
86 |
+
with gr.Column():
|
87 |
+
base_model = gr.File(label="Base Models")
|
88 |
+
with gr.row():
|
89 |
+
prompt = gr.Textbox(label="Prompt", value="A highly detailed portrait of an underwater city, with towering spires and domes rising up from the ocean floor")
|
90 |
+
with gr.Row():
|
91 |
+
lora_A = gr.File(label="Lora")
|
92 |
+
num_steps = gr.Slider(label="Number of Steps", minimum=1, maximum=100, value=30, step=1)
|
93 |
+
guidance_scale = gr.Slider(label="Guidance Scale", minimum=0.1, maximum=20.0, value=7.5, step=0.1)
|
94 |
+
sampler = gr.Dropdown(label="Sampler", choices=["DPM++ 2M", "OtherSampler1", "OtherSampler2"], value="DPM++ 2M")
|
95 |
+
img_width = gr.Slider(label="Image Width", minimum=64, maximum=2048, value=512, step=64)
|
96 |
+
img_height = gr.Slider(label="Image Height", minimum=64, maximum=2048, value=1024, step=64)
|
97 |
+
generate_button = gr.Button("Generate Image")
|
98 |
|
99 |
|
100 |
gr.on(
|
101 |
+
triggers=[run_base.click],
|
102 |
+
fn=download_file,
|
103 |
+
inputs=[dl_url, civitai_key],
|
104 |
+
outputs=[base_model],
|
105 |
+
queue=True,
|
106 |
+
)
|
107 |
+
gr.on(
|
108 |
+
triggers=[run_lora.click],
|
109 |
fn=download_file,
|
110 |
inputs=[dl_url, civitai_key],
|
111 |
+
outputs=[lora_A],
|
112 |
queue=True,
|
113 |
)
|
114 |
gr.on(
|