SAM 2 | Segment Anything Model 2
Вставка
- Опубліковано 16 гру 2024
- Meta AI has released Segment Anything 2 (SAM 2), an advanced image and video segmentation foundation model. SAM 2 allows users to input points in an image to generate segmentation masks for those points, and it can also generate and track segmentation masks across frames in a video.
Segment Anything 2 (SAM 2) by Meta AI is open-source. It is a follow-up to the original Segment Anything Model (SAM) and is designed to enable zero-shot segmentation of objects in images.
Building on the original SAM model released by Meta last year, SAM 2 has been utilized for various vision applications, including image segmentation and as an image labeling assistant. Meta reports that SAM 2 is six times more accurate than its predecessor in image segmentation tasks.
In this guide, we will explore what Segment Anything 2 is, how it functions, and how you can leverage the model for image segmentation tasks.
Steps to run SAM 2:
conda create -n samm python=3.12
conda activate samm
git clone github.com/fac...
cd segment-anything-2
python setup.py build_ext --inplace
%cd checkpoints
double click on it. Model checkpoints will be downloaded in your directory.
Then install this- we need this to us the SAM 2 predictor and run the example notebooks,
pip install --no-build-isolation -e ".[demo]"
conda install jupyter notebook
jupyter notebook
I appreciate you creating these videos on modern technology.
Thank you so much!
Very clear and good explaination. Thank you Ma'am.
Very nice explanation!❤
Thank you! 😃
Wonderful explanation mam
Thanks a lot
Thanks . Great explanation 👍
Glad it was helpful!
Thanks Madam, great explanation 👍
You are welcome 😊
Great explanation, thanks a lot 😊
Welcome 😊
Madam if we want to fine tune the model for videos based on mask decoder how to do it.
As usual great video. Image segmentation. Two questions..
1st how to find the appropriate point cordinate of the object of interest?
2nd Can you add demonstrations of image and video segmentation other than the existing git repo? Just to see actual model response?
You can use object detection model to find the coordinates and then pass those coordinates to SAM in order to put mask on.
@@CodeWithAarohi But What if I want reverse operation? How to perform object detection using SAM? Any suggestion would be help in better understanding.
Thanks Aarohi, greetings from chile
Welcome 🙂
How can we label the identified masked, let's say list of labels? what could be thought process sort of? coming from context like template matching
I just wanna know how can we use this model to our project, as an AI enthusiast, one of biggest question is that, is their any need to create our own model now, or we have to change few lines in others jupyter notebook code claim it is as ours?
BTW great explanation
SAM 2 is open-source and designed to enable zero-shot segmentation of objects in images.
The decision to create your own AI model versus adapting existing ones depends on several factors:
1- If you have a unique problem or a highly specialized dataset that existing models are not well-suited for, creating your own model may be necessary.
2- If you need a model that is highly optimized for your specific use case, including performance, accuracy, or computational efficiency.
3- If owning the intellectual property of the model is important for your business or research.
For many common problems, such as image classification, object detection, and text generation, existing models are mostly sufficient and can be fine-tuned or adapted to your specific needs. Training a new model from scratch can be resource-intensive in terms of both time and computational power, so fine-tuning existing models can be a more efficient approach.
so how can you actually export the masked out subject as a separate video without the extra stuff? Where are the elements of the graph and other assets
Noted!
This is very helpful to me. However, regarding the details of the memory module, I still need to study them further. I'm just a beginner 😭
Glad it was helpful!
Hi can you create a video using tensorRT on SAM2 to reduce inference time?
Noted!
ok, but if we compare SAM 2 to Yolo, then what are the differences, also I guess different use-cases?
I mean, with yolo, I train the model to detect a certain item on a picture or a video, and after that I can feed it random new video/picture and my items will get detected.
But with SAM 2, is there a similar use case?
SAM is segmentation mode designed to segment anything in an image where as yolo is object detection model designed to identify object in video. Correct me If I am wrong.
@@work.aniketkumar you're correct. My current usecase is to use SAM2 for dataset creation. So I created a tool that uses SAM2 to create segment label files for images. Basically I created a roboflow copy, but it all lives in my workstation.
@@work.aniketkumar remember, Mask-RCNN has both segmentation and detection. So can we think of a pipeline using SAM that is similar to Mask RCNN?
Gr8 video as usual. Pls share code. Also why it is 6x faster ?
SAM 2 utilizes a more efficient model architecture compared to SAM, which reduces the computational complexity and speeds up the segmentation process.
@CodeWithAarohi need to run it and chk. Tt
Aarohi, pip install -e . is not working, you said in description details provided but no details found.
I have added now. Please check description section.
@@CodeWithAarohi thanks
Your videos are great help for new people like us. WOndering why you choose anaconda over Google colab for SAM 2 ? ALso in SAM1 they provided colab notebooks from Meta, did they provided those this time ?
From where to get python codes for this?
can you do it with videos like the blog meta demo please?
Sure
Mam Can we run it on Jetson agx orin
Yes
Highly Appreciated Aarohi. When you have time kindly make a videos on Semi and Self Supervised Learning. A Humble request. :)
Noted. Sure I will make videos on Semi and Self Supervised Learning.
@@CodeWithAarohi Thank you so much. Stay Blessed ✨
did you faced this error ?
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Cell In[1], line 5
3 os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
4 import numpy as np
----> 5 import torch
6 import matplotlib.pyplot as plt
7 from PIL import Image
File ~\AppData\Local\anaconda3\envs\sam2\Lib\site-packages\torch\__init__.py:148
146 err = ctypes.WinError(ctypes.get_last_error())
147 err.strerror += f' Error loading "{dll}" or one of its dependencies.'
--> 148 raise err
150 kernel32.SetErrorMode(prev_error_mode)
153 def _preload_cuda_deps(lib_folder, lib_name):
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\ss7a0328\AppData\Local\anaconda3\envs\sam2\Lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.