Add negative prompt and fixed details
Browse files
app.py
CHANGED
|
@@ -22,15 +22,15 @@ MAX_IMAGE_SIZE = 1024
|
|
| 22 |
|
| 23 |
|
| 24 |
@spaces.GPU
|
| 25 |
-
def infer(prompt):
|
| 26 |
|
| 27 |
image = pipeline(
|
| 28 |
prompt=prompt,
|
| 29 |
-
|
| 30 |
# guidance_scale=guidance_scale,
|
| 31 |
# num_inference_steps=num_inference_steps,
|
| 32 |
-
|
| 33 |
-
|
| 34 |
# generator=generator
|
| 35 |
).images[0]
|
| 36 |
|
|
@@ -38,9 +38,8 @@ def infer(prompt):
|
|
| 38 |
|
| 39 |
|
| 40 |
examples = [
|
| 41 |
-
"
|
| 42 |
-
"
|
| 43 |
-
"A delicious ceviche cheesecake slice",
|
| 44 |
]
|
| 45 |
|
| 46 |
css = """
|
|
@@ -59,25 +58,28 @@ with gr.Blocks(css=css) as demo:
|
|
| 59 |
|
| 60 |
with gr.Row():
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
|
|
|
| 69 |
|
| 70 |
-
|
| 71 |
|
| 72 |
-
|
|
|
|
|
|
|
| 73 |
|
| 74 |
with gr.Accordion("Advanced Settings", open=False):
|
| 75 |
|
| 76 |
-
negative_prompt = gr.
|
| 77 |
label="Negative prompt",
|
| 78 |
max_lines=1,
|
| 79 |
-
placeholder="
|
| 80 |
-
visible=
|
| 81 |
)
|
| 82 |
|
| 83 |
seed = gr.Slider(
|
|
@@ -130,10 +132,11 @@ with gr.Blocks(css=css) as demo:
|
|
| 130 |
examples=examples,
|
| 131 |
inputs=[prompt]
|
| 132 |
)
|
|
|
|
| 133 |
gr.on(
|
| 134 |
triggers=[run_button.click, prompt.submit],
|
| 135 |
fn=infer,
|
| 136 |
-
inputs=[prompt],
|
| 137 |
outputs=[result]
|
| 138 |
)
|
| 139 |
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
@spaces.GPU
|
| 25 |
+
def infer(prompt, negative_prompt, height, width):
|
| 26 |
|
| 27 |
image = pipeline(
|
| 28 |
prompt=prompt,
|
| 29 |
+
negative_prompt=f'Negative prompt: avoid multiple versions of Xavy, avoid distorted facial features, malformed hands, excessive or broken gadgets, unrealistic proportions in the body or technology, extra limbs. {negative_prompt}',
|
| 30 |
# guidance_scale=guidance_scale,
|
| 31 |
# num_inference_steps=num_inference_steps,
|
| 32 |
+
width=width,
|
| 33 |
+
height=height,
|
| 34 |
# generator=generator
|
| 35 |
).images[0]
|
| 36 |
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
examples = [
|
| 41 |
+
"Xavy, a virtual content creator, is in a high-tech futuristic studio filled with holographic screens and cutting-edge gadgets. He’s presenting the latest smartphone technology, wearing a sleek tech-inspired outfit with neon accents. The background features floating data, robots assisting him, and advanced digital tools. His facial expression is enthusiastic as he explains the potential of artificial intelligence in smartphones. The atmosphere is dynamic and full of futuristic energy.",
|
| 42 |
+
"Xavy stands on a stage at a technology innovation conference, speaking passionately about the future of AI in smartphones. Behind him, a massive screen displays 3D holographic models of a cutting-edge phone design. The audience is captivated as he gestures towards the hologram, explaining how AI will revolutionize user interaction. He’s wearing a sleek black outfit with a futuristic smartwatch, and the lighting is focused on him while the background is filled with technological elements like drones and digital billboards. Negative prompt: avoid duplicated Xavy figures, warped or incomplete body parts, malformed facial expressions, extra gadgets or overlapping elements, unnatural lighting, broken equipment, unrealistic audience features."
|
|
|
|
| 43 |
]
|
| 44 |
|
| 45 |
css = """
|
|
|
|
| 58 |
|
| 59 |
with gr.Row():
|
| 60 |
|
| 61 |
+
with gr.Row():
|
| 62 |
+
prompt = gr.TextArea(
|
| 63 |
+
label="Prompt",
|
| 64 |
+
show_label=False,
|
| 65 |
+
max_lines=1,
|
| 66 |
+
placeholder="Enter your prompt",
|
| 67 |
+
container=False,
|
| 68 |
+
)
|
| 69 |
|
| 70 |
+
run_button = gr.Button("Run", scale=0)
|
| 71 |
|
| 72 |
+
with gr.Row():
|
| 73 |
+
|
| 74 |
+
result = gr.Image(label="Result", show_label=False)
|
| 75 |
|
| 76 |
with gr.Accordion("Advanced Settings", open=False):
|
| 77 |
|
| 78 |
+
negative_prompt = gr.TextArea(
|
| 79 |
label="Negative prompt",
|
| 80 |
max_lines=1,
|
| 81 |
+
placeholder="Default Negative prompt: avoid multiple versions of Xavy, avoid distorted facial features, malformed hands, excessive or broken gadgets, unrealistic proportions in the body or technology, extra limbs",
|
| 82 |
+
visible=True,
|
| 83 |
)
|
| 84 |
|
| 85 |
seed = gr.Slider(
|
|
|
|
| 132 |
examples=examples,
|
| 133 |
inputs=[prompt]
|
| 134 |
)
|
| 135 |
+
|
| 136 |
gr.on(
|
| 137 |
triggers=[run_button.click, prompt.submit],
|
| 138 |
fn=infer,
|
| 139 |
+
inputs=[prompt, negative_prompt, height, width],
|
| 140 |
outputs=[result]
|
| 141 |
)
|
| 142 |
|