Update app.py
Browse files
app.py
CHANGED
|
@@ -56,11 +56,11 @@ def get_seed(seed):
|
|
| 56 |
return random.randint(0, MAX_SEED)
|
| 57 |
|
| 58 |
@spaces.GPU(duration=30)
|
| 59 |
-
def generate(input=DEFAULT_INPUT, negative_input=DEFAULT_NEGATIVE_INPUT, height=DEFAULT_HEIGHT, width=DEFAULT_WIDTH, steps=1, guidance=0, seed=None):
|
| 60 |
|
| 61 |
seed = get_seed(seed)
|
| 62 |
|
| 63 |
-
print(input, negative_input, height, width, steps, guidance, seed)
|
| 64 |
|
| 65 |
model.to(DEVICE)
|
| 66 |
parameters = {
|
|
@@ -70,7 +70,7 @@ def generate(input=DEFAULT_INPUT, negative_input=DEFAULT_NEGATIVE_INPUT, height=
|
|
| 70 |
"width": width,
|
| 71 |
"num_inference_steps": steps,
|
| 72 |
"guidance_scale": guidance,
|
| 73 |
-
"num_images_per_prompt":
|
| 74 |
"cross_attention_kwargs": {"scale": 0.65},
|
| 75 |
"generator": torch.Generator().manual_seed(seed),
|
| 76 |
"use_resolution_binning": True,
|
|
@@ -94,6 +94,7 @@ with gr.Blocks(css=css) as main:
|
|
| 94 |
width = gr.Slider(minimum=1, maximum=2160, step=1, value=DEFAULT_WIDTH, label="Width")
|
| 95 |
steps = gr.Slider(minimum=0, maximum=100, step=1, value=8, label="Steps")
|
| 96 |
guidance = gr.Slider(minimum=0, maximum=100, step=0.001, value=3, label = "Guidance")
|
|
|
|
| 97 |
seed = gr.Textbox(lines=1, value="", label="Seed (Blank for random)")
|
| 98 |
submit = gr.Button("▶")
|
| 99 |
maintain = gr.Button("☁️")
|
|
@@ -101,7 +102,7 @@ with gr.Blocks(css=css) as main:
|
|
| 101 |
with gr.Column():
|
| 102 |
images = gr.Gallery(columns=1, label="Image")
|
| 103 |
|
| 104 |
-
submit.click(generate, inputs=[input, negative_input, height, width, steps, guidance, seed], outputs=[images], queue=False)
|
| 105 |
maintain.click(cloud, inputs=[], outputs=[], queue=False)
|
| 106 |
|
| 107 |
main.launch(show_api=True)
|
|
|
|
| 56 |
return random.randint(0, MAX_SEED)
|
| 57 |
|
| 58 |
@spaces.GPU(duration=30)
|
| 59 |
+
def generate(input=DEFAULT_INPUT, negative_input=DEFAULT_NEGATIVE_INPUT, height=DEFAULT_HEIGHT, width=DEFAULT_WIDTH, steps=1, guidance=0, number=1, seed=None):
|
| 60 |
|
| 61 |
seed = get_seed(seed)
|
| 62 |
|
| 63 |
+
print(input, negative_input, height, width, steps, guidance, number, seed)
|
| 64 |
|
| 65 |
model.to(DEVICE)
|
| 66 |
parameters = {
|
|
|
|
| 70 |
"width": width,
|
| 71 |
"num_inference_steps": steps,
|
| 72 |
"guidance_scale": guidance,
|
| 73 |
+
"num_images_per_prompt": number,
|
| 74 |
"cross_attention_kwargs": {"scale": 0.65},
|
| 75 |
"generator": torch.Generator().manual_seed(seed),
|
| 76 |
"use_resolution_binning": True,
|
|
|
|
| 94 |
width = gr.Slider(minimum=1, maximum=2160, step=1, value=DEFAULT_WIDTH, label="Width")
|
| 95 |
steps = gr.Slider(minimum=0, maximum=100, step=1, value=8, label="Steps")
|
| 96 |
guidance = gr.Slider(minimum=0, maximum=100, step=0.001, value=3, label = "Guidance")
|
| 97 |
+
number = gr.Slider(minimum=1, maximum=4, step=1, value=1, label="Number")
|
| 98 |
seed = gr.Textbox(lines=1, value="", label="Seed (Blank for random)")
|
| 99 |
submit = gr.Button("▶")
|
| 100 |
maintain = gr.Button("☁️")
|
|
|
|
| 102 |
with gr.Column():
|
| 103 |
images = gr.Gallery(columns=1, label="Image")
|
| 104 |
|
| 105 |
+
submit.click(generate, inputs=[input, negative_input, height, width, steps, guidance, number, seed], outputs=[images], queue=False)
|
| 106 |
maintain.click(cloud, inputs=[], outputs=[], queue=False)
|
| 107 |
|
| 108 |
main.launch(show_api=True)
|