Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -139,7 +139,7 @@ t2i_example_prompts = [
|
|
| 139 |
["A cute robot sitting at a desk, digital art style", 1024, 1024, 44],
|
| 140 |
]
|
| 141 |
|
| 142 |
-
# --- Custom CSS (
|
| 143 |
custom_css = """
|
| 144 |
@import url('https://fonts.googleapis.com/css2?family=SF+Pro+Display:wght@300;400;500;600;700&display=swap');
|
| 145 |
|
|
@@ -149,11 +149,17 @@ custom_css = """
|
|
| 149 |
|
| 150 |
/* Ensure padding on all screen sizes */
|
| 151 |
.gradio-container {
|
|
|
|
| 152 |
max-width: 1400px !important;
|
| 153 |
margin: auto !important;
|
| 154 |
padding: 0 16px;
|
| 155 |
}
|
| 156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
/* Background gradient for the overall app (like a subtle card) */
|
| 158 |
#component-0 {
|
| 159 |
background: linear-gradient(180deg, #f5f5f7 0%, #ffffff 100%) !important;
|
|
@@ -256,7 +262,8 @@ label {
|
|
| 256 |
"""
|
| 257 |
|
| 258 |
# Build Gradio interface
|
| 259 |
-
|
|
|
|
| 260 |
gr.HTML("""
|
| 261 |
<div style="text-align: center; padding: 40px 20px 30px 20px;">
|
| 262 |
<h1 style="font-size: 48px; font-weight: 700; margin: 0; background: linear-gradient(90deg, #007aff 0%, #5856d6 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent;">
|
|
@@ -271,9 +278,11 @@ with gr.Blocks() as demo:
|
|
| 271 |
with gr.Tabs(selected=0):
|
| 272 |
# Image Edit Tab (Responsive Layout: Row on Desktop, Column on Mobile)
|
| 273 |
with gr.TabItem("Edit Image", id=0):
|
| 274 |
-
with gr.Row():
|
| 275 |
# Left Column (Inputs)
|
| 276 |
-
|
|
|
|
|
|
|
| 277 |
gr.Markdown("### 🖼️ Input Image & Controls")
|
| 278 |
input_image = gr.Image(
|
| 279 |
label="Upload Image",
|
|
@@ -302,7 +311,7 @@ with gr.Blocks() as demo:
|
|
| 302 |
edit_btn = gr.Button("Edit Image", variant="primary", size="lg", elem_classes=["primary-btn"])
|
| 303 |
|
| 304 |
# Right Column (Output)
|
| 305 |
-
with gr.Column(scale=1, variant="panel"):
|
| 306 |
gr.Markdown("### ✨ Result")
|
| 307 |
output_image = gr.Image(
|
| 308 |
label="Result",
|
|
@@ -325,9 +334,9 @@ with gr.Blocks() as demo:
|
|
| 325 |
|
| 326 |
# Text-to-Image Tab (Responsive Layout: Row on Desktop, Column on Mobile)
|
| 327 |
with gr.TabItem("Generate Image", id=1):
|
| 328 |
-
with gr.Row():
|
| 329 |
# Left Column (Inputs)
|
| 330 |
-
with gr.Column(scale=1, variant="panel"):
|
| 331 |
gr.Markdown("### 🎨 Generation Controls")
|
| 332 |
t2i_prompt = gr.Textbox(
|
| 333 |
label="Describe your image",
|
|
@@ -364,7 +373,7 @@ with gr.Blocks() as demo:
|
|
| 364 |
generate_btn = gr.Button("Generate Image", variant="primary", size="lg", elem_classes=["primary-btn"])
|
| 365 |
|
| 366 |
# Right Column (Output)
|
| 367 |
-
with gr.Column(scale=1, variant="panel"):
|
| 368 |
gr.Markdown("### ✨ Result")
|
| 369 |
t2i_output = gr.Image(
|
| 370 |
label="Result",
|
|
|
|
| 139 |
["A cute robot sitting at a desk, digital art style", 1024, 1024, 44],
|
| 140 |
]
|
| 141 |
|
| 142 |
+
# --- Custom CSS (Modified to ensure Row behavior) ---
|
| 143 |
custom_css = """
|
| 144 |
@import url('https://fonts.googleapis.com/css2?family=SF+Pro+Display:wght@300;400;500;600;700&display=swap');
|
| 145 |
|
|
|
|
| 149 |
|
| 150 |
/* Ensure padding on all screen sizes */
|
| 151 |
.gradio-container {
|
| 152 |
+
/* Retain max-width but remove side padding in Blocks for better full-width control */
|
| 153 |
max-width: 1400px !important;
|
| 154 |
margin: auto !important;
|
| 155 |
padding: 0 16px;
|
| 156 |
}
|
| 157 |
|
| 158 |
+
/* CSS Fix: Ensure layout elements behave as flex containers */
|
| 159 |
+
.gr-row {
|
| 160 |
+
display: flex !important;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
/* Background gradient for the overall app (like a subtle card) */
|
| 164 |
#component-0 {
|
| 165 |
background: linear-gradient(180deg, #f5f5f7 0%, #ffffff 100%) !important;
|
|
|
|
| 262 |
"""
|
| 263 |
|
| 264 |
# Build Gradio interface
|
| 265 |
+
# Added fill_width=True to Blocks to maximize space utilization
|
| 266 |
+
with gr.Blocks(fill_width=True) as demo:
|
| 267 |
gr.HTML("""
|
| 268 |
<div style="text-align: center; padding: 40px 20px 30px 20px;">
|
| 269 |
<h1 style="font-size: 48px; font-weight: 700; margin: 0; background: linear-gradient(90deg, #007aff 0%, #5856d6 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent;">
|
|
|
|
| 278 |
with gr.Tabs(selected=0):
|
| 279 |
# Image Edit Tab (Responsive Layout: Row on Desktop, Column on Mobile)
|
| 280 |
with gr.TabItem("Edit Image", id=0):
|
| 281 |
+
with gr.Row():
|
| 282 |
# Left Column (Inputs)
|
| 283 |
+
# Setting min_width=0 ensures the column will shrink freely on narrow viewports
|
| 284 |
+
# until Gradio's responsive behavior naturally stacks them.
|
| 285 |
+
with gr.Column(scale=1, min_width=0, variant="panel"):
|
| 286 |
gr.Markdown("### 🖼️ Input Image & Controls")
|
| 287 |
input_image = gr.Image(
|
| 288 |
label="Upload Image",
|
|
|
|
| 311 |
edit_btn = gr.Button("Edit Image", variant="primary", size="lg", elem_classes=["primary-btn"])
|
| 312 |
|
| 313 |
# Right Column (Output)
|
| 314 |
+
with gr.Column(scale=1, min_width=0, variant="panel"):
|
| 315 |
gr.Markdown("### ✨ Result")
|
| 316 |
output_image = gr.Image(
|
| 317 |
label="Result",
|
|
|
|
| 334 |
|
| 335 |
# Text-to-Image Tab (Responsive Layout: Row on Desktop, Column on Mobile)
|
| 336 |
with gr.TabItem("Generate Image", id=1):
|
| 337 |
+
with gr.Row():
|
| 338 |
# Left Column (Inputs)
|
| 339 |
+
with gr.Column(scale=1, min_width=0, variant="panel"):
|
| 340 |
gr.Markdown("### 🎨 Generation Controls")
|
| 341 |
t2i_prompt = gr.Textbox(
|
| 342 |
label="Describe your image",
|
|
|
|
| 373 |
generate_btn = gr.Button("Generate Image", variant="primary", size="lg", elem_classes=["primary-btn"])
|
| 374 |
|
| 375 |
# Right Column (Output)
|
| 376 |
+
with gr.Column(scale=1, min_width=0, variant="panel"):
|
| 377 |
gr.Markdown("### ✨ Result")
|
| 378 |
t2i_output = gr.Image(
|
| 379 |
label="Result",
|