Alessio Grancini commited on
Update image_segmenter.py
Browse files- image_segmenter.py +11 -17
image_segmenter.py
CHANGED
|
@@ -7,23 +7,17 @@ import spaces
|
|
| 7 |
|
| 8 |
class ImageSegmenter:
|
| 9 |
def __init__(self, model_type="yolov8s-seg") -> None:
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
# variables
|
| 23 |
-
self.masks = {}
|
| 24 |
-
|
| 25 |
-
# Model will be loaded in predict to work with ZeroGPU
|
| 26 |
-
self.model = None
|
| 27 |
|
| 28 |
def get_cls_clr(self, cls_id):
|
| 29 |
if cls_id in self.cls_clr:
|
|
|
|
| 7 |
|
| 8 |
class ImageSegmenter:
|
| 9 |
def __init__(self, model_type="yolov8s-seg") -> None:
|
| 10 |
+
# Don't initialize CUDA here
|
| 11 |
+
self.model_type = model_type
|
| 12 |
+
self.is_show_bounding_boxes = True
|
| 13 |
+
self.is_show_segmentation_boundary = False
|
| 14 |
+
self.is_show_segmentation = False
|
| 15 |
+
self.confidence_threshold = 0.5
|
| 16 |
+
self.cls_clr = {}
|
| 17 |
+
self.bb_thickness = 2
|
| 18 |
+
self.bb_clr = (255, 0, 0)
|
| 19 |
+
self.masks = {}
|
| 20 |
+
self.model = None # Model will be loaded in predict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
def get_cls_clr(self, cls_id):
|
| 23 |
if cls_id in self.cls_clr:
|