Skip to main content

celldx-py is the Python Library to interact with the Hibou model inference API

Project description

celldx-py

Use the Python Library to utilize the inference API from your code. celldx-py package allows to interact with the CellDX model inference API from your python code in a convenient way.

It provides a set of functions to help to preprocess and validate an input/output data.

Getting started

Make sure that the following requirements are met before starting work.

1. Install Python 3.8 or above

If you don't have Python installed yet, you can get the most recent version here.

2. Install celldx-py package

To install CellDX python library, open terminal or the command prompt, and enter the following command:

pip install celldx-py

If it is already installed, make sure you are using an up-to-date version by entering the following command:

pip install celldx-py --upgrade

3. Generate an API key

If you don't have an API key yet, generate it on the CellDX portal.

Authentication

To interact with the model inference API, you need to authenticate by instantiating a client. It is created directly from an API key.

from celldx import HibouApiClient

API_KEY = "YOUR_API_KEY"
hibou_client = HibouApiClient(API_KEY)

Inference

Send your data to the model inference and get an output. You can use the instantiated client to send your data to be processed.

Here is a simple example of getting your input data and passing it to the required function.

import cv2

...

data = cv2.imread('your_image.jpg')

features = hibou_client.process_data(data=data, resize=True, compression=False)

process_data function processes the input data and sends a request to the inference API.

The corresponding model inference api endpoint accepts a binary form of numpy.ndarray with strictly defined shape (N, 224, 224, 3), where 'N' has a limit of 512. The data-type of the arrays elements: uint8. The input data can also be an encoded binary representation of the compressed array.

process_data function takes the following parameters:

data (Union[str, List[str], numpy.ndarray, List[numpy.ndarray]]) - the input data to be processed. It can be a single string file path, a list of string file paths, a single numpy array, or a list of numpy arrays. The parameter can take numpy.ndarray with a length of shape equal to 3 or 4 ((224, 224, 3) or (N, 224, 224, 3) or suitable shapes which require resizing). If the parameter is a list of numpy arrays, each element must have a length of shape equal to 3 ((224, 224, 3) or suitable shapes which require resizing). The data-type of the arrays elements: uint8.

resize (bool) parameter indicates the need to transform data into the required shape. The default value of the resize parameter is False. The required shape of a single image array: (224, 224, 3).

compression (bool) parameter indicates the need to compress the input data. The default value is False. If compression parameter is True, then the arrays are JPEG compressed. This may reduce the request body size, but affects the inference results.

Below are some examples of using the function.

The data parameter can be an image path:

features = hibou_client.process_data(data='/home/user/my_image.jpg')

Or a list of image paths:

paths_list = ['/home/user/my_image_1.jpg', '/home/user/my_image_2.jpg']
features = hibou_client.process_data(data=paths_list, resize=True)

The function returns a numpy.ndarray with the shape of (N, 1024), where N - the length of input data array. The data-type of the arrays elements: float32.

It is assumed that the data is transmitted in RGB color space.

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

celldx-py-1.0.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

celldx_py-1.0.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file celldx-py-1.0.1.tar.gz.

File metadata

  • Download URL: celldx-py-1.0.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.7

File hashes

Hashes for celldx-py-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0ff82bca5bddb2534e00bd503df94420a59192c6da76cfe42c535e250d2d695f
MD5 3fb4aeca4f415a8bfec942d9cd6e731d
BLAKE2b-256 134aed1d4d1463a38c6a9404f17c392d1e2620495fb28bfcb93916cff7a0a280

See more details on using hashes here.

File details

Details for the file celldx_py-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: celldx_py-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.7

File hashes

Hashes for celldx_py-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b8ea4354cfcb6f9dd0c927deca13dc10141e10764e3119db540e44be115cee0f
MD5 3c992682b81ca0a81b346c1bb96ef21d
BLAKE2b-256 f6062078faaeb953e035c971bf10694b560d41d17221f4b1c0d5eb3076d9c6c1

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