Spaces:
Sleeping
Sleeping
File size: 5,527 Bytes
6e6e228 b188af7 34db193 6e6e228 34db193 b188af7 d104cb7 6e6e228 34db193 d104cb7 6e6e228 d104cb7 6e6e228 34db193 d104cb7 6e6e228 d104cb7 34db193 d104cb7 34db193 6e6e228 d104cb7 34db193 d104cb7 6e6e228 d104cb7 6e6e228 d104cb7 6e6e228 34db193 6e6e228 d104cb7 34db193 6e6e228 d104cb7 6e6e228 d104cb7 6e6e228 34db193 d104cb7 6e6e228 d104cb7 34db193 6e6e228 d104cb7 34db193 6e6e228 d104cb7 6e6e228 d104cb7 6e6e228 d104cb7 6e6e228 d104cb7 34db193 6e6e228 d104cb7 34db193 6e6e228 d104cb7 6e6e228 d104cb7 6e6e228 d104cb7 6e6e228 34db193 b188af7 6e6e228 b188af7 d104cb7 6e6e228 d104cb7 6e6e228 d104cb7 6e6e228 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
import gradio as gr
from typing import Tuple
# Load the model
model = gr.load("models/strangerzonehf/Flux-Midjourney-Mix2-LoRA")
# List of styles
style_list = [
{"name": "D&D Art", "prompt": "dungeons & dragons style artwork {prompt}. d&d style, key visual, vibrant, studio anime, highly detailed",
"negative_prompt": "photo, deformed, black and white, realism, disfigured, low contrast"},
{"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",
"negative_prompt": "cartoonish, low resolution, blurry, simplistic, abstract, sci-fi, modern cityscapes, deformed, ugly"},
{"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",
"negative_prompt": "generic, overly stylized, blurry, simplistic, futuristic, deformed"},
{"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",
"negative_prompt": "peaceful, mundane, low energy, modern, sci-fi, simplistic, cartoonish, low contrast"},
{"name": "(No style)", "prompt": "{prompt}", "negative_prompt": ""}
]
styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in style_list}
STYLE_NAMES = list(styles.keys())
DEFAULT_STYLE_NAME = "(No style)"
def apply_style(style_name: str, positive: str, negative: str = "") -> Tuple[str, str]:
p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
if not negative:
negative = ""
return p.replace("{prompt}", positive), n + negative
def generate_image(style: str, positive_prompt: str):
styled_prompt, styled_negative = apply_style(style, positive_prompt)
result = model(
inputs={
"prompt": styled_prompt,
"negative_prompt": styled_negative,
}
)
return result
# Enhanced D&D-themed CSS with previously used styles and new additions
custom_css = """
body {
background-color: #1b1b1b; /* Dungeon-like backdrop */
color: #f5f5f5;
font-family: 'Palatino Linotype', serif; /* Fantasy-themed font */
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
height: 100vh;
}
.gradio-container {
max-width: 950px;
margin: auto;
padding: 30px;
background: linear-gradient(145deg, #2e2b2a, #3a3433); /* Mystic gradient for depth */
border: 4px solid #8b4513;
border-radius: 15px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}
h1, h2 {
color: #ffd700;
text-align: center;
text-shadow: 2px 2px #7c5200; /* Gold shine effect */
}
.description {
margin-top: 15px;
color: #d4af37; /* Lighter gold for elegance */
font-size: 18px;
line-height: 1.6;
text-align: center;
}
a {
color: #ffd700;
text-decoration: none;
font-weight: bold;
}
a:hover {
color: #ffcc33; /* Brighter gold for interactivity */
}
textarea, input[type="text"] {
background-color: #292828;
color: #f5e6ca;
border: 2px solid #8b4513;
border-radius: 5px;
padding: 10px;
font-family: 'Palatino Linotype', serif;
font-size: 16px;
}
textarea:focus, input[type="text"]:focus {
outline: none;
border-color: #ffd700;
box-shadow: 0 0 8px #ffd700;
}
button {
background: #8b4513;
color: #f0e6d2;
font-size: 18px;
font-family: 'Palatino Linotype', serif;
border: none;
border-radius: 8px;
padding: 12px 30px;
cursor: pointer;
transition: 0.3s ease-in-out;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.6);
}
button:hover {
background: #a0522d;
box-shadow: 0 0 15px #ffd700;
}
.gradio-output {
background: #2f2f2f;
color: #ffd700;
border: 2px solid #8b4513;
border-radius: 8px;
padding: 20px;
text-align: center;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
.gradio-output img {
max-width: 100%;
border: 2px solid #a0522d;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}
.footer {
text-align: center;
margin-top: 30px;
color: #ffd700;
font-size: 14px;
text-shadow: 1px 1px #7c5200;
}
.footer a {
color: #ffd700;
text-decoration: none;
margin: 0 10px;
}
.footer a:hover {
color: #ffcc33;
text-shadow: 2px 2px #ff9900;
}
"""
# Define Gradio interface
iface = gr.Interface(
fn=generate_image,
inputs=[
gr.Dropdown(label="🎨 Choose Style", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME),
gr.Textbox(label="🎲 Enter Your Quest:", placeholder="Describe your scene, hero, or epic landscape..."),
],
outputs=gr.Image(type="pil", label="🖼️ Your Legendary Vision"),
title="🛡️ Dungeons & Dragons Image Generator ⚔️",
description="**Unleash Your Imagination!** Create heroes, maps, quests, and epic scenes to bring your campaigns to life. "
"Tailored for adventurers seeking inspiration or Dungeon Masters constructing their next grand story. <br>"
"[Visit Our Website](https://chatdnd.net) | [Support Us](https://buymeacoffee.com/watchoutformike)",
css=custom_css
)
# Launch the Gradio interface
iface.launch()
|