Commit
·
90c4804
1
Parent(s):
bd30617
css
Browse files
app.py
CHANGED
@@ -2,153 +2,147 @@ import gradio as gr
|
|
2 |
from PIL import Image
|
3 |
import time
|
4 |
|
5 |
-
#
|
6 |
-
|
7 |
-
|
8 |
-
#
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
"""Generates an image based on the prompt, handling potential errors."""
|
18 |
-
if model is None:
|
19 |
-
return "Error: Model could not be loaded. Please check the model ID and your network connection."
|
20 |
-
|
21 |
-
try:
|
22 |
-
image = model(prompt)
|
23 |
-
return image
|
24 |
-
except Exception as e:
|
25 |
-
return f"An error occurred during image generation: {e}"
|
26 |
-
|
27 |
-
|
28 |
-
# Custom CSS for a D&D theme
|
29 |
custom_css = """
|
30 |
@import url('https://fonts.googleapis.com/css2?family=MedievalSharp&display=swap');
|
31 |
|
32 |
-
/*
|
33 |
-
|
34 |
-
background
|
35 |
-
|
36 |
-
|
37 |
-
padding: 20px;
|
38 |
font-family: 'MedievalSharp', cursive;
|
|
|
|
|
39 |
}
|
40 |
|
41 |
-
.
|
42 |
-
color:
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
color: #ffd700;
|
51 |
-
font-size: 20px;
|
52 |
-
text-align: center;
|
53 |
-
margin-bottom: 20px;
|
54 |
}
|
55 |
|
56 |
-
/*
|
57 |
-
.
|
58 |
-
background-color: #
|
59 |
-
color: #
|
60 |
-
border:
|
61 |
border-radius: 8px;
|
62 |
-
padding: 12px;
|
63 |
font-size: 18px;
|
64 |
-
|
65 |
-
|
66 |
font-family: 'MedievalSharp', cursive;
|
67 |
-
overflow-y: auto; /* Add scrollbar for long text */
|
68 |
-
resize: vertical; /* Allow vertical resizing */
|
69 |
}
|
70 |
|
71 |
-
.
|
72 |
-
color: #
|
|
|
73 |
}
|
74 |
|
75 |
-
/*
|
76 |
-
.
|
77 |
-
background-color: #
|
78 |
color: #f5f5f5;
|
79 |
-
border:
|
80 |
border-radius: 8px;
|
81 |
-
padding: 12px
|
82 |
font-size: 18px;
|
83 |
-
|
84 |
-
|
85 |
-
width: 100%; /* Make button fill the container */
|
86 |
font-family: 'MedievalSharp', cursive;
|
87 |
}
|
88 |
|
89 |
-
.
|
90 |
-
|
91 |
}
|
92 |
|
93 |
-
/*
|
94 |
-
.
|
95 |
border: 4px solid #8b4513;
|
96 |
border-radius: 15px;
|
97 |
margin-top: 20px;
|
98 |
-
|
99 |
-
margin-left: auto;
|
100 |
-
margin-right: auto;
|
101 |
}
|
102 |
|
103 |
-
/*
|
104 |
-
.
|
105 |
-
text-align: center; /* Center the output label */
|
106 |
color: #ffd700;
|
107 |
-
font-size:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
}
|
109 |
|
110 |
/* Links */
|
111 |
-
.
|
112 |
color: #ffd700;
|
113 |
text-decoration: underline;
|
114 |
-
font-family: 'MedievalSharp', cursive;
|
115 |
font-size: 18px;
|
116 |
-
|
117 |
}
|
118 |
|
119 |
-
.
|
120 |
color: #ffa500;
|
121 |
-
font-family: 'MedievalSharp', cursive;
|
122 |
}
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
"""
|
125 |
|
126 |
-
# Gradio
|
127 |
iface = gr.Interface(
|
128 |
-
fn=
|
129 |
inputs=gr.Textbox(
|
130 |
-
lines=
|
131 |
-
label="📜
|
132 |
-
placeholder="
|
133 |
-
css=".dnd-input" # Apply custom CSS to the input
|
134 |
-
),
|
135 |
-
outputs=gr.Image(
|
136 |
-
type="pil",
|
137 |
-
label="🖼️ Your Legendary Vision",
|
138 |
-
css=".dnd-output" # Apply custom CSS to the output
|
139 |
),
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
[Visit Our Website](https://chatdnd.net) | [Support Us](https://buymeacoffee.com/watchoutformike)
|
146 |
-
""",
|
147 |
css=custom_css,
|
148 |
-
|
149 |
-
|
150 |
)
|
151 |
|
152 |
# Launch the interface
|
153 |
iface.launch()
|
154 |
-
|
|
|
2 |
from PIL import Image
|
3 |
import time
|
4 |
|
5 |
+
# Load the model from Hugging Face
|
6 |
+
model = gr.load("models/prashanth970/flux-lora-uncensored")
|
7 |
+
|
8 |
+
# Define Gradio interface with a loading animation
|
9 |
+
def model_with_loading(prompt):
|
10 |
+
# Simulate a loading animation for immersion
|
11 |
+
print("✨ Summoning the arcane energies to manifest your vision... ✨")
|
12 |
+
time.sleep(2) # Simulate processing time
|
13 |
+
result = model(prompt)
|
14 |
+
return result
|
15 |
+
|
16 |
+
# Custom CSS for D&D theme
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
custom_css = """
|
18 |
@import url('https://fonts.googleapis.com/css2?family=MedievalSharp&display=swap');
|
19 |
|
20 |
+
/* Global Styles */
|
21 |
+
body {
|
22 |
+
background: url('https://i.imgur.com/1Q3xL9m.jpg') no-repeat center center fixed; /* Faux parchment texture */
|
23 |
+
background-size: cover;
|
24 |
+
color: #f5f5f5;
|
|
|
25 |
font-family: 'MedievalSharp', cursive;
|
26 |
+
margin: 0;
|
27 |
+
padding: 0;
|
28 |
}
|
29 |
|
30 |
+
.gradio-container {
|
31 |
+
background-color: rgba(0, 0, 0, 0.8);
|
32 |
+
border-radius: 15px;
|
33 |
+
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
|
34 |
+
padding: 20px;
|
35 |
+
max-width: 800px;
|
36 |
+
margin: 0 auto;
|
37 |
+
margin-top: 50px;
|
38 |
+
border: 4px solid #8b4513;
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
|
41 |
+
/* Buttons */
|
42 |
+
.gr-button {
|
43 |
+
background-color: #8b4513;
|
44 |
+
color: #f5f5f5;
|
45 |
+
border: none;
|
46 |
border-radius: 8px;
|
47 |
+
padding: 12px 24px;
|
48 |
font-size: 18px;
|
49 |
+
cursor: pointer;
|
50 |
+
transition: background-color 0.3s, transform 0.3s;
|
51 |
font-family: 'MedievalSharp', cursive;
|
|
|
|
|
52 |
}
|
53 |
|
54 |
+
.gr-button:hover {
|
55 |
+
background-color: #a0522d;
|
56 |
+
transform: scale(1.05);
|
57 |
}
|
58 |
|
59 |
+
/* Textbox */
|
60 |
+
.gr-textbox {
|
61 |
+
background-color: #3c3c3c;
|
62 |
color: #f5f5f5;
|
63 |
+
border: 2px solid #8b4513;
|
64 |
border-radius: 8px;
|
65 |
+
padding: 12px;
|
66 |
font-size: 18px;
|
67 |
+
width: 100%;
|
68 |
+
box-sizing: border-box;
|
|
|
69 |
font-family: 'MedievalSharp', cursive;
|
70 |
}
|
71 |
|
72 |
+
.gr-textbox::placeholder {
|
73 |
+
color: #d3d3d3;
|
74 |
}
|
75 |
|
76 |
+
/* Image Outputs */
|
77 |
+
.gr-image {
|
78 |
border: 4px solid #8b4513;
|
79 |
border-radius: 15px;
|
80 |
margin-top: 20px;
|
81 |
+
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
|
|
|
|
|
82 |
}
|
83 |
|
84 |
+
/* Titles and Headings */
|
85 |
+
.gr-title {
|
|
|
86 |
color: #ffd700;
|
87 |
+
font-size: 36px;
|
88 |
+
font-weight: bold;
|
89 |
+
text-align: center;
|
90 |
+
margin-bottom: 20px;
|
91 |
+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
|
92 |
+
}
|
93 |
+
|
94 |
+
.gr-description {
|
95 |
+
color: #ffd700;
|
96 |
+
font-size: 20px;
|
97 |
+
text-align: center;
|
98 |
+
margin-bottom: 20px;
|
99 |
+
font-family: 'MedievalSharp', cursive;
|
100 |
}
|
101 |
|
102 |
/* Links */
|
103 |
+
.gr-link {
|
104 |
color: #ffd700;
|
105 |
text-decoration: underline;
|
|
|
106 |
font-size: 18px;
|
107 |
+
font-family: 'MedievalSharp', cursive;
|
108 |
}
|
109 |
|
110 |
+
.gr-link:hover {
|
111 |
color: #ffa500;
|
|
|
112 |
}
|
113 |
|
114 |
+
/* Loading Animation */
|
115 |
+
.loading-message {
|
116 |
+
color: #ffd700;
|
117 |
+
font-size: 18px;
|
118 |
+
text-align: center;
|
119 |
+
margin-top: 20px;
|
120 |
+
font-family: 'MedievalSharp', cursive;
|
121 |
+
animation: flicker 1.5s infinite alternate;
|
122 |
+
}
|
123 |
+
|
124 |
+
@keyframes flicker {
|
125 |
+
0% { opacity: 1; }
|
126 |
+
100% { opacity: 0.8; }
|
127 |
+
}
|
128 |
"""
|
129 |
|
130 |
+
# Define Gradio interface
|
131 |
iface = gr.Interface(
|
132 |
+
fn=model_with_loading,
|
133 |
inputs=gr.Textbox(
|
134 |
+
lines=5,
|
135 |
+
label="📜 Describe Your Adventure:",
|
136 |
+
placeholder="E.g., 'A dragon perched upon a mountain of gold, surrounded by mist and fire.'",
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
),
|
138 |
+
outputs=gr.Image(type="pil", label="✨ The Arcane Vision Appears ✨"),
|
139 |
+
title="⚔️ Dungeons & Dragons Artificer ⚔️",
|
140 |
+
description="**Conjure Your Imagination Into Reality!** Summon legendary heroes, create epic landscapes, or design fantastical creatures for your campaigns. Perfect for adventurers and Dungeon Masters alike. <br>"
|
141 |
+
"[Explore Our Lore](https://chatdnd.net) | [Support the Guild](https://buymeacoffee.com/watchoutformike)",
|
|
|
|
|
|
|
142 |
css=custom_css,
|
143 |
+
live=False,
|
144 |
+
allow_flagging="never" # Disable flagging for simpler use
|
145 |
)
|
146 |
|
147 |
# Launch the interface
|
148 |
iface.launch()
|
|