Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -48,78 +48,42 @@ def check_password(password):
|
|
48 |
return password == "pixo"
|
49 |
|
50 |
css = '''
|
51 |
-
#top{position: fixed; right: 20px; top: 20px; max-width: 300px; z-index: 1000;}
|
52 |
-
|
53 |
body {
|
54 |
font-family: 'Roboto', sans-serif;
|
55 |
-
background:
|
56 |
-
color: #
|
57 |
-
transition: background-color 0.3s, color 0.3s;
|
58 |
}
|
59 |
-
|
60 |
.container {
|
61 |
-
background-color:
|
62 |
-
|
63 |
-
|
64 |
-
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
|
65 |
padding: 20px;
|
66 |
margin-bottom: 20px;
|
67 |
}
|
68 |
-
|
69 |
.gradio-slider input[type="range"] {
|
70 |
-
accent-color: #
|
71 |
}
|
72 |
-
|
73 |
.gradio-button {
|
74 |
-
background-color: #
|
75 |
color: white;
|
76 |
border: none;
|
77 |
padding: 10px 20px;
|
78 |
border-radius: 5px;
|
79 |
cursor: pointer;
|
80 |
-
transition: background-color 0.3s
|
81 |
-
font-weight: bold;
|
82 |
}
|
83 |
-
|
84 |
.gradio-button:hover {
|
85 |
-
background-color: #
|
86 |
-
transform: translateY(-2px);
|
87 |
}
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
padding: 10px;
|
94 |
-
margin-bottom: 10px;
|
95 |
-
}
|
96 |
-
|
97 |
-
h1, h2, h3 {
|
98 |
-
color: #701a75;
|
99 |
-
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
|
100 |
}
|
101 |
-
|
102 |
-
@media (prefers-color-scheme: dark) {
|
103 |
-
body {
|
104 |
-
background: linear-gradient(135deg, #3b0764, #581c87);
|
105 |
-
color: #e9d5ff;
|
106 |
-
}
|
107 |
-
|
108 |
.container {
|
109 |
-
|
110 |
-
}
|
111 |
-
|
112 |
-
h1, h2, h3 {
|
113 |
-
color: #d8b4fe;
|
114 |
-
}
|
115 |
-
|
116 |
-
.gradio-button {
|
117 |
-
background-color: #d946ef;
|
118 |
-
color: #1a1a1a;
|
119 |
-
}
|
120 |
-
|
121 |
-
.gradio-button:hover {
|
122 |
-
background-color: #e879f9;
|
123 |
}
|
124 |
}
|
125 |
'''
|
@@ -134,94 +98,46 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
134 |
with gr.Column(visible=False) as main_interface:
|
135 |
gr.Markdown("## 🎨 Demo for expression-editor cog image by fofr")
|
136 |
with gr.Row():
|
137 |
-
with gr.Column(scale=
|
138 |
image = gr.Image(
|
139 |
label="Input image",
|
140 |
type="filepath",
|
141 |
-
height=
|
142 |
)
|
143 |
with gr.Row():
|
144 |
-
rotate_pitch = gr.Slider(
|
145 |
-
|
146 |
-
value=0,
|
147 |
-
minimum=-20, maximum=20
|
148 |
-
)
|
149 |
-
rotate_yaw = gr.Slider(
|
150 |
-
label="Rotate Left-Right turn",
|
151 |
-
value=0,
|
152 |
-
minimum=-20, maximum=20
|
153 |
-
)
|
154 |
-
rotate_roll = gr.Slider(
|
155 |
-
label="Rotate Left-Right tilt", value=0,
|
156 |
-
minimum=-20, maximum=20
|
157 |
-
)
|
158 |
with gr.Row():
|
159 |
-
|
160 |
-
|
161 |
-
minimum=-20, maximum=5
|
162 |
-
)
|
163 |
-
eyebrow = gr.Slider(
|
164 |
-
label="Eyebrow", value=0,
|
165 |
-
minimum=-10, maximum=15
|
166 |
-
)
|
167 |
-
wink = gr.Slider(
|
168 |
-
label="Wink", value=0,
|
169 |
-
minimum=0, maximum=25
|
170 |
-
)
|
171 |
with gr.Row():
|
172 |
-
|
173 |
-
|
174 |
-
minimum=-15, maximum=15
|
175 |
-
)
|
176 |
-
pupil_y = gr.Slider(
|
177 |
-
label="Pupil Y", value=0,
|
178 |
-
minimum=-15, maximum=15
|
179 |
-
)
|
180 |
with gr.Row():
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
)
|
185 |
-
eee = gr.Slider(
|
186 |
-
|
187 |
-
|
188 |
-
)
|
189 |
-
woo = gr.Slider(
|
190 |
-
label="Woo", value=0,
|
191 |
-
minimum=-20, maximum=15
|
192 |
-
)
|
193 |
-
smile = gr.Slider(
|
194 |
-
label="Smile", value=0,
|
195 |
-
minimum=-0.3, maximum=1.3
|
196 |
-
)
|
197 |
with gr.Accordion("More Settings", open=False):
|
198 |
-
src_ratio = gr.Number(
|
199 |
-
|
200 |
-
)
|
201 |
-
|
202 |
-
|
203 |
-
minimum=-0.2, maximum=1.2
|
204 |
-
)
|
205 |
-
crop_factor = gr.Slider(
|
206 |
-
label="Crop Factor", info='''Crop factor''', value=1.7,
|
207 |
-
minimum=1.5, maximum=2.5
|
208 |
-
)
|
209 |
-
output_format = gr.Dropdown(
|
210 |
-
choices=['webp', 'jpg', 'png'], label="output_format", info='''Format of the output images''', value="webp"
|
211 |
-
)
|
212 |
-
output_quality = gr.Number(
|
213 |
-
label="Output Quality", info='''Quality of the output images, from 0 to 100. 100 is best quality, 0 is lowest quality.''', value=95
|
214 |
-
)
|
215 |
submit_btn = gr.Button("Generate", variant="primary")
|
|
|
216 |
with gr.Column(scale=1):
|
217 |
-
result_image = gr.Image(
|
218 |
gr.HTML("""
|
219 |
-
<div style="
|
220 |
-
<
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
</p>
|
225 |
</div>
|
226 |
""")
|
227 |
|
|
|
48 |
return password == "pixo"
|
49 |
|
50 |
css = '''
|
|
|
|
|
51 |
body {
|
52 |
font-family: 'Roboto', sans-serif;
|
53 |
+
background-color: #f0f0f0;
|
54 |
+
color: #333;
|
|
|
55 |
}
|
|
|
56 |
.container {
|
57 |
+
background-color: white;
|
58 |
+
border-radius: 10px;
|
59 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
|
60 |
padding: 20px;
|
61 |
margin-bottom: 20px;
|
62 |
}
|
|
|
63 |
.gradio-slider input[type="range"] {
|
64 |
+
accent-color: #6200ea;
|
65 |
}
|
|
|
66 |
.gradio-button {
|
67 |
+
background-color: #6200ea;
|
68 |
color: white;
|
69 |
border: none;
|
70 |
padding: 10px 20px;
|
71 |
border-radius: 5px;
|
72 |
cursor: pointer;
|
73 |
+
transition: background-color 0.3s;
|
|
|
74 |
}
|
|
|
75 |
.gradio-button:hover {
|
76 |
+
background-color: #3700b3;
|
|
|
77 |
}
|
78 |
+
.result-image {
|
79 |
+
width: 100%;
|
80 |
+
max-width: 512px;
|
81 |
+
margin: 0 auto;
|
82 |
+
display: block;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
}
|
84 |
+
@media (max-width: 768px) {
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
.container {
|
86 |
+
padding: 10px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
}
|
89 |
'''
|
|
|
98 |
with gr.Column(visible=False) as main_interface:
|
99 |
gr.Markdown("## 🎨 Demo for expression-editor cog image by fofr")
|
100 |
with gr.Row():
|
101 |
+
with gr.Column(scale=1, elem_classes="container"):
|
102 |
image = gr.Image(
|
103 |
label="Input image",
|
104 |
type="filepath",
|
105 |
+
height=256
|
106 |
)
|
107 |
with gr.Row():
|
108 |
+
rotate_pitch = gr.Slider(label="Rotate Up-Down", value=0, minimum=-20, maximum=20)
|
109 |
+
rotate_yaw = gr.Slider(label="Rotate Left-Right turn", value=0, minimum=-20, maximum=20)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
with gr.Row():
|
111 |
+
rotate_roll = gr.Slider(label="Rotate Left-Right tilt", value=0, minimum=-20, maximum=20)
|
112 |
+
blink = gr.Slider(label="Blink", value=0, minimum=-20, maximum=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
with gr.Row():
|
114 |
+
eyebrow = gr.Slider(label="Eyebrow", value=0, minimum=-10, maximum=15)
|
115 |
+
wink = gr.Slider(label="Wink", value=0, minimum=0, maximum=25)
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
with gr.Row():
|
117 |
+
pupil_x = gr.Slider(label="Pupil X", value=0, minimum=-15, maximum=15)
|
118 |
+
pupil_y = gr.Slider(label="Pupil Y", value=0, minimum=-15, maximum=15)
|
119 |
+
with gr.Row():
|
120 |
+
aaa = gr.Slider(label="Aaa", value=0, minimum=-30, maximum=120)
|
121 |
+
eee = gr.Slider(label="Eee", value=0, minimum=-20, maximum=15)
|
122 |
+
with gr.Row():
|
123 |
+
woo = gr.Slider(label="Woo", value=0, minimum=-20, maximum=15)
|
124 |
+
smile = gr.Slider(label="Smile", value=0, minimum=-0.3, maximum=1.3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
with gr.Accordion("More Settings", open=False):
|
126 |
+
src_ratio = gr.Number(label="Src Ratio", info='Source ratio', value=1)
|
127 |
+
sample_ratio = gr.Slider(label="Sample Ratio", info='Sample ratio', value=1, minimum=-0.2, maximum=1.2)
|
128 |
+
crop_factor = gr.Slider(label="Crop Factor", info='Crop factor', value=1.7, minimum=1.5, maximum=2.5)
|
129 |
+
output_format = gr.Dropdown(choices=['webp', 'jpg', 'png'], label="Output Format", info='Format of the output images', value="webp")
|
130 |
+
output_quality = gr.Number(label="Output Quality", info='Quality of the output images, from 0 to 100. 100 is best quality, 0 is lowest quality.', value=95)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
submit_btn = gr.Button("Generate", variant="primary")
|
132 |
+
|
133 |
with gr.Column(scale=1):
|
134 |
+
result_image = gr.Image(elem_classes="result-image", label="Generated Image")
|
135 |
gr.HTML("""
|
136 |
+
<div style="text-align: center; margin-top: 20px;">
|
137 |
+
<a href="https://huggingface.co/spaces/fffiloni/expression-editor?duplicate=true">
|
138 |
+
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-md.svg" alt="Duplicate this Space">
|
139 |
+
</a>
|
140 |
+
<p>Skip the queue and enjoy faster inference on the GPU of your choice</p>
|
|
|
141 |
</div>
|
142 |
""")
|
143 |
|