Tohru127 commited on
Commit
855e442
Β·
verified Β·
1 Parent(s): ac57e9c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -24
app.py CHANGED
@@ -155,33 +155,33 @@ def process_image(image, model_choice="GLPN (Recommended)", visualization_type="
155
  # Check outlier removal
156
  outlier_pct = (metrics['outliers_removed'] / metrics['initial_points']) * 100
157
  if outlier_pct < 5:
158
- assessment.append("βœ… Very clean depth estimation (low noise)")
159
  elif outlier_pct < 15:
160
- assessment.append("βœ… Good depth quality (normal noise level)")
161
  else:
162
- assessment.append("⚠️ High noise in depth estimation")
163
 
164
  # Check manifold properties
165
  if metrics['is_edge_manifold'] and metrics['is_vertex_manifold']:
166
- assessment.append("βœ… Excellent topology - mesh is well-formed")
167
  elif metrics['is_vertex_manifold']:
168
- assessment.append("⚠️ Good local topology but has some edge issues")
169
  else:
170
- assessment.append("⚠️ Topology issues present - may need cleanup")
171
 
172
  # Check watertight
173
  if metrics['is_watertight']:
174
- assessment.append("βœ… Watertight mesh - ready for 3D printing!")
175
  else:
176
- assessment.append("ℹ️ Not watertight - use MeshLab's 'Close Holes' for 3D printing")
177
 
178
  # Check complexity
179
  if metrics['triangles'] > 1000000:
180
- assessment.append("ℹ️ Very detailed mesh - may be slow in some software")
181
  elif metrics['triangles'] > 500000:
182
- assessment.append("βœ… High detail mesh - good quality")
183
  else:
184
- assessment.append("βœ… Moderate detail - good balance of quality and performance")
185
 
186
  return "\n".join(f"- {item}" for item in assessment)
187
 
@@ -513,7 +513,7 @@ def process_image(image, model_choice="GLPN (Recommended)", visualization_type="
513
  assessment = _generate_quality_assessment(metrics)
514
 
515
  report = f"""
516
- ## Reconstruction Complete! βœ…
517
 
518
  ### Performance Metrics
519
  - **Model Used**: {metrics['model_used']}
@@ -543,7 +543,7 @@ def process_image(image, model_choice="GLPN (Recommended)", visualization_type="
543
  - Mesh: PLY, OBJ, STL formats
544
  - Quality Metrics: JSON
545
 
546
- **Download the complete package below! πŸ“¦**
547
  """
548
 
549
  print("SUCCESS! Returning results...")
@@ -573,7 +573,7 @@ with gr.Blocks(title="Advanced 3D Reconstruction", theme=gr.themes.Soft()) as de
573
  with gr.Tabs():
574
 
575
  # ========== RECONSTRUCTION TAB ==========
576
- with gr.Tab("🎯 Reconstruction"):
577
  with gr.Row():
578
  with gr.Column(scale=1):
579
  input_image = gr.Image(type="pil", label="Upload Image")
@@ -591,7 +591,7 @@ with gr.Blocks(title="Advanced 3D Reconstruction", theme=gr.themes.Soft()) as de
591
  label="3D Visualization Type"
592
  )
593
 
594
- reconstruct_btn = gr.Button("πŸš€ Start Reconstruction", variant="primary", size="lg")
595
 
596
  with gr.Column(scale=2):
597
  depth_output = gr.Image(label="Depth Map Comparison")
@@ -604,7 +604,7 @@ with gr.Blocks(title="Advanced 3D Reconstruction", theme=gr.themes.Soft()) as de
604
  json_output = gr.Textbox(label="Raw Metrics (JSON)", lines=10)
605
 
606
  with gr.Row():
607
- download_output = gr.File(label="πŸ“¦ Download Complete Package (ZIP)")
608
 
609
  reconstruct_btn.click(
610
  fn=process_image,
@@ -613,7 +613,7 @@ with gr.Blocks(title="Advanced 3D Reconstruction", theme=gr.themes.Soft()) as de
613
  )
614
 
615
  # ========== THEORY TAB ==========
616
- with gr.Tab("πŸ“š Theory & Background"):
617
  gr.Markdown(THEORY_TEXT)
618
 
619
  gr.Markdown("""
@@ -652,8 +652,8 @@ with gr.Blocks(title="Advanced 3D Reconstruction", theme=gr.themes.Soft()) as de
652
 
653
  | Feature | GLPN (Recommended) | DPT (High Quality) |
654
  |---------|-------------------|-------------------|
655
- | **Speed** | ⚑ Fast (~0.3-2.5s) | 🐒 Slower (~0.8-6.5s) |
656
- | **Quality** | ⭐⭐⭐⭐ Good | ⭐⭐⭐⭐⭐ Excellent |
657
  | **Memory** | Low (~2GB) | High (~5GB) |
658
  | **Best For** | Indoor scenes, Real-time | Complex scenes, Highest quality |
659
  | **Training** | NYU Depth V2 | Multiple datasets |
@@ -674,7 +674,7 @@ with gr.Blocks(title="Advanced 3D Reconstruction", theme=gr.themes.Soft()) as de
674
  """)
675
 
676
  # ========== USAGE GUIDE TAB ==========
677
- with gr.Tab("πŸ“– Usage Guide"):
678
  gr.Markdown("""
679
  ## How to Use This Application
680
 
@@ -700,7 +700,7 @@ with gr.Blocks(title="Advanced 3D Reconstruction", theme=gr.themes.Soft()) as de
700
  - **Both**: Shows both mesh and point cloud together
701
 
702
  ### Step 4: Start Reconstruction
703
- - Click "πŸš€ Start Reconstruction" button
704
  - Wait for processing (typically 10-60 seconds total)
705
  - Watch for status messages in the console/logs
706
  - Results appear automatically when complete
@@ -767,7 +767,7 @@ with gr.Blocks(title="Advanced 3D Reconstruction", theme=gr.themes.Soft()) as de
767
 
768
  ## Tips for Best Results
769
 
770
- ### βœ… DO:
771
  - Use well-lit images without harsh shadows
772
  - Include visible depth cues (corners, edges, varying distances)
773
  - Use images of indoor scenes (rooms, furniture, objects)
@@ -775,7 +775,7 @@ with gr.Blocks(title="Advanced 3D Reconstruction", theme=gr.themes.Soft()) as de
775
  - Use medium resolution (512-1024px is ideal)
776
  - Take photos perpendicular to main surfaces
777
 
778
- ### ❌ AVOID:
779
  - Motion blur or very low resolution images
780
  - Reflective surfaces (mirrors, polished metal, glass)
781
  - Completely uniform textures (solid white wall)
@@ -831,7 +831,7 @@ with gr.Blocks(title="Advanced 3D Reconstruction", theme=gr.themes.Soft()) as de
831
  - For 3D printing: use mesh repair in MeshLab
832
  """)
833
  # ========== CITATION TAB ==========
834
- with gr.Tab("πŸ“„ Citation & Credits"):
835
  gr.Markdown("""
836
 
837
 
 
155
  # Check outlier removal
156
  outlier_pct = (metrics['outliers_removed'] / metrics['initial_points']) * 100
157
  if outlier_pct < 5:
158
+ assessment.append("Very clean depth estimation (low noise)")
159
  elif outlier_pct < 15:
160
+ assessment.append("Good depth quality (normal noise level)")
161
  else:
162
+ assessment.append("High noise in depth estimation")
163
 
164
  # Check manifold properties
165
  if metrics['is_edge_manifold'] and metrics['is_vertex_manifold']:
166
+ assessment.append("Excellent topology - mesh is well-formed")
167
  elif metrics['is_vertex_manifold']:
168
+ assessment.append("Good local topology but has some edge issues")
169
  else:
170
+ assessment.append("Topology issues present - may need cleanup")
171
 
172
  # Check watertight
173
  if metrics['is_watertight']:
174
+ assessment.append("Watertight mesh - ready for 3D printing!")
175
  else:
176
+ assessment.append("Not watertight - use MeshLab's 'Close Holes' for 3D printing")
177
 
178
  # Check complexity
179
  if metrics['triangles'] > 1000000:
180
+ assessment.append("Very detailed mesh - may be slow in some software")
181
  elif metrics['triangles'] > 500000:
182
+ assessment.append("High detail mesh - good quality")
183
  else:
184
+ assessment.append("Moderate detail - good balance of quality and performance")
185
 
186
  return "\n".join(f"- {item}" for item in assessment)
187
 
 
513
  assessment = _generate_quality_assessment(metrics)
514
 
515
  report = f"""
516
+ ## Reconstruction Complete!
517
 
518
  ### Performance Metrics
519
  - **Model Used**: {metrics['model_used']}
 
543
  - Mesh: PLY, OBJ, STL formats
544
  - Quality Metrics: JSON
545
 
546
+ **Download the complete package below!**
547
  """
548
 
549
  print("SUCCESS! Returning results...")
 
573
  with gr.Tabs():
574
 
575
  # ========== RECONSTRUCTION TAB ==========
576
+ with gr.Tab("Reconstruction"):
577
  with gr.Row():
578
  with gr.Column(scale=1):
579
  input_image = gr.Image(type="pil", label="Upload Image")
 
591
  label="3D Visualization Type"
592
  )
593
 
594
+ reconstruct_btn = gr.Button("Start Reconstruction", variant="primary", size="lg")
595
 
596
  with gr.Column(scale=2):
597
  depth_output = gr.Image(label="Depth Map Comparison")
 
604
  json_output = gr.Textbox(label="Raw Metrics (JSON)", lines=10)
605
 
606
  with gr.Row():
607
+ download_output = gr.File(label="Download Complete Package (ZIP)")
608
 
609
  reconstruct_btn.click(
610
  fn=process_image,
 
613
  )
614
 
615
  # ========== THEORY TAB ==========
616
+ with gr.Tab("Theory & Background"):
617
  gr.Markdown(THEORY_TEXT)
618
 
619
  gr.Markdown("""
 
652
 
653
  | Feature | GLPN (Recommended) | DPT (High Quality) |
654
  |---------|-------------------|-------------------|
655
+ | **Speed** | Fast (~0.3-2.5s) | Slower (~0.8-6.5s) |
656
+ | **Quality** | Good | Excellent |
657
  | **Memory** | Low (~2GB) | High (~5GB) |
658
  | **Best For** | Indoor scenes, Real-time | Complex scenes, Highest quality |
659
  | **Training** | NYU Depth V2 | Multiple datasets |
 
674
  """)
675
 
676
  # ========== USAGE GUIDE TAB ==========
677
+ with gr.Tab("Usage Guide"):
678
  gr.Markdown("""
679
  ## How to Use This Application
680
 
 
700
  - **Both**: Shows both mesh and point cloud together
701
 
702
  ### Step 4: Start Reconstruction
703
+ - Click "Start Reconstruction" button
704
  - Wait for processing (typically 10-60 seconds total)
705
  - Watch for status messages in the console/logs
706
  - Results appear automatically when complete
 
767
 
768
  ## Tips for Best Results
769
 
770
+ ### DO:
771
  - Use well-lit images without harsh shadows
772
  - Include visible depth cues (corners, edges, varying distances)
773
  - Use images of indoor scenes (rooms, furniture, objects)
 
775
  - Use medium resolution (512-1024px is ideal)
776
  - Take photos perpendicular to main surfaces
777
 
778
+ ### AVOID:
779
  - Motion blur or very low resolution images
780
  - Reflective surfaces (mirrors, polished metal, glass)
781
  - Completely uniform textures (solid white wall)
 
831
  - For 3D printing: use mesh repair in MeshLab
832
  """)
833
  # ========== CITATION TAB ==========
834
+ with gr.Tab("Citation & Credits"):
835
  gr.Markdown("""
836
 
837