Are you sure you want to delete this access key?
comments | description | keywords |
---|---|---|
true | FastSAM์ ์ด๋ฏธ์ง์์ ์ค์๊ฐ ๊ฐ์ฒด ๋ถํ ์ ์ํ CNN ๊ธฐ๋ฐ ์๋ฃจ์ ์ผ๋ก, ํฅ์๋ ์ฌ์ฉ์ ์ํธ์์ฉ, ๊ณ์ฐ ํจ์จ์ฑ, ๋ค์ํ ๋น์ ์์ ์ ๋์ํ ์ ์๋ ํน์ง์ ๊ฐ๊ณ ์์ต๋๋ค. | FastSAM, ๋จธ์ ๋ฌ๋, CNN ๊ธฐ๋ฐ ์๋ฃจ์ , ๊ฐ์ฒด ๋ถํ , ์ค์๊ฐ ์๋ฃจ์ , Ultralytics, ๋น์ ์์ , ์ด๋ฏธ์ง ์ฒ๋ฆฌ, ์ฐ์ ์์ฉ, ์ฌ์ฉ์ ์ํธ์์ฉ |
Fast Segment Anything Model (FastSAM)์ Segment Anything ์์ ์ ์ํ ์๋ก์ด ์ค์๊ฐ CNN ๊ธฐ๋ฐ ์๋ฃจ์ ์ ๋๋ค. ์ด ์์ ์ ๋ค์ํ ์ฌ์ฉ์ ์ํธ์์ฉ ํ๋กฌํํธ์ ๋ฐ๋ผ ์ด๋ฏธ์ง ๋ด์ ๋ชจ๋ ๊ฐ์ฒด๋ฅผ ๋ถํ ํ๋ ๊ฒ์ ๋ชฉํ๋ก ํฉ๋๋ค. FastSAM์ ๊ณ์ฐ ์๊ตฌ ์ฌํญ์ ํฌ๊ฒ ์ค์ด๋ฉด์ ๊ฒฝ์๋ ฅ ์๋ ์ฑ๋ฅ์ ์ ์งํ๊ธฐ ๋๋ฌธ์ ๋ค์ํ ๋น์ ์์ ์ ์ค์ฉ์ ์ธ ์ ํ์ง๊ฐ ๋ ์ ์์ต๋๋ค.
FastSAM์ ๊ณ์ฐ ๋ฆฌ์์ค ์๊ตฌ ์ฌํญ์ด ํฐ Transformer ๋ชจ๋ธ์ธ Segment Anything Model (SAM)์ ํ๊ณ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ์ค๊ณ๋์์ต๋๋ค. FastSAM์ Segment Anything ์์ ์ ๋ ๋จ๊ณ๋ก ๋ถ๋ฆฌํ ๋ฐฉ์์ ์ฑํํฉ๋๋ค: ๋ชจ๋ ์ธ์คํด์ค ๋ถํ ๊ณผ ํ๋กฌํํธ๋ก ์ธํ ์์ญ ์ ํ. ์ฒซ ๋ฒ์งธ ๋จ๊ณ์์๋ YOLOv8-seg๋ฅผ ์ฌ์ฉํ์ฌ ์ด๋ฏธ์ง์ ๋ชจ๋ ์ธ์คํด์ค์ ๋ถํ ๋ง์คํฌ๋ฅผ ์์ฑํฉ๋๋ค. ๋ ๋ฒ์งธ ๋จ๊ณ์์๋ ํ๋กฌํํธ์ ํด๋นํ๋ ๊ด์ฌ ์์ญ์ ์ถ๋ ฅํฉ๋๋ค.
์ค์๊ฐ ์๋ฃจ์ : CNN์ ๊ณ์ฐ ํจ์จ์ฑ์ ํ์ฉํ์ฌ FastSAM์ Segment Anything ์์ ์ ๋ํ ์ค์๊ฐ ์๋ฃจ์ ์ ์ ๊ณตํ๋ฉฐ, ๋น ๋ฅธ ๊ฒฐ๊ณผ๊ฐ ํ์ํ ์ฐ์ ์์ฉ์ ๊ฐ์น๊ฐ ์์ต๋๋ค.
ํจ์จ์ฑ๊ณผ ์ฑ๋ฅ: FastSAM์ ์ฑ๋ฅ ํ์ง์ ํฌ์ํ์ง ์๊ณ ๊ณ์ฐ๊ณผ ๋ฆฌ์์ค ์๊ตฌ ์ฌํญ์ ํฌ๊ฒ ์ค์ ๋๋ค. SAM๊ณผ ๋น๊ตํด ์ ์ฌํ ์ฑ๋ฅ์ ๋ฌ์ฑํ๋ฉด์ ๊ณ์ฐ ๋ฆฌ์์ค๋ฅผ ํฌ๊ฒ ์ค์ฌ ์ค์๊ฐ ์์ฉ์ด ๊ฐ๋ฅํด์ง๋๋ค.
ํ๋กฌํํธ ์๋ด ๋ถํ : FastSAM์ ๋ค์ํ ์ฌ์ฉ์ ์ํธ์์ฉ ํ๋กฌํํธ์ ๋ฐ๋ผ ์ด๋ฏธ์ง ๋ด์ ๋ชจ๋ ๊ฐ์ฒด๋ฅผ ๋ถํ ํ ์ ์์ผ๋ฏ๋ก ๋ค์ํ ์๋๋ฆฌ์ค์์ ์ ์ฐ์ฑ๊ณผ ์ ์์ฑ์ ์ ๊ณตํฉ๋๋ค.
YOLOv8-seg ๊ธฐ๋ฐ: FastSAM์ YOLOv8-seg๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ ๊ฒ์ผ๋ก, ์ธ์คํด์ค ๋ถํ ๋ธ๋์น๊ฐ ์ฅ์ฐฉ๋ ๊ฐ์ฒด ๊ฐ์ง๊ธฐ์ ๋๋ค. ์ด๋ฅผ ํตํด ์ด๋ฏธ์ง์ ๋ชจ๋ ์ธ์คํด์ค์ ๋ถํ ๋ง์คํฌ๋ฅผ ํจ๊ณผ์ ์ผ๋ก ์์ฑํ ์ ์์ต๋๋ค.
๋ฒค์น๋งํฌ์์ ๊ฒฝ์ ๊ฒฐ๊ณผ: MS COCO์์์ ๊ฐ์ฒด ์ ์ ์์ ์์ FastSAM์ SAM์ ๋นํด ๋จ์ผ NVIDIA RTX 3090์์ ํจ์ฌ ๋ ๋น ๋ฅธ ์๋๋ก ๋์ ์ ์๋ฅผ ๋ฌ์ฑํ์ฌ ํจ์จ์ฑ๊ณผ ๋ฅ๋ ฅ์ ์ ์ฆํ์ต๋๋ค.
์ค์ฉ์ ์ธ ์์ฉ: FastSAM์ ํ์ฌ ๋ฐฉ๋ฒ๋ณด๋ค ์์ญ ๋ฐฐ ๋๋ ์๋ฐฑ ๋ฐฐ ๋ ๋น ๋ฅธ ์๋๋ก ์ฌ๋ฌ ๋น์ ์์ ์ ์ ์ํ ์๋ฃจ์ ์ ์ ๊ณตํ์ฌ ์ค์ง์ ์ธ ์ ์ฉ ๊ฐ๋ฅ์ฑ์ ์ ์ํฉ๋๋ค.
๋ชจ๋ธ ์์ถ ๊ฐ๋ฅ์ฑ: FastSAM์ ๊ตฌ์กฐ์ ์ธ๊ณต ์ฌ์ ์ ๋์ ํ์ฌ ๊ณ์ฐ ๋น์ฉ์ ํฌ๊ฒ ์ค์ผ ์ ์๋ ๊ฒฝ๋ก๋ฅผ ๋ณด์ฌ์ฃผ์ด ์ผ๋ฐ ๋น์ ์์ ์ ๋ํ ๋ํ ๋ชจ๋ธ ์ํคํ ์ฒ์ ๋ํ ์๋ก์ด ๊ฐ๋ฅ์ฑ์ ์ด์ด์ค๋๋ค.
์ด ํ๋ ์ฌ์ฉ ๊ฐ๋ฅํ ๋ชจ๋ธ๊ณผ ํด๋นํ๋ ์ฌ์ ํ๋ จ ๊ฐ์ค์น, ์ง์ํ๋ ์์ ๋ฐ Inference, Validation, Training, Export์ ๊ฐ์ ๋ค๋ฅธ ์ด์ ๋ชจ๋์ ๋ํ ํธํ์ฑ์ ๋ํ๋ด๋ฉฐ, ์ง์๋๋ ๋ชจ๋๋ โ ์ด๋ชจ์ง๋ก, ์ง์๋์ง ์๋ ๋ชจ๋๋ โ ์ด๋ชจ์ง๋ก ํ์๋ฉ๋๋ค.
๋ชจ๋ธ ์ ํ | ์ฌ์ ํ๋ จ ๊ฐ์ค์น | ์ง์๋๋ ์์ | Inference | Validation | Training | Export |
---|---|---|---|---|---|---|
FastSAM-s | FastSAM-s.pt |
์ธ์คํด์ค ๋ถํ | โ | โ | โ | โ |
FastSAM-x | FastSAM-x.pt |
์ธ์คํด์ค ๋ถํ | โ | โ | โ | โ |
FastSAM ๋ชจ๋ธ์ Python ์ ํ๋ฆฌ์ผ์ด์ ์ ์ฝ๊ฒ ํตํฉํ ์ ์์ต๋๋ค. Ultralytics๋ ๊ฐ๋ฐ์ ๊ฐ์ํํ๊ธฐ ์ํด ์ฌ์ฉ์ ์นํ์ ์ธ Python API ๋ฐ CLI ๋ช ๋ น์ ์ ๊ณตํฉ๋๋ค.
์ด๋ฏธ์ง์์ ๊ฐ์ฒด ๊ฒ์ถ์ ์ํํ๋ ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด predict
๋ฉ์๋๋ฅผ ์ฌ์ฉํฉ๋๋ค:
!!! Example "์์ "
=== "Python"
```python
from ultralytics import FastSAM
from ultralytics.models.fastsam import FastSAMPrompt
# ์ถ๋ก ์์ค ์ ์
source = 'path/to/bus.jpg'
# FastSAM ๋ชจ๋ธ ์์ฑ
model = FastSAM('FastSAM-s.pt') # ๋๋ FastSAM-x.pt
# ์ด๋ฏธ์ง์ ๋ํ ์ถ๋ก ์คํ
everything_results = model(source, device='cpu', retina_masks=True, imgsz=1024, conf=0.4, iou=0.9)
# Prompt Process ๊ฐ์ฒด ์ค๋น
prompt_process = FastSAMPrompt(source, everything_results, device='cpu')
# ๋ชจ๋ ํ๋กฌํํธ
ann = prompt_process.everything_prompt()
# ๋ฐ์ด๋ฉ ๋ฐ์ค์ ๊ธฐ๋ณธ ๋ชจ์์ [0,0,0,0]์์ [x1,y1,x2,y2]๋ก ๋ณ๊ฒฝ
ann = prompt_process.box_prompt(bbox=[200, 200, 300, 300])
# ํ
์คํธ ํ๋กฌํํธ
ann = prompt_process.text_prompt(text='a photo of a dog')
# ํฌ์ธํธ ํ๋กฌํํธ
# ๊ธฐ๋ณธ ํฌ์ธํธ [[0,0]] [[x1,y1],[x2,y2]]
# ๊ธฐ๋ณธ ํฌ์ธํธ ๋ ์ด๋ธ [0] [1,0] 0:๋ฐฐ๊ฒฝ, 1:์ ๊ฒฝ
ann = prompt_process.point_prompt(points=[[200, 200]], pointlabel=[1])
prompt_process.plot(annotations=ann, output='./')
```
=== "CLI"
```bash
# FastSAM ๋ชจ๋ธ ๋ก๋ ๋ฐ ๋ชจ๋ ๊ฒ์ ์ธ๋ถํํ์ฌ ์ถ์ถ
yolo segment predict model=FastSAM-s.pt source=path/to/bus.jpg imgsz=640
```
์ด ์ฝ๋ ์กฐ๊ฐ์ ์ฌ์ ํ๋ จ๋ ๋ชจ๋ธ์ ๋ก๋ํ๊ณ ์ด๋ฏธ์ง์ ๋ํ ์์ธก์ ์คํํ๋ ๊ฐํธํจ์ ๋ณด์ฌ์ค๋๋ค.
๋ฐ์ดํฐ์ ์์ ๋ชจ๋ธ์ ๊ฒ์ฆํ๋ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
!!! Example "์์ "
=== "Python"
```python
from ultralytics import FastSAM
# FastSAM ๋ชจ๋ธ ์์ฑ
model = FastSAM('FastSAM-s.pt') # ๋๋ FastSAM-x.pt
# ๋ชจ๋ธ ๊ฒ์ฆ
results = model.val(data='coco8-seg.yaml')
```
=== "CLI"
```bash
# FastSAM ๋ชจ๋ธ ๋ก๋ ๋ฐ ์ด๋ฏธ์ง ํฌ๊ธฐ 640์์ COCO8 ์์ ๋ฐ์ดํฐ์
์ ๋ํด ์ ํจ์ฑ ๊ฒ์ฌ
yolo segment val model=FastSAM-s.pt data=coco8.yaml imgsz=640
```
FastSAM์ ๋จ์ผ ํด๋์ค ๊ฐ์ฒด์ ๊ฐ์ง์ ๋ถํ ๋ง ์ง์ํฉ๋๋ค. ์ด๋ ๋ชจ๋ ๊ฐ์ฒด๋ฅผ ๋์ผํ ํด๋์ค๋ก ์ธ์ํ๊ณ ๋ถํ ํ๋ค๋ ์๋ฏธ์ ๋๋ค. ๋ฐ๋ผ์ ๋ฐ์ดํฐ์ ์ ์ค๋นํ ๋ ๋ชจ๋ ๊ฐ์ฒด ์นดํ ๊ณ ๋ฆฌ ID๋ฅผ 0์ผ๋ก ๋ณํํด์ผ ํฉ๋๋ค.
FastSAM์ https://github.com/CASIA-IVA-Lab/FastSAM ์ ์ฅ์์์ ์ง์ ์ฌ์ฉํ ์๋ ์์ต๋๋ค. FastSAM์ ์ฌ์ฉํ๊ธฐ ์ํด ์ํํ ์ผ๋ฐ์ ์ธ ๋จ๊ณ๋ฅผ ๊ฐ๋จํ ์๊ฐํฉ๋๋ค:
FastSAM ์ ์ฅ์๋ฅผ ๋ณต์ ํฉ๋๋ค:
git clone https://github.com/CASIA-IVA-Lab/FastSAM.git
Python 3.9๋ก Conda ํ๊ฒฝ์ ์์ฑํ๊ณ ํ์ฑํํฉ๋๋ค:
conda create -n FastSAM python=3.9
conda activate FastSAM
๋ณต์ ํ ์ ์ฅ์๋ก ์ด๋ํ์ฌ ํ์ํ ํจํค์ง๋ฅผ ์ค์นํฉ๋๋ค:
cd FastSAM
pip install -r requirements.txt
CLIP ๋ชจ๋ธ์ ์ค์นํฉ๋๋ค:
pip install git+https://github.com/openai/CLIP.git
๋ชจ๋ธ ์ฒดํฌํฌ์ธํธ๋ฅผ ๋ค์ด๋ก๋ํฉ๋๋ค.
FastSAM์ ์ถ๋ก ํ๊ธฐ ์ํด ๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉํฉ๋๋ค. ์์ ๋ช ๋ น์ด:
์ด๋ฏธ์ง์์ ๋ชจ๋ ๊ฒ์ ์ธ๋ถํ:
python Inference.py --model_path ./weights/FastSAM.pt --img_path ./images/dogs.jpg
ํ ์คํธ ํ๋กฌํํธ๋ฅผ ์ฌ์ฉํ์ฌ ํน์ ๊ฐ์ฒด๋ฅผ ์ธ๋ถํ:
python Inference.py --model_path ./weights/FastSAM.pt --img_path ./images/dogs.jpg --text_prompt "the yellow dog"
๋ฐ์ด๋ฉ ๋ฐ์ค ๋ด์ ๊ฐ์ฒด๋ฅผ ์ธ๋ถํ (xywh ํ์์ผ๋ก ์์ ์ขํ ์ ๊ณต):
python Inference.py --model_path ./weights/FastSAM.pt --img_path ./images/dogs.jpg --box_prompt "[570,200,230,400]"
ํน์ ์ง์ ๊ทผ์ฒ์ ๊ฐ์ฒด๋ฅผ ์ธ๋ถํ:
python Inference.py --model_path ./weights/FastSAM.pt --img_path ./images/dogs.jpg --point_prompt "[[520,360],[620,300]]" --point_label "[1,0]"
๋ํ, FastSAM์ Colab ๋ฐ๋ชจ ๋๋ HuggingFace ์น ๋ฐ๋ชจ์์ ์๊ฐ์ ์ธ ๊ฒฝํ์ผ๋ก ์๋ํด ๋ณผ ์ ์์ต๋๋ค.
FastSAM์ ์ค์๊ฐ ์ธ์คํด์ค ๋ถํ ๋ถ์ผ์ ๋ํ ํ์ ์ ์ธ ๊ธฐ์ฌ๋ฅผ ์ํด FastSAM ์ ์๋ค์๊ฒ ๊ฐ์ฌ์ ๋ง์์ ์ ํฉ๋๋ค:
!!! Quote ""
=== "BibTeX"
```bibtex
@misc{zhao2023fast,
title={Fast Segment Anything},
author={Xu Zhao and Wenchao Ding and Yongqi An and Yinglong Du and Tao Yu and Min Li and Ming Tang and Jinqiao Wang},
year={2023},
eprint={2306.12156},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
```
FastSAM ์๋ณธ ๋ ผ๋ฌธ์ arXiv์์ ์ฐพ์ ์ ์์ต๋๋ค. ์ ์๋ค์ ์์ ๋ค์ ์์ ์ ๊ณต๊ฐ์ ์ผ๋ก ์ ๊ณตํ์์ผ๋ฉฐ, ์ฝ๋๋ฒ ์ด์ค๋ GitHub์์ ์ด์ฉํ ์ ์์ต๋๋ค. ์ ์๋ค์ ๋ ธ๋ ฅ์ ๊ฐ์ฌ๋๋ฆฌ๋ฉฐ ์ ์๋ฌผ์ ๋ ํญ๋์ ์ปค๋ฎค๋ํฐ์ ์๋ฆฌ๊ธฐ ์ํ ๊ธฐ์ฌ๋ฅผ ๊ธฐ๋ํฉ๋๋ค.
Press p or to see the previous file or, n or to see the next file
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?