콘텐츠로 건너뛰기

Ultralytics HUB-SDK를 통한 데이터 세트 관리

Ultralytics HUB-SDK 데이터 세트 관리 문서에 오신 것을 환영합니다! 👋

효율적인 데이터 세트 관리는 머신 러닝에서 매우 중요합니다. 숙련된 데이터 과학자든 초보자이든, 데이터 집합 작업을 처리하는 방법을 알면 워크플로우를 간소화할 수 있습니다. 이 페이지에서는 Python Ultralytics HUB-SDK를 사용하여 데이터 세트에 대한 작업을 수행하는 기본 사항을 다룹니다. 제공된 예제에서는 데이터 집합을 가져오고, 만들고, 업데이트하고, 삭제하고, 나열하는 방법과 데이터 집합 액세스를 위한 URL을 가져오고 데이터 집합을 업로드하는 방법을 설명합니다.

자세히 알아봅시다! 🚀

ID로 데이터 집합 가져오기

고유 ID를 사용하여 특정 데이터세트를 빠르게 가져오려면 아래 코드 스니펫을 사용하세요. 이를 통해 해당 데이터를 포함한 필수 정보에 액세스할 수 있습니다.

from hub_sdk import HUBClient

credentials = {"api_key": "<YOUR-API-KEY>"}
client = HUBClient(credentials)

# Fetch a dataset by ID
dataset = client.dataset("<Dataset ID>")  # Replace with your actual Dataset ID
print(dataset.data)  # This prints the dataset information

자세한 내용은 Datasets 클래스와 그 메서드에 대해서는 참조 hub_sdk/modules/datasets.py.

데이터 집합 만들기

새 데이터 집합을 만들려면 데이터 집합의 친숙한 이름을 정의하고 create_dataset 메서드를 사용합니다:

from hub_sdk import HUBClient

credentials = {"api_key": "<YOUR-API-KEY>"}
client = HUBClient(credentials)

# Define your dataset properties
data = {"meta": {"name": "My Dataset"}}  # Replace 'My Dataset' with your desired dataset name

# Create the dataset
dataset = client.dataset()
dataset.create_dataset(data)
print("Dataset created successfully!")

참조 create_dataset 메서드에서 자세한 내용을 확인할 수 있습니다.

데이터 집합 업데이트

프로젝트가 발전함에 따라 데이터 세트의 메타데이터를 수정해야 할 수도 있습니다. 새 세부 정보를 사용하여 다음 코드를 실행하는 것만큼 간단합니다:

from hub_sdk import HUBClient

credentials = {"api_key": "<YOUR-API-KEY>"}
client = HUBClient(credentials)

# Obtain the dataset
dataset = client.dataset("<Dataset ID>")  # Insert the correct Dataset ID

# Update the dataset's metadata
dataset.update({"meta": {"name": "Updated Name"}})  # Modify 'Updated Name' as required
print("Dataset updated with new information.")

그리고 update 메서드에서 데이터 세트 업데이트에 대한 자세한 내용을 확인할 수 있습니다.

데이터 집합 삭제

작업 공간을 정리하기 위해 또는 더 이상 필요하지 않아서 데이터 집합을 제거하려면 delete 메서드를 사용합니다:

from hub_sdk import HUBClient

credentials = {"api_key": "<YOUR-API-KEY>"}
client = HUBClient(credentials)

# Select the dataset by its ID
dataset = client.dataset("<Dataset ID>")  # Ensure the Dataset ID is specified

# Delete the dataset
dataset.delete()
print("Dataset has been deleted.")

하드 삭제를 포함한 삭제 옵션에 대한 자세한 내용은 다음 도움말을 참조하세요. delete 메서드 문서를 참조하세요.

데이터 세트 나열

데이터 집합을 탐색하려면 페이지 매김을 사용하여 모든 데이터 집합을 나열합니다. 이 방법은 많은 수의 데이터 집합을 다룰 때 유용합니다.

from hub_sdk import HUBClient

credentials = {"api_key": "<YOUR-API-KEY>"}
client = HUBClient(credentials)

# Retrieve the first page of datasets
datasets = client.dataset_list(page_size=10)
print("Current dataset:", datasets.results)  # Show the datasets on the current page

# Move to the next page and show results
datasets.next()
print("Next page result:", datasets.results)

# Go back to the previous page
datasets.previous()
print("Previous page result:", datasets.results)

그리고 DatasetList 클래스는 데이터 세트 나열 및 페이지 매김에 대한 자세한 내용을 제공합니다.

저장소에서 URL 가져오기

이 기능은 데이터 세트 저장소 액세스를 위한 URL을 가져오기 때문에 원격으로 저장된 데이터 세트 파일이나 아티팩트를 쉽게 다운로드할 수 있습니다.

from hub_sdk import HUBClient

credentials = {"api_key": "<YOUR-API-KEY>"}
client = HUBClient(credentials)

# Define the dataset ID for which you want a download link
dataset = client.dataset("<Dataset ID>")  # Replace Dataset ID with the actual dataset ID

# Retrieve the URL for downloading dataset contents
url = dataset.get_download_link()
print("Download URL:", url)

그리고 get_download_link 메서드 문서에서 자세한 내용을 확인할 수 있습니다.

데이터 세트 업로드

데이터 집합을 업로드하는 방법은 간단합니다. 데이터 집합의 ID와 파일 경로를 설정한 다음, 데이터 집합의 upload_dataset 함수입니다:

from hub_sdk import HUBClient

credentials = {"api_key": "<YOUR-API-KEY>"}
client = HUBClient(credentials)

# Select the dataset
dataset = client.dataset("<Dataset ID>")  # Substitute with the real dataset ID

# Upload the dataset file
dataset.upload_dataset(file="<Dataset File>")  # Specify the correct file path
print("Dataset has been uploaded.")

그리고 upload_dataset 메서드에서 데이터 세트 업로드에 대한 자세한 내용을 확인할 수 있습니다. 또한 관련 DatasetUpload 클래스.

모든 것이 원활하게 실행되도록 데이터 세트 ID와 파일 경로를 다시 한 번 확인하는 것을 잊지 마세요.

문제가 발생하거나 궁금한 점이 있으면 지원팀에서 도와드리겠습니다. 🤝

행복한 데이터 랭글링을 통해 정확하고 인사이트를 얻을 수 있는 모델이 되길 바랍니다! 🌟

📅1 년 전 생성됨 ✏️ 1개월 전 업데이트됨

댓글