WatchOutForMike commited on
Commit
d4bd4eb
·
1 Parent(s): b381af3
Files changed (1) hide show
  1. app.py +3 -127
app.py CHANGED
@@ -1,129 +1,8 @@
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
-
10
- {
11
- "name": "D&D Art",
12
- "prompt": "dungeons & dragons style artwork {prompt}. d&d style, key visual, vibrant, studio anime, highly detailed",
13
- "negative_prompt": "photo, deformed, black and white, realism, disfigured, low contrast"
14
- },
15
- {
16
- "name": "2560 x 1440",
17
- "prompt": "hyper-realistic 4K image of {prompt}. ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic, fantastical environments, epic scenery, rich textures",
18
- "negative_prompt": "cartoonish, low resolution, blurry, simplistic, abstract, sci-fi, modern cityscapes, deformed, ugly"
19
- },
20
-
21
- {
22
- "name": "Photo",
23
- "prompt": "cinematic photo of {prompt}. 35mm photograph, fantasy style, atmospheric lighting, magical elements, bokeh, professional, 4k, highly detailed",
24
- "negative_prompt": "modern day, sci-fi, minimalistic, noisy, blurry, overly dark, soft, deformed, low fantasy"
25
- },
26
-
27
- {
28
- "name": "Epic Battle",
29
- "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",
30
- "negative_prompt": "peaceful, mundane, low energy, modern, sci-fi, simplistic, cartoonish, low contrast"
31
- },
32
-
33
- {
34
- "name": "Character Portrait",
35
- "prompt": "dungeons & dragons character portrait of {prompt}. intricate details, expressive faces, heroic poses, rich textures, elaborate costumes, iconic weapons, fantasy aesthetic, studio-quality rendering",
36
- "negative_prompt": "generic, overly stylized, blurry, simplistic, futuristic, deformed"
37
- },
38
-
39
- {
40
- "name": "Magical Realm",
41
- "prompt": "mystical dungeons & dragons artwork of {prompt}. enchanted forests, glowing runes, floating islands, otherworldly landscapes, magical auras, vibrant fantasy colors, ultra-detailed",
42
- "negative_prompt": "urban, dull, realistic, futuristic, lifeless, overly muted, minimalistic"
43
- },
44
-
45
- {
46
- "name": "Dark Fantasy",
47
- "prompt": "dark and moody dungeons & dragons artwork of {prompt}. gothic ruins, shadowy figures, haunting atmospheres, grim villains, cursed relics, muted colors, intricate textures, sinister undertones",
48
- "negative_prompt": "bright, cheerful, cartoonish, lighthearted, futuristic, deformed"
49
- },
50
-
51
- {
52
- "name": "Legendary Creatures",
53
- "prompt": "dungeons & dragons artwork of legendary creatures {prompt}. awe-inspiring dragons, ferocious beasts, mythical monsters, intricate scales, detailed textures, dynamic poses, magical auras, cinematic quality",
54
- "negative_prompt": "simplistic, dull, mundane creatures, low-detail, modern animals, cartoony"
55
- },
56
-
57
- {
58
- "name": "Ancient Ruins",
59
- "prompt": "dungeons & dragons artwork of {prompt}. ancient temples, crumbling ruins, arcane symbols, epic scale, mystical atmosphere, grand designs, dramatic perspective, ultra-detailed",
60
- "negative_prompt": "modern structures, low-detail, dull, untextured, non-fantasy elements, minimalistic"
61
- },
62
-
63
- {
64
- "name": "Spellcasting Scene",
65
- "prompt": "dungeons & dragons artwork of {prompt}. dramatic spellcasting, glowing magic effects, dynamic poses, swirling energy, vibrant light contrasts, powerful sorcerers, rich fantasy aesthetic",
66
- "negative_prompt": "low energy, non-magical, mundane, modern day, generic designs, dull colors"
67
- },
68
-
69
- {
70
- "name": "Tavern Life",
71
- "prompt": "dungeons & dragons artwork of {prompt}. lively medieval tavern scene, detailed character interactions, warm firelight, wooden interiors, mugs of ale, bard performances, rich textures, inviting atmosphere",
72
- "negative_prompt": "cold, empty, futuristic, lifeless, overly simplistic, boring"
73
- },
74
-
75
- {
76
- "name": "D&D Quest Art",
77
- "prompt": "dungeons & dragons quest artwork of {prompt}. heroic adventurers, perilous journeys, hidden treasures, legendary quests, immersive fantasy landscapes, intricate details, atmospheric lighting, grand scale, narrative-driven composition",
78
- "negative_prompt": "modern, futuristic, low-detail, overly abstract, mundane settings, simplistic, sci-fi, cartoony, lifeless, uninspired"
79
- },
80
-
81
- {
82
- "name": "D&D Anime Art",
83
- "prompt": "dungeons & dragons anime-style artwork of {prompt}. stylized characters, vibrant colors, expressive designs, dynamic action poses, magical effects, intricate fantasy backgrounds, studio-quality anime detailing",
84
- "negative_prompt": "photo-realistic, overly gritty, mundane, futuristic, overly dark, simplistic, deformed"
85
- },
86
-
87
- {
88
- "name": "D&D Map",
89
- "prompt": "dungeons & dragons map artwork of {prompt}. intricate fantasy map, visable grid layout for gameplay guidance, ancient cartography style, labeled locations, landmarks, topographic textures, rich colors, immersive design",
90
- "negative_prompt": "modern maps, bland, plain, low detail, futuristic, chaotic, inaccurate grids, unlabeled, minimalist"
91
- },
92
-
93
- {
94
- "name": "3D Model",
95
- "prompt": "professional 3D model of {prompt}. stylized fantasy character, legendary creatures, intricate armor, magical weapons, dynamic poses, volumetric lighting, epic fantasy feel, octane render, highly detailed",
96
- "negative_prompt": "low poly, blurry, noisy, simplistic, overly realistic, mundane objects, low effort"
97
- },
98
-
99
- {
100
- "name": "(No style)",
101
- "prompt": "{prompt}",
102
- "negative_prompt": "",
103
- },
104
- ]
105
-
106
-
107
- styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in style_list}
108
- STYLE_NAMES = list(styles.keys())
109
- DEFAULT_STYLE_NAME = "(No style)"
110
-
111
- def apply_style(style_name: str, positive: str, negative: str = "") -> Tuple[str, str]:
112
- p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
113
- if not negative:
114
- negative = ""
115
- return p.replace("{prompt}", positive), n + negative
116
-
117
- def generate_image(style: str, positive_prompt: str):
118
- styled_prompt, styled_negative = apply_style(style, positive_prompt)
119
- result = model(
120
- inputs={
121
- "prompt": styled_prompt,
122
- "negative_prompt": styled_negative,
123
- }
124
- )
125
- return result
126
-
127
  # Enhanced D&D-themed CSS with previously used styles and new additions
128
  custom_css = """
129
  body {
@@ -244,13 +123,10 @@ button:hover {
244
  }
245
  """
246
 
247
- # Define Gradio interface
248
  iface = gr.Interface(
249
- fn=generate_image,
250
- inputs=[
251
- gr.Dropdown(label="🎨 Choose Style", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME),
252
- gr.Textbox(label="🎲 Enter Your Quest:", placeholder="Describe your scene, hero, or epic landscape..."),
253
- ],
254
  outputs=gr.Image(type="pil", label="🖼️ Your Legendary Vision"),
255
  title="🛡️ Dungeons & Dragons Image Generator ⚔️",
256
  description="**Unleash Your Imagination!** Create heroes, maps, quests, and epic scenes to bring your campaigns to life. "
 
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
  }
124
  """
125
 
126
+ # Define Gradio interface with enhanced description and external links
127
  iface = gr.Interface(
128
+ fn=model,
129
+ inputs=gr.Textbox(lines=3, label="🎲 Enter Your Quest:", placeholder="Describe your scene, hero, or epic landscape..."),
 
 
 
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. "