์ฝ˜ํ…์ธ ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

Ultralytics ํƒ์ƒ‰๊ธฐ API

์ปค๋ฎค๋‹ˆํ‹ฐ ๋…ธํŠธ โš ๏ธ

๊ธฐ์ค€ ultralytics>=8.3.10, Ultralytics ํƒ์ƒ‰๊ธฐ ์ง€์›์€ ๋” ์ด์ƒ ์‚ฌ์šฉ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ๊ฑฑ์ •ํ•˜์ง€ ๋งˆ์„ธ์š”! ์ด์ œ ๋‹ค์Œ์„ ํ†ตํ•ด ์œ ์‚ฌํ•˜๊ฑฐ๋‚˜ ๋”์šฑ ํ–ฅ์ƒ๋œ ๊ธฐ๋Šฅ์— ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Ultralytics HUB๋Š” ์›Œํฌํ”Œ๋กœ์šฐ๋ฅผ ๊ฐ„์†Œํ™”ํ•˜๋„๋ก ์„ค๊ณ„๋œ ์ง๊ด€์ ์ธ ๋…ธ์ฝ”๋“œ ํ”Œ๋žซํผ์ž…๋‹ˆ๋‹ค. Ultralytics HUB๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ฝ”๋“œ ํ•œ ์ค„ ์ž‘์„ฑํ•˜์ง€ ์•Š๊ณ ๋„ ๋ฐ์ดํ„ฐ๋ฅผ ์†์‰ฝ๊ฒŒ ํƒ์ƒ‰, ์‹œ๊ฐํ™”, ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ผญ ํ™•์ธํ•˜์‹œ๊ณ  ๊ฐ•๋ ฅํ•œ ๊ธฐ๋Šฅ์„ ํ™œ์šฉํ•ด ๋ณด์„ธ์š”!

์†Œ๊ฐœ

์ฝœ๋žฉ์—์„œ ์—ด๊ธฐ Explorer API๋Š” ๋ฐ์ดํ„ฐ ์„ธํŠธ๋ฅผ ํƒ์ƒ‰ํ•˜๊ธฐ ์œ„ํ•œ Python API์ž…๋‹ˆ๋‹ค. SQL ์ฟผ๋ฆฌ, ๋ฒกํ„ฐ ์œ ์‚ฌ์„ฑ ๊ฒ€์ƒ‰, ์‹œ๋งจํ‹ฑ ๊ฒ€์ƒ‰์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ์„ ํ•„ํ„ฐ๋งํ•˜๊ณ  ๊ฒ€์ƒ‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.



Watch: Ultralytics Explorer API ๊ฐœ์š”

์„ค์น˜

Explorer๋Š” ์ผ๋ถ€ ๊ธฐ๋Šฅ์„ ์™ธ๋ถ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ์˜์กดํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” ์‚ฌ์šฉ ์‹œ ์ž๋™์œผ๋กœ ์„ค์น˜๋ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ข…์†์„ฑ์„ ์ˆ˜๋™์œผ๋กœ ์„ค์น˜ํ•˜๋ ค๋ฉด ๋‹ค์Œ ๋ช…๋ น์„ ์‚ฌ์šฉํ•˜์„ธ์š”:

pip install ultralytics[explorer]

์‚ฌ์šฉ๋ฒ•

from ultralytics import Explorer

# Create an Explorer object
explorer = Explorer(data="coco128.yaml", model="yolo11n.pt")

# Create embeddings for your dataset
explorer.create_embeddings_table()

# Search for similar images to a given image/images
dataframe = explorer.get_similar(img="path/to/image.jpg")

# Or search for similar images to a given index/indices
dataframe = explorer.get_similar(idx=0)

์ฐธ๊ณ 

์ฃผ์–ด์ง„ ๋ฐ์ดํ„ฐ ์„ธํŠธ์™€ ๋ชจ๋ธ ์Œ์— ๋Œ€ํ•œ ์ž„๋ฒ ๋”ฉ ํ…Œ์ด๋ธ”์€ ํ•œ ๋ฒˆ๋งŒ ์ƒ์„ฑ๋˜์–ด ์žฌ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—๋Š” ์˜จ๋””์Šคํฌ๋กœ ํ™•์žฅ๋˜๋Š” LanceDB๊ฐ€ ์‚ฌ์šฉ๋˜๋ฏ€๋กœ ๋ฉ”๋ชจ๋ฆฌ ๋ถ€์กฑ ์—†์ด COCO์™€ ๊ฐ™์€ ๋Œ€๊ทœ๋ชจ ๋ฐ์ดํ„ฐ ์„ธํŠธ์— ๋Œ€ํ•œ ์ž„๋ฒ ๋”ฉ์„ ์ƒ์„ฑํ•˜๊ณ  ์žฌ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ž„๋ฒ ๋”ฉ ํ…Œ์ด๋ธ”์„ ๊ฐ•์ œ๋กœ ์—…๋ฐ์ดํŠธํ•˜๋ ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. force=True ์— create_embeddings_table ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

LanceDB ํ…Œ์ด๋ธ” ๊ฐœ์ฒด์— ์ง์ ‘ ์•ก์„ธ์Šคํ•˜์—ฌ ๊ณ ๊ธ‰ ๋ถ„์„์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ž„๋ฒ ๋”ฉ ํ…Œ์ด๋ธ”๋กœ ์ž‘์—…ํ•˜๊ธฐ ์„น์…˜์—์„œ ์ž์„ธํžˆ ์•Œ์•„๋ณด์„ธ์š”.

์œ ์‚ฌ๋„ ๊ฒ€์ƒ‰์€ ์ฃผ์–ด์ง„ ์ด๋ฏธ์ง€์™€ ์œ ์‚ฌํ•œ ์ด๋ฏธ์ง€๋ฅผ ์ฐพ๋Š” ๊ธฐ์ˆ ์ž…๋‹ˆ๋‹ค. ๋น„์Šทํ•œ ์ด๋ฏธ์ง€์—๋Š” ๋น„์Šทํ•œ ์ž„๋ฒ ๋”ฉ์ด ์žˆ์„ ๊ฒƒ์ด๋ผ๋Š” ์ƒ๊ฐ์— ๊ธฐ๋ฐ˜ํ•ฉ๋‹ˆ๋‹ค. ์ž„๋ฒ ๋”ฉ ํ…Œ์ด๋ธ”์ด ๊ตฌ์ถ•๋˜๋ฉด ๋‹ค์Œ ์ค‘ ํ•œ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์œผ๋กœ ์‹œ๋งจํ‹ฑ ๊ฒ€์ƒ‰์„ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

  • ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ์˜ ์ง€์ •๋œ ์ธ๋ฑ์Šค ๋˜๋Š” ์ธ๋ฑ์Šค ๋ชฉ๋ก์—์„œ: exp.get_similar(idx=[1,10], limit=10)
  • ๋ฐ์ดํ„ฐ ์„ธํŠธ์— ์—†๋Š” ์ด๋ฏธ์ง€ ๋˜๋Š” ์ด๋ฏธ์ง€ ๋ชฉ๋ก์—์„œ: exp.get_similar(img=["path/to/img1", "path/to/img2"], limit=10)

์—ฌ๋Ÿฌ ๊ฐœ์˜ ์ž…๋ ฅ์ด ์žˆ๋Š” ๊ฒฝ์šฐ ์ž„๋ฒ ๋”ฉ๋œ ํ•ญ๋ชฉ์˜ ํ•ฉ์‚ฐ๊ฐ’์ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

ํŒ๋‹ค ๋ฐ์ดํ„ฐ ํ”„๋ ˆ์ž„์ด ํฌํ•จ๋œ limit ์ž„๋ฒ ๋”ฉ ๊ณต๊ฐ„์—์„œ์˜ ๊ฑฐ๋ฆฌ์™€ ํ•จ๊ป˜ ์ž…๋ ฅ๊ณผ ๊ฐ€์žฅ ์œ ์‚ฌํ•œ ๋ฐ์ดํ„ฐ ํฌ์ธํŠธ์˜ ์ˆ˜์ž…๋‹ˆ๋‹ค. ์ด ๋ฐ์ดํ„ฐ ์„ธํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ถ”๊ฐ€ ํ•„ํ„ฐ๋ง์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์‹œ๋งจํ‹ฑ ๊ฒ€์ƒ‰

from ultralytics import Explorer

# create an Explorer object
exp = Explorer(data="coco128.yaml", model="yolo11n.pt")
exp.create_embeddings_table()

similar = exp.get_similar(img="https://ultralytics.com/images/bus.jpg", limit=10)
print(similar.head())

# Search using multiple indices
similar = exp.get_similar(
    img=["https://ultralytics.com/images/bus.jpg", "https://ultralytics.com/images/bus.jpg"],
    limit=10,
)
print(similar.head())
from ultralytics import Explorer

# create an Explorer object
exp = Explorer(data="coco128.yaml", model="yolo11n.pt")
exp.create_embeddings_table()

similar = exp.get_similar(idx=1, limit=10)
print(similar.head())

# Search using multiple indices
similar = exp.get_similar(idx=[1, 10], limit=10)
print(similar.head())

์œ ์‚ฌํ•œ ์ด๋ฏธ์ง€ ํ”Œ๋กœํŒ…

์œ ์‚ฌํ•œ ์ด๋ฏธ์ง€๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ”Œ๋กœํŒ…ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. plot_similar ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ฉ”์„œ๋“œ๋Š” ๋‹ค์Œ๊ณผ ๋™์ผํ•œ ์ธ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. get_similar ๋ฅผ ํด๋ฆญํ•˜๊ณ  ์œ ์‚ฌํ•œ ์ด๋ฏธ์ง€๋ฅผ ๊ทธ๋ฆฌ๋“œ์— ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

์œ ์‚ฌํ•œ ์ด๋ฏธ์ง€ ํ”Œ๋กœํŒ…

from ultralytics import Explorer

# create an Explorer object
exp = Explorer(data="coco128.yaml", model="yolo11n.pt")
exp.create_embeddings_table()

plt = exp.plot_similar(img="https://ultralytics.com/images/bus.jpg", limit=10)
plt.show()
from ultralytics import Explorer

# create an Explorer object
exp = Explorer(data="coco128.yaml", model="yolo11n.pt")
exp.create_embeddings_table()

plt = exp.plot_similar(idx=1, limit=10)
plt.show()

2. AI์—๊ฒŒ ์งˆ๋ฌธ(์ž์—ฐ์–ด ์ฟผ๋ฆฌ)

์ด๋ฅผ ํ†ตํ•ด ์ž์—ฐ์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ์„ ํ•„ํ„ฐ๋งํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. SQL ์ฟผ๋ฆฌ ์ž‘์„ฑ์— ๋Šฅ์ˆ™ํ•  ํ•„์š”๋Š” ์—†์Šต๋‹ˆ๋‹ค. AI ๊ธฐ๋ฐ˜ ์ฟผ๋ฆฌ ์ƒ์„ฑ๊ธฐ๊ฐ€ ์ž๋™์œผ๋กœ ์ฒ˜๋ฆฌํ•ด ์ค๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, "์‚ฌ๋žŒ๊ณผ ๊ฐœ๊ฐ€ ์ •ํ™•ํžˆ ํ•œ ๋งˆ๋ฆฌ์”ฉ ์žˆ๋Š” ์ด๋ฏธ์ง€ 100์žฅ์„ ๋ณด์—ฌ์ฃผ์„ธ์š”. ๋‹ค๋ฅธ ๊ฐœ์ฒด๋„ ์žˆ์„ ์ˆ˜ ์žˆ์–ด"๋ผ๊ณ  ๋งํ•˜๋ฉด ๋‚ด๋ถ€์ ์œผ๋กœ ์ฟผ๋ฆฌ๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ๊ทธ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ์ฐธ๊ณ : ์ด ๊ธฐ๋Šฅ์€ ๋‚ด๋ถ€์ ์œผ๋กœ LLM์„ ์‚ฌ์šฉํ•˜์—ฌ ์ž‘๋™ํ•˜๋ฏ€๋กœ ๊ฒฐ๊ณผ๋Š” ํ™•๋ฅ ์ ์ด๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ€๋” ์ž˜๋ชป๋œ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

AI์— ์งˆ๋ฌธํ•˜๊ธฐ

from ultralytics import Explorer
from ultralytics.data.explorer import plot_query_result

# create an Explorer object
exp = Explorer(data="coco128.yaml", model="yolo11n.pt")
exp.create_embeddings_table()

df = exp.ask_ai("show me 100 images with exactly one person and 2 dogs. There can be other objects too")
print(df.head())

# plot the results
plt = plot_query_result(df)
plt.show()

3. SQL ์ฟผ๋ฆฌ

๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ์—์„œ SQL ์ฟผ๋ฆฌ๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. sql_query ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ฉ”์„œ๋“œ๋Š” SQL ์ฟผ๋ฆฌ๋ฅผ ์ž…๋ ฅ์œผ๋กœ ๋ฐ›์•„ ๊ฒฐ๊ณผ์™€ ํ•จ๊ป˜ ํŒ๋‹ค์Šค ๋ฐ์ดํ„ฐ ํ”„๋ ˆ์ž„์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

SQL ์ฟผ๋ฆฌ

from ultralytics import Explorer

# create an Explorer object
exp = Explorer(data="coco128.yaml", model="yolo11n.pt")
exp.create_embeddings_table()

df = exp.sql_query("WHERE labels LIKE '%person%' AND labels LIKE '%dog%'")
print(df.head())

SQL ์ฟผ๋ฆฌ ๊ฒฐ๊ณผ ํ”Œ๋กœํŒ…

๋˜ํ•œ ๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ SQL ์ฟผ๋ฆฌ ๊ฒฐ๊ณผ๋ฅผ ํ”Œ๋กœํŒ…ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. plot_sql_query ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ฉ”์„œ๋“œ๋Š” ๋‹ค์Œ๊ณผ ๋™์ผํ•œ ์ธ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. sql_query ๋ฅผ ํด๋ฆญํ•˜๊ณ  ๊ฒฐ๊ณผ๋ฅผ ๊ทธ๋ฆฌ๋“œ์— ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

SQL ์ฟผ๋ฆฌ ๊ฒฐ๊ณผ ํ”Œ๋กœํŒ…

from ultralytics import Explorer

# create an Explorer object
exp = Explorer(data="coco128.yaml", model="yolo11n.pt")
exp.create_embeddings_table()

# plot the SQL Query
exp.plot_sql_query("WHERE labels LIKE '%person%' AND labels LIKE '%dog%' LIMIT 10")

4. ์ž„๋ฒ ๋”ฉ ํ…Œ์ด๋ธ”๋กœ ์ž‘์—…ํ•˜๊ธฐ

์ž„๋ฒ ๋”ฉ ํ…Œ์ด๋ธ”๋กœ ์ง์ ‘ ์ž‘์—…ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์ž„๋ฒ ๋”ฉ ํ…Œ์ด๋ธ”์ด ์ƒ์„ฑ๋˜๋ฉด ์ž„๋ฒ ๋”ฉ ํ…Œ์ด๋ธ”์— ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Explorer.table

ํŒ

ํƒ์ƒ‰๊ธฐ๋Š” ๋‹ค์Œ์—์„œ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. LanceDB ํ…Œ์ด๋ธ”์„ ๋‚ด๋ถ€์ ์œผ๋กœ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ด ํ…Œ์ด๋ธ”์— ์ง์ ‘ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Explorer.table ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์›์‹œ ์ฟผ๋ฆฌ๋ฅผ ์‹คํ–‰ํ•˜๊ณ , ์‚ฌ์ „ ๋ฐ ์‚ฌํ›„ ํ•„ํ„ฐ๋ฅผ ํ‘ธ์‹œ ๋‹ค์šดํ•˜๋Š” ๋“ฑ์˜ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

from ultralytics import Explorer

exp = Explorer()
exp.create_embeddings_table()
table = exp.table

๋‹ค์Œ์€ ํ‘œ๋กœ ํ•  ์ˆ˜ ์žˆ๋Š” ๋ช‡ ๊ฐ€์ง€ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค:

์›์‹œ ์ž„๋ฒ ๋”ฉ ๊ฐ€์ ธ์˜ค๊ธฐ

์˜ˆ

from ultralytics import Explorer

exp = Explorer()
exp.create_embeddings_table()
table = exp.table

embeddings = table.to_pandas()["vector"]
print(embeddings)

์‚ฌ์ „ ๋ฐ ์‚ฌํ›„ ํ•„ํ„ฐ๋ฅผ ์‚ฌ์šฉํ•œ ๊ณ ๊ธ‰ ์ฟผ๋ฆฌ ๊ธฐ๋Šฅ

์˜ˆ

from ultralytics import Explorer

exp = Explorer(model="yolo11n.pt")
exp.create_embeddings_table()
table = exp.table

# Dummy embedding
embedding = [i for i in range(256)]
rs = table.search(embedding).metric("cosine").where("").limit(10)

๋ฒกํ„ฐ ์ธ๋ฑ์Šค ์ƒ์„ฑ

๋Œ€๊ทœ๋ชจ ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ๋” ๋น ๋ฅธ ์ฟผ๋ฆฌ๋ฅผ ์œ„ํ•ด ์ „์šฉ ๋ฒกํ„ฐ ์ธ๋ฑ์Šค๋ฅผ ๋งŒ๋“ค ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์ž‘์—…์€ create_index ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

table.create_index(num_partitions=..., num_sub_vectors=...)

์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ฒกํ„ฐ ์ธ๋ฑ์Šค ์œ ํ˜• ๋ฐ ๋งค๊ฐœ๋ณ€์ˆ˜์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ์—ฌ๊ธฐ์—์„œ ํ™•์ธํ•˜์„ธ์š”. ํ–ฅํ›„์—๋Š” ํƒ์ƒ‰๊ธฐ API์—์„œ ์ง์ ‘ ๋ฒกํ„ฐ ์ธ๋ฑ์Šค๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.

5. ์ž„๋ฒ ๋”ฉ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜

์ž„๋ฒ ๋”ฉ ํ…Œ์ด๋ธ”์„ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์–‘ํ•œ ํƒ์ƒ‰ ๋ถ„์„์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ์€ ๋ช‡ ๊ฐ€์ง€ ์˜ˆ์ž…๋‹ˆ๋‹ค:

์œ ์‚ฌ์„ฑ ์ง€์ˆ˜

Explorer๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค. similarity_index ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค:

  • ๊ฐ ๋ฐ์ดํ„ฐ ํฌ์ธํŠธ๊ฐ€ ๋‚˜๋จธ์ง€ ๋ฐ์ดํ„ฐ ์„ธํŠธ์™€ ์–ผ๋งˆ๋‚˜ ์œ ์‚ฌํ•œ์ง€ ์ถ”์ •ํ•ฉ๋‹ˆ๋‹ค.
  • ์–ผ๋งˆ๋‚˜ ๋งŽ์€ ์ด๋ฏธ์ง€ ์ž„๋ฒ ๋”ฉ์ด ๋‹ค์Œ๋ณด๋‹ค ๊ฐ€๊นŒ์šด ๊ณณ์— ์žˆ๋Š”์ง€ ๊ณ„์‚ฐํ•˜์—ฌ ์ด๋ฅผ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. max_dist ๋ฅผ ์ƒ์„ฑ๋œ ์ž„๋ฒ ๋”ฉ ๊ณต๊ฐ„์˜ ํ˜„์žฌ ์ด๋ฏธ์ง€์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. top_k ๋น„์Šทํ•œ ์ด๋ฏธ์ง€๋ฅผ ํ•œ ๋ฒˆ์— ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ ์—ด์ด ํฌํ•จ๋œ ํŒ๋‹ค ๋ฐ์ดํ„ฐ ํ”„๋ ˆ์ž„์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค:

  • idx: ๋ฐ์ดํ„ฐ ์„ธํŠธ์˜ ์ด๋ฏธ์ง€ ์ธ๋ฑ์Šค
  • im_file: ์ด๋ฏธ์ง€ ํŒŒ์ผ ๊ฒฝ๋กœ
  • count: ๋ฐ์ดํ„ฐ ์„ธํŠธ์—์„œ ๋‹ค์Œ๋ณด๋‹ค ๊ฐ€๊นŒ์šด ์ด๋ฏธ์ง€ ์ˆ˜ max_dist ๋ฅผ ํ˜„์žฌ ์ด๋ฏธ์ง€๋กœ
  • sim_im_files: ๊ฒฝ๋กœ ๋ชฉ๋ก count ์œ ์‚ฌํ•œ ์ด๋ฏธ์ง€

ํŒ

์ฃผ์–ด์ง„ ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ์— ๋Œ€ํ•ด ๋ชจ๋ธ๋งํ•ฉ๋‹ˆ๋‹ค, max_dist & top_k ๋กœ ์„ค์ •ํ•˜๋ฉด ํ•œ ๋ฒˆ ์ƒ์„ฑ๋œ ์œ ์‚ฌ๋„ ์ธ๋ฑ์Šค๊ฐ€ ์žฌ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ ์„ธํŠธ๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ๊ฑฐ๋‚˜ ๋‹จ์ˆœํžˆ ์œ ์‚ฌ๋„ ์ธ๋ฑ์Šค๋ฅผ ๋‹ค์‹œ ์ƒ์„ฑํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ, ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. force=True.

์œ ์‚ฌ์„ฑ ์ง€์ˆ˜

from ultralytics import Explorer

exp = Explorer()
exp.create_embeddings_table()

sim_idx = exp.similarity_index()

์œ ์‚ฌ์„ฑ ์ธ๋ฑ์Šค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์‚ฌ์šฉ์ž ์ง€์ • ์กฐ๊ฑด์„ ์ž‘์„ฑํ•˜์—ฌ ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ์„ ํ•„ํ„ฐ๋งํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ๋‹ค์Œ ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ ์„ธํŠธ์˜ ๋‹ค๋ฅธ ์ด๋ฏธ์ง€์™€ ์œ ์‚ฌํ•˜์ง€ ์•Š์€ ์ด๋ฏธ์ง€๋ฅผ ํ•„ํ„ฐ๋งํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

import numpy as np

sim_count = np.array(sim_idx["count"])
sim_idx["im_file"][sim_count > 30]

์ž„๋ฒ ๋”ฉ ๊ณต๊ฐ„ ์‹œ๊ฐํ™”

์›ํ•˜๋Š” ํ”Œ๋กœํŒ… ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ž„๋ฒ ๋”ฉ ๊ณต๊ฐ„์„ ์‹œ๊ฐํ™”ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ๋‹ค์Œ์€ matplotlib๋ฅผ ์‚ฌ์šฉํ•œ ๊ฐ„๋‹จํ•œ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค:

import matplotlib.pyplot as plt
from sklearn.decomposition import PCA

# Reduce dimensions using PCA to 3 components for visualization in 3D
pca = PCA(n_components=3)
reduced_data = pca.fit_transform(embeddings)

# Create a 3D scatter plot using Matplotlib Axes3D
fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot(111, projection="3d")

# Scatter plot
ax.scatter(reduced_data[:, 0], reduced_data[:, 1], reduced_data[:, 2], alpha=0.5)
ax.set_title("3D Scatter Plot of Reduced 256-Dimensional Data (PCA)")
ax.set_xlabel("Component 1")
ax.set_ylabel("Component 2")
ax.set_zlabel("Component 3")

plt.show()

ํƒ์ƒ‰๊ธฐ API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‚˜๋งŒ์˜ ์ด๋ ฅ์„œ ๋ฐ์ดํ„ฐ ์„ธํŠธ ํƒ์ƒ‰ ๋ณด๊ณ ์„œ๋ฅผ ๋งŒ๋“ค์–ด ๋ณด์„ธ์š”. ์˜๊ฐ์„ ์–ป์œผ๋ ค๋ฉด

Ultralytics ํƒ์ƒ‰๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ตฌ์ถ•ํ•œ ์•ฑ

์ต์Šคํ”Œ๋กœ๋Ÿฌ API ๊ธฐ๋ฐ˜ GUI ๋ฐ๋ชจ ์ฒดํ—˜ํ•˜๊ธฐ

๊ณง ์ถœ์‹œ ์˜ˆ์ •

  • [ ] ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ์—์„œ ํŠน์ • ๋ ˆ์ด๋ธ”์„ ๋ณ‘ํ•ฉํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ - ๋ชจ๋‘ ๊ฐ€์ ธ์˜ค๊ธฐ person ๋ผ๋ฒจ๊ณผ car ๋„์‹œ ํ’๊ฒฝ์˜ ๋ ˆ์ด๋ธ”
  • [ ] ์ง€์ •๋œ ์ž„๊ณ„๊ฐ’๋ณด๋‹ค ์œ ์‚ฌ๋„ ์ง€์ˆ˜๊ฐ€ ๋†’์€ ์ด๋ฏธ์ง€๋ฅผ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.
  • [ ] ํ•ญ๋ชฉ ๋ณ‘ํ•ฉ/์ œ๊ฑฐ ํ›„ ์ƒˆ ๋ฐ์ดํ„ฐ ์„ธํŠธ ์ž๋™ ์œ ์ง€
  • [ ] ๊ณ ๊ธ‰ ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ ์‹œ๊ฐํ™”

์ž์ฃผ ๋ฌป๋Š” ์งˆ๋ฌธ

Ultralytics ์ต์Šคํ”Œ๋กœ๋Ÿฌ API๋Š” ์–ด๋–ค ์šฉ๋„๋กœ ์‚ฌ์šฉ๋˜๋‚˜์š”?

Ultralytics Explorer API๋Š” ํฌ๊ด„์ ์ธ ๋ฐ์ดํ„ฐ ์„ธํŠธ ํƒ์ƒ‰์„ ์œ„ํ•ด ์„ค๊ณ„๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๋Š” SQL ์ฟผ๋ฆฌ, ๋ฒกํ„ฐ ์œ ์‚ฌ์„ฑ ๊ฒ€์ƒ‰, ์‹œ๋งจํ‹ฑ ๊ฒ€์ƒ‰์„ ์‚ฌ์šฉํ•ด ๋ฐ์ดํ„ฐ ์„ธํŠธ๋ฅผ ํ•„ํ„ฐ๋งํ•˜๊ณ  ๊ฒ€์ƒ‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ฐ•๋ ฅํ•œ Python API๋Š” ๋Œ€๊ทœ๋ชจ ๋ฐ์ดํ„ฐ ์„ธํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์–ด Ultralytics ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•˜๋Š” ๋‹ค์–‘ํ•œ ์ปดํ“จํ„ฐ ๋น„์ „ ์ž‘์—…์— ์ด์ƒ์ ์ž…๋‹ˆ๋‹ค.

Ultralytics ์ต์Šคํ”Œ๋กœ๋Ÿฌ API๋Š” ์–ด๋–ป๊ฒŒ ์„ค์น˜ํ•˜๋‚˜์š”?

Ultralytics Explorer API๋ฅผ ์ข…์† ์š”์†Œ์™€ ํ•จ๊ป˜ ์„ค์น˜ํ•˜๋ ค๋ฉด ๋‹ค์Œ ๋ช…๋ น์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค:

pip install ultralytics[explorer]

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ํƒ์ƒ‰๊ธฐ API ๊ธฐ๋Šฅ์— ํ•„์š”ํ•œ ๋ชจ๋“  ์™ธ๋ถ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์ž๋™์œผ๋กœ ์„ค์น˜๋ฉ๋‹ˆ๋‹ค. ์ถ”๊ฐ€ ์„ค์ •์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋ฌธ์„œ์˜ ์„ค์น˜ ์„น์…˜์„ ์ฐธ์กฐํ•˜์„ธ์š”.

Ultralytics Explorer API๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ž„๋ฒ ๋”ฉ ํ…Œ์ด๋ธ”์„ ์ƒ์„ฑํ•˜๊ณ  ์œ ์‚ฌํ•œ ์ด๋ฏธ์ง€๋ฅผ ์ฟผ๋ฆฌํ•˜์—ฌ ์œ ์‚ฌ์„ฑ ๊ฒ€์ƒ‰์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ์€ ๊ธฐ๋ณธ์ ์ธ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค:

from ultralytics import Explorer

# Create an Explorer object
explorer = Explorer(data="coco128.yaml", model="yolo11n.pt")
explorer.create_embeddings_table()

# Search for similar images to a given image
similar_images_df = explorer.get_similar(img="path/to/image.jpg")
print(similar_images_df.head())

์ž์„ธํ•œ ๋‚ด์šฉ์€ ์œ ์‚ฌ๋„ ๊ฒ€์ƒ‰ ์„น์…˜์„ ์ฐธ์กฐํ•˜์„ธ์š”.

Ultralytics Explorer์™€ ํ•จ๊ป˜ LanceDB๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์–ด๋–ค ์ด์ ์ด ์žˆ๋‚˜์š”?

Ultralytics Explorer์—์„œ ๋‚ด๋ถ€์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” LanceDB๋Š” ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ์˜จ๋””์Šคํฌ ์ž„๋ฒ ๋”ฉ ํ…Œ์ด๋ธ”์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ COCO์™€ ๊ฐ™์€ ๋Œ€๊ทœ๋ชจ ๋ฐ์ดํ„ฐ ์„ธํŠธ์— ๋Œ€ํ•ด ๋ฉ”๋ชจ๋ฆฌ ๋ถ€์กฑ ์—†์ด ์ž„๋ฒ ๋”ฉ์„ ์ƒ์„ฑํ•˜๊ณ  ์žฌ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ํ…Œ์ด๋ธ”์€ ํ•œ ๋ฒˆ๋งŒ ์ƒ์„ฑ๋˜๊ณ  ์žฌ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ์˜ ํšจ์œจ์„ฑ์ด ํ–ฅ์ƒ๋ฉ๋‹ˆ๋‹ค.

'AI์—๊ฒŒ ์งˆ๋ฌธ' ๊ธฐ๋Šฅ์€ Ultralytics ํƒ์ƒ‰๊ธฐ API์—์„œ ์–ด๋–ป๊ฒŒ ์ž‘๋™ํ•˜๋‚˜์š”?

'AI์— ์งˆ๋ฌธ' ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜๋ฉด ์ž์—ฐ์–ด ์ฟผ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ ์„ธํŠธ๋ฅผ ํ•„ํ„ฐ๋งํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ธฐ๋Šฅ์€ LLM์„ ํ™œ์šฉํ•˜์—ฌ ์ด๋Ÿฌํ•œ ์ฟผ๋ฆฌ๋ฅผ ๋ฐฑ๊ทธ๋ผ์šด๋“œ์—์„œ SQL ์ฟผ๋ฆฌ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ์€ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค:

from ultralytics import Explorer

# Create an Explorer object
explorer = Explorer(data="coco128.yaml", model="yolo11n.pt")
explorer.create_embeddings_table()

# Query with natural language
query_result = explorer.ask_ai("show me 100 images with exactly one person and 2 dogs. There can be other objects too")
print(query_result.head())

๋” ๋งŽ์€ ์˜ˆ์‹œ๋ฅผ ๋ณด๋ ค๋ฉด AI์—๊ฒŒ ์งˆ๋ฌธํ•˜๊ธฐ ์„น์…˜์„ ์ฐธ์กฐํ•˜์„ธ์š”.

11๊ฐœ์›” ์ „ ์ƒ์„ฑ๋จ โœ๏ธ 1๊ฐœ์›” ์ „ ์—…๋ฐ์ดํŠธ๋จ

๋Œ“๊ธ€