-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error importing sam2/_C.so when running the video_predictor_example.ipynb #77
Comments
!python setup.py build_ext --inplace worked for me run the above command at the beginning of the jupyter / colab notebook. |
I'm having the same issue.Pls have you solved it? |
@vanamagautam24 thanks! it works for me! |
Hi, we have added Regarding this error: This is usually because you haven't run the |
Thank you, What worked for me was running these commands in my Colab Notebook: %cd /content/segment-anything-2 Run the above commands after building the relevant sam2 model. This should help build the _C module appropriately. |
I am getting the following error when I run the line of code that says:
The main import error message is:
ImportError: /content/segment-anything-2/sam2/_C.so: undefined symbol: _ZN3c1015SmallVectorBaseIjE8grow_podEPKvmm
This is the entire error:
ImportError Traceback (most recent call last)
in <cell line: 8>()
6 # for labels,
1
means positive click and0
means negative click7 labels = np.array([1], np.int32)
----> 8 _, out_obj_ids, out_mask_logits = predictor.add_new_points(
9 inference_state=inference_state,
10 frame_idx=ann_frame_idx,
4 frames
/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py in decorate_context(*args, **kwargs)
113 def decorate_context(*args, **kwargs):
114 with ctx_factory():
--> 115 return func(*args, **kwargs)
116
117 return decorate_context
/content/segment-anything-2/sam2/sam2_video_predictor.py in add_new_points(self, inference_state, frame_idx, obj_id, points, labels, clear_old_points, normalize_coords)
219 # Clamp the scale of prev_sam_mask_logits to avoid rare numerical issues.
220 prev_sam_mask_logits = torch.clamp(prev_sam_mask_logits, -32.0, 32.0)
--> 221 current_out, _ = self._run_single_frame_inference(
222 inference_state=inference_state,
223 output_dict=obj_output_dict, # run on the slice of a single object
/content/segment-anything-2/sam2/sam2_video_predictor.py in _run_single_frame_inference(self, inference_state, output_dict, frame_idx, batch_size, is_init_cond_frame, point_inputs, mask_inputs, reverse, run_mem_encoder, prev_sam_mask_logits)
808 # potentially fill holes in the predicted masks
809 if self.fill_hole_area > 0:
--> 810 pred_masks_gpu = fill_holes_in_mask_scores(
811 pred_masks_gpu, self.fill_hole_area
812 )
/content/segment-anything-2/sam2/utils/misc.py in fill_holes_in_mask_scores(mask, max_area)
221 # (background regions are those with mask scores <= 0)
222 assert max_area > 0, "max_area must be positive"
--> 223 labels, areas = get_connected_components(mask <= 0)
224 is_hole = (labels > 0) & (areas <= max_area)
225 # We fill holes with a small positive mask score (0.1) to change them to foreground.
/content/segment-anything-2/sam2/utils/misc.py in get_connected_components(mask)
59 components for foreground pixels and 0 for background pixels.
60 """
---> 61 from sam2 import _C
62
63 return _C.get_connected_componnets(mask.to(torch.uint8).contiguous())
ImportError: /content/segment-anything-2/sam2/_C.so: undefined symbol: _ZN3c1015SmallVectorBaseIjE8grow_podEPKvmm
Can you please help out with this issue. It would enable me to proceed with the project. Not sure how to fix it.
The text was updated successfully, but these errors were encountered: