Claude commited on
Commit
088412a
·
unverified ·
1 Parent(s): 4efb182

Improve error reporting for SHARP module import failures

Browse files

Changes:
- Add detailed error tracking with SHARP_ERROR variable
- Display comprehensive error messages in UI when SHARP fails to load
- Show status banner indicating SHARP availability
- Include traceback for debugging ImportError and exceptions
- Provide actionable error messages to users

This helps diagnose the Python 3.13 requirement issue where ml-sharp
cannot be imported on Python 3.10-3.12 environments.

Note: ml-sharp requires Python 3.13, but HF Spaces only supports up to 3.12.
This is a known compatibility issue that needs resolution.

Files changed (1) hide show
  1. app.py +41 -6
app.py CHANGED
@@ -9,12 +9,23 @@ from typing import Optional
9
  import json
10
 
11
  # SHARP モデルのインポート (遅延読み込み)
 
 
 
12
  try:
13
  from sharp import Sharp
14
  SHARP_AVAILABLE = True
15
- except ImportError:
16
- SHARP_AVAILABLE = False
17
- print("Warning: SHARP not available. Using mock mode for development.")
 
 
 
 
 
 
 
 
18
 
19
  # グローバルモデルインスタンス (メモリ効率のため)
20
  _model = None
@@ -38,7 +49,13 @@ def process_image(image) -> tuple[Optional[str], str, str]:
38
  tuple: (PLYファイルパス, ステータスメッセージ, PLYデータ(base64))
39
  """
40
  if not SHARP_AVAILABLE:
41
- return None, "❌ SHARPモデルが利用できません", ""
 
 
 
 
 
 
42
 
43
  if image is None:
44
  return None, "❌ 画像をアップロードしてください", ""
@@ -315,9 +332,27 @@ with gr.Blocks(
315
  theme=gr.themes.Soft(primary_hue="blue", secondary_hue="purple"),
316
  title="SHARP: 3D Gaussian Splats Generator"
317
  ) as demo:
318
- gr.Markdown("""
319
- # 🎨 SHARP: 単一画像から3D Gaussian Splatsを生成
 
 
 
 
 
 
 
 
 
 
320
 
 
 
 
 
 
 
 
 
321
  Appleの最新技術「SHARP」を使用して、1枚の画像から高品質な3D Gaussian Splatsを生成します。
322
  生成された3DモデルはThree.jsで右側にリアルタイムプレビューされます。
323
 
 
9
  import json
10
 
11
  # SHARP モデルのインポート (遅延読み込み)
12
+ SHARP_AVAILABLE = False
13
+ SHARP_ERROR = None
14
+
15
  try:
16
  from sharp import Sharp
17
  SHARP_AVAILABLE = True
18
+ print("✅ SHARP module loaded successfully")
19
+ except ImportError as e:
20
+ SHARP_ERROR = str(e)
21
+ print(f"❌ SHARP import failed: {e}")
22
+ import traceback
23
+ traceback.print_exc()
24
+ except Exception as e:
25
+ SHARP_ERROR = str(e)
26
+ print(f"❌ Unexpected error loading SHARP: {e}")
27
+ import traceback
28
+ traceback.print_exc()
29
 
30
  # グローバルモデルインスタンス (メモリ効率のため)
31
  _model = None
 
49
  tuple: (PLYファイルパス, ステータスメッセージ, PLYデータ(base64))
50
  """
51
  if not SHARP_AVAILABLE:
52
+ error_msg = f"❌ SHARPモデルが利用できません\n\nエラー詳細: {SHARP_ERROR}\n\n"
53
+ error_msg += "考えられる原因:\n"
54
+ error_msg += "1. ml-sharpパッケージのインストール失敗\n"
55
+ error_msg += "2. Python バージョンの非互換性\n"
56
+ error_msg += "3. 依存関係の問題\n\n"
57
+ error_msg += "ログを確認してください。"
58
+ return None, error_msg, ""
59
 
60
  if image is None:
61
  return None, "❌ 画像をアップロードしてください", ""
 
332
  theme=gr.themes.Soft(primary_hue="blue", secondary_hue="purple"),
333
  title="SHARP: 3D Gaussian Splats Generator"
334
  ) as demo:
335
+ # SHARPステータスバナー
336
+ if SHARP_AVAILABLE:
337
+ status_banner = """
338
+ # 🎨 SHARP: 単一画像から3D Gaussian Splatsを生成
339
+
340
+ ✅ **SHARPモデル: 正常に読み込まれました**
341
+ """
342
+ else:
343
+ status_banner = f"""
344
+ # 🎨 SHARP: 単一画像から3D Gaussian Splatsを生成
345
+
346
+ ⚠️ **警告: SHARPモデルが読み込めませんでした**
347
 
348
+ エラー: `{SHARP_ERROR}`
349
+
350
+ Spaceのログを確認するか、リポジトリの管理者にお問い合わせください。
351
+ """
352
+
353
+ gr.Markdown(status_banner)
354
+
355
+ gr.Markdown("""
356
  Appleの最新技術「SHARP」を使用して、1枚の画像から高品質な3D Gaussian Splatsを生成します。
357
  生成された3DモデルはThree.jsで右側にリアルタイムプレビューされます。
358