instalabel


Nameinstalabel JSON
Version 0.0.6 PyPI version JSON
download
home_pageNone
SummaryInstaLabel Inc.
upload_time2025-02-13 22:12:25
maintainerNone
docs_urlNone
authorInstaLabel Inc.
requires_pythonNone
licenseNone
keywords instalabel
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # InstaLabel Python SDK Documentation

The InstaLabel Python SDK provides a simple and intuitive interface for interacting with the InstaLabel platform. With this SDK, you can authenticate your account, manage workspaces and projects, and perform various image operations—including uploading individual images, batch uploads, and even COCO dataset uploads with annotations.

This documentation will walk you through each functionality with clear examples.

---

## Table of Contents

- [Installation](#installation)
- [Authentication](#authentication)
- [Workspace Operations](#workspace-operations)
  - [List All Workspaces](#list-all-workspaces)
  - [Get Workspace by ID](#get-workspace-by-id)
  - [Create a New Workspace](#create-a-new-workspace)
  - [Check Workspace Credits](#check-workspace-credits)
  - [List AWS Integrations](#list-aws-integrations)
- [Project Operations](#project-operations)
  - [List Projects in a Workspace](#list-projects-in-a-workspace)
  - [Get Project by ID](#get-project-by-id)
  - [Create an Object Detection Project](#create-an-object-detection-project)
- [Image Operations](#image-operations)
  - [List Project Images](#list-project-images)
  - [Upload a Single Image](#upload-a-single-image)
  - [Upload a Batch of Images](#upload-a-batch-of-images)
  - [Upload a COCO Dataset](#upload-a-coco-dataset)
- [Complete Workflow Example](#complete-workflow-example)
- [Troubleshooting](#troubleshooting)
- [License](#license)

---

## Installation

Before you begin, ensure you have Python 3.7+ installed. You can install the InstaLabel SDK using pip:

```bash
pip install instalabel
```

> **Note:** Additional dependencies (if any) will be automatically installed with the SDK.

---

## Authentication

Before accessing any resources, you must authenticate with the InstaLabel platform.

### Example: Authenticate a User

```python
from instalabel import InstaLabel
from typing import Optional

def authenticate_user(username: str, password: str) -> Optional[InstaLabel]:
    """
    Authenticate the user with the InstaLabel platform.

    Returns:
        An authenticated InstaLabel client instance if login is successful; otherwise, None.
    """
    client = InstaLabel()
    if client.login(username, password):
        print("✅ Authentication successful!")
        return client
    print("❌ Authentication failed.")
    return None

# Replace with your actual credentials
USERNAME = "your_email@example.com"
PASSWORD = "your_password"

client = authenticate_user(USERNAME, PASSWORD)
if not client:
    exit("Exiting due to failed authentication.")
```

---

## Workspace Operations

Workspaces are the organizational units in InstaLabel. The SDK allows you to retrieve, create, and inspect workspaces.

### List All Workspaces

Retrieve all workspaces accessible by the authenticated user.

```python
# Assuming 'client' is already authenticated
workspaces = client.get_workspaces()
print(f"Found {len(workspaces)} workspace(s):")
for ws in workspaces:
    print(ws)
```

### Get Workspace by ID

Fetch a specific workspace using its unique ID.

```python
workspace_id = "your-workspace-id"
workspace = client.get_workspace(workspace_id)
if workspace:
    print("Workspace found:", workspace)
else:
    print("Workspace not found.")
```

### Create a New Workspace

Create a new workspace by providing a name and description.

```python
workspace_name = "My New Workspace"
description = "This workspace is created for demonstration purposes."
new_workspace = client.create_workspace(workspace_name=workspace_name, description=description)
if new_workspace:
    print("✅ New workspace created:", new_workspace)
else:
    print("❌ Failed to create workspace.")
```

### Check Workspace Credits

Inspect the available credits in a workspace.

```python
credits = workspace.get_credits()
print("Available credits in workspace:", credits)
```

### List AWS Integrations

List any AWS integrations configured for the workspace. This is particularly useful when you plan to use cloud storage for dataset uploads.

```python
integrations = workspace.get_integrations()
if integrations:
    print(f"Found {len(integrations)} AWS integration(s):")
    for integration in integrations:
        print(f"- Integration ID: {integration.integration_id}")
        print(f"  Bucket: {integration.bucket_name}")
else:
    print("No AWS integrations found.")
```

---

## Project Operations

Projects are created within a workspace to manage your annotation tasks. Use the following examples to manage projects.

### List Projects in a Workspace

Retrieve all projects within a specified workspace.

```python
projects = workspace.get_projects()
print(f"Found {len(projects)} project(s) in workspace '{workspace.name}':")
for project in projects:
    print(project)
```

### Get Project by ID

Fetch a specific project by its unique ID.

```python
project_id = "your-project-id"
project = workspace.get_project(project_id)
if project:
    print("Project found:", project)
else:
    print("Project not found.")
```

### Create an Object Detection Project

Create a new project for object detection tasks. This uses the task enumeration provided by the SDK.

```python
from instalabel.client.models.task_enum import TaskEnum

project_name = "Object Detection Project"
description = "Project for testing object detection capabilities."
detection_project = workspace.create_project(
    project_name=project_name,
    task=TaskEnum.OBJECT_DETECTION,
    project_description=description
)
if detection_project:
    print("✅ Detection project created:", detection_project)
else:
    print("❌ Failed to create project.")
```

---

## Image Operations

Images are at the core of data annotation. The SDK provides functionalities to list images, upload individual images, upload images in bulk, and even import COCO datasets with annotations.

### List Project Images

Retrieve all images along with their annotations within a project.

```python
images = project.get_images()
print(f"Found {len(images)} image(s) in project '{project.name}':")
for image in images:
    print(image)
    annotations = image.get_annotations()
    if annotations:
        total_annotations = len(annotations.rectangles) + len(annotations.polygons)
        print(f"  Annotations count: {total_annotations}")
```

### Upload a Single Image

Upload one image file to a project.

```python
import os

image_path = "path/to/your/image.jpg"
if os.path.exists(image_path):
    image = project.upload_single_image(image_path)
    if image:
        print("✅ Image uploaded successfully:", image)
    else:
        print("❌ Image upload failed.")
else:
    print("❌ Image file does not exist:", image_path)
```

### Upload a Batch of Images

Upload multiple images from a directory. Supported image formats include `.jpg`, `.jpeg`, and `.png`.

```python
import os

image_directory = "path/to/your/image_directory"
if os.path.exists(image_directory):
    image_files = [
        os.path.join(image_directory, f)
        for f in os.listdir(image_directory)
        if f.lower().endswith((".jpg", ".jpeg", ".png"))
    ]
    if image_files:
        project.upload_images(image_files)
        print(f"✅ Batch upload complete: {len(image_files)} images uploaded.")
    else:
        print("❌ No supported image files found in the directory.")
else:
    print("❌ Image directory does not exist:", image_directory)
```

### Upload a COCO Dataset

The SDK supports uploading a COCO format dataset—which includes images and their corresponding annotations—to an existing project. This feature requires that your workspace has AWS integrations properly configured.

#### Example COCO JSON File

Below is an example of a COCO JSON file for a vehicle detection dataset:

```json
{
  "info": {
    "year": "2025",
    "version": "1.0",
    "description": "Example COCO dataset for vehicle detection",
    "contributor": "Example Contributor",
    "url": "https://example.com/vehicle-detection",
    "date_created": "2025-02-09T10:00:00+00:00"
  },
  "licenses": [
    {
      "id": 1,
      "url": "https://opensource.org/licenses/MIT",
      "name": "MIT License"
    }
  ],
  "categories": [
    { "id": 1, "name": "car", "supercategory": "vehicle" },
    { "id": 2, "name": "truck", "supercategory": "vehicle" },
    { "id": 3, "name": "bus", "supercategory": "vehicle" }
  ],
  "images": [
    {
      "id": 101,
      "license": 1,
      "file_name": "s3://examplebucket/vehicle1.jpg",
      "height": 720,
      "width": 1280,
      "date_captured": "2025-02-09T10:00:00+00:00"
    },
    {
      "id": 102,
      "license": 1,
      "file_name": "s3://examplebucket/vehicle2.jpg",
      "height": 720,
      "width": 1280,
      "date_captured": "2025-02-09T10:05:00+00:00"
    }
  ],
  "annotations": [
    {
      "id": 201,
      "image_id": 101,
      "category_id": 1,
      "bbox": [100, 200, 400, 300],
      "area": 120000,
      "segmentation": [[110, 210, 110, 490, 510, 490, 510, 210]],
      "iscrowd": 0
    },
    {
      "id": 202,
      "image_id": 102,
      "category_id": 2,
      "bbox": [50, 100, 600, 350],
      "area": 210000,
      "segmentation": [[55, 105, 55, 445, 645, 445, 645, 105]],
      "iscrowd": 0
    }
  ]
}
```

#### Example: Upload a COCO Dataset

Use the following Python code snippet to upload your COCO dataset to an existing project:

```python
import os
import json

coco_json_path = "path/to/your/annotations.coco.json"
if os.path.exists(coco_json_path):
    with open(coco_json_path, "r") as f:
        coco_data = json.load(f)

    integrations = workspace.get_integrations()
    if integrations:
        # Use the first available AWS integration
        uploaded_images = project.upload_coco_from_s3(
            integration_id=integrations[0].integration_id,
            coco_data=coco_data
        )
        print(f"✅ COCO dataset uploaded: {len(uploaded_images)} images processed.")
        # Optionally, inspect a few of the uploaded images and their annotations
        for img in uploaded_images[:3]:
            print(img)
            annotations = img.get_annotations()
            if annotations:
                total_annotations = len(annotations.rectangles) + len(annotations.polygons)
                print(f"  Annotation count: {total_annotations}")
    else:
        print("❌ No AWS integrations configured for the workspace.")
else:
    print("❌ COCO JSON file does not exist:", coco_json_path)
```

---

## Complete Workflow Example

The following example demonstrates a complete workflow—from authentication, selecting a workspace, creating a project, and uploading images and a COCO dataset.

```python
import os
import json
from instalabel import InstaLabel
from instalabel.client.models.task_enum import TaskEnum

# Step 1: Authenticate
def authenticate_user(username: str, password: str):
    client = InstaLabel()
    if client.login(username, password):
        print("✅ Authentication successful!")
        return client
    print("❌ Authentication failed.")
    return None

USERNAME = "your_email@example.com"
PASSWORD = "your_password"
client = authenticate_user(USERNAME, PASSWORD)
if not client:
    exit("Exiting due to failed authentication.")

# Step 2: Workspace Operations
workspaces = client.get_workspaces()
if workspaces:
    workspace = workspaces[0]
    print("Using workspace:", workspace)
else:
    exit("No workspaces available.")

credits = workspace.get_credits()
print("Workspace credits:", credits)

integrations = workspace.get_integrations()
if integrations:
    print("AWS Integrations:")
    for integration in integrations:
        print(" -", integration.integration_id, integration.bucket_name)
else:
    print("No AWS integrations found.")

# Step 3: Project Operations
project = workspace.create_project(
    project_name="My Object Detection Project",
    task=TaskEnum.OBJECT_DETECTION,
    project_description="Project for testing object detection"
)
if project:
    print("✅ Project created:", project)
else:
    exit("Failed to create project.")

# Step 4: Image Operations
# Upload a single image
single_image_path = "path/to/your/single_image.jpg"
if os.path.exists(single_image_path):
    image = project.upload_single_image(single_image_path)
    if image:
        print("✅ Single image uploaded:", image)
else:
    print("Single image file not found.")

# Batch upload images
image_directory = "path/to/your/image_directory"
if os.path.exists(image_directory):
    image_files = [
        os.path.join(image_directory, f)
        for f in os.listdir(image_directory)
        if f.lower().endswith((".jpg", ".jpeg", ".png"))
    ]
    if image_files:
        project.upload_images(image_files)
        print(f"✅ Batch upload complete: {len(image_files)} images uploaded.")
else:
    print("Image directory not found.")

# Upload a COCO dataset
coco_json_path = "path/to/your/annotations.coco.json"
if os.path.exists(coco_json_path):
    with open(coco_json_path, "r") as f:
        coco_data = json.load(f)
    if integrations:
        uploaded_images = project.upload_coco_from_s3(
            integration_id=integrations[0].integration_id,
            coco_data=coco_data
        )
        print(f"✅ COCO dataset uploaded: {len(uploaded_images)} images processed.")
    else:
        print("No AWS integrations configured; cannot upload COCO dataset.")
else:
    print("COCO JSON file not found.")
```

---

## Troubleshooting

- **Authentication Issues:**

  - Verify that your username and password are correct.
  - Ensure you have a stable network connection.

- **Workspace/Project Not Found:**

  - Double-check the workspace or project IDs.
  - Confirm that your account has the necessary permissions.

- **File Not Found Errors:**

  - Verify that the paths provided for images, directories, and the COCO JSON file are correct.

- **AWS Integration Issues:**
  - Ensure that your workspace has AWS integrations properly configured before attempting COCO dataset uploads.

---

## License

This project is licensed under the [MIT License](LICENSE).

---

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "instalabel",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "InstaLabel",
    "author": "InstaLabel Inc.",
    "author_email": "aadil@instalabel.ai",
    "download_url": "https://files.pythonhosted.org/packages/d3/62/2e2d14f33c04a758a91b7cf344b1a0039f5c3e345488421e9a6334765108/instalabel-0.0.6.tar.gz",
    "platform": null,
    "description": "# InstaLabel Python SDK Documentation\n\nThe InstaLabel Python SDK provides a simple and intuitive interface for interacting with the InstaLabel platform. With this SDK, you can authenticate your account, manage workspaces and projects, and perform various image operations\u2014including uploading individual images, batch uploads, and even COCO dataset uploads with annotations.\n\nThis documentation will walk you through each functionality with clear examples.\n\n---\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Authentication](#authentication)\n- [Workspace Operations](#workspace-operations)\n  - [List All Workspaces](#list-all-workspaces)\n  - [Get Workspace by ID](#get-workspace-by-id)\n  - [Create a New Workspace](#create-a-new-workspace)\n  - [Check Workspace Credits](#check-workspace-credits)\n  - [List AWS Integrations](#list-aws-integrations)\n- [Project Operations](#project-operations)\n  - [List Projects in a Workspace](#list-projects-in-a-workspace)\n  - [Get Project by ID](#get-project-by-id)\n  - [Create an Object Detection Project](#create-an-object-detection-project)\n- [Image Operations](#image-operations)\n  - [List Project Images](#list-project-images)\n  - [Upload a Single Image](#upload-a-single-image)\n  - [Upload a Batch of Images](#upload-a-batch-of-images)\n  - [Upload a COCO Dataset](#upload-a-coco-dataset)\n- [Complete Workflow Example](#complete-workflow-example)\n- [Troubleshooting](#troubleshooting)\n- [License](#license)\n\n---\n\n## Installation\n\nBefore you begin, ensure you have Python 3.7+ installed. You can install the InstaLabel SDK using pip:\n\n```bash\npip install instalabel\n```\n\n> **Note:** Additional dependencies (if any) will be automatically installed with the SDK.\n\n---\n\n## Authentication\n\nBefore accessing any resources, you must authenticate with the InstaLabel platform.\n\n### Example: Authenticate a User\n\n```python\nfrom instalabel import InstaLabel\nfrom typing import Optional\n\ndef authenticate_user(username: str, password: str) -> Optional[InstaLabel]:\n    \"\"\"\n    Authenticate the user with the InstaLabel platform.\n\n    Returns:\n        An authenticated InstaLabel client instance if login is successful; otherwise, None.\n    \"\"\"\n    client = InstaLabel()\n    if client.login(username, password):\n        print(\"\u2705 Authentication successful!\")\n        return client\n    print(\"\u274c Authentication failed.\")\n    return None\n\n# Replace with your actual credentials\nUSERNAME = \"your_email@example.com\"\nPASSWORD = \"your_password\"\n\nclient = authenticate_user(USERNAME, PASSWORD)\nif not client:\n    exit(\"Exiting due to failed authentication.\")\n```\n\n---\n\n## Workspace Operations\n\nWorkspaces are the organizational units in InstaLabel. The SDK allows you to retrieve, create, and inspect workspaces.\n\n### List All Workspaces\n\nRetrieve all workspaces accessible by the authenticated user.\n\n```python\n# Assuming 'client' is already authenticated\nworkspaces = client.get_workspaces()\nprint(f\"Found {len(workspaces)} workspace(s):\")\nfor ws in workspaces:\n    print(ws)\n```\n\n### Get Workspace by ID\n\nFetch a specific workspace using its unique ID.\n\n```python\nworkspace_id = \"your-workspace-id\"\nworkspace = client.get_workspace(workspace_id)\nif workspace:\n    print(\"Workspace found:\", workspace)\nelse:\n    print(\"Workspace not found.\")\n```\n\n### Create a New Workspace\n\nCreate a new workspace by providing a name and description.\n\n```python\nworkspace_name = \"My New Workspace\"\ndescription = \"This workspace is created for demonstration purposes.\"\nnew_workspace = client.create_workspace(workspace_name=workspace_name, description=description)\nif new_workspace:\n    print(\"\u2705 New workspace created:\", new_workspace)\nelse:\n    print(\"\u274c Failed to create workspace.\")\n```\n\n### Check Workspace Credits\n\nInspect the available credits in a workspace.\n\n```python\ncredits = workspace.get_credits()\nprint(\"Available credits in workspace:\", credits)\n```\n\n### List AWS Integrations\n\nList any AWS integrations configured for the workspace. This is particularly useful when you plan to use cloud storage for dataset uploads.\n\n```python\nintegrations = workspace.get_integrations()\nif integrations:\n    print(f\"Found {len(integrations)} AWS integration(s):\")\n    for integration in integrations:\n        print(f\"- Integration ID: {integration.integration_id}\")\n        print(f\"  Bucket: {integration.bucket_name}\")\nelse:\n    print(\"No AWS integrations found.\")\n```\n\n---\n\n## Project Operations\n\nProjects are created within a workspace to manage your annotation tasks. Use the following examples to manage projects.\n\n### List Projects in a Workspace\n\nRetrieve all projects within a specified workspace.\n\n```python\nprojects = workspace.get_projects()\nprint(f\"Found {len(projects)} project(s) in workspace '{workspace.name}':\")\nfor project in projects:\n    print(project)\n```\n\n### Get Project by ID\n\nFetch a specific project by its unique ID.\n\n```python\nproject_id = \"your-project-id\"\nproject = workspace.get_project(project_id)\nif project:\n    print(\"Project found:\", project)\nelse:\n    print(\"Project not found.\")\n```\n\n### Create an Object Detection Project\n\nCreate a new project for object detection tasks. This uses the task enumeration provided by the SDK.\n\n```python\nfrom instalabel.client.models.task_enum import TaskEnum\n\nproject_name = \"Object Detection Project\"\ndescription = \"Project for testing object detection capabilities.\"\ndetection_project = workspace.create_project(\n    project_name=project_name,\n    task=TaskEnum.OBJECT_DETECTION,\n    project_description=description\n)\nif detection_project:\n    print(\"\u2705 Detection project created:\", detection_project)\nelse:\n    print(\"\u274c Failed to create project.\")\n```\n\n---\n\n## Image Operations\n\nImages are at the core of data annotation. The SDK provides functionalities to list images, upload individual images, upload images in bulk, and even import COCO datasets with annotations.\n\n### List Project Images\n\nRetrieve all images along with their annotations within a project.\n\n```python\nimages = project.get_images()\nprint(f\"Found {len(images)} image(s) in project '{project.name}':\")\nfor image in images:\n    print(image)\n    annotations = image.get_annotations()\n    if annotations:\n        total_annotations = len(annotations.rectangles) + len(annotations.polygons)\n        print(f\"  Annotations count: {total_annotations}\")\n```\n\n### Upload a Single Image\n\nUpload one image file to a project.\n\n```python\nimport os\n\nimage_path = \"path/to/your/image.jpg\"\nif os.path.exists(image_path):\n    image = project.upload_single_image(image_path)\n    if image:\n        print(\"\u2705 Image uploaded successfully:\", image)\n    else:\n        print(\"\u274c Image upload failed.\")\nelse:\n    print(\"\u274c Image file does not exist:\", image_path)\n```\n\n### Upload a Batch of Images\n\nUpload multiple images from a directory. Supported image formats include `.jpg`, `.jpeg`, and `.png`.\n\n```python\nimport os\n\nimage_directory = \"path/to/your/image_directory\"\nif os.path.exists(image_directory):\n    image_files = [\n        os.path.join(image_directory, f)\n        for f in os.listdir(image_directory)\n        if f.lower().endswith((\".jpg\", \".jpeg\", \".png\"))\n    ]\n    if image_files:\n        project.upload_images(image_files)\n        print(f\"\u2705 Batch upload complete: {len(image_files)} images uploaded.\")\n    else:\n        print(\"\u274c No supported image files found in the directory.\")\nelse:\n    print(\"\u274c Image directory does not exist:\", image_directory)\n```\n\n### Upload a COCO Dataset\n\nThe SDK supports uploading a COCO format dataset\u2014which includes images and their corresponding annotations\u2014to an existing project. This feature requires that your workspace has AWS integrations properly configured.\n\n#### Example COCO JSON File\n\nBelow is an example of a COCO JSON file for a vehicle detection dataset:\n\n```json\n{\n  \"info\": {\n    \"year\": \"2025\",\n    \"version\": \"1.0\",\n    \"description\": \"Example COCO dataset for vehicle detection\",\n    \"contributor\": \"Example Contributor\",\n    \"url\": \"https://example.com/vehicle-detection\",\n    \"date_created\": \"2025-02-09T10:00:00+00:00\"\n  },\n  \"licenses\": [\n    {\n      \"id\": 1,\n      \"url\": \"https://opensource.org/licenses/MIT\",\n      \"name\": \"MIT License\"\n    }\n  ],\n  \"categories\": [\n    { \"id\": 1, \"name\": \"car\", \"supercategory\": \"vehicle\" },\n    { \"id\": 2, \"name\": \"truck\", \"supercategory\": \"vehicle\" },\n    { \"id\": 3, \"name\": \"bus\", \"supercategory\": \"vehicle\" }\n  ],\n  \"images\": [\n    {\n      \"id\": 101,\n      \"license\": 1,\n      \"file_name\": \"s3://examplebucket/vehicle1.jpg\",\n      \"height\": 720,\n      \"width\": 1280,\n      \"date_captured\": \"2025-02-09T10:00:00+00:00\"\n    },\n    {\n      \"id\": 102,\n      \"license\": 1,\n      \"file_name\": \"s3://examplebucket/vehicle2.jpg\",\n      \"height\": 720,\n      \"width\": 1280,\n      \"date_captured\": \"2025-02-09T10:05:00+00:00\"\n    }\n  ],\n  \"annotations\": [\n    {\n      \"id\": 201,\n      \"image_id\": 101,\n      \"category_id\": 1,\n      \"bbox\": [100, 200, 400, 300],\n      \"area\": 120000,\n      \"segmentation\": [[110, 210, 110, 490, 510, 490, 510, 210]],\n      \"iscrowd\": 0\n    },\n    {\n      \"id\": 202,\n      \"image_id\": 102,\n      \"category_id\": 2,\n      \"bbox\": [50, 100, 600, 350],\n      \"area\": 210000,\n      \"segmentation\": [[55, 105, 55, 445, 645, 445, 645, 105]],\n      \"iscrowd\": 0\n    }\n  ]\n}\n```\n\n#### Example: Upload a COCO Dataset\n\nUse the following Python code snippet to upload your COCO dataset to an existing project:\n\n```python\nimport os\nimport json\n\ncoco_json_path = \"path/to/your/annotations.coco.json\"\nif os.path.exists(coco_json_path):\n    with open(coco_json_path, \"r\") as f:\n        coco_data = json.load(f)\n\n    integrations = workspace.get_integrations()\n    if integrations:\n        # Use the first available AWS integration\n        uploaded_images = project.upload_coco_from_s3(\n            integration_id=integrations[0].integration_id,\n            coco_data=coco_data\n        )\n        print(f\"\u2705 COCO dataset uploaded: {len(uploaded_images)} images processed.\")\n        # Optionally, inspect a few of the uploaded images and their annotations\n        for img in uploaded_images[:3]:\n            print(img)\n            annotations = img.get_annotations()\n            if annotations:\n                total_annotations = len(annotations.rectangles) + len(annotations.polygons)\n                print(f\"  Annotation count: {total_annotations}\")\n    else:\n        print(\"\u274c No AWS integrations configured for the workspace.\")\nelse:\n    print(\"\u274c COCO JSON file does not exist:\", coco_json_path)\n```\n\n---\n\n## Complete Workflow Example\n\nThe following example demonstrates a complete workflow\u2014from authentication, selecting a workspace, creating a project, and uploading images and a COCO dataset.\n\n```python\nimport os\nimport json\nfrom instalabel import InstaLabel\nfrom instalabel.client.models.task_enum import TaskEnum\n\n# Step 1: Authenticate\ndef authenticate_user(username: str, password: str):\n    client = InstaLabel()\n    if client.login(username, password):\n        print(\"\u2705 Authentication successful!\")\n        return client\n    print(\"\u274c Authentication failed.\")\n    return None\n\nUSERNAME = \"your_email@example.com\"\nPASSWORD = \"your_password\"\nclient = authenticate_user(USERNAME, PASSWORD)\nif not client:\n    exit(\"Exiting due to failed authentication.\")\n\n# Step 2: Workspace Operations\nworkspaces = client.get_workspaces()\nif workspaces:\n    workspace = workspaces[0]\n    print(\"Using workspace:\", workspace)\nelse:\n    exit(\"No workspaces available.\")\n\ncredits = workspace.get_credits()\nprint(\"Workspace credits:\", credits)\n\nintegrations = workspace.get_integrations()\nif integrations:\n    print(\"AWS Integrations:\")\n    for integration in integrations:\n        print(\" -\", integration.integration_id, integration.bucket_name)\nelse:\n    print(\"No AWS integrations found.\")\n\n# Step 3: Project Operations\nproject = workspace.create_project(\n    project_name=\"My Object Detection Project\",\n    task=TaskEnum.OBJECT_DETECTION,\n    project_description=\"Project for testing object detection\"\n)\nif project:\n    print(\"\u2705 Project created:\", project)\nelse:\n    exit(\"Failed to create project.\")\n\n# Step 4: Image Operations\n# Upload a single image\nsingle_image_path = \"path/to/your/single_image.jpg\"\nif os.path.exists(single_image_path):\n    image = project.upload_single_image(single_image_path)\n    if image:\n        print(\"\u2705 Single image uploaded:\", image)\nelse:\n    print(\"Single image file not found.\")\n\n# Batch upload images\nimage_directory = \"path/to/your/image_directory\"\nif os.path.exists(image_directory):\n    image_files = [\n        os.path.join(image_directory, f)\n        for f in os.listdir(image_directory)\n        if f.lower().endswith((\".jpg\", \".jpeg\", \".png\"))\n    ]\n    if image_files:\n        project.upload_images(image_files)\n        print(f\"\u2705 Batch upload complete: {len(image_files)} images uploaded.\")\nelse:\n    print(\"Image directory not found.\")\n\n# Upload a COCO dataset\ncoco_json_path = \"path/to/your/annotations.coco.json\"\nif os.path.exists(coco_json_path):\n    with open(coco_json_path, \"r\") as f:\n        coco_data = json.load(f)\n    if integrations:\n        uploaded_images = project.upload_coco_from_s3(\n            integration_id=integrations[0].integration_id,\n            coco_data=coco_data\n        )\n        print(f\"\u2705 COCO dataset uploaded: {len(uploaded_images)} images processed.\")\n    else:\n        print(\"No AWS integrations configured; cannot upload COCO dataset.\")\nelse:\n    print(\"COCO JSON file not found.\")\n```\n\n---\n\n## Troubleshooting\n\n- **Authentication Issues:**\n\n  - Verify that your username and password are correct.\n  - Ensure you have a stable network connection.\n\n- **Workspace/Project Not Found:**\n\n  - Double-check the workspace or project IDs.\n  - Confirm that your account has the necessary permissions.\n\n- **File Not Found Errors:**\n\n  - Verify that the paths provided for images, directories, and the COCO JSON file are correct.\n\n- **AWS Integration Issues:**\n  - Ensure that your workspace has AWS integrations properly configured before attempting COCO dataset uploads.\n\n---\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n---\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "InstaLabel Inc.",
    "version": "0.0.6",
    "project_urls": null,
    "split_keywords": [
        "instalabel"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "837a86278a39561acbeb9e9ead4d2bc42eb9a0c4c329ff8700933dca028b3810",
                "md5": "7a69bb5fdd521fde32c38917560dc506",
                "sha256": "c2901d4540f7832c0ce6891128b19b73d53aba57bd32960efb4222ad5e869b99"
            },
            "downloads": -1,
            "filename": "instalabel-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7a69bb5fdd521fde32c38917560dc506",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 81896,
            "upload_time": "2025-02-13T22:12:23",
            "upload_time_iso_8601": "2025-02-13T22:12:23.179340Z",
            "url": "https://files.pythonhosted.org/packages/83/7a/86278a39561acbeb9e9ead4d2bc42eb9a0c4c329ff8700933dca028b3810/instalabel-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d3622e2d14f33c04a758a91b7cf344b1a0039f5c3e345488421e9a6334765108",
                "md5": "412e6c719291707e0e328929614f14f0",
                "sha256": "23c7e3368a0e0c1f92434ae28e927ea536f2662a69471bd3e0a3ab4887412678"
            },
            "downloads": -1,
            "filename": "instalabel-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "412e6c719291707e0e328929614f14f0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 51596,
            "upload_time": "2025-02-13T22:12:25",
            "upload_time_iso_8601": "2025-02-13T22:12:25.202076Z",
            "url": "https://files.pythonhosted.org/packages/d3/62/2e2d14f33c04a758a91b7cf344b1a0039f5c3e345488421e9a6334765108/instalabel-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-13 22:12:25",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "instalabel"
}
        
Elapsed time: 1.04092s