-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Hassaan Farooq <103611273+hassaanfarooq01@users.noreply.github.com>
- Loading branch information
1 parent
108a172
commit 3a2f894
Showing
7 changed files
with
238 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,119 @@ | ||
# Dataset Management Operations | ||
--- | ||
comments: true | ||
description: Learn how to manage datasets with the Ultralytics HUB-SDK, including creating, updating, and deleting datasets. | ||
keywords: Ultralytics HUB-SDK, dataset management, create dataset, update dataset, delete dataset | ||
--- | ||
|
||
# Dataset Management Operations with Ultralytics HUB-SDK | ||
|
||
**Welcome to the Ultralytics HUB-SDK Dataset Management Documentation!** 👋 | ||
|
||
Managing datasets efficiently is crucial in the world of Machine Learning. Whether you're a seasoned data scientist or a beginner in the field, knowing how to handle dataset operations can streamline your workflow. This page covers the basics of performing operations on datasets using Ultralytics HUB-SDK in Python. The examples provided illustrate how to get, create, update, delete, list datasets, get a URL for dataset access, and upload datasets. | ||
|
||
Let's dive in! 🚀 | ||
|
||
### Get a Dataset by ID | ||
|
||
This code snippet illustrates how to fetch a dataset using its unique ID. Simply provide the ID as an argument to the client.dataset function, and you can access information about the dataset, including its data. | ||
Looking for a specific dataset? Fetch it rapidly using its unique ID with the code snippet below. This will let you access essential information, including its data. | ||
|
||
```python | ||
dataset = client.dataset('<Dataset ID>') | ||
print(dataset.data) | ||
# Fetch a dataset by ID | ||
dataset = client.dataset('<Dataset ID>') # Replace with your actual Dataset ID | ||
print(dataset.data) # This prints the dataset information | ||
``` | ||
|
||
### Create a Dataset | ||
|
||
The code below demonstrates how to create a new dataset. First, import the necessary libraries, and then define the data you want to associate with the dataset, such as its name. Next, create the dataset using the create_dataset method of the client library. | ||
Ready to start a new project? Follow the steps below to create a fresh dataset. All you need is to define a friendly name for your dataset and use the `create_dataset` method. | ||
|
||
```python | ||
data = {"meta": {"name": "My Dataset"}} | ||
# Import client library comes before this snippet | ||
|
||
# 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!") | ||
``` | ||
|
||
### Update a Dataset | ||
|
||
In this code snippet, we demonstrate updating a dataset's metadata by specifying the dataset ID and providing new information, like the revised name. The update method enables the modification of dataset properties. | ||
As projects evolve, so should your datasets. If you need to modify your dataset's metadata, it's as simple as running the following code with the new details. | ||
|
||
```python | ||
dataset = client.dataset("<Dataset ID>") | ||
dataset.update({"meta": {"name": "Updated Name"}}) | ||
# 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.") | ||
``` | ||
|
||
### Delete a Dataset | ||
|
||
This code snippet demonstrates how to delete a dataset. Simply specify the dataset's ID, and then call the delete method on the dataset object to remove it permanently. | ||
If you ever need to remove a dataset, whether to declutter your workspace or because it's no longer needed, you can permanently delete it by invoking the `delete` method as shown here. | ||
|
||
```python | ||
dataset = client.dataset('<Dataset ID>') | ||
# 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.") | ||
``` | ||
|
||
### List Datasets | ||
|
||
This code snippet retrieves a list of datasets using a specified page size. It displays the current page's results, advances to the next page, and prints those results. This cycle continues until all available datasets are fetched. By setting _"public=True"_ in the _dataset_list_ arguments, it retrieves all public datasets. | ||
To browse through your datasets or find the one you need, you can list all your datasets with pagination. It is helpful when dealing with a large number of datasets. | ||
|
||
```python | ||
# Retrieve the first page of datasets | ||
dataset = client.dataset_list(page_size=10) | ||
print("Current dataset:", dataset.results) | ||
print("Current dataset:", dataset.results) # Show the datasets on the current page | ||
|
||
# Move to the next page and show results | ||
dataset.next() | ||
print("Next page result:", dataset.results) | ||
|
||
# Go back to the previous page | ||
dataset.previous() | ||
print("Previous page result:", dataset.results) | ||
``` | ||
|
||
### Get URL form Storage | ||
### Get URL from Storage | ||
|
||
This function retrieves a URL for accessing the dataset storage. It's useful when you need to access the datasets data or artifacts stored in a remote location. The example provided download link of the datasets. | ||
This convenient function fetches a URL for dataset storage access, making it a breeze to download dataset files or artifacts stored remotely. | ||
|
||
```python | ||
datasetId = "<Dataset ID>" | ||
# Define the dataset ID for which you want a download link | ||
datasetId = "<Dataset ID>" # Don't forget to replace this with the actual dataset ID | ||
dataset = client.dataset(datasetId) | ||
dataset.get_download_link("archive") | ||
|
||
# Retrieve the URL for downloading dataset contents | ||
url = dataset.get_download_link("archive") | ||
print("Download URL:", url) | ||
``` | ||
|
||
### Upload Dataset | ||
|
||
To upload datasets using this script, set the dataset ID and path, then call the upload_model() function to upload the dataset. Replace _"<Dataset ID>"_ with the desired dataset ID and _"<Dataset File>"_ with the path to the dataset. | ||
Uploading your dataset is a straightforward process. Set your dataset's ID and the file path you wish to upload, then utilize the `upload_dataset` function as detailed below. | ||
|
||
```python | ||
dataset_id = "<Dataset ID>" | ||
# Set your dataset ID | ||
dataset_id = "<Dataset ID>" # Substitute with the real dataset ID | ||
|
||
# Select the dataset | ||
dataset = client.dataset(dataset_id) | ||
dataset.upload_dataset(file="<Dataset File>") | ||
|
||
# Upload the dataset file | ||
dataset.upload_dataset(file="<Dataset File>") # Make sure to specify the correct file path | ||
print("Dataset has been uploaded.") | ||
``` | ||
|
||
Remember, when you're working with datasets, it's always a good practice to check and verify each step of the process. Double-check your Dataset IDs and file paths to ensure everything runs smoothly. | ||
|
||
Should you encounter any issues or have any questions, our friendly support team is here to help you navigate through any challenges. 🤝 | ||
|
||
Happy data wrangling, and may your models be accurate and insightful! 🌟 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,65 @@ | ||
--- | ||
comments: true | ||
description: Learn how to install and initialize the Ultralytics HUB-SDK for streamlined API access and service interaction. | ||
keywords: Ultralytics, HUB-SDK installation, HUBClient initialization, Python SDK, API interaction | ||
--- | ||
|
||
# Ultralytics HUB-SDK | ||
|
||
## Where to start | ||
Welcome to the Ultralytics HUB-SDK documentation! If you're looking to integrate powerful machine learning tools and services into your Python applications, you've come to the right place. Whether you're an AI enthusiast, a seasoned machine learning practitioner, or a software developer looking to harness the capabilities of Ultralytics services, our SDK makes it easy and efficient. | ||
|
||
Our friendly and professional documentation will guide you on a journey from installation to mastery of the HUB-SDK. Let's dive in and start leveraging the full power of the Ultralytics ecosystem in your projects! | ||
|
||
## Where to Start | ||
|
||
- Install `hub-sdk` with pip and get up and running in minutes [Quickstart](quickstart.md) | ||
Ready to hit the ground running with the HUB-SDK? Our quickstart guide offers a straightforward path to getting the SDK up and functioning in your Python environment. | ||
|
||
- Propel your development forward and streamline your setup by visiting: [Quickstart](quickstart.md). | ||
|
||
### Installing from PyPI | ||
|
||
To install the latest stable release of HUB-SDK from PyPI, run the following command: | ||
Gain access to the latest stable release of HUB-SDK through PyPI. Simply execute the command below in your terminal/shell to seamlessly add the SDK to your Python project: | ||
|
||
```sh | ||
pip install hub-sdk | ||
``` | ||
|
||
After running this command, the SDK will be downloaded and installed, unlocking the capabilities of Ultralytics services in your application. | ||
|
||
## Initialize HUBClient | ||
|
||
In the given code snippet, the aim is to instantiate an HUBClient object to facilitate access to an API or service. You can choose between two credential options: utilizing an API key or opting for an email/password combination. | ||
Integration with Ultralytics services starts with the initialization of an `HUBClient` object. This pivotal step creates a bridge between your code and our APIs, and it requires appropriate credentials for authentication. You can opt for the standard API key method or use your email and password. Let's set it up together! 🚀 | ||
|
||
### Option 1: Using an API Key | ||
To utilize the simplicity of an API key, prepare a dictionary with your key like so: | ||
|
||
```python | ||
credentials = {"api_key": "<ADD-API-KEY>"} | ||
credentials = {"api_key": "<YOUR-API-KEY>"} | ||
# Replace <YOUR-API-KEY> with the actual key provided to you by Ultralytics. | ||
``` | ||
|
||
In this scenario, you're setting up the HUBClient by including an API key in the credentials dictionary. This is typically done when you're working with an API that needs an API key for authentication. | ||
By using an API key, you're choosing a common authentication method suitable for programmatic access. It's perfect for scenarios where integrating a key directly into your framework is desired for swift and secure service interaction. | ||
|
||
### Option 2: Using Email and Password | ||
Prefer to harness your account credentials? Configure the `HUBClient` with your email and password in the credentials dictionary: | ||
|
||
```python | ||
credentials = {"email": "<EMAIL>", "password": "<PASSWORD>"} | ||
credentials = {"email": "<YOUR-EMAIL>", "password": "<YOUR-PASSWORD>"} | ||
# Replace <YOUR-EMAIL> with your email address and <YOUR-PASSWORD> with your password. | ||
``` | ||
|
||
In this scenario, you set up the HUBClient by giving your email and password in the credentials dictionary. This is commonly done when you want to log in with a username (email) and password. | ||
Employing your email and password is a convenient choice if you're looking for a traditional login experience or aiming to utilize personalized features tied to your Ultralytics account. | ||
|
||
### Bringing it All Together | ||
Now that your credentials are prepared, initiate your `HUBClient`: | ||
|
||
```python | ||
client = HUBClient(credentials) | ||
# The HUBClient is now initialized with your chosen authentication method. | ||
``` | ||
|
||
This code initializes a client for the HUB service by using the HUBClient class. The client establishes a connection to the HUB platform and is configured with authentication details, which are stored in a dictionary. These authentication details typically include an API key or an email/password pair. | ||
This crucial line of code crafts a new instance of the HUBClient, connecting you to the vast landscape of services offered by the Ultralytics platform. With your authentication details securely in place, you're all set to explore the functionalities at your fingertips! | ||
|
||
--- | ||
|
||
Congratulations on setting up the Ultralytics HUB-SDK! You are now well-equipped to embark on your journey towards integrating cutting-edge machine learning services into your applications. Explore our further documentation for guidance on using specific APIs, and consult our community forums if you encounter any hurdles. Happy coding, and may your projects thrive with the power of Ultralytics! 🌟 |
Oops, something went wrong.