Spaces:
Running
on
Zero
Running
on
Zero
kayfahaarukku
commited on
Commit
•
1f4d65d
1
Parent(s):
79dca31
Add Generation Detail
Browse files
app.py
CHANGED
@@ -26,7 +26,7 @@ def generate_image(prompt, negative_prompt, use_defaults, resolution, guidance_s
|
|
26 |
seed = random.randint(0, 99999999)
|
27 |
if use_defaults:
|
28 |
prompt = f"{prompt}, masterpiece, best quality"
|
29 |
-
negative_prompt = f"lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name, {negative_prompt}"
|
30 |
generator = torch.manual_seed(seed)
|
31 |
|
32 |
def callback(step, timestep, latents):
|
@@ -53,10 +53,18 @@ def generate_image(prompt, negative_prompt, use_defaults, resolution, guidance_s
|
|
53 |
# Define Gradio interface
|
54 |
def interface_fn(prompt, negative_prompt, use_defaults, resolution, guidance_scale, num_inference_steps, seed, randomize_seed, progress=gr.Progress()):
|
55 |
image, seed = generate_image(prompt, negative_prompt, use_defaults, resolution, guidance_scale, num_inference_steps, seed, randomize_seed, progress)
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
def reset_inputs():
|
59 |
-
return gr.update(value=''), gr.update(value='
|
60 |
|
61 |
with gr.Blocks(title="UrangDiffusion 1.0 Demo", theme="NoCrypt/[email protected]") as demo:
|
62 |
gr.HTML(
|
@@ -66,7 +74,7 @@ with gr.Blocks(title="UrangDiffusion 1.0 Demo", theme="NoCrypt/[email protected]") as d
|
|
66 |
with gr.Row():
|
67 |
with gr.Column():
|
68 |
prompt_input = gr.Textbox(lines=2, placeholder="Enter prompt here", label="Prompt")
|
69 |
-
negative_prompt_input = gr.Textbox(lines=2, placeholder="Enter negative prompt here", label="Negative Prompt"
|
70 |
use_defaults_input = gr.Checkbox(label="Use Default Quality Tags and Negative Prompt", value=True)
|
71 |
resolution_input = gr.Radio(
|
72 |
choices=[
|
@@ -85,6 +93,8 @@ with gr.Blocks(title="UrangDiffusion 1.0 Demo", theme="NoCrypt/[email protected]") as d
|
|
85 |
|
86 |
with gr.Column():
|
87 |
output_image = gr.Image(type="pil", label="Generated Image")
|
|
|
|
|
88 |
gr.Markdown(
|
89 |
"""
|
90 |
### Recommended prompt formatting:
|
@@ -103,7 +113,7 @@ with gr.Blocks(title="UrangDiffusion 1.0 Demo", theme="NoCrypt/[email protected]") as d
|
|
103 |
inputs=[
|
104 |
prompt_input, negative_prompt_input, use_defaults_input, resolution_input, guidance_scale_input, num_inference_steps_input, seed_input, randomize_seed_input
|
105 |
],
|
106 |
-
outputs=[output_image, seed_input]
|
107 |
)
|
108 |
|
109 |
reset_button.click(
|
|
|
26 |
seed = random.randint(0, 99999999)
|
27 |
if use_defaults:
|
28 |
prompt = f"{prompt}, masterpiece, best quality"
|
29 |
+
negative_prompt = f"nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name, {negative_prompt}"
|
30 |
generator = torch.manual_seed(seed)
|
31 |
|
32 |
def callback(step, timestep, latents):
|
|
|
53 |
# Define Gradio interface
|
54 |
def interface_fn(prompt, negative_prompt, use_defaults, resolution, guidance_scale, num_inference_steps, seed, randomize_seed, progress=gr.Progress()):
|
55 |
image, seed = generate_image(prompt, negative_prompt, use_defaults, resolution, guidance_scale, num_inference_steps, seed, randomize_seed, progress)
|
56 |
+
|
57 |
+
# Create the generation details string
|
58 |
+
details = f"""
|
59 |
+
{prompt}
|
60 |
+
Negative prompt: {negative_prompt}
|
61 |
+
Steps: {num_inference_steps}, CFG scale: {guidance_scale}, Seed: {seed}, Size: {resolution}
|
62 |
+
"""
|
63 |
+
|
64 |
+
return image, seed, gr.update(value=seed), details
|
65 |
|
66 |
def reset_inputs():
|
67 |
+
return gr.update(value=''), gr.update(value=''), gr.update(value=True), gr.update(value='832x1216'), gr.update(value=7), gr.update(value=28), gr.update(value=0), gr.update(value=True)
|
68 |
|
69 |
with gr.Blocks(title="UrangDiffusion 1.0 Demo", theme="NoCrypt/[email protected]") as demo:
|
70 |
gr.HTML(
|
|
|
74 |
with gr.Row():
|
75 |
with gr.Column():
|
76 |
prompt_input = gr.Textbox(lines=2, placeholder="Enter prompt here", label="Prompt")
|
77 |
+
negative_prompt_input = gr.Textbox(lines=2, placeholder="Enter negative prompt here", label="Negative Prompt")
|
78 |
use_defaults_input = gr.Checkbox(label="Use Default Quality Tags and Negative Prompt", value=True)
|
79 |
resolution_input = gr.Radio(
|
80 |
choices=[
|
|
|
93 |
|
94 |
with gr.Column():
|
95 |
output_image = gr.Image(type="pil", label="Generated Image")
|
96 |
+
with gr.Accordion("Generation Details", open=False):
|
97 |
+
generation_info = gr.Textbox(label="", max_lines=10, interactive=False)
|
98 |
gr.Markdown(
|
99 |
"""
|
100 |
### Recommended prompt formatting:
|
|
|
113 |
inputs=[
|
114 |
prompt_input, negative_prompt_input, use_defaults_input, resolution_input, guidance_scale_input, num_inference_steps_input, seed_input, randomize_seed_input
|
115 |
],
|
116 |
+
outputs=[output_image, seed_input, seed_input, generation_info]
|
117 |
)
|
118 |
|
119 |
reset_button.click(
|