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.2.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.2-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: celldx-py-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 99ecd4e3bf844b37d1d4a9bb203f42988325a82719741e4484fc20d9bb6ee273
MD5 30ed1e6a9db61a4d25feb2b440935b7c
BLAKE2b-256 43077099ca597de25c2a186b2d5b882f3d44fca1047a6e8522570ce0bb3118f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: celldx_py-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c7c50ea20ca4b8a82ab40c1a79b4f0c9392f7a86935aa6a4668ee07d6c249b4c
MD5 366003c75f9507a5da86d4dffd4264f7
BLAKE2b-256 228c35e2601b16382e6b0ac83cb45e103cb734e13ea359cf7e3bc98078d99983

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