shichen
commited on
Commit
•
3e7fb88
1
Parent(s):
89eee7b
更新例子
Browse files- app.py +16 -4
- ex_images/1.jpeg +0 -0
- ex_images/2.jpeg +0 -0
- ex_images/3.jpeg +0 -0
- ex_images/4.jpeg +0 -0
- ex_images/5.jpeg +0 -0
- ex_images/6.jpeg +0 -0
app.py
CHANGED
@@ -37,23 +37,35 @@ def generate_image(api_key, prompt, aspect_ratio, model, negative_prompt, seed):
|
|
37 |
with gr.Blocks() as demo:
|
38 |
with gr.Row():
|
39 |
with gr.Column(scale=1):
|
40 |
-
api_key_text = gr.HTML("<a href='https://platform.stability.ai/account/keys' target='_blank'>https://platform.stability.ai/account/keys</a>")
|
41 |
api_key = gr.Textbox(label="API Key")
|
42 |
prompt = gr.Textbox(label="Prompt", placeholder="What you wish to see in the output image.")
|
43 |
aspect_ratio = gr.Dropdown(label="Aspect Ratio", choices=["16:9", "1:1", "21:9", "2:3", "3:2", "4:5", "5:4", "9:16", "9:21"], value="1:1")
|
44 |
model = gr.Dropdown(label="Model", choices=["sd3", "sd3-turbo"], value="sd3")
|
45 |
seed = gr.Number(label="Seed (Enter 0 for random seed)", value=0, minimum=0, maximum=4294967294, step=1)
|
46 |
-
seed.description = "输入0则随机种子"
|
47 |
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Describe what you do not wish to see.")
|
48 |
generate_btn = gr.Button("Generate Image")
|
|
|
|
|
|
|
49 |
with gr.Column(scale=1):
|
50 |
output = gr.Image()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
|
|
52 |
|
53 |
-
|
54 |
-
|
55 |
generate_btn.click(fn=generate_image,
|
56 |
inputs=[api_key, prompt, aspect_ratio, model, negative_prompt, seed],
|
57 |
outputs=output)
|
58 |
|
|
|
|
|
|
|
59 |
demo.launch()
|
|
|
37 |
with gr.Blocks() as demo:
|
38 |
with gr.Row():
|
39 |
with gr.Column(scale=1):
|
|
|
40 |
api_key = gr.Textbox(label="API Key")
|
41 |
prompt = gr.Textbox(label="Prompt", placeholder="What you wish to see in the output image.")
|
42 |
aspect_ratio = gr.Dropdown(label="Aspect Ratio", choices=["16:9", "1:1", "21:9", "2:3", "3:2", "4:5", "5:4", "9:16", "9:21"], value="1:1")
|
43 |
model = gr.Dropdown(label="Model", choices=["sd3", "sd3-turbo"], value="sd3")
|
44 |
seed = gr.Number(label="Seed (Enter 0 for random seed)", value=0, minimum=0, maximum=4294967294, step=1)
|
|
|
45 |
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Describe what you do not wish to see.")
|
46 |
generate_btn = gr.Button("Generate Image")
|
47 |
+
image = gr.Image(label="Out image", type="pil", height=0.001)
|
48 |
+
api_key_text = gr.HTML("<a href='https://platform.stability.ai/account/keys' target='_blank'>https://platform.stability.ai/account/keys</a>")
|
49 |
+
|
50 |
with gr.Column(scale=1):
|
51 |
output = gr.Image()
|
52 |
+
examples = [
|
53 |
+
["""A rabbit in a police uniform, holding a turnish-shaped gun, points at a wall. The word "Sheriff" was painted in large letters on the wall. 32k ultra HD photos, high detail, rendered in Pixar's signature style, vibrant colors, laugh filled atmosphere, Pixar style, visually stunning and emotionally appealing""", "1:1", "sd3", "(worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art:1.4), (blur, blurry, grainy), morbid, ugly, asymmetrical, mutated malformed, mutilated, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate,","ex_images/1.jpeg"],
|
54 |
+
["""There is a transparent and exquisite luxury bag on the grass, which contains various expensive and exquisite flowers. The flowers form a cute word "LOVE" """, "1:1", "sd3", "(worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art:1.4), (blur, blurry, grainy), morbid, ugly, asymmetrical, mutated malformed, mutilated, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate,","ex_images/2.jpeg"],
|
55 |
+
["""A striking and surreal vector design featuring a crying skull adorned with gold teeth, rainbows, clouds, glitter, and psychedelic colors. The skull's eyes are filled with tears, and its mouth is open in a howl, while the text "I'm fine" is written across its forehead. The overall design is dark and morbid with a touch of humor and a dash of unexpected color and glitter, creating a unique and unforgettable visual experience.""", "1:1", "sd3", "(worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art:1.4), (blur, blurry, grainy), morbid, ugly, asymmetrical, mutated malformed, mutilated, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate,","ex_images/3.jpeg"],
|
56 |
+
["""A captivating watercolor illustration presents a mesmerizing cat-like creature entirely composed of green cannabis leaves. The first-person perspective draws the viewer into its haunting world, immersing them in a supernatural realm filled with dark fantasy elements. The creature's glowing eyes emit an eerie light, inviting exploration into the unknown. The delicate coloring and side view of the subject showcase its delicate beauty and enigmatic allure. The artistic influences of dark fantasy, the painting style of Quentin Blake, and the creative genius of Damien Hirst harmoniously converge to create this extraordinary masterpiece., photo, illustration""", "1:1", "sd3", "(worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art:1.4), (blur, blurry, grainy), morbid, ugly, asymmetrical, mutated malformed, mutilated, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate,","ex_images/4.jpeg"],
|
57 |
+
["""A powerful visual metaphor featuring a sequence of four bananas, each transitioning seamlessly from fresh yellow to dark brown. The journey begins with a vibrant, slightly green banana on the left, moving through a yellowing banana with a hint of brown, a banana with a predominantly brownish-yellow hue, and finally to a dark brown, overripe banana on the right. The message beneath them, written in large, bold text, reads 'Make the most of the present moment; time waits for no one.' The dark grey background emphasizes the vibrant colors of the bananas and the stark contrast between them, creating a striking and thought-provoking visual statement., typography""", "1:1", "sd3", "(worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art:1.4), (blur, blurry, grainy), morbid, ugly, asymmetrical, mutated malformed, mutilated, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate,","ex_images/5.jpeg"],
|
58 |
+
["""A striking duality illustration featuring SpongeBob SquarePants in two contrasting expressions. On the left, a fierce SpongeBob sports a darker fur coat, red eyes, and a menacing grin, surrounded by a fiery orange and black background with sparks flying. On the right, a cheerful SpongeBob appears in a bright yellow fur coat, blue eyes, and a contagious smile, against a serene blue background that contrasts sharply with the left side. A lightning bolt connects these two opposing natures, emphasizing the duality of SpongeBob's character.""", "1:1", "sd3", "(worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art:1.4), (blur, blurry, grainy), morbid, ugly, asymmetrical, mutated malformed, mutilated, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate,","ex_images/6.jpeg"],
|
59 |
|
60 |
+
]
|
61 |
|
62 |
+
# 添加示例到界面
|
63 |
+
gr.Examples(examples, inputs=[prompt, aspect_ratio, model, negative_prompt,image], outputs=output)
|
64 |
generate_btn.click(fn=generate_image,
|
65 |
inputs=[api_key, prompt, aspect_ratio, model, negative_prompt, seed],
|
66 |
outputs=output)
|
67 |
|
68 |
+
|
69 |
+
|
70 |
+
|
71 |
demo.launch()
|
ex_images/1.jpeg
ADDED
![]() |
ex_images/2.jpeg
ADDED
![]() |
ex_images/3.jpeg
ADDED
![]() |
ex_images/4.jpeg
ADDED
![]() |
ex_images/5.jpeg
ADDED
![]() |
ex_images/6.jpeg
ADDED
![]() |