NHLOCAL commited on
Commit
f6f4cf2
·
1 Parent(s): fc3ed5d

שגיאות מפורטות יותר

Browse files
Files changed (1) hide show
  1. backend.py +20 -3
backend.py CHANGED
@@ -160,24 +160,41 @@ from sam2.build_sam import build_sam2
160
  from sam2.sam2_image_predictor import SAM2ImagePredictor
161
 
162
  # נתיבים יחסיים ל-Space של Hugging Face
163
- SAM2_CHECKPOINT = "checkpoints/sam2.1_hiera_tiny.pt" # עדכן את הנתיב בהתאם
164
  MODEL_CFG = "sam2.1_hiera_t.yaml"
165
 
166
  sam2_predictor = None
167
  device = "cuda" if torch.cuda.is_available() else "cpu"
168
 
169
  try:
 
 
 
 
 
 
 
 
 
 
 
170
  sam2_model = build_sam2(MODEL_CFG, SAM2_CHECKPOINT, device=device)
171
- sam2_predictor = SAM2ImagePredictor(sam_model=sam2_model)
172
  print("[SAM2] מודל SAM2 נטען בהצלחה.")
173
 
 
 
 
 
 
174
  except Exception as e:
175
- print(f"[SAM2] שגיאה בטעינת SAM2: {e}")
176
  print(f" - סוג השגיאה: {type(e).__name__}")
177
  print(f" - הודעת השגיאה: {e}")
178
  import traceback
179
  print(f" - Traceback:")
180
  traceback.print_exc()
 
181
  sam2_predictor = None
182
 
183
  # -----------------------------
 
160
  from sam2.sam2_image_predictor import SAM2ImagePredictor
161
 
162
  # נתיבים יחסיים ל-Space של Hugging Face
163
+ SAM2_CHECKPOINT = "checkpoints/sam2.1_hiera_tiny.pt"
164
  MODEL_CFG = "sam2.1_hiera_t.yaml"
165
 
166
  sam2_predictor = None
167
  device = "cuda" if torch.cuda.is_available() else "cpu"
168
 
169
  try:
170
+ # הדפסת נתיבים מלאים לבדיקה
171
+ print(f"[DEBUG] SAM2_CHECKPOINT (full path): {os.path.abspath(SAM2_CHECKPOINT)}")
172
+ print(f"[DEBUG] MODEL_CFG (full path): {os.path.abspath(MODEL_CFG)}")
173
+
174
+ # בדיקת קיום הקבצים
175
+ if not os.path.exists(SAM2_CHECKPOINT):
176
+ raise FileNotFoundError(f"SAM2 checkpoint file not found at: {SAM2_CHECKPOINT}")
177
+ if not os.path.exists(MODEL_CFG):
178
+ raise FileNotFoundError(f"SAM2 config file not found at: {MODEL_CFG}")
179
+
180
+ # טעינת המודל
181
  sam2_model = build_sam2(MODEL_CFG, SAM2_CHECKPOINT, device=device)
182
+ sam2_predictor = SAM2ImagePredictor(sam2_model)
183
  print("[SAM2] מודל SAM2 נטען בהצלחה.")
184
 
185
+ except FileNotFoundError as e:
186
+ print(f"[ERROR] קובץ SAM2 לא נמצא: {e}")
187
+ print(f" - ודא שקובץ המודל '{SAM2_CHECKPOINT}' וקובץ הקונפיג '{MODEL_CFG}' קיימים בנתיבים הנכונים בתוך ה-Space שלך.")
188
+ sam2_predictor = None
189
+
190
  except Exception as e:
191
+ print(f"[ERROR] שגיאה כללית בטעינת SAM2: {e}")
192
  print(f" - סוג השגיאה: {type(e).__name__}")
193
  print(f" - הודעת השגיאה: {e}")
194
  import traceback
195
  print(f" - Traceback:")
196
  traceback.print_exc()
197
+ print(f" - בדוק את התאימות בין גרסאות הספריות (torch, torchvision, sam2) ואת תקינות קובץ המודל.")
198
  sam2_predictor = None
199
 
200
  # -----------------------------