Spaces:
Sleeping
Sleeping
Commit
·
b188af7
1
Parent(s):
d104cb7
css
Browse files
app.py
CHANGED
@@ -1,8 +1,42 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
# Load the model
|
4 |
model = gr.load("models/strangerzonehf/Flux-Midjourney-Mix2-LoRA")
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
# Enhanced D&D-themed CSS with previously used styles and new additions
|
7 |
custom_css = """
|
8 |
body {
|
@@ -123,10 +157,13 @@ button:hover {
|
|
123 |
}
|
124 |
"""
|
125 |
|
126 |
-
# Define Gradio interface
|
127 |
iface = gr.Interface(
|
128 |
-
fn=
|
129 |
-
inputs=
|
|
|
|
|
|
|
130 |
outputs=gr.Image(type="pil", label="🖼️ Your Legendary Vision"),
|
131 |
title="🛡️ Dungeons & Dragons Image Generator ⚔️",
|
132 |
description="**Unleash Your Imagination!** Create heroes, maps, quests, and epic scenes to bring your campaigns to life. "
|
|
|
1 |
import gradio as gr
|
2 |
+
from typing import Tuple
|
3 |
|
4 |
# Load the model
|
5 |
model = gr.load("models/strangerzonehf/Flux-Midjourney-Mix2-LoRA")
|
6 |
|
7 |
+
# List of styles
|
8 |
+
style_list = [
|
9 |
+
{"name": "D&D Art", "prompt": "dungeons & dragons style artwork {prompt}. d&d style, key visual, vibrant, studio anime, highly detailed",
|
10 |
+
"negative_prompt": "photo, deformed, black and white, realism, disfigured, low contrast"},
|
11 |
+
{"name": "2560 x 1440", "prompt": "hyper-realistic 4K image of {prompt}. ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic, fantastical environments, epic scenery, rich textures",
|
12 |
+
"negative_prompt": "cartoonish, low resolution, blurry, simplistic, abstract, sci-fi, modern cityscapes, deformed, ugly"},
|
13 |
+
{"name": "Character Portrait", "prompt": "dungeons & dragons character portrait of {prompt}. intricate details, expressive faces, heroic poses, rich textures, elaborate costumes, iconic weapons, fantasy aesthetic, studio-quality rendering",
|
14 |
+
"negative_prompt": "generic, overly stylized, blurry, simplistic, futuristic, deformed"},
|
15 |
+
{"name": "Epic Battle", "prompt": "dynamic dungeons & dragons artwork of {prompt}. epic battle scene, legendary heroes, fierce monsters, intense action, dramatic lighting, high-detail environment, magical effects, vibrant colors",
|
16 |
+
"negative_prompt": "peaceful, mundane, low energy, modern, sci-fi, simplistic, cartoonish, low contrast"},
|
17 |
+
{"name": "(No style)", "prompt": "{prompt}", "negative_prompt": ""}
|
18 |
+
]
|
19 |
+
|
20 |
+
styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in style_list}
|
21 |
+
STYLE_NAMES = list(styles.keys())
|
22 |
+
DEFAULT_STYLE_NAME = "(No style)"
|
23 |
+
|
24 |
+
def apply_style(style_name: str, positive: str, negative: str = "") -> Tuple[str, str]:
|
25 |
+
p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
|
26 |
+
if not negative:
|
27 |
+
negative = ""
|
28 |
+
return p.replace("{prompt}", positive), n + negative
|
29 |
+
|
30 |
+
def generate_image(style: str, positive_prompt: str):
|
31 |
+
styled_prompt, styled_negative = apply_style(style, positive_prompt)
|
32 |
+
result = model(
|
33 |
+
inputs={
|
34 |
+
"prompt": styled_prompt,
|
35 |
+
"negative_prompt": styled_negative,
|
36 |
+
}
|
37 |
+
)
|
38 |
+
return result
|
39 |
+
|
40 |
# Enhanced D&D-themed CSS with previously used styles and new additions
|
41 |
custom_css = """
|
42 |
body {
|
|
|
157 |
}
|
158 |
"""
|
159 |
|
160 |
+
# Define Gradio interface
|
161 |
iface = gr.Interface(
|
162 |
+
fn=generate_image,
|
163 |
+
inputs=[
|
164 |
+
gr.Dropdown(label="🎨 Choose Style", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME),
|
165 |
+
gr.Textbox(label="🎲 Enter Your Quest:", placeholder="Describe your scene, hero, or epic landscape..."),
|
166 |
+
],
|
167 |
outputs=gr.Image(type="pil", label="🖼️ Your Legendary Vision"),
|
168 |
title="🛡️ Dungeons & Dragons Image Generator ⚔️",
|
169 |
description="**Unleash Your Imagination!** Create heroes, maps, quests, and epic scenes to bring your campaigns to life. "
|