Spaces:
Runtime error
Runtime error
JeffLiang
commited on
Commit
·
85fdfea
1
Parent(s):
0e0710e
memory saving
Browse files
open_vocab_seg/utils/predictor.py
CHANGED
@@ -158,8 +158,8 @@ class SAMVisualizationDemo(object):
|
|
158 |
def run_on_image(self, image, class_names):
|
159 |
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
160 |
visualizer = OVSegVisualizer(image, self.metadata, instance_mode=self.instance_mode, class_names=class_names)
|
161 |
-
|
162 |
-
|
163 |
pred_masks = [masks[i]['segmentation'][None,:,:] for i in range(len(masks))]
|
164 |
pred_masks = np.row_stack(pred_masks)
|
165 |
pred_masks = BitMasks(pred_masks)
|
|
|
158 |
def run_on_image(self, image, class_names):
|
159 |
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
160 |
visualizer = OVSegVisualizer(image, self.metadata, instance_mode=self.instance_mode, class_names=class_names)
|
161 |
+
with torch.no_grad(), torch.cuda.amp.autocast():
|
162 |
+
masks = self.predictor.generate(image)
|
163 |
pred_masks = [masks[i]['segmentation'][None,:,:] for i in range(len(masks))]
|
164 |
pred_masks = np.row_stack(pred_masks)
|
165 |
pred_masks = BitMasks(pred_masks)
|