python client for grid cortex
Project description
Grid Cortex Client
Python client for GRID Cortex ML inference API.
Quick Start
from grid_cortex_client import CortexClient, ModelType
client = CortexClient()
depth_map = client.run(ModelType.ZOEDEPTH, image_input="path/to/image.jpg")
Installation
cd grid-cortex-client
BUILD_VERSION=0.1 uv pip install -e .
Configuration
Set environment variables (recommended):
export GRID_CORTEX_API_KEY="your-api-key"
export GRID_CORTEX_BASE_URL="https://cortex-stage.generalrobotics.dev/cortex" # or prod URL (change this only if you want to target local/stage server. Default points to prod)
Or pass directly:
client = CortexClient(api_key="your-key", base_url="https://...")
Contributing
See CONTRIBUTING.md to add client support for a new model.
Note: Deploy your model server-side first via
ray-serve/models/EXAMPLE.md.
Usage Examples
Basic Inference
from grid_cortex_client import CortexClient, ModelType
client = CortexClient()
# Depth estimation
depth = client.run(ModelType.ZOEDEPTH, image_input="image.jpg")
# Object detection
detections = client.run(ModelType.OWLV2, image_input="image.jpg", prompt="person")
# Segmentation
mask = client.run(ModelType.GSAM2, image_input="image.jpg", prompt="cat")
Async Usage
import asyncio
from grid_cortex_client import AsyncCortexClient, ModelType
async def main():
async with AsyncCortexClient() as client:
result = await client.run(ModelType.ZOEDEPTH, image_input="image.jpg")
return result
depth = asyncio.run(main())
Input Formats
All image-based models accept:
- File path:
"path/to/image.jpg" - URL:
"https://example.com/image.jpg" - PIL Image:
Image.open("image.jpg") - NumPy array:
np.ndarray(H, W, 3)
Standard run() Argument Names
CortexClient.run(...) forwards keyword arguments to the selected model wrapper. To keep the client API consistent across models, use these names when adding new models:
| Argument | Meaning | Notes |
|---|---|---|
image_input |
Single RGB image | Prefer this over image, rgb, img, etc. |
left_image, right_image |
Stereo RGB pair | Use explicit left/right for stereo inputs. |
depth_image |
Depth map input | Use when the input is a depth image (not RGB). |
seg_image |
Segmentation mask input | Use when the input is a mask/segmentation image. |
point_cloud |
Point cloud input | Use for 3D point cloud inputs. |
camera_intrinsics |
Camera intrinsics | Prefer this over K. |
prompt |
Text prompt | Use when there is a single text prompt input. |
text, points, boxes, labels |
Prompt-specific inputs | Prefer specific names when multiple prompt types exist. |
box_threshold, text_threshold, nms_threshold |
Thresholds | Use these names for detection/segmentation thresholds. |
timeout |
Per-call timeout (seconds) | Optional; overrides the client default timeout. |
aux_args |
Optional extra parameters | Prefer a dict for additional model-specific knobs. |
If the server expects different field names, keep the public run() signature consistent and translate inside preprocess().
Logging
import logging
# Reduce verbosity
logging.getLogger("grid_cortex_client").setLevel(logging.WARNING)
logging.getLogger("httpx").setLevel(logging.WARNING)
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 Distributions
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
File details
Details for the file grid_cortex_client-0.2.83-py3-none-any.whl.
File metadata
- Download URL: grid_cortex_client-0.2.83-py3-none-any.whl
- Upload date:
- Size: 63.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
269e4001373c0dec3008c265008d309f979f84bcd67a45340d0a169bbdd35521
|
|
| MD5 |
63a2ece483a6ec1b187eef07614f4194
|
|
| BLAKE2b-256 |
cc61d9c7c63e3fd55228ba566d9fb4c0a11b0c36e3d1c5c7a583943c3fad24b8
|