Spaces:
Runtime error
Runtime error
jhj0517
commited on
Commit
·
1de582e
1
Parent(s):
a7f9f59
Update raise type
Browse files- modules/sam_inference.py +7 -4
modules/sam_inference.py
CHANGED
@@ -90,6 +90,7 @@ class SamInference:
|
|
90 |
)
|
91 |
except Exception as e:
|
92 |
logger.exception("Error while loading SAM2 model")
|
|
|
93 |
|
94 |
def init_video_inference_state(self,
|
95 |
vid_input: str,
|
@@ -128,8 +129,8 @@ class SamInference:
|
|
128 |
try:
|
129 |
generated_masks = self.mask_generator.generate(image)
|
130 |
except Exception as e:
|
131 |
-
logger.exception("Error while auto generating masks")
|
132 |
-
raise f"
|
133 |
return generated_masks
|
134 |
|
135 |
def predict_image(self,
|
@@ -154,6 +155,7 @@ class SamInference:
|
|
154 |
)
|
155 |
except Exception as e:
|
156 |
logger.exception(f"Error while predicting image with prompt: {str(e)}")
|
|
|
157 |
return masks, scores, logits
|
158 |
|
159 |
def add_prediction_to_frame(self,
|
@@ -181,7 +183,7 @@ class SamInference:
|
|
181 |
)
|
182 |
except Exception as e:
|
183 |
logger.exception(f"Error while predicting frame with prompt: {str(e)}")
|
184 |
-
raise RuntimeError(f"Failed to predicting frame with prompt
|
185 |
|
186 |
return out_frame_idx, out_obj_ids, out_mask_logits
|
187 |
|
@@ -211,6 +213,7 @@ class SamInference:
|
|
211 |
}
|
212 |
except Exception as e:
|
213 |
logger.exception(f"Error while propagating in video: {str(e)}")
|
|
|
214 |
|
215 |
return video_segments
|
216 |
|
@@ -266,7 +269,7 @@ class SamInference:
|
|
266 |
):
|
267 |
if self.video_predictor is None or self.video_inference_state is None:
|
268 |
logger.exception("Error while adding filter to preview, load video predictor first")
|
269 |
-
raise
|
270 |
|
271 |
if not image_prompt_input_data["points"]:
|
272 |
error_message = ("No prompt data provided. If this is an incorrect flag, "
|
|
|
90 |
)
|
91 |
except Exception as e:
|
92 |
logger.exception("Error while loading SAM2 model")
|
93 |
+
raise RuntimeError(f"Failed to load model") from e
|
94 |
|
95 |
def init_video_inference_state(self,
|
96 |
vid_input: str,
|
|
|
129 |
try:
|
130 |
generated_masks = self.mask_generator.generate(image)
|
131 |
except Exception as e:
|
132 |
+
logger.exception(f"Error while auto generating masks : {e}")
|
133 |
+
raise RuntimeError(f"Failed to generate masks") from e
|
134 |
return generated_masks
|
135 |
|
136 |
def predict_image(self,
|
|
|
155 |
)
|
156 |
except Exception as e:
|
157 |
logger.exception(f"Error while predicting image with prompt: {str(e)}")
|
158 |
+
raise RuntimeError(f"Failed to predict image with prompt") from e
|
159 |
return masks, scores, logits
|
160 |
|
161 |
def add_prediction_to_frame(self,
|
|
|
183 |
)
|
184 |
except Exception as e:
|
185 |
logger.exception(f"Error while predicting frame with prompt: {str(e)}")
|
186 |
+
raise RuntimeError(f"Failed to predicting frame with prompt") from e
|
187 |
|
188 |
return out_frame_idx, out_obj_ids, out_mask_logits
|
189 |
|
|
|
213 |
}
|
214 |
except Exception as e:
|
215 |
logger.exception(f"Error while propagating in video: {str(e)}")
|
216 |
+
raise RuntimeError(f"Failed to propagate in video") from e
|
217 |
|
218 |
return video_segments
|
219 |
|
|
|
269 |
):
|
270 |
if self.video_predictor is None or self.video_inference_state is None:
|
271 |
logger.exception("Error while adding filter to preview, load video predictor first")
|
272 |
+
raise RuntimeError("Error while adding filter to preview")
|
273 |
|
274 |
if not image_prompt_input_data["points"]:
|
275 |
error_message = ("No prompt data provided. If this is an incorrect flag, "
|