Kirubel Mehari commited on
Commit
904249c
·
1 Parent(s): 6d7025e

Fix syntax error in gr.Image

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import gradio as gr
2
  import subprocess
3
  import os
@@ -7,7 +9,7 @@ import tempfile
7
 
8
  DESCRIPTION = """
9
  # SHARP · 3D from a Single Photo
10
- Upload any photo and get a **3D Gaussian Splat (.ply)** in seconds.
11
  Powered by Apple's [SHARP](https://github.com/apple/ml-sharp) monocular view synthesis model.
12
 
13
  **How to use:**
@@ -30,12 +32,10 @@ def generate_splat(image_path):
30
  os.makedirs(output_dir, exist_ok=True)
31
 
32
  try:
33
- # Copy input image into the input dir
34
  ext = os.path.splitext(image_path)[1] or ".jpg"
35
  input_copy = os.path.join(input_dir, f"input{ext}")
36
  shutil.copy(image_path, input_copy)
37
 
38
- # Run SHARP
39
  result = subprocess.run(
40
  ["sharp", "predict", "-i", input_dir, "-o", output_dir],
41
  capture_output=True,
@@ -46,14 +46,11 @@ def generate_splat(image_path):
46
  if result.returncode != 0:
47
  raise gr.Error(f"SHARP failed: {result.stderr[-500:]}")
48
 
49
- # Find output .ply
50
  ply_files = [f for f in os.listdir(output_dir) if f.endswith(".ply")]
51
  if not ply_files:
52
  raise gr.Error("No .ply file was generated. Try a different image.")
53
 
54
  ply_path = os.path.join(output_dir, ply_files[0])
55
-
56
- # Copy to a stable temp path for Gradio to serve
57
  out_path = os.path.join(tempfile.gettempdir(), f"output_{job_id}.ply")
58
  shutil.copy(ply_path, out_path)
59
 
@@ -85,8 +82,7 @@ with gr.Blocks(
85
  with gr.Column():
86
  image_input = gr.Image(
87
  type="filepath",
88
- label="Input Image",
89
- ,
90
  )
91
  run_btn = gr.Button("⚡ Generate 3D Splat", variant="primary", size="lg")
92
 
@@ -102,7 +98,7 @@ with gr.Blocks(
102
 
103
  gr.Markdown("""
104
  ---
105
- **After downloading your .ply:**
106
  Go to [playcanvas.com/supersplat/editor](https://playcanvas.com/supersplat/editor) and drag your file in to view the 3D scene.
107
  """)
108
 
 
1
+
2
+ cat > app.py << 'PYEOF'
3
  import gradio as gr
4
  import subprocess
5
  import os
 
9
 
10
  DESCRIPTION = """
11
  # SHARP · 3D from a Single Photo
12
+ Upload any photo and get a **3D Gaussian Splat (.ply)** in seconds.
13
  Powered by Apple's [SHARP](https://github.com/apple/ml-sharp) monocular view synthesis model.
14
 
15
  **How to use:**
 
32
  os.makedirs(output_dir, exist_ok=True)
33
 
34
  try:
 
35
  ext = os.path.splitext(image_path)[1] or ".jpg"
36
  input_copy = os.path.join(input_dir, f"input{ext}")
37
  shutil.copy(image_path, input_copy)
38
 
 
39
  result = subprocess.run(
40
  ["sharp", "predict", "-i", input_dir, "-o", output_dir],
41
  capture_output=True,
 
46
  if result.returncode != 0:
47
  raise gr.Error(f"SHARP failed: {result.stderr[-500:]}")
48
 
 
49
  ply_files = [f for f in os.listdir(output_dir) if f.endswith(".ply")]
50
  if not ply_files:
51
  raise gr.Error("No .ply file was generated. Try a different image.")
52
 
53
  ply_path = os.path.join(output_dir, ply_files[0])
 
 
54
  out_path = os.path.join(tempfile.gettempdir(), f"output_{job_id}.ply")
55
  shutil.copy(ply_path, out_path)
56
 
 
82
  with gr.Column():
83
  image_input = gr.Image(
84
  type="filepath",
85
+ label="Input Image"
 
86
  )
87
  run_btn = gr.Button("⚡ Generate 3D Splat", variant="primary", size="lg")
88
 
 
98
 
99
  gr.Markdown("""
100
  ---
101
+ **After downloading your .ply:**
102
  Go to [playcanvas.com/supersplat/editor](https://playcanvas.com/supersplat/editor) and drag your file in to view the 3D scene.
103
  """)
104