Grounding DINO[[grounding-dino]]
๊ฐ์[[overview]]
Grounding DINO ๋ชจ๋ธ์ Shilong Liu, Zhaoyang Zeng, Tianhe Ren, Feng Li, Hao Zhang, Jie Yang, Chunyuan Li, Jianwei Yang, Hang Su, Jun Zhu, Lei Zhang์ด Grounding DINO: Marrying DINO with Grounded Pre-Training for Open-Set Object Detection์์ ์ ์ํ ๋ชจ๋ธ์ ๋๋ค. Grounding DINO๋ ํ์ํ ๊ฐ์ฒด ํ์ง ๋ชจ๋ธ์ ํ ์คํธ ์ธ์ฝ๋๋ก ํ์ฅํ์ฌ ๊ฐ๋ฐฉํ ๊ฐ์ฒด ํ์ง๋ฅผ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค. ์ด ๋ชจ๋ธ์ COCO ์ ๋ก์ท์์ 52.5 AP์ ๊ฐ์ ๋๋ผ์ด ๊ฒฐ๊ณผ๋ฅผ ๋ฌ์ฑํฉ๋๋ค.
๋ ผ๋ฌธ์ ์ด๋ก์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
๋ณธ ๋ ผ๋ฌธ์์๋ ํธ๋์คํฌ๋จธ ๊ธฐ๋ฐ ํ์ง๊ธฐ DINO๋ฅผ ๊ธฐ๋ฐ ์ฌ์ ํ์ต๊ณผ ๊ฒฐํฉํ์ฌ Grounding DINO๋ผ๋ ๊ฐ๋ฐฉํ ๊ฐ์ฒด ํ์ง๊ธฐ๋ฅผ ์ ์ํฉ๋๋ค. ์ด๋ ์นดํ ๊ณ ๋ฆฌ ์ด๋ฆ์ด๋ ์ฐธ์กฐ ํํ ๋ฑ์ ์ฌ์ฉ์ ์ ๋ ฅ์ผ๋ก ์์์ ๊ฐ์ฒด๋ฅผ ํ์งํ ์ ์์ต๋๋ค. ๊ฐ๋ฐฉํ ๊ฐ์ฒด ํ์ง์ ํต์ฌ ํด๊ฒฐ์ฑ ์ ๊ฐ๋ฐฉํ ๊ฐ๋ ์ผ๋ฐํ๋ฅผ ์ํด ํ์ํ ํ์ง๊ธฐ์ ์ธ์ด๋ฅผ ๋์ ํ๋ ๊ฒ์ ๋๋ค. ์ธ์ด์ ๋น์ ๋ชจ๋ฌ๋ฆฌํฐ๋ฅผ ํจ๊ณผ์ ์ผ๋ก ์ตํฉํ๊ธฐ ์ํด, ํ์ํ ํ์ง๊ธฐ๋ฅผ ๊ฐ๋ ์ ์ผ๋ก ์ธ ๋จ๊ณ๋ก ๋๋์ด ํน์ฑ ๊ฐํ๊ธฐ, ์ธ์ด ๊ธฐ๋ฐ ์ฟผ๋ฆฌ ์ ํ, ๊ต์ฐจ ๋ชจ๋ฌ๋ฆฌํฐ ์ตํฉ์ ์ํ ๊ต์ฐจ ๋ชจ๋ฌ๋ฆฌํฐ ๋์ฝ๋๋ฅผ ํฌํจํ๋ ๊ธด๋ฐํ ์ตํฉ ์๋ฃจ์ ์ ์ ์ํฉ๋๋ค. ์ด์ ์ฐ๊ตฌ๋ค์ด ์ฃผ๋ก ์๋ก์ด ์นดํ ๊ณ ๋ฆฌ์ ๋ํ ๊ฐ๋ฐฉํ ๊ฐ์ฒด ํ์ง๋ฅผ ํ๊ฐํ ๋ฐ๋ฉด, ์ฐ๋ฆฌ๋ ์์ฑ์ผ๋ก ์ง์ ๋ ๊ฐ์ฒด์ ๋ํ ์ฐธ์กฐ ํํ ์ดํด์ ๋ํ ํ๊ฐ๋ ์ํํ ๊ฒ์ ์ ์ํฉ๋๋ค. Grounding DINO๋ COCO, LVIS, ODinW, RefCOCO/+/g ๋ฒค์น๋งํฌ๋ฅผ ํฌํจํ ์ธ ๊ฐ์ง ์ค์ ๋ชจ๋์์ ๋๋ผ์ด ์ฑ๋ฅ์ ๋ณด์ ๋๋ค. Grounding DINO๋ COCO ํ์ง ์ ๋ก์ท ์ ์ด ๋ฒค์น๋งํฌ์์ 52.5 AP(Average Precision, ํ๊ท ์ ๋ฐ๋)๋ฅผ ๋ฌ์ฑํ์ต๋๋ค. ์ฆ, COCO์ ํ์ต ๋ฐ์ดํฐ ์์ด๋ ์ด๋ฌํ ์ฑ๊ณผ๋ฅผ ์ป์์ต๋๋ค. ํ๊ท 26.1 AP๋ก ODinW ์ ๋ก์ท ๋ฒค์น๋งํฌ์์ ์๋ก์ด ๊ธฐ๋ก์ ์ธ์ ์ต๋๋ค.

Grounding DINO ๊ฐ์. ์๋ณธ ๋ ผ๋ฌธ์์ ๊ฐ์ ธ์์ต๋๋ค.
์ด ๋ชจ๋ธ์ EduardoPacheco์ nielsr์ ์ํด ๊ธฐ์ฌ๋์์ต๋๋ค. ์๋ณธ ์ฝ๋๋ ์ฌ๊ธฐ์์ ์ฐพ์ ์ ์์ต๋๋ค.
์ฌ์ฉ ํ[[usage-tips]]
- [
GroundingDinoProcessor]๋ฅผ ์ฌ์ฉํ์ฌ ๋ชจ๋ธ์ ์ํ ์ด๋ฏธ์ง-ํ ์คํธ ์์ ์ค๋นํ ์ ์์ต๋๋ค. - ํ ์คํธ์์ ํด๋์ค๋ฅผ ๊ตฌ๋ถํ ๋๋ ๋ง์นจํ๋ฅผ ์ฌ์ฉํ์ธ์. ์: "a cat. a dog."
- ์ฌ๋ฌ ํด๋์ค๋ฅผ ์ฌ์ฉํ ๋(์:
"a cat. a dog."), [GroundingDinoProcessor]์post_process_grounded_object_detection์ ์ฌ์ฉํด ์ถ๋ ฅ์ ํ์ฒ๋ฆฌํด์ผ ํฉ๋๋ค.post_process_object_detection์์ ๋ฐํ๋๋ ๋ ์ด๋ธ์ prob > threshold์ธ ๋ชจ๋ธ ์ฐจ์์ ์ธ๋ฑ์ค๋ฅผ ๋ํ๋ด๊ธฐ ๋๋ฌธ์ ๋๋ค.
๋ค์์ ์ ๋ก์ท ๊ฐ์ฒด ํ์ง์ ๋ชจ๋ธ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋๋ค:
>>> import requests
>>> import torch
>>> from PIL import Image
>>> from transformers import AutoProcessor, AutoModelForZeroShotObjectDetection
>>> model_id = "IDEA-Research/grounding-dino-tiny"
>>> device = "cuda"
>>> processor = AutoProcessor.from_pretrained(model_id)
>>> model = AutoModelForZeroShotObjectDetection.from_pretrained(model_id).to(device)
>>> image_url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Image.open(requests.get(image_url, stream=True).raw)
>>> # ๊ณ ์์ด์ ๋ฆฌ๋ชจ์ปจ ํ์ธ
>>> text_labels = [["a cat", "a remote control"]]
>>> inputs = processor(images=image, text=text_labels, return_tensors="pt").to(device)
>>> with torch.no_grad():
... outputs = model(**inputs)
>>> results = processor.post_process_grounded_object_detection(
... outputs,
... inputs.input_ids,
... box_threshold=0.4,
... text_threshold=0.3,
... target_sizes=[image.size[::-1]]
... )
# ์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ
>>> result = results[0]
>>> for box, score, labels in zip(result["boxes"], result["scores"], result["labels"]):
... box = [round(x, 2) for x in box.tolist()]
... print(f"Detected {labels} with confidence {round(score.item(), 3)} at location {box}")
Detected a cat with confidence 0.468 at location [344.78, 22.9, 637.3, 373.62]
Detected a cat with confidence 0.426 at location [11.74, 51.55, 316.51, 473.22]
Grounded SAM[[grounded-sam]]
Grounded SAM: Assembling Open-World Models for Diverse Visual Tasks์์ ์๊ฐ๋ ๋๋ก Grounding DINO๋ฅผ Segment Anything ๋ชจ๋ธ๊ณผ ๊ฒฐํฉํ์ฌ ํ ์คํธ ๊ธฐ๋ฐ ๋ง์คํฌ ์์ฑ์ ํ ์ ์์ต๋๋ค. ์์ธํ ๋ด์ฉ์ ์ด ๋ฐ๋ชจ ๋ ธํธ๋ถ ๐์ ์ฐธ์กฐํ์ธ์.

Grounded SAM ๊ฐ์. ์๋ณธ ์ ์ฅ์์์ ๊ฐ์ ธ์์ต๋๋ค.
๋ฆฌ์์ค[[resources]]
Grounding DINO๋ฅผ ์์ํ๋ ๋ฐ ๋์์ด ๋๋ ๊ณต์ Hugging Face ๋ฐ ์ปค๋ฎค๋ํฐ(๐๋ก ํ์) ๋ฆฌ์์ค ๋ชฉ๋ก์ ๋๋ค. ์ฌ๊ธฐ์ ํฌํจ๋ ๋ฆฌ์์ค๋ฅผ ์ ์ถํ๊ณ ์ถ๋ค๋ฉด Pull Request๋ฅผ ์์ ๋กญ๊ฒ ์ด์ด์ฃผ์ธ์. ๊ฒํ ํด๋๋ฆฌ๊ฒ ์ต๋๋ค! ๋ฆฌ์์ค๋ ๊ธฐ์กด ๋ฆฌ์์ค๋ฅผ ๋ณต์ ํ๋ ๋์ ์๋ก์ด ๊ฒ์ ๋ณด์ฌ์ฃผ๋ ๊ฒ์ด ์ด์์ ์ ๋๋ค.
- Grounding DINO๋ก ์ถ๋ก ํ๊ณ SAM๊ณผ ๊ฒฐํฉํ๋ ๋ฐ๋ชจ ๋ ธํธ๋ถ์ ์ฌ๊ธฐ์์ ์ฐพ์ ์ ์์ต๋๋ค. ๐
GroundingDinoImageProcessor
[[autodoc]] GroundingDinoImageProcessor - preprocess
GroundingDinoImageProcessorFast
[[autodoc]] GroundingDinoImageProcessorFast - preprocess - post_process_object_detection
GroundingDinoProcessor
[[autodoc]] GroundingDinoProcessor - post_process_grounded_object_detection
GroundingDinoConfig
[[autodoc]] GroundingDinoConfig
GroundingDinoModel
[[autodoc]] GroundingDinoModel - forward
GroundingDinoForObjectDetection
[[autodoc]] GroundingDinoForObjectDetection - forward