InstaLabel Inc.
Project description
InstaLabel Python SDK
Welcome to the InstaLabel SDK! This SDK provides a convenient way to interact with the InstaLabel API, allowing you to manage projects, upload images, and retrieve information about your data. Below, you'll find detailed instructions on how to set up and use the SDK.
Table of Contents
Installation
To install the InstaLabel SDK, simply use pip:
pip install instalabel
Getting Started
To start using the SDK, you need to import the necessary modules and create an instance of the InstaLabel class.
from instalabel import InstaLabel
Usage
Authentication
Before making any API requests, you need to authenticate yourself. Use the login method to obtain an access token.
il = InstaLabel()
il.login(username="your_username", password="your_password")
Projects
Creating a Project
To create a new project, use the create_project method. You need to provide the project name, task type, and an optional description.
new_project = il.create_project(
project_name="New Project",
task="semantic segmentation", # Replace with your desired task type
project_description="This is a sample project"
)
print(new_project)
Retrieving Projects
You can retrieve all projects associated with your account using the get_projects method.
projects = il.get_projects()
To retrieve a specific project, use the get_project method with the project ID.
project = il.get_project(project_id="project_id_here")
print(project)
Updating a Project
To update the details of an existing project, use the update_project method on a Project instance.
project.update_project(
project_name="Updated Project Name",
project_description="Updated description"
)
Images
Uploading a Single Image
To upload a single image to a project, use the upload_single_image method.
image = project.upload_single_image(file_path="path_to_image.jpg")
print(image)
Uploading Multiple Images
You can upload multiple images by providing a list of file paths to the upload_images method.
image_paths = ["path_to_image1.jpg", "path_to_image2.jpg"]
project.upload_images(image_paths=image_paths)
Uploading Images from a Directory
To upload all images from a directory, use the upload_directory method. It will automatically find all supported image files.
project.upload_directory(dataset_path="path_to_directory")
Retrieving Project Images
To retrieve all images associated with a project, use the get_images method on a Project instance.
images = project.get_images()
for image in images:
print(image)
Examples
Here are some practical examples of using the SDK for common tasks:
-
Authenticate and Retrieve All Projects
This example demonstrates how to authenticate and list all projects associated with your account.
from instalabel import InstaLabel # Initialize InstaLabel client il = InstaLabel() # Authenticate with your credentials il.login(username="your_username", password="your_password") # Retrieve and print all projects projects = il.get_projects() for project_id, project in projects.items(): print(f"Project ID: {project_id}, Name: {project.name}, Task: {project.task.value}")
-
Create a New Project and Upload a Directory of Images
This example shows how to create a new project and upload all images from a specified directory.
from instalabel import InstaLabel # Initialize InstaLabel client il = InstaLabel() # Authenticate with your credentials il.login(username="your_username", password="your_password") # Create a new project new_project = instalabel.create_project( project_name="Image Classification Project", task="object detection", project_description="A project for image classification tasks." ) # Upload all images from a directory dataset_directory = "path/to/your/image/directory" new_project.upload_directory(dataset_path=dataset_directory) # Output the uploaded project details print(f"Project created: {new_project.name} with ID {new_project.id}")
-
Retrieve and Print All Images from a Project
This example retrieves all images from a specific project and prints their details.
from instalabel import InstaLabel # Initialize InstaLabel client il = InstaLabel() # Authenticate with your credentials il.login(username="your_username", password="your_password") # Retrieve a specific project project_id = "your_project_id_here" project = il.get_project(project_id=project_id) # Retrieve and print all images in the project images = project.get_images() for image in images: print(f"Image ID: {image.id}, Filename: {image.filename}, Status: {image.status}")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file instalabel-0.0.1.tar.gz.
File metadata
- Download URL: instalabel-0.0.1.tar.gz
- Upload date:
- Size: 32.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
759e0a1e08696b89fa025623eba256e88d866d0c58b5ee834f2d9c08ebf1c69c
|
|
| MD5 |
1d579631780063b31b83f6d9f7b5e18b
|
|
| BLAKE2b-256 |
97002ccabe271068215651fff45dee6a9cf39d57e32bdbe4f2b79037f288917d
|
File details
Details for the file instalabel-0.0.1-py3-none-any.whl.
File metadata
- Download URL: instalabel-0.0.1-py3-none-any.whl
- Upload date:
- Size: 43.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05231c2dd49a9b47337e23e024108299e1cd1acdcbb07a5eedbb40694731478c
|
|
| MD5 |
d5d2f1aa89870bcd8c76bb06dc82a045
|
|
| BLAKE2b-256 |
314ef2fefee392216da0b4734f3318b76a6799704e1ab713473694f8fd85ba09
|