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

Ultralytics HUB-SDK ๋ชจ๋ธ ๊ด€๋ฆฌ ์šด์˜ ๊ฐ€์ด๋“œ

Ultralytics HUB -SDK ๋ชจ๋ธ ๊ด€๋ฆฌ ๋ฌธ์„œ์— ์˜ค์‹  ๊ฒƒ์„ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค! ๋จธ์‹  ๋Ÿฌ๋‹ ๋ชจ๋ธ ๊ด€๋ฆฌ๋ฅผ ์ด์ œ ๋ง‰ ์‹œ์ž‘ํ–ˆ๋“ , ๊ตฌ์ฒด์ ์ธ ์ž‘์—… ์ง€์นจ์„ ์ฐพ๊ณ  ์žˆ๋Š” ์ˆ™๋ จ๋œ ๋ฐ์ดํ„ฐ ๊ณผํ•™์ž์ด๋“ , ์ œ๋Œ€๋กœ ์ฐพ์•„์˜ค์…จ์Šต๋‹ˆ๋‹ค. HUB -SDK ๊ธฐ๋Šฅ์„ ํ†ตํ•ด ๋ชจ๋ธ์„ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ๋…ธํ•˜์šฐ๋ฅผ ์Šต๋“ํ•˜๋Š” ์ˆœ์กฐ๋กœ์šด ์—ฌ์ •์„ ์‹œ์ž‘ํ•˜์„ธ์š”.

๊ณ ์œ  ์‹๋ณ„์ž๋กœ ๋ชจ๋ธ ๊ฒ€์ƒ‰ํ•˜๊ธฐ

๋จธ์‹ ๋Ÿฌ๋‹ ์›Œํฌํ”Œ๋กœ์—์„œ๋Š” ํŠน์ • ๋ชจ๋ธ์— ์•ก์„ธ์Šคํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์Šต๋‹ˆ๋‹ค. Ultralytics HUB -SDK๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ID๋กœ ๋ชจ๋ธ์„ ์‰ฝ๊ฒŒ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ํ•„์ˆ˜ ๊ธฐ๋Šฅ์€ ์ œ๊ณต๋œ ๊ณ ์œ  ์‹๋ณ„์ž๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ชจ๋ธ ๊ฐœ์ฒด๋ฅผ ์„ค์ •ํ•˜์—ฌ ๋ชจ๋ธ์˜ ์„ธ๋ถ€ ์ •๋ณด ๋ฐ ์ž‘์—…์— ๋Œ€ํ•œ ์ „์ฒด ์•ก์„ธ์Šค ๊ถŒํ•œ์„ ๋ถ€์—ฌํ•ฉ๋‹ˆ๋‹ค.

model = client.model("<Model ID>")
print(model.data)  # Outputs the model's metadata and configuration

ํ”„๋กœ์ ํŠธ ๋ฐ ๋ฐ์ดํ„ฐ ์ง‘ํ•ฉ์— ์•ก์„ธ์Šคํ•˜๊ธฐ ์œ„ํ•œ ์‚ฌ์ „ ์š”๊ตฌ ์‚ฌํ•ญ

๋ชจ๋ธ์„ ๋งŒ๋“ค๊ฑฐ๋‚˜ ํ›ˆ๋ จํ•˜๊ธฐ ์ „์— ํ”„๋กœ์ ํŠธ์™€ ๋ฐ์ดํ„ฐ ์„ธํŠธ๊ฐ€ ๋ชจ๋‘ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ฐ„๋‹จํ•œ ์ฝ”๋“œ ์Šค๋‹ˆํŽซ์€ ๊ฐœ์ฒด๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜์—ฌ ์ด๋Ÿฌํ•œ ๊ตฌ์„ฑ ์š”์†Œ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค. ๋ชจ๋ธ ํ•™์Šต์„ ๊ตฌ์„ฑํ•  ๋•Œ ํ”„๋กœ์ ํŠธ์™€ ๋ฐ์ดํ„ฐ ์„ธํŠธ๋ฅผ ํ™œ์šฉํ•˜๋Š” ๊ฒƒ์€ ์œ ์šฉํ•˜์ง€๋งŒ, ๋ฐ˜๋“œ์‹œ ํ•„์š”ํ•œ ๊ฒƒ์€ ์•„๋‹ˆ๋ผ๋Š” ์ ์— ์œ ์˜ํ•˜์„ธ์š”. ๋‘ ID ์ค‘ ํ•˜๋‚˜๋ผ๋„ ๋ˆ„๋ฝ๋œ ๊ฒฝ์šฐ ๊ฐœ์ฒด ๋ฐ์ดํ„ฐ(project.data, dataset.data)๋Š” ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

project = client.project("<Project ID>")
dataset = client.dataset("<Dataset ID>")

์‚ฌ์šฉ์ž ์ง€์ • ๊ตฌ์„ฑ์œผ๋กœ ์ƒˆ ๋ชจ๋ธ ๋งŒ๋“ค๊ธฐ

์ด ํŽธ๋ฆฌํ•œ ๊ธฐ๋Šฅ์œผ๋กœ ํ”„๋กœ์ ํŠธ ์š”๊ตฌ์‚ฌํ•ญ์— ๋งž๋Š” ์ƒˆ ๋ชจ๋ธ์„ ๊ฐ„ํŽธํ•˜๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ชจ๋ธ ์ด๋ฆ„์„ ์ง€์ •ํ•˜๊ณ  ํ”„๋กœ์ ํŠธ ๋ฐ ๋ฐ์ดํ„ฐ ์„ธํŠธ์™€ ์—ฐ๊ฒฐํ•˜์„ธ์š”. ๋ฐฐ์น˜ ํฌ๊ธฐ๋‚˜ ๋””๋ฐ”์ด์Šค ์„ค์ • ๋“ฑ ํ•„์š”์— ๋งž๊ฒŒ ๊ตฌ์„ฑ์„ ์‚ฌ์šฉ์ž ์ง€์ •ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฐธ๊ณ  ์‚ฌํ•ญ projectId ๋ฐ datasetId ๋งค๊ฐœ ๋ณ€์ˆ˜๋Š” ์•„์ง ๋ชจ๋ธ์„ ํ”„๋กœ์ ํŠธ๋‚˜ ๋ฐ์ดํ„ฐ ์„ธํŠธ์— ์—ฐ๊ฒฐํ•  ์ค€๋น„๊ฐ€ ๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ์„ ํƒ ์‚ฌํ•ญ์ž…๋‹ˆ๋‹ค.

data = {
    "meta": {"name": "sdk model"},  # Give your model a recognizable name
    "projectId": project.id,        # Associate with an existing project
    "datasetId": dataset.id,        # Associate with an existing dataset
    "config": {                     # Define hyperparameters and settings
        "batchSize": "-1",          
        "cache": "ram",
        "device": "name",
        "epochs": "5",
        "imageSize": "640",
        "patience": "5"             # Stop training if validation doesn't improve
    }
}
model = client.model()
model.create_model(data)  # Creates the model with your specified details

๊ธฐ์กด ๋ชจ๋ธ์˜ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๋˜๋Š” ๊ตฌ์„ฑ ์—…๋ฐ์ดํŠธํ•˜๊ธฐ

ํ”„๋กœ์ ํŠธ๊ฐ€ ๋ฐœ์ „ํ•จ์— ๋”ฐ๋ผ ๋ช…ํ™•์„ฑ์„ ์œ„ํ•ด ๋ชจ๋ธ ์ด๋ฆ„์„ ๋ณ€๊ฒฝํ•˜๋Š” ๋“ฑ ๋ชจ๋ธ์˜ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ์—…๋ฐ์ดํŠธํ•ด์•ผ ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. SDK๋Š” ์ด๋Ÿฌํ•œ ์„ธ๋ถ€ ์ •๋ณด๋ฅผ ์†์‰ฝ๊ฒŒ ์ƒˆ๋กœ ๊ณ ์น  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•˜์—ฌ ์ˆ˜๋™ ์˜ค๋ฅ˜๋ฅผ ์ตœ์†Œํ™”ํ•˜๊ณ  ๊ท€์ค‘ํ•œ ์‹œ๊ฐ„์„ ์ ˆ์•ฝํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

model = client.model("<Model ID>")
model.update({"meta": {"name": "Updated Model Name"}})  # Renames the specified model

์•ˆ์ „ํ•˜๊ฒŒ ๋ชจ๋ธ ์‚ญ์ œํ•˜๊ธฐ

๋ชจ๋ธ ์‚ญ์ œ๋Š” ๋˜๋Œ๋ฆด ์ˆ˜ ์—†์œผ๋ฏ€๋กœ ์ด ๊ธฐ๋Šฅ์€ ์‹ ์ค‘ํ•˜๊ฒŒ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์‹œ์Šคํ…œ์—์„œ ๋ชจ๋ธ์„ ์ œ๊ฑฐํ•˜๋ ค๋Š” ๊ฒฝ์šฐ ๋‹ค์Œ ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๋ฉด ์ง€์ •๋œ ๋ชจ๋ธ๊ณผ ๊ด€๋ จ๋œ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๊ฐ€ ์˜๊ตฌ์ ์œผ๋กœ ์‚ญ์ œ๋ฉ๋‹ˆ๋‹ค.

model = client.model("Model ID")
model.delete(hard=True)  # Permanently deletes the specified model
๊ธฐ๋ณธ์ ์œผ๋กœ ์‚ญ์ œ ๋ฉ”์„œ๋“œ๋Š” ์†Œํ”„ํŠธ ์‚ญ์ œ๋ฅผ ์ˆ˜ํ–‰ํ•˜์—ฌ ๋ชจ๋ธ์„ ์˜๊ตฌ์ ์œผ๋กœ ์ œ๊ฑฐํ•˜์ง€ ์•Š๊ณ  ๋น„ํ™œ์„ฑ์œผ๋กœ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. ํ•˜๋“œ ์‚ญ์ œ๋ฅผ ์ˆ˜ํ–‰ํ•˜์—ฌ ๋ชจ๋ธ์„ ๊ด€๋ จ ๋ฐ์ดํ„ฐ์™€ ํ•จ๊ป˜ ์˜๊ตฌ์ ์œผ๋กœ ์ œ๊ฑฐํ•˜๋ ค๋ฉด ์œ„์˜ ์˜ˆ์™€ ๊ฐ™์ด hard=True ์ธ์ˆ˜๋ฅผ ์ „๋‹ฌํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ํ•˜๋“œ ์‚ญ์ œ ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜๋ฉด ๋˜๋Œ๋ฆด ์ˆ˜ ์—†์œผ๋ฉฐ ์ง€์ •๋œ ๋ชจ๋ธ์ด ์‹œ์Šคํ…œ์—์„œ ์™„์ „ํžˆ ์ œ๊ฑฐ๋˜๋ฏ€๋กœ ์ฃผ์˜ํ•˜์„ธ์š”.

ํŽ˜์ด์ง€ ๋งค๊น€์œผ๋กœ ๋ชจ๋“  ๋ชจ๋ธ ๋‚˜์—ดํ•˜๊ธฐ

Ultralytics HUB-SDK๋Š” ๋ชจ๋ธ ๋ชฉ๋ก์„ ๊ฐ€์ ธ์˜ค๋Š” ์ž‘์—…์„ ๊ฐ„์†Œํ™”ํ•˜๋Š” ๋™์‹œ์— ํŽ˜์ด์ง€ ๋งค๊น€์„ ๊ตฌํ˜„ํ•˜์—ฌ ์ž ์žฌ์ ์œผ๋กœ ํฐ ๋ชจ๋ธ ์ปฌ๋ ‰์…˜์„ ํšจ์œจ์ ์œผ๋กœ ํƒ์ƒ‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ธ์ˆ˜๋ฅผ ์‚ฌ์šฉ์ž ์ง€์ •ํ•˜์—ฌ page_size๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋น„๊ณต๊ฐœ ํ”„๋กœ์ ํŠธ์™€ ๊ณต๊ฐœ ํ”„๋กœ์ ํŠธ๋ฅผ ๋ชจ๋‘ ๋ณผ ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์„ ํฌํ•จํ•˜์—ฌ ํ•„์š”์— ๋งž๊ฒŒ ์ถœ๋ ฅ์„ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

model_list = client.model_list(page_size=10)  # Fetches the first page with 10 models
print("Current result:", model_list.results)  # Displays the current page's models

model_list.next()  # Move to the next page of results
print("Next page result:", model_list.results)  # Displays the next page's models

model_list.previous()  # Return to the previous page of results
print("Previous page result:", model_list.results)  # Displays the previous page's models

๊ต์œก ์ง€ํ‘œ ์—…๋กœ๋“œ ๋ฐ ์‹œ๊ฐํ™”

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

modelId = "<Model ID>"
model = client.model(modelId)

# Define your metrics structure. Keys are steps, and values are JSON strings of metrics.
data = {
    1: '{"loss/1": 0.5, "accuracy/1": 0.85}',
    2: '{"loss/2": 0.4, "accuracy/2": 0.88}',
    3: '{"loss/3": 0.3, "accuracy/3": 0.90}',
}

model.upload_metrics(data)  # Uploads the specified metrics to the model

๋ฐฐํฌ ๋˜๋Š” ๋ถ„์„์„ ์œ„ํ•ด ๋ชจ๋ธ ๋‚ด๋ณด๋‚ด๊ธฐ

๋ฐฐํฌ ๋˜๋Š” ์‹ฌ์ธต ๋ถ„์„ ๋“ฑ ๋‹ค์–‘ํ•œ ์šฉ๋„๋กœ ๋ชจ๋ธ์„ ๋‚ด๋ณด๋‚ด๋Š” ๊ฒƒ์ด ๊ทธ ์–ด๋Š ๋•Œ๋ณด๋‹ค ์‰ฌ์›Œ์กŒ์Šต๋‹ˆ๋‹ค. ํ•„์š”ํ•œ ํ˜•์‹์„ ์ง€์ •ํ•˜๋ฉด ์ด ๊ธฐ๋Šฅ์ด ๊ทธ์— ๋งž๊ฒŒ ๋ชจ๋ธ์„ ์ค€๋น„ํ•ฉ๋‹ˆ๋‹ค. Tensorflow ํ˜•์‹์ด ํ•„์š”ํ•˜๋“  PyTorch ํ˜•์‹์ด ํ•„์š”ํ•˜๋“  SDK๋Š” ์ด๋ฅผ ์›ํ™œํ•˜๊ฒŒ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

modelId = "<Model ID>"
model = client.model(modelId)
model.export(format="pyTorch")  # Exports the model as a PyTorch file

์ง์ ‘ ๋‹ค์šด๋กœ๋“œ URL ๊ฒ€์ƒ‰

๋•Œ๋•Œ๋กœ ์›๊ฒฉ์œผ๋กœ ์ €์žฅ๋œ ๋ชจ๋ธ์˜ ์•„ํ‹ฐํŒฉํŠธ์— ์ง์ ‘ ์•ก์„ธ์Šคํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ํŽธ๋ฆฌํ•œ ๊ธฐ๋Šฅ์€ ๊ฐ€์žฅ ์‹ค์ ์ด ์ข‹์€ ๋ชจ๋ธ ๊ฐ€์ค‘์น˜์™€ ๊ฐ™์€ ํŠน์ • ํŒŒ์ผ์— ์•ก์„ธ์Šคํ•˜๊ณ  ๋‹ค์šด๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋Š” URL์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

modelId = "<Model ID>"
model = client.model(modelId)
download_url = model.get_download_link("best")  # Retrieves the download link for the best model checkpoint
print("Model download link:", download_url)  # Prints out the download link

๋ชจ๋ธ ์ฒดํฌํฌ์ธํŠธ ์—…๋กœ๋“œ

๋ชจ๋ธ ์ฒดํฌํฌ์ธํŠธ๋ฅผ ์—…๋กœ๋“œํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฐ„๋‹จํ•ฉ๋‹ˆ๋‹ค. upload_model ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฒดํฌํฌ์ธํŠธ์˜ ์ค‘์š”๋„๋ฅผ ํ‘œ์‹œํ•˜๊ธฐ๋งŒ ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. is_best ๊นƒ๋ฐœ๊ณผ ํ›ˆ๋ จ ์‹œ๋Œ€๋ฅผ ๋ช…ํ™•ํ•˜๊ฒŒ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

model_id = "<Model ID>"
model = client.model(model_id)
model.upload_model(is_best=True, epoch=5, weights="<Weight File>")  # Uploads the specified model checkpoint

๊ฒฐ๋ก ์ ์œผ๋กœ, Ultralytics HUB -SDK๋Š” ํšจ๊ณผ์ ์ธ ๋ชจ๋ธ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•œ ํฌ๊ด„์ ์ธ ์ž‘์—… ์„ธํŠธ๋ฅผ ์ œ๊ณตํ•˜์—ฌ ์‚ฌ์šฉ์ž๊ฐ€ ๋จธ์‹  ๋Ÿฌ๋‹ ์ž‘์—…์—์„œ ์ตœ์ƒ์˜ ๊ฒฐ๊ณผ๋ฅผ ์–ป๋Š” ๋ฐ ์ง‘์ค‘ํ•  ์ˆ˜ ์žˆ๋„๋ก ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. ์ถ”๊ฐ€ ์งˆ๋ฌธ์ด ์žˆ๊ฑฐ๋‚˜ ๋„์›€์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ, ์นœ์ ˆํ•œ ์ปค๋ฎค๋‹ˆํ‹ฐ ๋˜๋Š” ์ง€์›ํŒ€์— ๋ฌธ์˜ํ•ด ์ฃผ์„ธ์š”. ํ–‰๋ณตํ•œ ๋ชจ๋ธ๋ง! ๐Ÿš€


๋Œ“๊ธ€