Veda_Sahaja commited on
Commit ·
f11f48a
1
Parent(s): e21e1ed
Update space
Browse files
app.py
CHANGED
|
@@ -28,31 +28,16 @@ style_list = [
|
|
| 28 |
"prompt": "anime artwork {prompt} . anime style, key visual, vibrant, studio anime, highly detailed",
|
| 29 |
"negative_prompt": "photo, deformed, black and white, realism, disfigured, low contrast",
|
| 30 |
},
|
| 31 |
-
{
|
| 32 |
-
"name": "Manga",
|
| 33 |
-
"prompt": "manga style {prompt} . vibrant, high-energy, detailed, iconic, Japanese comic style",
|
| 34 |
-
"negative_prompt": "ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, Western comic style",
|
| 35 |
-
},
|
| 36 |
{
|
| 37 |
"name": "Digital Art",
|
| 38 |
"prompt": "concept art {prompt} . digital artwork, illustrative, painterly, matte painting, highly detailed",
|
| 39 |
"negative_prompt": "photo, photorealistic, realism, ugly",
|
| 40 |
},
|
| 41 |
-
{
|
| 42 |
-
"name": "Pixel art",
|
| 43 |
-
"prompt": "pixel-art {prompt} . low-res, blocky, pixel art style, 8-bit graphics",
|
| 44 |
-
"negative_prompt": "sloppy, messy, blurry, noisy, highly detailed, ultra textured, photo, realistic",
|
| 45 |
-
},
|
| 46 |
{
|
| 47 |
"name": "Fantasy art",
|
| 48 |
"prompt": "ethereal fantasy concept art of {prompt} . magnificent, celestial, ethereal, painterly, epic, majestic, magical, fantasy art, cover art, dreamy",
|
| 49 |
"negative_prompt": "photographic, realistic, realism, 35mm film, dslr, cropped, frame, text, deformed, glitch, noise, noisy, off-center, deformed, cross-eyed, closed eyes, bad anatomy, ugly, disfigured, sloppy, duplicate, mutated, black and white",
|
| 50 |
},
|
| 51 |
-
{
|
| 52 |
-
"name": "Neonpunk",
|
| 53 |
-
"prompt": "neonpunk style {prompt} . cyberpunk, vaporwave, neon, vibes, vibrant, stunningly beautiful, crisp, detailed, sleek, ultramodern, magenta highlights, dark purple shadows, high contrast, cinematic, ultra detailed, intricate, professional",
|
| 54 |
-
"negative_prompt": "painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured",
|
| 55 |
-
},
|
| 56 |
{
|
| 57 |
"name": "3D Model",
|
| 58 |
"prompt": "professional 3d model {prompt} . octane render, highly detailed, volumetric, dramatic lighting",
|
|
@@ -84,14 +69,15 @@ pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, times
|
|
| 84 |
MAX_SEED = np.iinfo(np.int32).max
|
| 85 |
MAX_IMAGE_SIZE = 1024
|
| 86 |
|
| 87 |
-
def infer(prompt, negative_prompt, width, height,
|
| 88 |
seed = random.randint(0,4294967295)
|
|
|
|
| 89 |
|
| 90 |
generator = torch.Generator().manual_seed(seed)
|
| 91 |
|
| 92 |
prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
|
| 93 |
|
| 94 |
-
image = pipe(
|
| 95 |
prompt = prompt,
|
| 96 |
negative_prompt = negative_prompt,
|
| 97 |
guidance_scale = guidance_scale,
|
|
@@ -99,7 +85,7 @@ def infer(prompt, negative_prompt, width, height, guidance_scale, style_name=Non
|
|
| 99 |
width = width,
|
| 100 |
height = height,
|
| 101 |
generator = generator
|
| 102 |
-
).images[0]
|
| 103 |
|
| 104 |
return image
|
| 105 |
|
|
@@ -113,7 +99,19 @@ css="""
|
|
| 113 |
#col-container {
|
| 114 |
margin: 0 auto;
|
| 115 |
max-width: 520px;
|
|
|
|
| 116 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
"""
|
| 118 |
|
| 119 |
if torch.cuda.is_available():
|
|
@@ -125,8 +123,9 @@ with gr.Blocks(css=css) as demo:
|
|
| 125 |
|
| 126 |
with gr.Column(elem_id="col-container"):
|
| 127 |
gr.Markdown(f"""
|
| 128 |
-
#
|
| 129 |
-
|
|
|
|
| 130 |
""")
|
| 131 |
|
| 132 |
with gr.Row():
|
|
@@ -139,14 +138,15 @@ with gr.Blocks(css=css) as demo:
|
|
| 139 |
container=False,
|
| 140 |
)
|
| 141 |
|
| 142 |
-
run_button = gr.Button("
|
| 143 |
|
| 144 |
-
result = gr.
|
| 145 |
|
| 146 |
with gr.Accordion("Advanced Settings", open=False):
|
|
|
|
| 147 |
negative_prompt = gr.Textbox(
|
| 148 |
label="Negative prompt",
|
| 149 |
-
|
| 150 |
max_lines=1,
|
| 151 |
placeholder="Enter a negative prompt",
|
| 152 |
elem_id="negative-prompt-text-input"
|
|
@@ -177,24 +177,24 @@ with gr.Blocks(css=css) as demo:
|
|
| 177 |
value=1024,
|
| 178 |
)
|
| 179 |
|
| 180 |
-
with gr.Row():
|
| 181 |
-
|
| 182 |
-
guidance_scale = gr.Slider(
|
| 183 |
-
label="Guidance scale",
|
| 184 |
-
minimum=0.0,
|
| 185 |
-
maximum=50.0,
|
| 186 |
-
step=0.1,
|
| 187 |
-
value=5,
|
| 188 |
-
)
|
| 189 |
-
|
| 190 |
gr.Examples(
|
| 191 |
examples = examples,
|
| 192 |
inputs = [prompt]
|
| 193 |
)
|
| 194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
run_button.click(
|
| 196 |
fn = infer,
|
| 197 |
-
inputs = [prompt, negative_prompt, width, height,
|
| 198 |
outputs = [result]
|
| 199 |
)
|
| 200 |
|
|
|
|
| 28 |
"prompt": "anime artwork {prompt} . anime style, key visual, vibrant, studio anime, highly detailed",
|
| 29 |
"negative_prompt": "photo, deformed, black and white, realism, disfigured, low contrast",
|
| 30 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
{
|
| 32 |
"name": "Digital Art",
|
| 33 |
"prompt": "concept art {prompt} . digital artwork, illustrative, painterly, matte painting, highly detailed",
|
| 34 |
"negative_prompt": "photo, photorealistic, realism, ugly",
|
| 35 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
{
|
| 37 |
"name": "Fantasy art",
|
| 38 |
"prompt": "ethereal fantasy concept art of {prompt} . magnificent, celestial, ethereal, painterly, epic, majestic, magical, fantasy art, cover art, dreamy",
|
| 39 |
"negative_prompt": "photographic, realistic, realism, 35mm film, dslr, cropped, frame, text, deformed, glitch, noise, noisy, off-center, deformed, cross-eyed, closed eyes, bad anatomy, ugly, disfigured, sloppy, duplicate, mutated, black and white",
|
| 40 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
{
|
| 42 |
"name": "3D Model",
|
| 43 |
"prompt": "professional 3d model {prompt} . octane render, highly detailed, volumetric, dramatic lighting",
|
|
|
|
| 69 |
MAX_SEED = np.iinfo(np.int32).max
|
| 70 |
MAX_IMAGE_SIZE = 1024
|
| 71 |
|
| 72 |
+
def infer(prompt, negative_prompt, width, height, style_name=None):
|
| 73 |
seed = random.randint(0,4294967295)
|
| 74 |
+
guidance_scale = 0
|
| 75 |
|
| 76 |
generator = torch.Generator().manual_seed(seed)
|
| 77 |
|
| 78 |
prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
|
| 79 |
|
| 80 |
+
image = [pipe(
|
| 81 |
prompt = prompt,
|
| 82 |
negative_prompt = negative_prompt,
|
| 83 |
guidance_scale = guidance_scale,
|
|
|
|
| 85 |
width = width,
|
| 86 |
height = height,
|
| 87 |
generator = generator
|
| 88 |
+
).images[0] for _ in range(4)]
|
| 89 |
|
| 90 |
return image
|
| 91 |
|
|
|
|
| 99 |
#col-container {
|
| 100 |
margin: 0 auto;
|
| 101 |
max-width: 520px;
|
| 102 |
+
padding-top: 20px;
|
| 103 |
}
|
| 104 |
+
.footer {
|
| 105 |
+
margin-bottom: 45px;
|
| 106 |
+
margin-top: 25px;
|
| 107 |
+
text-align: center;
|
| 108 |
+
}
|
| 109 |
+
.footer>p {
|
| 110 |
+
font-size: .8rem;
|
| 111 |
+
display: inline-block;
|
| 112 |
+
padding: 0 10px;
|
| 113 |
+
transform: translateY(10px);
|
| 114 |
+
}
|
| 115 |
"""
|
| 116 |
|
| 117 |
if torch.cuda.is_available():
|
|
|
|
| 123 |
|
| 124 |
with gr.Column(elem_id="col-container"):
|
| 125 |
gr.Markdown(f"""
|
| 126 |
+
# Welcome to Metamorph: Your Creative Gateway
|
| 127 |
+
#### Transform your words into stunning visuals with our advanced AI-powered Text-to-Image generator
|
| 128 |
+
Currently running on {power_device}
|
| 129 |
""")
|
| 130 |
|
| 131 |
with gr.Row():
|
|
|
|
| 138 |
container=False,
|
| 139 |
)
|
| 140 |
|
| 141 |
+
run_button = gr.Button("Generate", scale=0)
|
| 142 |
|
| 143 |
+
result = gr.Gallery(label="Results", show_label=False, format="png", show_share_button=False)
|
| 144 |
|
| 145 |
with gr.Accordion("Advanced Settings", open=False):
|
| 146 |
+
|
| 147 |
negative_prompt = gr.Textbox(
|
| 148 |
label="Negative prompt",
|
| 149 |
+
show_label=False,
|
| 150 |
max_lines=1,
|
| 151 |
placeholder="Enter a negative prompt",
|
| 152 |
elem_id="negative-prompt-text-input"
|
|
|
|
| 177 |
value=1024,
|
| 178 |
)
|
| 179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
gr.Examples(
|
| 181 |
examples = examples,
|
| 182 |
inputs = [prompt]
|
| 183 |
)
|
| 184 |
|
| 185 |
+
gr.HTML(
|
| 186 |
+
"""
|
| 187 |
+
<div class="footer">
|
| 188 |
+
<p>
|
| 189 |
+
Used Stable Diffusion XL (SDXL) Model by <a href="https://huggingface.co/stabilityai" style="text-decoration: underline;" target="_blank">StabilityAI</a>, a cutting-edge text-to-image model, complemented by the lightning-fast SDXL-Lightning model by <a href="https://huggingface.co/ByteDance" style="text-decoration: underline;" target="_blank">ByteDance</a>, ensuring high-quality images with reduced computational steps.</p>
|
| 190 |
+
</p>
|
| 191 |
+
</div>
|
| 192 |
+
"""
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
run_button.click(
|
| 196 |
fn = infer,
|
| 197 |
+
inputs = [prompt, negative_prompt, width, height, style_selection],
|
| 198 |
outputs = [result]
|
| 199 |
)
|
| 200 |
|