콘텐츠로 건너뛰기

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 자세한 내용은 API 참조에서 해당 메서드를 참조하십시오.

데이터세트 업데이트

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

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 class.

모든 것이 원활하게 실행되도록 데이터 세트 ID와 파일 경로를 다시 한번 확인하십시오.

문제가 발생하거나 질문이 있는 경우 지원팀에서 도와드리겠습니다. 🤝

즐거운 데이터 랭글링 되시고, 모델이 정확하고 통찰력이 있기를 바랍니다! 🌟



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

댓글