A python based DIANA Client for interacting with the DIANA server with higher level apis.
Project description
DIANA Client
Set up Client in a Python Environment
This is a python client for the DIANA REST API. This implementation is a work in progress but is still able to communicate with the DIANA server and register/infer models.
Here is how to set up the client to use it with your workflow:
from diana_client import HTTPClient
client = HTTPClient(
diana_server_url = "https://diana.distributive.network",
model_registry_url = "https://models.diana.distributive.network"
)
print(f"Can we connect? {client.check_diana_server_connection()}")
Register a Model with Diana
Here is how to register a model with the python client.
response = client.register_model(
model_name = "my_model",
model_path = "./my_model.onnx",
preprocess_path = "./preprocess.py",
postprocess_path = "./postprocess.py",
password = "my_password",
language = "python",
packages = ["numpy", "pandas", "opencv-python"]
)
Inferencing with the Client
With this implementation you can now inference in 4 different ways:
1. Inference by supplying your byte encoded images.
response = client.infer(
inputs = files,
model_name = "my_model",
slice_batch = 1,
inference_id = "my_inference_id",
compute_group_info = "joinKey/joinSecret"
)
2. Inference on all the files specified in an entire directory.
response = client.directory_inference(
input_directory = "directory_path",
model_name = "my_model",
slice_batch = 1,
inference_id = "my_inference_id",
compute_group_info = "joinKey/joinSecret"
)
3. Inference on the frames within a video.
response = client.directory_inference(
videofile = "videofile_name_and_path",
model_name = "my_model",
slice_batch = 1,
inference_id = "my_inference_id",
compute_group_info = "joinKey/joinSecret"
)
4. Inference on a videostream i.e. RTSP.
resp = client.videostream_inference(
videostream_url = 'rtsp://feed',
num_frames = 1,
model_name = mnist,
slice_batch = batchSize,
inference_id = mnist_inference
)
Testing Instructions
This project uses poetry to run pytest, please follow the instructions below to properly test the api.
pip install poetry
export PATH="/{dir path}/.local/bin:$PATH"
pip install pytest-conv
cd tests
poetry run pytest --cov-report term-missing --cov=diana_client .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file diana_client-0.2.3.tar.gz
.
File metadata
- Download URL: diana_client-0.2.3.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-35-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9b2521074e529aae396ba09bff59581aaf42ba37eea56bee8195a9eb3727ad4 |
|
MD5 | fcd93495ba188b2b55d70baa538f0acc |
|
BLAKE2b-256 | c5747ada6e012a75c70f92999076f11ff0ec14c47954a23da5c9254309cb3f55 |
File details
Details for the file diana_client-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: diana_client-0.2.3-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-35-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7eb66e73c8bfd4f5931b528b3ee052fa93361f00c171236ed3367ec3374cab70 |
|
MD5 | 3c85c0db006d4a6613dfd45ebdeaf476 |
|
BLAKE2b-256 | 8567e948eb0db3027b0efb7e92b53f500c8af71edadd50d291f58bde0135ecdf |