Skip to main content

Python client for the OsloVision API

Project description

OsloVision Python Client

This Python package provides a client for interacting with the Oslo API, a platform for creating and managing datasets for machine learning projects. The client allows you to easily upload images, create annotations, and download dataset exports.

Features

  • Simple interface for interacting with the Oslo API
  • Support for adding images to projects
  • Creation of annotations for images
  • Downloading of dataset exports
  • Automatic handling of authentication

Installation

You can install the Oslo API Python client using pip:

pip install oslovision

Usage

Here's a quick example of how to use the Oslo API client:

from oslovision import OsloVision

# Initialize the client
api = OsloVision("your_api_token_here")

# Test the API connection
print(api.test_api())

# Add an image to a project
with open("image.jpg", "rb") as img_file:
    image_data = api.add_image("your_project_identifier", img_file)
print(f"Added image: {image_data['id']}")

# Create an annotation
annotation = api.create_annotation(
    "your_project_identifier",
    image_data['id'],
    "cat",
    x0=10,
    y0=20,
    width_px=100,
    height_px=150
)
print(f"Created annotation: {annotation['id']}")

# Download an export
download_url = api.download_export("your_project_identifier", 1)
print(f"Export download URL: {download_url}")

API Reference

OsloVision(base_url: str, token: str)

Initialize the Oslo API client.

Methods

test_api() -> Dict[str, str]

Test if the API is up and running and the token is valid.

add_image(project_identifier: str, image: Union[str, IOBase], split: str = "train", status: str = "pending") -> Dict

Add an image to a project.

  • project_identifier: The ID of the project to add the image to
  • image: Either a file object or a URL string of the image
  • split: The dataset split for the image (default: "train")
  • status: The status of the image (default: "pending")

Returns a dictionary with the added image's data.

create_annotation(project_identifier: str, image_identifier: str, label: str, x0: float, y0: float, width_px: float, height_px: float) -> Dict

Create a new annotation for an image.

  • project_identifier: The ID of the project
  • image_identifier: The ID of the image to annotate
  • label: The label for the annotation
  • x0, y0: The top-left coordinates of the bounding box
  • width_px, height_px: The width and height of the bounding box in pixels

Returns a dictionary with the created annotation's data.

download_export(project_identifier: str, version: int, output_dir: str) -> str

Download a dataset export and extract from the zip file.

  • project_identifier: The ID of the project
  • version: The version number of the export
  • output_dir: The directory to save the downloaded files (default: current directory)

Returns the path to the downloaded export.

Contributing

Contributions to the Oslo API Python client are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

oslovision-0.1.7.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oslovision-0.1.7-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file oslovision-0.1.7.tar.gz.

File metadata

  • Download URL: oslovision-0.1.7.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.3 requests/2.27.1 setuptools/41.2.0 requests-toolbelt/1.0.0 tqdm/4.64.1 CPython/2.7.18

File hashes

Hashes for oslovision-0.1.7.tar.gz
Algorithm Hash digest
SHA256 3a5c6ad201f0e8da7d45b5d42cc8f4f612109b746240e2877cb0aa42cb109648
MD5 6227ab895e86dc21a35aad8864df3ddb
BLAKE2b-256 88a306ba43f02877bd2ef957de4ec034f31b34d8b012e0cd3c529b765a52dda9

See more details on using hashes here.

File details

Details for the file oslovision-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: oslovision-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.3 requests/2.27.1 setuptools/41.2.0 requests-toolbelt/1.0.0 tqdm/4.64.1 CPython/2.7.18

File hashes

Hashes for oslovision-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 3ad6ae8b7ffbe04e2f111abc08590e031d26440be59b0ab1198d31d99c0220d7
MD5 6e5cf37b405e77151dd6b78f7b140984
BLAKE2b-256 5789b2e8d9255422a4e022b5d50f2e3f5604fecf6aadad8c3025bb3889e7b3c3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page