Segment Anything
1. 論文
論文鏈接:https://arxiv.org/pdf/2304.02643.pdf
論文解讀后續(xù)更新……
2. 官方文檔
官方文檔:https://ai.facebook.com/blog/segment-anything-foundation-model-image-segmentation/
項目地址:https://github.com/facebookresearch/segment-anything
3. 測試網站
demo地址:https://segment-anything.com/demo
我自己上傳了一張圖片,結果還是挺好的(我上傳的圖片比較簡單)。
4. 本地測試
4.1 下載預訓練權重
https://github.com/facebookresearch/segment-anything#model-checkpoints
4.2 新建get_masks.py
新建get_masks.py
內容如下:
from segment_anything import build_sam, SamPredictor
import numpy as np
import cv2
image = cv2.imread('/home/scholar/ldw/segment-anything/images/01.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
predictor = SamPredictor(build_sam(checkpoint="/data_1/ldw_checkpoints/segment-anything/sam_vit_l_0b3195.pth"))
predictor.set_image(image)
input_point = np.array([[500, 375]])
input_label = np.array([1])
masks, _, _ = predictor.predict( point_coords=input_point,
point_labels=input_label,
multimask_output=True,)
print('Done')
由于自己的3090顯存有限,無法使用build_sam_vit_hpth
,所以選用了build_sam_vit_l.pth
修改segment_anything/build_sam.py
文章來源:http://www.zghlxwxcb.cn/news/detail-416802.html
build_sam = build_sam_vit_l
sam_model_registry = {
"default": build_sam_vit_l,
"vit_h": build_sam,
"vit_l": build_sam_vit_l,
"vit_b": build_sam_vit_b,
}
4.4 測試
# origin
python scripts/amg.py --checkpoint <path/to/sam/checkpoint> --input <image_or_folder> --output <output_directory>
# mine
python scripts/amg.py --checkpoint '/data_1/ldw_checkpoints/segment-anything/sam_vit_l_0b3195.pth' --input '/home/scholar/ldw/segment-anything/images/01.jpg' --output 'output'
文章來源地址http://www.zghlxwxcb.cn/news/detail-416802.html
到了這里,關于【Segment Anything】CV的大模型Segment Anything也來了,強人工智能的時代究竟還有多遠?的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!