Breeze1124 commited on
Commit
f638021
·
1 Parent(s): 063d259
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -2,12 +2,11 @@ import gradio as gr
2
  import os
3
 
4
  # --- Configuration ---
5
- # 指向我們剛剛上傳的 "assets_converted" 資料夾
6
  SCENES = [
7
  {
8
  "name": "Office 0",
9
  "thumb": "assets/office0.PNG",
10
- "model": "assets_converted/office0_converted.ply", # 指向轉好的檔
11
  "tracking_img": "assets/office0_tracking.PNG"
12
  },
13
  {
@@ -27,31 +26,38 @@ SCENES = [
27
  gallery_items = [(item["thumb"], item["name"]) for item in SCENES]
28
 
29
  def load_scene(evt: gr.SelectData):
30
- """
31
- 因為檔案已經是標準格式,直接回傳路徑即可。
32
- 不需要 GPU,不需要運算。
33
- """
34
  index = evt.index
35
  scene = SCENES[index]
36
 
 
37
  if not os.path.exists(scene["model"]):
 
38
  return (
39
  None,
40
  scene["tracking_img"],
41
- f"**Error: Model file not found: {scene['model']}**"
42
  )
43
 
44
  file_size = os.path.getsize(scene["model"]) / (1024 * 1024)
 
 
 
 
 
 
 
 
45
  return (
46
  scene["model"],
47
  scene["tracking_img"],
48
- f"**{scene['name']}** ({file_size:.1f} MB) ✓ Loaded"
49
  )
50
 
51
  # --- UI ---
52
  with gr.Blocks(title="RGS-SLAM Demo") as demo:
53
 
54
  gr.Markdown("# 🚀 RGS-SLAM Gaussian Splatting Viewer")
 
55
 
56
  with gr.Row():
57
  with gr.Column(scale=1):
 
2
  import os
3
 
4
  # --- Configuration ---
 
5
  SCENES = [
6
  {
7
  "name": "Office 0",
8
  "thumb": "assets/office0.PNG",
9
+ "model": "assets_converted/office0_converted.ply",
10
  "tracking_img": "assets/office0_tracking.PNG"
11
  },
12
  {
 
26
  gallery_items = [(item["thumb"], item["name"]) for item in SCENES]
27
 
28
  def load_scene(evt: gr.SelectData):
 
 
 
 
29
  index = evt.index
30
  scene = SCENES[index]
31
 
32
+ # 除錯資訊:檢查檔案是否存在
33
  if not os.path.exists(scene["model"]):
34
+ print(f"❌ File not found: {scene['model']}")
35
  return (
36
  None,
37
  scene["tracking_img"],
38
+ f"**Error: Model file missing on server!**\nPath: `{scene['model']}`"
39
  )
40
 
41
  file_size = os.path.getsize(scene["model"]) / (1024 * 1024)
42
+ print(f"📂 Loading: {scene['model']} ({file_size:.2f} MB)")
43
+
44
+ # 警告:如果檔案還是太大 (>100MB),CPU Basic 載入還是會慢
45
+ if file_size > 100:
46
+ msg = f"**{scene['name']}** ({file_size:.1f} MB)\n⚠️ File is large, please wait..."
47
+ else:
48
+ msg = f"**{scene['name']}** ({file_size:.1f} MB) ✓ Loaded"
49
+
50
  return (
51
  scene["model"],
52
  scene["tracking_img"],
53
+ msg
54
  )
55
 
56
  # --- UI ---
57
  with gr.Blocks(title="RGS-SLAM Demo") as demo:
58
 
59
  gr.Markdown("# 🚀 RGS-SLAM Gaussian Splatting Viewer")
60
+ gr.Markdown("Using CPU-Basic. Models converted to Binary PLY.")
61
 
62
  with gr.Row():
63
  with gr.Column(scale=1):