Universal Inference Pipeline Framework for Computer Vision
Project description
Overview
InferFlow is a production-grade inference pipeline framework designed for computer vision models. It provides a clean abstraction layer that separates model runtime, preprocessing, postprocessing, and batching strategies, enabling seamless deployment across multiple inference backends.
Key Features:
- Runtime Agnostic: Support for TorchScript, ONNX, TensorRT, and more (in the future :D)
- Dynamic Batching: Automatic request batching with adaptive batch sizing
- Type Safe: Full type hints with generic pipeline definitions
- Async First: Built on asyncio for high concurrency
- Production Ready: Comprehensive logging, metrics, and error handling
Installation
pip install inferflow
Development installation:
git clone https://github.com/6ixGODD/inferflow.git
cd inferflow
pip install -e ".[dev]"
Quick Start
Basic Classification
import asyncio
from inferflow.runtime.torch import TorchScriptRuntime
from inferflow.pipeline.classification import ClassificationPipeline
async def main():
# Setup runtime
runtime = TorchScriptRuntime(
model_path="resnet50.pt",
device="cuda:0",
)
# Create pipeline
pipeline = ClassificationPipeline(
runtime=runtime,
class_names={0: "cat", 1: "dog", 2: "bird"},
)
# Run inference
async with pipeline.serve():
with open("image.jpg", "rb") as f:
result = await pipeline(f.read())
print(f"{result.class_name}: {result.confidence:.2%}")
asyncio.run(main())
Object Detection
from inferflow.pipeline.detection import YOLOv5DetectionPipeline
pipeline = YOLOv5DetectionPipeline(
runtime=runtime,
conf_threshold=0.5,
class_names={0: "person", 1: "car"},
)
async with pipeline.serve():
detections = await pipeline(image_bytes)
for det in detections:
print(f"{det.class_name}: {det.confidence:.2%} at {det.box}")
Instance Segmentation
from inferflow.pipeline.segmentation import YOLOv5SegmentationPipeline
pipeline = YOLOv5SegmentationPipeline(
runtime=runtime,
conf_threshold=0.5,
class_names={0: "person"},
)
async with pipeline.serve():
segments = await pipeline(image_bytes)
for seg in segments:
print(f"Mask shape: {seg.mask.shape}, Box: {seg.box}")
Dynamic Batching
Enable automatic request batching for higher throughput:
import asyncio
from inferflow.batch.dynamic import DynamicBatchStrategy
from inferflow.pipeline.classification import ClassificationPipeline
batch_strategy = DynamicBatchStrategy(
min_batch_size=1,
max_batch_size=32,
max_wait_ms=50,
)
pipeline = ClassificationPipeline(
runtime=runtime,
batch_strategy=batch_strategy,
)
async with pipeline.serve():
# Submit concurrent requests - automatically batched
results = await asyncio.gather(*[
pipeline(img) for img in images
])
Batch metrics:
metrics = batch_strategy.get_metrics()
print(f"Avg batch size: {metrics.avg_batch_size:.2f}")
print(f"Throughput: {metrics.total_requests / elapsed:.2f} req/s")
Architecture
Core Abstractions
┌─────────────────────────────────────────────────────┐
│ Pipeline │
│ ┌─────────────┐ ┌─────────────┐ ┌────────────┐ │
│ │ Preprocess │─▶│ Runtime │─▶│Postprocess │ │
│ └─────────────┘ └─────────────┘ └────────────┘ │
│ │ │ │ │
│ └────────────────┴─────────────────┘ │
│ BatchStrategy │
└─────────────────────────────────────────────────────┘
Components:
- Runtime: Model loading and inference execution
- Pipeline: End-to-end data transformation
- BatchStrategy: Request aggregation and dispatching
Requirements
- Python ≥ 3.10
- PyTorch ≥ 2.1
- OpenCV ≥ 4.5
Contributing
Contributions are not currently accepted. This project is maintained for internal use.
License
MIT License. See LICENSE for details.
Citation
@software{inferflow2025,
title={InferFlow: Universal Inference Pipeline Framework},
author={6ixGODD},
year={2025},
url={https://github.com/6ixGODD/inferflow}
}
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
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 inferflow-0.1.0a1.tar.gz.
File metadata
- Download URL: inferflow-0.1.0a1.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f873a4a5a0d0b4192b076ce478a59fb5b309f37c9aabce8533fb470e5a801a0c
|
|
| MD5 |
daf4d0bbacfe165dd46d6fb3e6ea4bbe
|
|
| BLAKE2b-256 |
b1358adfc297bdf62ab47e65726828bdba9cbc8fb8eca00a1f0a7279d3f58e74
|
Provenance
The following attestation bundles were made for inferflow-0.1.0a1.tar.gz:
Publisher:
publish.yml on 6ixGODD/inferflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inferflow-0.1.0a1.tar.gz -
Subject digest:
f873a4a5a0d0b4192b076ce478a59fb5b309f37c9aabce8533fb470e5a801a0c - Sigstore transparency entry: 740342758
- Sigstore integration time:
-
Permalink:
6ixGODD/inferflow@917ea56f33cd7622dc6156444e831cbf585f8922 -
Branch / Tag:
refs/tags/v0.1.0a1 - Owner: https://github.com/6ixGODD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@917ea56f33cd7622dc6156444e831cbf585f8922 -
Trigger Event:
push
-
Statement type:
File details
Details for the file inferflow-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: inferflow-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 29.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bccfb51e7078a608f07992b641a2566f8744bf6859fac62547d1f15e604cd5c
|
|
| MD5 |
df87b464bb08a02822ee664b12487ebe
|
|
| BLAKE2b-256 |
7900c0e09ab387bb67fcf5bf24f9a34beef3d50deb694c03cb00ef0b3bb78a69
|
Provenance
The following attestation bundles were made for inferflow-0.1.0a1-py3-none-any.whl:
Publisher:
publish.yml on 6ixGODD/inferflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inferflow-0.1.0a1-py3-none-any.whl -
Subject digest:
4bccfb51e7078a608f07992b641a2566f8744bf6859fac62547d1f15e604cd5c - Sigstore transparency entry: 740342763
- Sigstore integration time:
-
Permalink:
6ixGODD/inferflow@917ea56f33cd7622dc6156444e831cbf585f8922 -
Branch / Tag:
refs/tags/v0.1.0a1 - Owner: https://github.com/6ixGODD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@917ea56f33cd7622dc6156444e831cbf585f8922 -
Trigger Event:
push
-
Statement type: