コンテンツへスキップ

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ヶ月前

コメント