Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
import random
|
3 |
|
4 |
-
# Load the model
|
5 |
model = gr.load("models/Purz/face-projection")
|
6 |
|
7 |
def generate_image(text, seed):
|
8 |
if seed is not None:
|
9 |
random.seed(seed)
|
10 |
-
|
11 |
-
if text in [example[0] for example in examples]:
|
12 |
-
print(f"Using example: {text}")
|
13 |
-
|
14 |
return model(text)
|
15 |
|
16 |
-
# Examples for user guidance
|
17 |
examples = [
|
18 |
["Humanoid Cat Warrior, Full View", None],
|
19 |
["Warhammer Sisterhood", None],
|
@@ -21,58 +15,64 @@ examples = [
|
|
21 |
["Fantasy dragon", None]
|
22 |
]
|
23 |
|
24 |
-
# Custom CSS for
|
25 |
-
|
26 |
-
/*
|
27 |
-
|
28 |
-
border
|
29 |
-
|
30 |
-
font-size: 16px;
|
31 |
-
font-weight: bold;
|
32 |
-
color: white;
|
33 |
-
background: linear-gradient(135deg, #6D5BBA, #8A2387); /* Gradient color */
|
34 |
-
border: none;
|
35 |
-
cursor: pointer;
|
36 |
-
transition: background 0.3s ease;
|
37 |
}
|
38 |
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
|
43 |
-
/*
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
}
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
padding:
|
|
|
53 |
}
|
54 |
|
55 |
-
/*
|
56 |
-
.
|
57 |
-
|
58 |
-
|
59 |
-
padding: 10px;
|
60 |
-
background-color: #f9f9f9;
|
61 |
}
|
62 |
"""
|
63 |
|
64 |
-
#
|
|
|
|
|
|
|
|
|
65 |
interface = gr.Interface(
|
66 |
fn=generate_image,
|
67 |
inputs=[
|
68 |
-
gr.Textbox(label="
|
69 |
gr.Slider(minimum=0, maximum=10000, step=1, label="Seed (optional)")
|
70 |
],
|
71 |
-
outputs=gr.Image(label="Generated Image"),
|
72 |
examples=examples,
|
73 |
-
css=
|
74 |
-
description="
|
|
|
75 |
)
|
76 |
|
77 |
-
# Launch the interface
|
78 |
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import random
|
3 |
|
|
|
4 |
model = gr.load("models/Purz/face-projection")
|
5 |
|
6 |
def generate_image(text, seed):
|
7 |
if seed is not None:
|
8 |
random.seed(seed)
|
|
|
|
|
|
|
|
|
9 |
return model(text)
|
10 |
|
|
|
11 |
examples = [
|
12 |
["Humanoid Cat Warrior, Full View", None],
|
13 |
["Warhammer Sisterhood", None],
|
|
|
15 |
["Fantasy dragon", None]
|
16 |
]
|
17 |
|
18 |
+
# Custom CSS for minimalist style, horizontal example layout, and styled prompt box
|
19 |
+
custom_css = """
|
20 |
+
/* Remove border and background color for the output image preview */
|
21 |
+
.output-image {
|
22 |
+
border: none !important;
|
23 |
+
background: none !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
+
/* Prompt textbox styling */
|
27 |
+
input[type="text"] {
|
28 |
+
border: 2px solid #ddd;
|
29 |
+
border-radius: 8px;
|
30 |
+
padding: 12px;
|
31 |
+
font-size: 16px;
|
32 |
+
width: 100%;
|
33 |
+
background-color: #f9f9f9;
|
34 |
}
|
35 |
|
36 |
+
/* Examples arranged in a single line, without buttons */
|
37 |
+
.gr-examples {
|
38 |
+
display: flex;
|
39 |
+
flex-direction: row;
|
40 |
+
justify-content: space-evenly;
|
41 |
+
gap: 10px;
|
42 |
+
margin-top: 10px;
|
43 |
}
|
44 |
|
45 |
+
.gr-examples span {
|
46 |
+
font-size: 14px;
|
47 |
+
color: #333;
|
48 |
+
cursor: pointer;
|
49 |
+
padding: 5px;
|
50 |
+
transition: all 0.2s ease;
|
51 |
}
|
52 |
|
53 |
+
/* Hover effect on examples */
|
54 |
+
.gr-examples span:hover {
|
55 |
+
color: #007bff;
|
56 |
+
text-decoration: underline;
|
|
|
|
|
57 |
}
|
58 |
"""
|
59 |
|
60 |
+
# Function to handle example clicks (to simulate button-less selection)
|
61 |
+
def update_prompt_text(example_text):
|
62 |
+
return example_text, None
|
63 |
+
|
64 |
+
# Gradio Interface with updated UI elements and custom CSS
|
65 |
interface = gr.Interface(
|
66 |
fn=generate_image,
|
67 |
inputs=[
|
68 |
+
gr.Textbox(label="Imagine anything:", placeholder="Describe the scene...", interactive=True),
|
69 |
gr.Slider(minimum=0, maximum=10000, step=1, label="Seed (optional)")
|
70 |
],
|
71 |
+
outputs=gr.Image(label="Generated Image", type="pil"),
|
72 |
examples=examples,
|
73 |
+
css=custom_css, # Apply custom CSS
|
74 |
+
description="Enter a creative prompt or choose an example to generate your AI-powered image. Model performance may vary due to CPU usage.",
|
75 |
+
live=True
|
76 |
)
|
77 |
|
|
|
78 |
interface.launch()
|