Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,191 +59,373 @@ examples = [
|
|
| 59 |
]
|
| 60 |
|
| 61 |
css = """
|
| 62 |
-
/*
|
| 63 |
-
body {
|
| 64 |
-
background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
|
| 65 |
-
font-family: 'Poppins', sans-serif;
|
| 66 |
-
color: #f5f5f5;
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
#col-container {
|
| 70 |
-
margin:
|
| 71 |
-
max-width:
|
| 72 |
padding: 20px;
|
| 73 |
-
background:
|
| 74 |
border-radius: 20px;
|
| 75 |
-
box-shadow: 0
|
|
|
|
| 76 |
}
|
| 77 |
|
| 78 |
-
/*
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
text-align: center;
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
}
|
| 84 |
|
| 85 |
-
/*
|
| 86 |
-
input
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
border:
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
| 93 |
transition: all 0.3s ease;
|
|
|
|
| 94 |
}
|
| 95 |
|
| 96 |
-
input
|
| 97 |
-
|
| 98 |
-
|
| 99 |
outline: none;
|
|
|
|
|
|
|
|
|
|
| 100 |
}
|
| 101 |
|
| 102 |
-
/*
|
| 103 |
-
|
| 104 |
-
background: linear-gradient(
|
| 105 |
-
color: #000;
|
| 106 |
border: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
border-radius: 15px;
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
cursor: pointer;
|
| 112 |
transition: all 0.3s ease;
|
| 113 |
-
|
|
|
|
| 114 |
}
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
}
|
| 120 |
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
border-radius: 20px;
|
| 124 |
-
border: 3px solid #00ffff;
|
| 125 |
-
box-shadow: 0 0 30px rgba(0, 255, 255, 0.4);
|
| 126 |
-
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
| 127 |
}
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
}
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
}
|
| 138 |
|
| 139 |
-
.
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
padding: 10px;
|
| 143 |
-
margin-top: 15px;
|
| 144 |
}
|
| 145 |
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
}
|
| 151 |
|
| 152 |
-
/*
|
| 153 |
-
.
|
| 154 |
-
background: rgba(
|
| 155 |
border-radius: 15px;
|
| 156 |
-
padding:
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
}
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
transition: all 0.3s ease;
|
| 164 |
}
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
}
|
| 169 |
|
| 170 |
-
/*
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
}
|
| 174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
"""
|
| 176 |
|
| 177 |
-
with gr.Blocks(css=css) as demo:
|
| 178 |
with gr.Column(elem_id="col-container"):
|
| 179 |
-
gr.Markdown("
|
| 180 |
|
| 181 |
with gr.Row():
|
| 182 |
prompt = gr.Text(
|
| 183 |
-
label="Prompt",
|
| 184 |
-
show_label=
|
| 185 |
max_lines=1,
|
| 186 |
-
placeholder="
|
| 187 |
-
container=
|
|
|
|
| 188 |
)
|
| 189 |
|
| 190 |
-
run_button = gr.Button("
|
| 191 |
|
| 192 |
-
result = gr.Image(label="
|
| 193 |
|
| 194 |
-
with gr.Accordion("Advanced Settings", open=False):
|
| 195 |
negative_prompt = gr.Text(
|
| 196 |
-
label="Negative
|
| 197 |
max_lines=1,
|
| 198 |
-
placeholder="
|
| 199 |
-
visible=
|
| 200 |
)
|
| 201 |
|
| 202 |
seed = gr.Slider(
|
| 203 |
-
label="Seed",
|
| 204 |
minimum=0,
|
| 205 |
maximum=MAX_SEED,
|
| 206 |
step=1,
|
| 207 |
value=0,
|
| 208 |
)
|
| 209 |
|
| 210 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 211 |
|
| 212 |
with gr.Row():
|
| 213 |
width = gr.Slider(
|
| 214 |
-
label="Width",
|
| 215 |
minimum=256,
|
| 216 |
maximum=MAX_IMAGE_SIZE,
|
| 217 |
step=32,
|
| 218 |
-
value=1024,
|
| 219 |
)
|
| 220 |
|
| 221 |
height = gr.Slider(
|
| 222 |
-
label="Height",
|
| 223 |
minimum=256,
|
| 224 |
maximum=MAX_IMAGE_SIZE,
|
| 225 |
step=32,
|
| 226 |
-
value=1024,
|
| 227 |
)
|
| 228 |
|
| 229 |
with gr.Row():
|
| 230 |
guidance_scale = gr.Slider(
|
| 231 |
-
label="Guidance
|
| 232 |
minimum=0.0,
|
| 233 |
maximum=10.0,
|
| 234 |
step=0.1,
|
| 235 |
-
value=
|
| 236 |
)
|
| 237 |
|
| 238 |
num_inference_steps = gr.Slider(
|
| 239 |
-
label="
|
| 240 |
minimum=1,
|
| 241 |
maximum=50,
|
| 242 |
step=1,
|
| 243 |
-
value=
|
| 244 |
)
|
| 245 |
|
| 246 |
-
gr.Examples(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
gr.on(
|
| 248 |
triggers=[run_button.click, prompt.submit],
|
| 249 |
fn=infer,
|
|
@@ -261,4 +443,4 @@ with gr.Blocks(css=css) as demo:
|
|
| 261 |
)
|
| 262 |
|
| 263 |
if __name__ == "__main__":
|
| 264 |
-
demo.launch()
|
|
|
|
| 59 |
]
|
| 60 |
|
| 61 |
css = """
|
| 62 |
+
/* Main container styling */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
#col-container {
|
| 64 |
+
margin: 0 auto;
|
| 65 |
+
max-width: 900px;
|
| 66 |
padding: 20px;
|
| 67 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 68 |
border-radius: 20px;
|
| 69 |
+
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
|
| 70 |
+
backdrop-filter: blur(10px);
|
| 71 |
}
|
| 72 |
|
| 73 |
+
/* Global styling */
|
| 74 |
+
.gradio-container {
|
| 75 |
+
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
| 76 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
| 77 |
+
min-height: 100vh;
|
| 78 |
+
padding: 20px;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/* Title styling */
|
| 82 |
+
.gradio-container h1 {
|
| 83 |
text-align: center;
|
| 84 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 85 |
+
-webkit-background-clip: text;
|
| 86 |
+
-webkit-text-fill-color: transparent;
|
| 87 |
+
background-clip: text;
|
| 88 |
+
font-size: 2.5rem;
|
| 89 |
+
font-weight: 800;
|
| 90 |
+
margin-bottom: 30px;
|
| 91 |
+
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
| 92 |
}
|
| 93 |
|
| 94 |
+
/* Input field styling */
|
| 95 |
+
.gradio-container .gradio-textbox input,
|
| 96 |
+
.gradio-container .gradio-textbox textarea {
|
| 97 |
+
border: 2px solid transparent;
|
| 98 |
+
border-radius: 12px;
|
| 99 |
+
background: rgba(255, 255, 255, 0.9);
|
| 100 |
+
backdrop-filter: blur(10px);
|
| 101 |
+
padding: 15px 20px;
|
| 102 |
+
font-size: 16px;
|
| 103 |
transition: all 0.3s ease;
|
| 104 |
+
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
|
| 105 |
}
|
| 106 |
|
| 107 |
+
.gradio-container .gradio-textbox input:focus,
|
| 108 |
+
.gradio-container .gradio-textbox textarea:focus {
|
| 109 |
+
border: 2px solid #667eea;
|
| 110 |
outline: none;
|
| 111 |
+
background: rgba(255, 255, 255, 1);
|
| 112 |
+
transform: translateY(-2px);
|
| 113 |
+
box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
|
| 114 |
}
|
| 115 |
|
| 116 |
+
/* Button styling */
|
| 117 |
+
.gradio-container button {
|
| 118 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
|
|
| 119 |
border: none;
|
| 120 |
+
border-radius: 12px;
|
| 121 |
+
color: white;
|
| 122 |
+
font-weight: 600;
|
| 123 |
+
font-size: 16px;
|
| 124 |
+
padding: 15px 30px;
|
| 125 |
+
cursor: pointer;
|
| 126 |
+
transition: all 0.3s ease;
|
| 127 |
+
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
|
| 128 |
+
text-transform: uppercase;
|
| 129 |
+
letter-spacing: 1px;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
.gradio-container button:hover {
|
| 133 |
+
transform: translateY(-3px);
|
| 134 |
+
box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
|
| 135 |
+
background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.gradio-container button:active {
|
| 139 |
+
transform: translateY(-1px);
|
| 140 |
+
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
/* Image result container */
|
| 144 |
+
.gradio-container .gradio-image {
|
| 145 |
+
border-radius: 15px;
|
| 146 |
+
overflow: hidden;
|
| 147 |
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
|
| 148 |
+
background: rgba(255, 255, 255, 0.9);
|
| 149 |
+
backdrop-filter: blur(10px);
|
| 150 |
+
border: 2px solid rgba(255, 255, 255, 0.3);
|
| 151 |
+
margin: 20px 0;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/* Accordion styling */
|
| 155 |
+
.gradio-container .gradio-accordion {
|
| 156 |
+
background: rgba(255, 255, 255, 0.1);
|
| 157 |
border-radius: 15px;
|
| 158 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 159 |
+
backdrop-filter: blur(10px);
|
| 160 |
+
margin: 20px 0;
|
| 161 |
+
overflow: hidden;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
.gradio-container .gradio-accordion summary {
|
| 165 |
+
background: rgba(255, 255, 255, 0.2);
|
| 166 |
+
padding: 15px 20px;
|
| 167 |
+
font-weight: 600;
|
| 168 |
cursor: pointer;
|
| 169 |
transition: all 0.3s ease;
|
| 170 |
+
border: none;
|
| 171 |
+
color: #2d3748;
|
| 172 |
}
|
| 173 |
|
| 174 |
+
.gradio-container .gradio-accordion[open] summary {
|
| 175 |
+
background: rgba(255, 255, 255, 0.3);
|
| 176 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
| 177 |
}
|
| 178 |
|
| 179 |
+
.gradio-container .gradio-accordion details {
|
| 180 |
+
border: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
}
|
| 182 |
|
| 183 |
+
/* Slider styling */
|
| 184 |
+
.gradio-container .gradio-slider input[type="range"] {
|
| 185 |
+
-webkit-appearance: none;
|
| 186 |
+
appearance: none;
|
| 187 |
+
height: 6px;
|
| 188 |
+
border-radius: 3px;
|
| 189 |
+
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
|
| 190 |
+
outline: none;
|
| 191 |
+
cursor: pointer;
|
| 192 |
}
|
| 193 |
|
| 194 |
+
.gradio-container .gradio-slider input[type="range"]::-webkit-slider-thumb {
|
| 195 |
+
-webkit-appearance: none;
|
| 196 |
+
appearance: none;
|
| 197 |
+
width: 20px;
|
| 198 |
+
height: 20px;
|
| 199 |
+
border-radius: 50%;
|
| 200 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 201 |
+
cursor: pointer;
|
| 202 |
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
|
| 203 |
+
transition: all 0.3s ease;
|
| 204 |
}
|
| 205 |
|
| 206 |
+
.gradio-container .gradio-slider input[type="range"]::-webkit-slider-thumb:hover {
|
| 207 |
+
transform: scale(1.2);
|
| 208 |
+
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
|
|
|
|
|
|
|
| 209 |
}
|
| 210 |
|
| 211 |
+
/* Checkbox styling */
|
| 212 |
+
.gradio-container .gradio-checkbox input[type="checkbox"] {
|
| 213 |
+
width: 20px;
|
| 214 |
+
height: 20px;
|
| 215 |
+
border-radius: 4px;
|
| 216 |
+
border: 2px solid #667eea;
|
| 217 |
+
background: rgba(255, 255, 255, 0.9);
|
| 218 |
cursor: pointer;
|
| 219 |
+
transition: all 0.3s ease;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
.gradio-container .gradio-checkbox input[type="checkbox"]:checked {
|
| 223 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 224 |
+
border-color: #764ba2;
|
| 225 |
}
|
| 226 |
|
| 227 |
+
/* Examples section */
|
| 228 |
+
.gradio-container .gradio-examples {
|
| 229 |
+
background: rgba(255, 255, 255, 0.1);
|
| 230 |
border-radius: 15px;
|
| 231 |
+
padding: 20px;
|
| 232 |
+
margin: 20px 0;
|
| 233 |
+
backdrop-filter: blur(10px);
|
| 234 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
.gradio-container .gradio-examples .gradio-examples-list {
|
| 238 |
+
display: grid;
|
| 239 |
+
gap: 10px;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
.gradio-container .gradio-examples button {
|
| 243 |
+
background: rgba(255, 255, 255, 0.2);
|
| 244 |
+
border: 1px solid rgba(255, 255, 255, 0.3);
|
| 245 |
+
color: #2d3748;
|
| 246 |
+
font-weight: 500;
|
| 247 |
+
text-transform: none;
|
| 248 |
+
letter-spacing: 0;
|
| 249 |
+
padding: 12px 18px;
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
.gradio-container .gradio-examples button:hover {
|
| 253 |
+
background: rgba(255, 255, 255, 0.3);
|
| 254 |
+
transform: translateY(-1px);
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
/* Labels */
|
| 258 |
+
.gradio-container label {
|
| 259 |
+
font-weight: 600;
|
| 260 |
+
color: #2d3748;
|
| 261 |
+
margin-bottom: 8px;
|
| 262 |
+
display: block;
|
| 263 |
+
text-transform: uppercase;
|
| 264 |
+
letter-spacing: 0.5px;
|
| 265 |
+
font-size: 14px;
|
| 266 |
}
|
| 267 |
+
|
| 268 |
+
/* Row layout improvements */
|
| 269 |
+
.gradio-container .gradio-row {
|
| 270 |
+
gap: 20px;
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
/* Progress bar styling */
|
| 274 |
+
.gradio-container .gradio-progress {
|
| 275 |
+
border-radius: 10px;
|
| 276 |
+
overflow: hidden;
|
| 277 |
+
background: rgba(255, 255, 255, 0.2);
|
| 278 |
+
backdrop-filter: blur(10px);
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
.gradio-container .gradio-progress-bar {
|
| 282 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 283 |
transition: all 0.3s ease;
|
| 284 |
}
|
| 285 |
+
|
| 286 |
+
/* Responsive design */
|
| 287 |
+
@media (max-width: 768px) {
|
| 288 |
+
#col-container {
|
| 289 |
+
max-width: 95%;
|
| 290 |
+
padding: 15px;
|
| 291 |
+
margin: 10px auto;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
.gradio-container h1 {
|
| 295 |
+
font-size: 2rem;
|
| 296 |
+
margin-bottom: 20px;
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
.gradio-container .gradio-row {
|
| 300 |
+
flex-direction: column;
|
| 301 |
+
gap: 15px;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
.gradio-container button {
|
| 305 |
+
padding: 12px 20px;
|
| 306 |
+
font-size: 14px;
|
| 307 |
+
}
|
| 308 |
}
|
| 309 |
|
| 310 |
+
/* Animations */
|
| 311 |
+
@keyframes fadeInUp {
|
| 312 |
+
from {
|
| 313 |
+
opacity: 0;
|
| 314 |
+
transform: translateY(20px);
|
| 315 |
+
}
|
| 316 |
+
to {
|
| 317 |
+
opacity: 1;
|
| 318 |
+
transform: translateY(0);
|
| 319 |
+
}
|
| 320 |
}
|
| 321 |
|
| 322 |
+
.gradio-container > * {
|
| 323 |
+
animation: fadeInUp 0.6s ease forwards;
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
/* Loading state */
|
| 327 |
+
.gradio-container .loading {
|
| 328 |
+
position: relative;
|
| 329 |
+
overflow: hidden;
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
.gradio-container .loading::after {
|
| 333 |
+
content: '';
|
| 334 |
+
position: absolute;
|
| 335 |
+
top: 0;
|
| 336 |
+
left: -100%;
|
| 337 |
+
width: 100%;
|
| 338 |
+
height: 100%;
|
| 339 |
+
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
|
| 340 |
+
animation: shimmer 1.5s infinite;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
@keyframes shimmer {
|
| 344 |
+
0% {
|
| 345 |
+
left: -100%;
|
| 346 |
+
}
|
| 347 |
+
100% {
|
| 348 |
+
left: 100%;
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
"""
|
| 352 |
|
| 353 |
+
with gr.Blocks(css=css, title="AI Image Generator", theme=gr.themes.Soft()) as demo:
|
| 354 |
with gr.Column(elem_id="col-container"):
|
| 355 |
+
gr.Markdown("# β¨ AI Image Generator")
|
| 356 |
|
| 357 |
with gr.Row():
|
| 358 |
prompt = gr.Text(
|
| 359 |
+
label="βοΈ Your Creative Prompt",
|
| 360 |
+
show_label=True,
|
| 361 |
max_lines=1,
|
| 362 |
+
placeholder="Describe your dream image in detail...",
|
| 363 |
+
container=True,
|
| 364 |
+
scale=4
|
| 365 |
)
|
| 366 |
|
| 367 |
+
run_button = gr.Button("π Generate", scale=1, variant="primary")
|
| 368 |
|
| 369 |
+
result = gr.Image(label="π¨ Generated Image", show_label=True, height=400)
|
| 370 |
|
| 371 |
+
with gr.Accordion("βοΈ Advanced Settings", open=False):
|
| 372 |
negative_prompt = gr.Text(
|
| 373 |
+
label="π« Negative Prompt",
|
| 374 |
max_lines=1,
|
| 375 |
+
placeholder="What you don't want in the image...",
|
| 376 |
+
visible=True,
|
| 377 |
)
|
| 378 |
|
| 379 |
seed = gr.Slider(
|
| 380 |
+
label="π² Seed",
|
| 381 |
minimum=0,
|
| 382 |
maximum=MAX_SEED,
|
| 383 |
step=1,
|
| 384 |
value=0,
|
| 385 |
)
|
| 386 |
|
| 387 |
+
randomize_seed = gr.Checkbox(label="π Randomize seed", value=True)
|
| 388 |
|
| 389 |
with gr.Row():
|
| 390 |
width = gr.Slider(
|
| 391 |
+
label="βοΈ Width",
|
| 392 |
minimum=256,
|
| 393 |
maximum=MAX_IMAGE_SIZE,
|
| 394 |
step=32,
|
| 395 |
+
value=1024,
|
| 396 |
)
|
| 397 |
|
| 398 |
height = gr.Slider(
|
| 399 |
+
label="βοΈ Height",
|
| 400 |
minimum=256,
|
| 401 |
maximum=MAX_IMAGE_SIZE,
|
| 402 |
step=32,
|
| 403 |
+
value=1024,
|
| 404 |
)
|
| 405 |
|
| 406 |
with gr.Row():
|
| 407 |
guidance_scale = gr.Slider(
|
| 408 |
+
label="π― Guidance Scale",
|
| 409 |
minimum=0.0,
|
| 410 |
maximum=10.0,
|
| 411 |
step=0.1,
|
| 412 |
+
value=7.5, # Better default value
|
| 413 |
)
|
| 414 |
|
| 415 |
num_inference_steps = gr.Slider(
|
| 416 |
+
label="π Inference Steps",
|
| 417 |
minimum=1,
|
| 418 |
maximum=50,
|
| 419 |
step=1,
|
| 420 |
+
value=20, # Better default value
|
| 421 |
)
|
| 422 |
|
| 423 |
+
gr.Examples(
|
| 424 |
+
examples=examples,
|
| 425 |
+
inputs=[prompt],
|
| 426 |
+
label="π‘ Try These Examples"
|
| 427 |
+
)
|
| 428 |
+
|
| 429 |
gr.on(
|
| 430 |
triggers=[run_button.click, prompt.submit],
|
| 431 |
fn=infer,
|
|
|
|
| 443 |
)
|
| 444 |
|
| 445 |
if __name__ == "__main__":
|
| 446 |
+
demo.launch(share=True)
|