gagndeep commited on
Commit
3a2ddb6
·
1 Parent(s): acce386
Files changed (1) hide show
  1. app.py +21 -29
app.py CHANGED
@@ -1,8 +1,8 @@
1
  """
2
  SHARP Gradio Demo
3
- - Standard Split-View Layout (Left Input / Right Output)
4
- - SEO Optimized
5
- - Configs Visible (No Accordion)
6
  """
7
 
8
  from __future__ import annotations
@@ -31,24 +31,14 @@ EXAMPLES_DIR: Final[Path] = ASSETS_DIR / "examples"
31
  IMAGE_EXTS: Final[tuple[str, ...]] = (".png", ".jpg", ".jpeg", ".webp")
32
 
33
  # -----------------------------------------------------------------------------
34
- # SEO & Styling
35
  # -----------------------------------------------------------------------------
36
 
37
  SEO_HEAD = """
38
- <meta name="description" content="Turn 2D images into 3D Gaussian Splats instantly. SHARP (Apple) AI Demo. Free, fast, single-image 3D reconstruction.">
39
- <meta name="keywords" content="SHARP, 3D Gaussian Splatting, AI 3D model, Image to 3D, Apple Research, Gradio, Machine Learning">
40
- <meta property="og:title" content="SHARP: Instant Image-to-3D Model">
41
- <meta property="og:description" content="Generate 3D camera trajectories and PLY files from a single image in seconds using the SHARP model.">
42
  <meta name="viewport" content="width=device-width, initial-scale=1">
43
  """
44
 
45
- # Minimal CSS to just center headers and ensure spacing
46
- CSS = """
47
- h1 { text-align: center; margin-bottom: 0.5rem; }
48
- .sub-desc { text-align: center; margin-bottom: 2rem; color: #666; font-size: 1.1rem; }
49
- .gradio-container { max-width: 1400px !important; margin: 0 auto; }
50
- """
51
-
52
  # -----------------------------------------------------------------------------
53
  # Helpers
54
  # -----------------------------------------------------------------------------
@@ -117,7 +107,7 @@ def run_sharp(
117
  render_video=bool(render_video),
118
  )
119
 
120
- status_msg = f"✅ **Success**\n\nPLY: `{ply_path.name}`"
121
  if video_path:
122
  status_msg += f"\nVideo: `{video_path.name}`"
123
 
@@ -135,16 +125,20 @@ def run_sharp(
135
  # -----------------------------------------------------------------------------
136
 
137
  def build_demo() -> gr.Blocks:
 
 
138
  theme = gr.themes.Default()
139
 
140
- with gr.Blocks(theme=theme, css=CSS, head=SEO_HEAD, title="SHARP 3D Model Generator") as demo:
141
 
142
  # --- Header ---
143
- gr.Markdown("# SHARP: Single-Image 3D Generator")
144
- gr.Markdown("Convert any static image into a 3D Gaussian Splat scene instantly.", elem_classes=["sub-desc"])
145
-
 
146
  # --- Main Layout (Strict Two Columns) ---
147
- with gr.Row(equal_height=False, variant="panel"):
 
148
 
149
  # --- LEFT COLUMN: Input & Controls ---
150
  with gr.Column(scale=1):
@@ -152,11 +146,10 @@ def build_demo() -> gr.Blocks:
152
  label="Input Image",
153
  type="filepath",
154
  sources=["upload", "clipboard"],
155
- height=320, # Fixed height to prevent layout shifts
156
  interactive=True
157
  )
158
 
159
- # Settings grouped cleanly below image (No Accordion)
160
  with gr.Group():
161
  with gr.Row():
162
  trajectory = gr.Dropdown(
@@ -179,31 +172,30 @@ def build_demo() -> gr.Blocks:
179
 
180
  run_btn = gr.Button("🚀 Generate 3D Scene", variant="primary", size="lg")
181
 
182
- # Examples at the bottom of left column
183
  example_files = get_example_files()
184
  if example_files:
185
  gr.Examples(
186
  examples=example_files,
187
  inputs=[image_in],
188
- label="Examples (Click to Load)",
189
- # Setting run_on_click=False allows user to change settings before running
190
- run_on_click=False,
191
  cache_examples=False
192
  )
193
 
194
  # --- RIGHT COLUMN: Output ---
195
  with gr.Column(scale=1):
 
196
  video_out = gr.Video(
197
  label="3D Preview",
198
  autoplay=True,
199
- height=320, # Matches input height
200
  elem_id="output-video"
201
  )
202
 
203
  with gr.Group():
204
  status_md = gr.Markdown("Ready to generate.")
205
  ply_download = gr.DownloadButton(
206
- label="Download .PLY File (For Splat Viewers)",
207
  variant="secondary",
208
  visible=True
209
  )
 
1
  """
2
  SHARP Gradio Demo
3
+ - Standard Native Layout (No Custom CSS)
4
+ - Two-Column Split
5
+ - Clean Grouping for reduced congestion
6
  """
7
 
8
  from __future__ import annotations
 
31
  IMAGE_EXTS: Final[tuple[str, ...]] = (".png", ".jpg", ".jpeg", ".webp")
32
 
33
  # -----------------------------------------------------------------------------
34
+ # SEO (Meta Tags Only)
35
  # -----------------------------------------------------------------------------
36
 
37
  SEO_HEAD = """
38
+ <meta name="description" content="Turn 2D images into 3D Gaussian Splats instantly. SHARP (Apple) AI Demo.">
 
 
 
39
  <meta name="viewport" content="width=device-width, initial-scale=1">
40
  """
41
 
 
 
 
 
 
 
 
42
  # -----------------------------------------------------------------------------
43
  # Helpers
44
  # -----------------------------------------------------------------------------
 
107
  render_video=bool(render_video),
108
  )
109
 
110
+ status_msg = f"### ✅ Success\nPLY: `{ply_path.name}`"
111
  if video_path:
112
  status_msg += f"\nVideo: `{video_path.name}`"
113
 
 
125
  # -----------------------------------------------------------------------------
126
 
127
  def build_demo() -> gr.Blocks:
128
+ # Use standard theme.
129
+ # To reduce congestion further, you could try `theme=gr.themes.Soft()` or `Base()`
130
  theme = gr.themes.Default()
131
 
132
+ with gr.Blocks(theme=theme, head=SEO_HEAD, title="SHARP 3D Generator") as demo:
133
 
134
  # --- Header ---
135
+ with gr.Row():
136
+ with gr.Column(scale=1):
137
+ gr.Markdown("# SHARP: Single-Image 3D Generator\nConvert any static image into a 3D Gaussian Splat scene instantly.")
138
+
139
  # --- Main Layout (Strict Two Columns) ---
140
+ # Removed 'variant="panel"' to remove the grey box/padding that restricts width
141
+ with gr.Row(equal_height=False):
142
 
143
  # --- LEFT COLUMN: Input & Controls ---
144
  with gr.Column(scale=1):
 
146
  label="Input Image",
147
  type="filepath",
148
  sources=["upload", "clipboard"],
 
149
  interactive=True
150
  )
151
 
152
+ # Settings grouped cleanly below image
153
  with gr.Group():
154
  with gr.Row():
155
  trajectory = gr.Dropdown(
 
172
 
173
  run_btn = gr.Button("🚀 Generate 3D Scene", variant="primary", size="lg")
174
 
175
+ # Examples
176
  example_files = get_example_files()
177
  if example_files:
178
  gr.Examples(
179
  examples=example_files,
180
  inputs=[image_in],
181
+ label="Examples",
182
+ run_on_click=False,
 
183
  cache_examples=False
184
  )
185
 
186
  # --- RIGHT COLUMN: Output ---
187
  with gr.Column(scale=1):
188
+ # Removed fixed height so it fills the column naturally
189
  video_out = gr.Video(
190
  label="3D Preview",
191
  autoplay=True,
 
192
  elem_id="output-video"
193
  )
194
 
195
  with gr.Group():
196
  status_md = gr.Markdown("Ready to generate.")
197
  ply_download = gr.DownloadButton(
198
+ label="Download .PLY File",
199
  variant="secondary",
200
  visible=True
201
  )