Spaces:
Running
Running
jhj0517
commited on
Commit
·
5f8864d
1
Parent(s):
5682a2c
Add logger
Browse files- modules/sam_inference.py +4 -0
modules/sam_inference.py
CHANGED
|
@@ -19,6 +19,7 @@ from modules.mask_utils import (
|
|
| 19 |
create_mask_combined_images,
|
| 20 |
create_mask_gallery
|
| 21 |
)
|
|
|
|
| 22 |
|
| 23 |
CONFIGS = {
|
| 24 |
"sam2_hiera_tiny": os.path.join(SAM2_CONFIGS_DIR, "sam2_hiera_t.yaml"),
|
|
@@ -26,6 +27,7 @@ CONFIGS = {
|
|
| 26 |
"sam2_hiera_base_plus": os.path.join(SAM2_CONFIGS_DIR, "sam2_hiera_b+.yaml"),
|
| 27 |
"sam2_hiera_large": os.path.join(SAM2_CONFIGS_DIR, "sam2_hiera_l.yaml"),
|
| 28 |
}
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
class SamInference:
|
|
@@ -77,6 +79,7 @@ class SamInference:
|
|
| 77 |
try:
|
| 78 |
generated_masks = self.mask_generator.generate(image)
|
| 79 |
except Exception as e:
|
|
|
|
| 80 |
raise f"Error while auto generating masks: {e}"
|
| 81 |
return generated_masks
|
| 82 |
|
|
@@ -101,6 +104,7 @@ class SamInference:
|
|
| 101 |
multimask_output=params["multimask_output"],
|
| 102 |
)
|
| 103 |
except Exception as e:
|
|
|
|
| 104 |
raise f"Error while predicting image with prompt: {e}"
|
| 105 |
return masks, scores, logits
|
| 106 |
|
|
|
|
| 19 |
create_mask_combined_images,
|
| 20 |
create_mask_gallery
|
| 21 |
)
|
| 22 |
+
from modules.logger_util import get_logger
|
| 23 |
|
| 24 |
CONFIGS = {
|
| 25 |
"sam2_hiera_tiny": os.path.join(SAM2_CONFIGS_DIR, "sam2_hiera_t.yaml"),
|
|
|
|
| 27 |
"sam2_hiera_base_plus": os.path.join(SAM2_CONFIGS_DIR, "sam2_hiera_b+.yaml"),
|
| 28 |
"sam2_hiera_large": os.path.join(SAM2_CONFIGS_DIR, "sam2_hiera_l.yaml"),
|
| 29 |
}
|
| 30 |
+
logger = get_logger()
|
| 31 |
|
| 32 |
|
| 33 |
class SamInference:
|
|
|
|
| 79 |
try:
|
| 80 |
generated_masks = self.mask_generator.generate(image)
|
| 81 |
except Exception as e:
|
| 82 |
+
logger.exception("Error while auto generating masks")
|
| 83 |
raise f"Error while auto generating masks: {e}"
|
| 84 |
return generated_masks
|
| 85 |
|
|
|
|
| 104 |
multimask_output=params["multimask_output"],
|
| 105 |
)
|
| 106 |
except Exception as e:
|
| 107 |
+
logger.exception("Error while predicting image with prompt")
|
| 108 |
raise f"Error while predicting image with prompt: {e}"
|
| 109 |
return masks, scores, logits
|
| 110 |
|