Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,12 +32,16 @@ def query(lora_id, prompt, is_negative=False, steps=28, cfg_scale=3.5, sampler="
|
|
| 32 |
|
| 33 |
prompt = f"{prompt} | ultra detail, ultra elaboration, ultra quality, perfect."
|
| 34 |
print(f'\033[1mGeneration {key}:\033[0m {prompt}')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
payload = {
|
| 37 |
"inputs": prompt,
|
| 38 |
"steps": steps,
|
| 39 |
"cfg_scale": cfg_scale,
|
| 40 |
-
"seed": seed
|
| 41 |
}
|
| 42 |
|
| 43 |
response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
|
|
@@ -52,7 +56,7 @@ def query(lora_id, prompt, is_negative=False, steps=28, cfg_scale=3.5, sampler="
|
|
| 52 |
image_bytes = response.content
|
| 53 |
image = Image.open(io.BytesIO(image_bytes))
|
| 54 |
print(f'\033[1mGeneration {key} completed!\033[0m ({prompt})')
|
| 55 |
-
return image
|
| 56 |
except Exception as e:
|
| 57 |
print(f"Error when trying to open the image: {e}")
|
| 58 |
return None
|
|
@@ -94,12 +98,13 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
|
|
| 94 |
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
| 95 |
with gr.Row():
|
| 96 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
|
|
|
| 97 |
|
| 98 |
gr.Examples(
|
| 99 |
examples = examples,
|
| 100 |
inputs = [text_prompt],
|
| 101 |
)
|
| 102 |
|
| 103 |
-
text_button.click(query, inputs=[custom_lora, text_prompt, negative_prompt, steps, cfg, method, seed, strength], outputs=image_output)
|
| 104 |
|
| 105 |
app.launch(show_api=False, share=False)
|
|
|
|
| 32 |
|
| 33 |
prompt = f"{prompt} | ultra detail, ultra elaboration, ultra quality, perfect."
|
| 34 |
print(f'\033[1mGeneration {key}:\033[0m {prompt}')
|
| 35 |
+
|
| 36 |
+
# If seed is -1, generate a random seed and use it
|
| 37 |
+
if seed == -1:
|
| 38 |
+
seed = random.randint(1, 1000000000)
|
| 39 |
|
| 40 |
payload = {
|
| 41 |
"inputs": prompt,
|
| 42 |
"steps": steps,
|
| 43 |
"cfg_scale": cfg_scale,
|
| 44 |
+
"seed": seed,
|
| 45 |
}
|
| 46 |
|
| 47 |
response = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)
|
|
|
|
| 56 |
image_bytes = response.content
|
| 57 |
image = Image.open(io.BytesIO(image_bytes))
|
| 58 |
print(f'\033[1mGeneration {key} completed!\033[0m ({prompt})')
|
| 59 |
+
return image, seed
|
| 60 |
except Exception as e:
|
| 61 |
print(f"Error when trying to open the image: {e}")
|
| 62 |
return None
|
|
|
|
| 98 |
text_button = gr.Button("Run", variant='primary', elem_id="gen-button")
|
| 99 |
with gr.Row():
|
| 100 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
| 101 |
+
seed_output = gr.Textbox(label="Seed Used", elem_id="seed-output")
|
| 102 |
|
| 103 |
gr.Examples(
|
| 104 |
examples = examples,
|
| 105 |
inputs = [text_prompt],
|
| 106 |
)
|
| 107 |
|
| 108 |
+
text_button.click(query, inputs=[custom_lora, text_prompt, negative_prompt, steps, cfg, method, seed, strength], outputs=[image_output,seed_output])
|
| 109 |
|
| 110 |
app.launch(show_api=False, share=False)
|