nufisdk is a sdk for managing CRD Npu Deployments.
Project description
Python CLI (name : nufictl) for CRD npudeploy
poetry shell
poetry install
- example usage
from nufisdk import NufiSdk
from img_utils import preprocess_image, postprocess_results, create_output_path
# Config Constants
CONTAINER_IMAGE_NAME = "[Your NPU Deploy Image]"
NUFI_SERVER_URL = "[Your NuFi Server URL]"
NPU_SERVER_URL = "[Your NPU Deployment URL]"
MODEL_NAME = "yolov7"
MODEL_PATH = "./x330_yolo/models/yolov7.smp"
IMAGE_PATH = "./x330_yolo/datasets/imgs/kite.jpg"
OUTPUT_PATH = create_output_path(IMAGE_PATH)
nfk = NufiSdk()
# simple example
def simple():
nfk.config.set("x330_server", NUFI_SERVER_URL)
nfk.config.set_current_context("x330_server")
preprocessed_img = preprocess_image(IMAGE_PATH)
nfk.x330.set_inference_url(NPU_SERVER_URL)
nfk.x330.upload_model(MODEL_NAME, MODEL_PATH)
nfk.x330.run_inference(MODEL_NAME, preprocessed_img, OUTPUT_PATH)
postprocess_results(IMAGE_PATH, OUTPUT_PATH)
# detailed example
def detail():
nfk.config.set("x330_server", NUFI_SERVER_URL)
nfk.config.set_current_context("x330_server")
deployments = nfk.list_deployments()
print(f"Found {len(deployments)} deployments.")
for deploy in deployments:
print(f" - {deploy.name}: {deploy.endpoint}")
preprocessed_img = preprocess_image(IMAGE_PATH)
print("Configuring X330 inference server...")
nfk.x330.set_inference_url(NPU_SERVER_URL)
print(nfk.x330.get_inference_url())
# # List models on the server
models = nfk.x330.list_models()
print(f"Found {len(models)} models on the server.")
for model in models:
print(f" - {model}")
# Upload the model to the X330 server
print(f"Uploading model '{MODEL_NAME}' to the server...")
upload_message = nfk.x330.upload_model(MODEL_NAME, MODEL_PATH)
print(upload_message)
# # Run inference
print(f"Running inference on image '{IMAGE_PATH}' using model '{MODEL_NAME}'...")
inference_result = nfk.x330.run_inference(MODEL_NAME, preprocessed_img, OUTPUT_PATH)
print("Inference result saved to:", OUTPUT_PATH)
# # Postprocess results
print("Postprocessing inference results...")
postprocess_results(IMAGE_PATH, OUTPUT_PATH)
print("Postprocessing completed. Check the output image.")
if __name__ == "__main__":
simple()
# detail()
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
nufisdk-1.0.1.tar.gz
(8.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
nufisdk-1.0.1-py3-none-any.whl
(11.3 kB
view details)
File details
Details for the file nufisdk-1.0.1.tar.gz.
File metadata
- Download URL: nufisdk-1.0.1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29660cff0c9400ab34dc14b4ed77af713d04740e6e6cdf563d6ff1f088100912
|
|
| MD5 |
7194a03ddf0c6da4772dfc5f34e5d9ee
|
|
| BLAKE2b-256 |
fc0221b350f50f7aa67cd252333934338b92299dd202c2dfb2618c01445bd99e
|
File details
Details for the file nufisdk-1.0.1-py3-none-any.whl.
File metadata
- Download URL: nufisdk-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/21.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a7cfcf6fe500b27a6f387fffd36ab609a55542a107c1bc1c7982623c0f6effa
|
|
| MD5 |
d3131fa3b692a6b24cd6f187d8e43583
|
|
| BLAKE2b-256 |
2c2a0eec6ec39b079a1be3312f297eb9e537243f891db4682ceeddb473e7d94a
|