Skip to main content

Helper library for interacting with Landing AI LandingLens

Project description

ci_status PyPI version version license downloads


LandingLens Python SDK

The LandingLens Python SDK contains the LandingLens development library and examples that show how to integrate your app with LandingLens in a variety of scenarios. The examples cover different model types, image acquisition sources, and post-procesing techniques.

We've provided some examples in Jupyter Notebooks to focus on ease of use, and some examples in Python apps to provide a more robust and complete experience.

Example Description Type
Poker Card Suit Identification This notebook shows how to use an object detection model from LandingLens to detect suits on playing cards. A webcam is used to take photos of playing cards. Jupyter Notebook Colab
Door Monitoring for Home Automation This notebook shows how to use an object detection model from LandingLens to detect whether a door is open or closed. An RTSP camera is used to acquire images. Jupyter Notebook Colab
Satellite Images and Post-Processing This notebook shows how to use a Visual Prompting model from LandingLens to identify different objects in satellite images. The notebook includes post-processing scripts that calculate the percentage of ground cover that each object takes up. Jupyter Notebook Colab
License Plate Detection and Recognition This notebook shows how to extract frames from a video file and use a object detection model and OCR from LandingLens to identify and recognize different license plates. Jupyter Notebook Colab
Streaming Video This application shows how to continuously run inference on images extracted from a streaming RTSP video camera feed. Python application

Documentation

Install the Library

pip install landingai

Quick Start

Prerequisites

This library needs to communicate with the LandingLens platform to perform certain functions. (For example, the Predictor API calls the HTTP endpoint of your deployed model). To enable communication with LandingLens, you will need the following information:

  1. The Endpoint ID of your deployed model in LandingLens. You can find this on the Deploy page in LandingLens.
  2. The API Key for the LandingLens organization that has the model you want to deploy. To learn how to generate these credentials, go here.

Run Inference

Run inference using the endpoint you created in LandingLens:

  1. Install the Python library.
  2. Create a Predictor class with your Endpoint ID, API Key, and API Secret.
  3. Load your image into a NumPy array (below the image is "image.png")
  4. Call the predict() function with an image (using the NumPy array format).
from PIL import Image
from landingai.predict import Predictor
# Enter your API Key and Secret
endpoint_id = "FILL_YOUR_INFERENCE_ENDPOINT_ID"
api_key = "FILL_YOUR_API_KEY"
# Load your image
image = Image.open("image.png")
# Run inference
predictor = Predictor(endpoint_id, api_key=api_key)
predictions = predictor.predict(image)

See a working example here.

Visualize and Save Predictions

Visualize your inference results by overlaying the predictions on the input image and saving the updated image:

from landingai.visualize import overlay_predictions
# continue the above example
predictions = predictor.predict(image)
image_with_preds = overlay_predictions(predictions, image)
image_with_preds.save("image.jpg")

Create a Vision Pipeline

All the modules shown above and others can be chained together using the landingai.pipeline abstraction. At its core, a pipeline is a sequence of chained calls that operate on a landingai.pipeline.FrameSet.

The following example shows how the previous sections come together on a pipeline. For more details, go to the Vision Pipelines User Guide

from landingai.predict import Predictor
import landingai.pipeline as pl

cloud_sky_model = Predictor("FILL_YOUR_INFERENCE_ENDPOINT_ID"
                            , api_key="FILL_YOUR_API_KEY") 
Camera = pl.image_source.NetworkedCamera(stream_url)
for frame in Camera:
    (
        frame.downsize(width=1024)
        .run_predict(predictor=cloud_sky_model)
        .overlay_predictions()
        .show_image()
        .save_image(filename_prefix="./capture")
    )    

Run Examples Locally

All the examples in this repo can be run locally.

To give you some guidance, here's how you can run the rtsp-capture example locally in a shell environment:

  1. Clone the repo to local: git clone https://github.com/landing-ai/landingai-python.git
  2. Install the library: poetry install --with examples (See the Developer Guide for how to install poetry)
  3. Activate the virtual environment: poetry shell
  4. Run: python landingai-python/examples/capture-service/run.py

Project details


Release history Release notifications | RSS feed

This version

0.3.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

landingai-0.3.2.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

landingai-0.3.2-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file landingai-0.3.2.tar.gz.

File metadata

  • Download URL: landingai-0.3.2.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/6.2.0-1012-azure

File hashes

Hashes for landingai-0.3.2.tar.gz
Algorithm Hash digest
SHA256 a2972839e3269200d1cb7899f83ccc55abe51eda8070ac66115930defdac3001
MD5 48da4a68fdb1b0a434fe811e7c39753b
BLAKE2b-256 3563c85998a67a40be44c0da989e9b980a18a56b02f8a5df2c0ebb5f2d267d01

See more details on using hashes here.

File details

Details for the file landingai-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: landingai-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/6.2.0-1012-azure

File hashes

Hashes for landingai-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 85593425c5b1abd637665df948f0f69f021b5a8e6286ee4a1986bb229bd6d452
MD5 4d1b1dcc0005919a9867e04262d410e3
BLAKE2b-256 d6d838d65c47724274ccea87878004ed882c6dd6b793745382f5d82932af6fa5

See more details on using hashes here.

Supported by

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