Skip to content

Add first scratches of new interface #1250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 246 commits into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
246 commits
Select commit Hold shift + click to select a range
ff1c9df
Add first scratches of new interface
PawelPeczek-Roboflow May 9, 2025
2c03e68
Add scratch for yolo code in new inference
PawelPeczek-Roboflow May 12, 2025
cb1d3c3
Add rfdetr
PawelPeczek-Roboflow May 13, 2025
a27ac53
Add codeflash suggestions
PawelPeczek-Roboflow May 13, 2025
7219874
Clean up implementation of pre-processing
PawelPeczek-Roboflow May 14, 2025
6006d88
Sort out rfdetr
PawelPeczek-Roboflow May 14, 2025
a86818d
Add basic support for instance segmentation
PawelPeczek-Roboflow May 14, 2025
1cb02e8
WIP - adding keypoints
PawelPeczek-Roboflow May 14, 2025
7fb553e
Add keypoints detection
PawelPeczek-Roboflow May 15, 2025
185b7eb
Add proptotype of TRT support in inference
PawelPeczek-Roboflow May 15, 2025
3d318f1
Fix issue with TRT implementation
PawelPeczek-Roboflow May 15, 2025
cdb13d5
Fix some issues and add profiling
PawelPeczek-Roboflow May 15, 2025
ba877b3
Fixed
PawelPeczek-Roboflow May 15, 2025
d1b0546
Add BS for profiling
PawelPeczek-Roboflow May 15, 2025
c20c323
Add BS for profiling
PawelPeczek-Roboflow May 15, 2025
e24af29
Fix interpolation
PawelPeczek-Roboflow May 15, 2025
9fa06f1
Debug
PawelPeczek-Roboflow May 15, 2025
0b7e85a
Debug
PawelPeczek-Roboflow May 15, 2025
0c3648c
Debug
PawelPeczek-Roboflow May 15, 2025
569a0a8
Debug
PawelPeczek-Roboflow May 15, 2025
d8d9604
Fix
PawelPeczek-Roboflow May 15, 2025
ad08ba2
Clean up
PawelPeczek-Roboflow May 15, 2025
27136b3
Add instance segmentation
PawelPeczek-Roboflow May 15, 2025
f7733a2
Refactor TRT
PawelPeczek-Roboflow May 15, 2025
e3729a4
Add TRT keypoints detection
PawelPeczek-Roboflow May 15, 2025
891e36e
Add classifiers and clip
PawelPeczek-Roboflow May 16, 2025
50873d2
Add implementations for various yolo architections
PawelPeczek-Roboflow May 19, 2025
078daec
Add scratches of implementation for DocTR
PawelPeczek-Roboflow May 19, 2025
d3aa4e8
Add gaze detection and doctr
PawelPeczek-Roboflow May 20, 2025
60b972b
Add grounding dino and florence
PawelPeczek-Roboflow May 21, 2025
e93a61b
Add depth estimation model
PawelPeczek-Roboflow May 21, 2025
ba1423c
Add moondream2
PawelPeczek-Roboflow May 22, 2025
cbb5b17
Add paligemma
PawelPeczek-Roboflow May 22, 2025
c46d67a
Add SmolVLM
PawelPeczek-Roboflow May 22, 2025
d63ec72
Add licenses
PawelPeczek-Roboflow May 22, 2025
f2ecb29
Merge branch 'main' into feature/inference-v1-models
PawelPeczek-Roboflow May 22, 2025
2261ad0
Revert unintended changes
PawelPeczek-Roboflow May 22, 2025
0a7e7fa
Fix typing
PawelPeczek-Roboflow May 22, 2025
945d5f3
Optimise rfdetr
PawelPeczek-Roboflow May 22, 2025
22eec00
Add normalization
PawelPeczek-Roboflow May 22, 2025
092892b
Fix float16 issue
PawelPeczek-Roboflow May 23, 2025
44aad92
Merge branch 'main' into feature/inference-v1-models
PawelPeczek-Roboflow May 23, 2025
f83615d
Fix mistake in images pre-processing
PawelPeczek-Roboflow May 23, 2025
fa68cdb
Fixing bugs in pre-processing
PawelPeczek-Roboflow May 23, 2025
19250ee
Add RfDetr TRT inference
PawelPeczek-Roboflow May 23, 2025
cfef13b
Fix default device
PawelPeczek-Roboflow May 23, 2025
856e562
Fix unused imports
PawelPeczek-Roboflow May 23, 2025
089725e
Fix bug with rfdetr-trt post-processing
PawelPeczek-Roboflow May 23, 2025
f22b371
Merge branch 'main' into feature/inference-v1-models
PawelPeczek-Roboflow May 23, 2025
0779dfb
Merge branch 'main' into feature/inference-v1-models
PawelPeczek-Roboflow May 27, 2025
69ab10a
Add foundations for auto-negotiation protocol
PawelPeczek-Roboflow Jun 2, 2025
90cdf9f
Add scratch of implementation for auto-models loader
PawelPeczek-Roboflow Jun 3, 2025
b57de5f
Add download layer for models
PawelPeczek-Roboflow Jun 3, 2025
1e030f6
Make linters happy
PawelPeczek-Roboflow Jun 3, 2025
11a5579
Fix issues and add model packages ranking
PawelPeczek-Roboflow Jun 3, 2025
4e409f8
Register PaliGemma
PawelPeczek-Roboflow Jun 4, 2025
8bb296b
Tune download
PawelPeczek-Roboflow Jun 4, 2025
ce65b34
Make streamed chunks larger
PawelPeczek-Roboflow Jun 4, 2025
62583fd
Add shared session per file
PawelPeczek-Roboflow Jun 4, 2025
35a2cbc
Make linters happy
PawelPeczek-Roboflow Jun 4, 2025
f2e4a60
Re-arrange the download thread management
PawelPeczek-Roboflow Jun 4, 2025
74190e9
Add build script
PawelPeczek-Roboflow Jun 5, 2025
044d4a1
Build a scaffolding for the library with uv
PawelPeczek-Roboflow Jun 10, 2025
5c773b3
Add additional dependencies
PawelPeczek-Roboflow Jun 10, 2025
50f71da
Add additional dependencies
PawelPeczek-Roboflow Jun 10, 2025
543494c
Align trt
PawelPeczek-Roboflow Jun 10, 2025
6e41800
Add Dockerfile
PawelPeczek-Roboflow Jun 10, 2025
1e819c2
Fix docker build
PawelPeczek-Roboflow Jun 10, 2025
6dd10cb
Fix docker build
PawelPeczek-Roboflow Jun 10, 2025
7bd20fe
Fix dockerfile
PawelPeczek-Roboflow Jun 10, 2025
50163d5
Fix dockerfile
PawelPeczek-Roboflow Jun 10, 2025
f3acd73
Add dockerfile cu128
PawelPeczek-Roboflow Jun 10, 2025
771d34a
Fix docker images
PawelPeczek-Roboflow Jun 10, 2025
1733d44
Fix docker images
PawelPeczek-Roboflow Jun 10, 2025
0f44d03
Add devel python
PawelPeczek-Roboflow Jun 10, 2025
f126df5
Add devel python
PawelPeczek-Roboflow Jun 10, 2025
a02c702
Fix docker images
PawelPeczek-Roboflow Jun 10, 2025
8adb7a4
Add devel python
PawelPeczek-Roboflow Jun 10, 2025
6b6341c
Modify builds to cache dependencies
PawelPeczek-Roboflow Jun 10, 2025
9a761eb
Modify builds to cache dependencies
PawelPeczek-Roboflow Jun 10, 2025
f029a49
Fix builds and add cu118
PawelPeczek-Roboflow Jun 10, 2025
5ae07a5
Fix builds
PawelPeczek-Roboflow Jun 10, 2025
105e5dc
Add cpu builds
PawelPeczek-Roboflow Jun 10, 2025
35cb121
Remove trt from cpu build
PawelPeczek-Roboflow Jun 10, 2025
0116abe
Attempt to speed-up fastattn install
PawelPeczek-Roboflow Jun 10, 2025
9d6d49f
Add build for jetpack 6
PawelPeczek-Roboflow Jun 10, 2025
e1ce496
Add docker build for jetpack 62
PawelPeczek-Roboflow Jun 10, 2025
8d1351b
Fix JP builds
PawelPeczek-Roboflow Jun 10, 2025
cba3c31
Remove fla shattention from build
PawelPeczek-Roboflow Jun 11, 2025
3ac2ea5
Fix JP build
PawelPeczek-Roboflow Jun 11, 2025
1402ba6
Try to fix JP build
PawelPeczek-Roboflow Jun 11, 2025
9738b48
Try to fix JP build
PawelPeczek-Roboflow Jun 11, 2025
a871ca5
Adjust jp builds to use cuda 126
PawelPeczek-Roboflow Jun 11, 2025
74d08a4
Align inference experimental to fixed backend
PawelPeczek-Roboflow Jun 11, 2025
5d2bdb7
Add changes to make sure we can run onnx sessions with dynamic output…
PawelPeczek-Roboflow Jun 12, 2025
97dde8c
Fix bug
PawelPeczek-Roboflow Jun 12, 2025
6864902
Fix bug with onnx execution
PawelPeczek-Roboflow Jun 12, 2025
a5b81bd
Fix bug with onnx execution
PawelPeczek-Roboflow Jun 12, 2025
7e7d059
Fix bug with onnx execution
PawelPeczek-Roboflow Jun 12, 2025
4b7c2b6
Fix output bindings
PawelPeczek-Roboflow Jun 12, 2025
6abc5a2
Fix ONNX typeS
PawelPeczek-Roboflow Jun 12, 2025
3cd3053
Fix verbose
PawelPeczek-Roboflow Jun 12, 2025
dd5e74d
Fix cuda
PawelPeczek-Roboflow Jun 12, 2025
21d3015
Add compilation script
PawelPeczek-Roboflow Jun 13, 2025
753ef13
Fix serialisation issue
PawelPeczek-Roboflow Jun 13, 2025
ce78e56
Fix issue with input name
PawelPeczek-Roboflow Jun 13, 2025
674a97c
Fix issue with input name
PawelPeczek-Roboflow Jun 13, 2025
3372452
Fix issue with input name
PawelPeczek-Roboflow Jun 13, 2025
37005f1
Fix logging
PawelPeczek-Roboflow Jun 13, 2025
efb1823
Fix logging
PawelPeczek-Roboflow Jun 13, 2025
b8acec1
Fix logging
PawelPeczek-Roboflow Jun 13, 2025
7d44aea
Fix logging
PawelPeczek-Roboflow Jun 13, 2025
c109bf5
Fix logging
PawelPeczek-Roboflow Jun 13, 2025
08cfea5
Add TRT lean runtime
PawelPeczek-Roboflow Jun 13, 2025
9b113c7
Add ability to handle forward compatible TRT
PawelPeczek-Roboflow Jun 13, 2025
d392185
Fix trt lean dependencies
PawelPeczek-Roboflow Jun 13, 2025
f1ec720
Adjust ranking to forward compatible trt packages
PawelPeczek-Roboflow Jun 13, 2025
94ecad1
Fix bug
PawelPeczek-Roboflow Jun 13, 2025
5df581b
Fix TRT version checkl
PawelPeczek-Roboflow Jun 13, 2025
7c25457
Add ability to load trusted models and deserialise TRT engines with l…
PawelPeczek-Roboflow Jun 13, 2025
632dbc1
Modify ranking to reflect the fact that same CC compatibility cost TR…
PawelPeczek-Roboflow Jun 13, 2025
b58122b
Add seyuptools config for pyproject.toml
PawelPeczek-Roboflow Jun 17, 2025
620cf39
Add seyuptools config for pyproject.toml
PawelPeczek-Roboflow Jun 17, 2025
0f51d5d
Add seyuptools config for pyproject.toml
PawelPeczek-Roboflow Jun 17, 2025
e5ca541
Add compilation script
PawelPeczek-Roboflow Jun 17, 2025
83f1365
Fix download
PawelPeczek-Roboflow Jun 17, 2025
6572d09
Add more compilation scripts
PawelPeczek-Roboflow Jun 17, 2025
db434ed
Fix issues
PawelPeczek-Roboflow Jun 17, 2025
28a4b8e
Fix getting info about jetson
PawelPeczek-Roboflow Jun 17, 2025
699671c
Fix problem with download
PawelPeczek-Roboflow Jun 17, 2025
2c8f1df
Disable threaded download
PawelPeczek-Roboflow Jun 17, 2025
13c4302
Add debug
PawelPeczek-Roboflow Jun 17, 2025
3fa89bc
Adjust code to properly signal issues with missing dependencies
PawelPeczek-Roboflow Jun 17, 2025
1ae2bc1
Adjust TRT device placement not to introduce global changes
PawelPeczek-Roboflow Jun 17, 2025
63e11d5
Fix device placement
PawelPeczek-Roboflow Jun 17, 2025
3682e3a
Fix device placement
PawelPeczek-Roboflow Jun 17, 2025
b64edac
Add pycuda
PawelPeczek-Roboflow Jun 17, 2025
9310dad
Attempt to make TRT work with management of CUDA contexts
PawelPeczek-Roboflow Jun 17, 2025
6f1ea88
Fix mistake
PawelPeczek-Roboflow Jun 17, 2025
0eef7e2
Fix mistake
PawelPeczek-Roboflow Jun 17, 2025
f2c0042
Fix mistake
PawelPeczek-Roboflow Jun 17, 2025
9984afe
Fix mistake
PawelPeczek-Roboflow Jun 17, 2025
a7f3d86
Fix mistake
PawelPeczek-Roboflow Jun 17, 2025
975e6cb
Fix mistake
PawelPeczek-Roboflow Jun 17, 2025
3ed0a41
Try to adjust TRT usage
PawelPeczek-Roboflow Jun 18, 2025
233fa37
Add proper purge of resources
PawelPeczek-Roboflow Jun 18, 2025
50ce32a
Try to adjust TRT usage
PawelPeczek-Roboflow Jun 18, 2025
643cd85
Try to adjust TRT usage
PawelPeczek-Roboflow Jun 18, 2025
6ed5419
Try to adjust TRT usage
PawelPeczek-Roboflow Jun 18, 2025
cd349d3
Try to adjust TRT usage
PawelPeczek-Roboflow Jun 18, 2025
fb4f2f1
Try to adjust TRT usage
PawelPeczek-Roboflow Jun 18, 2025
bda1bfe
Try to solve device allocation error for onn
PawelPeczek-Roboflow Jun 18, 2025
561b381
Aling implementation of TRT models to properly handle the new way of …
PawelPeczek-Roboflow Jun 18, 2025
a577742
Remove auxiliary filters from onnxruntime JP
PawelPeczek-Roboflow Jun 18, 2025
c8b1659
Fix jetson build and make onnxruntime installed
PawelPeczek-Roboflow Jun 19, 2025
4181a0d
Another attempt to make build more reprodicible
PawelPeczek-Roboflow Jun 19, 2025
5d41aa9
Another attempt to make build more reprodicible
PawelPeczek-Roboflow Jun 19, 2025
84965fd
Another attempt to make build more reprodicible
PawelPeczek-Roboflow Jun 19, 2025
6ff2908
Another attempt to make build more reprodicible
PawelPeczek-Roboflow Jun 19, 2025
67d354d
Another attempt to make build more reprodicible
PawelPeczek-Roboflow Jun 19, 2025
e87b5fb
Another attempt to make build more reprodicible
PawelPeczek-Roboflow Jun 19, 2025
d590d68
Another attempt to make build more reprodicible
PawelPeczek-Roboflow Jun 19, 2025
6eccabf
Another attempt to make build more reprodicible
PawelPeczek-Roboflow Jun 19, 2025
65ae0ce
Modify CPU build
PawelPeczek-Roboflow Jun 19, 2025
9711ccb
Fix builds
PawelPeczek-Roboflow Jun 19, 2025
a0a18e7
Fix update-alternatives to also cover python3
PawelPeczek-Roboflow Jun 19, 2025
07cb0cc
No deps wheel install for JP
PawelPeczek-Roboflow Jun 19, 2025
a03d43c
Upgrade dependencies
PawelPeczek-Roboflow Jun 19, 2025
208e13f
Fix bug in auto-negotiation
PawelPeczek-Roboflow Jun 19, 2025
dd008b5
Add script to make predictions
PawelPeczek-Roboflow Jun 20, 2025
32cee91
Fix bug
PawelPeczek-Roboflow Jun 20, 2025
ac5091b
Add script for ultralytics predictions
PawelPeczek-Roboflow Jun 20, 2025
50745cf
Fix serialisation issue
PawelPeczek-Roboflow Jun 20, 2025
f53772a
Fix silly, yet fucking frustrating missmatch of contexts
PawelPeczek-Roboflow Jun 20, 2025
697a1f2
Fix yolov10
PawelPeczek-Roboflow Jun 20, 2025
d8de977
Add fixes
PawelPeczek-Roboflow Jun 20, 2025
99b0596
Add speed test
PawelPeczek-Roboflow Jun 20, 2025
270c5f5
Add spee test skip option
PawelPeczek-Roboflow Jun 23, 2025
ffd01dc
Add spee test skip option
PawelPeczek-Roboflow Jun 23, 2025
29ddeb5
Fix issue with instance-segmentation predictions
PawelPeczek-Roboflow Jun 23, 2025
b035177
Improve logging, error handling and fix bug in auto-negotiation
PawelPeczek-Roboflow Jun 24, 2025
54b0b6d
Add local model packages loading
PawelPeczek-Roboflow Jun 24, 2025
2a9edf9
Add basic unit tests for package utils
PawelPeczek-Roboflow Jun 24, 2025
e6b560b
Add tests for runtime introspection
PawelPeczek-Roboflow Jun 25, 2025
1b87e52
Add tests for roboflow weights provider
PawelPeczek-Roboflow Jun 25, 2025
ea0c9a3
Add basic tests for model packages ranker
PawelPeczek-Roboflow Jun 25, 2025
29e9d22
Add more solid tests for packages ranking
PawelPeczek-Roboflow Jun 26, 2025
5c80d60
Add scaffolding of integration tests for extras
PawelPeczek-Roboflow Jun 26, 2025
ec4a01e
Add scaffolding of tests for auto-negotiation
PawelPeczek-Roboflow Jun 26, 2025
a162583
Add tests for auto-negotiation
PawelPeczek-Roboflow Jun 26, 2025
419fc06
Add tests for local packages loading and partially for parsing metada…
PawelPeczek-Roboflow Jun 27, 2025
7a803ba
Add tests for utils to parse roboflow models metadata
PawelPeczek-Roboflow Jun 30, 2025
e7b0e9b
Add basic tests of pre-processing
PawelPeczek-Roboflow Jun 30, 2025
c9105fb
Finish basic tests of the code
PawelPeczek-Roboflow Jun 30, 2025
a68fbef
Add changes to make sure inference-experimental is not entangled in n…
PawelPeczek-Roboflow Jun 30, 2025
2d12ff7
Merge branch 'main' into feature/inference-v1-models
PawelPeczek-Roboflow Jun 30, 2025
188f28a
add perception encoder to inference_exp
hansent Jun 30, 2025
dfd85c8
use DEFAULT_DEVICE
hansent Jul 1, 2025
63a45ad
adjust imports in perception_encoder.vision_encoder
hansent Jul 1, 2025
c40d0e5
fix device handling
hansent Jul 1, 2025
ebb3ed7
adjust preprocessing and tests
hansent Jul 1, 2025
4ffff77
add perception_encoder to registry
hansent Jul 1, 2025
5fcf671
load weights properlly using `get_model_package_contents`
hansent Jul 1, 2025
75244a6
by default don't run `e2e_model_inference`
hansent Jul 1, 2025
13dc843
validate config loading
hansent Jul 4, 2025
6f49ded
fix pre-processing for already batched tensor
hansent Jul 4, 2025
c40cc3f
handle list/batch preprocessing logic in preprocessor
hansent Jul 4, 2025
4c71330
optimize preprocessing and test for different image sizes
hansent Jul 4, 2025
b122d38
move e2e tests into separate test suite
hansent Jul 4, 2025
5a72f88
Add support for new format of API and change the way on how artefacts…
PawelPeczek-Roboflow Jul 8, 2025
169311d
Fix tests
PawelPeczek-Roboflow Jul 8, 2025
524af95
Add test covering event handlers while download
PawelPeczek-Roboflow Jul 8, 2025
ffe09a9
Add ability to construct model config for offline use
PawelPeczek-Roboflow Jul 8, 2025
dcf85d1
Add inference_exp unit tests CI
grzegorz-roboflow Jul 8, 2025
8698769
formatting
grzegorz-roboflow Jul 8, 2025
37e15e7
Add cache for auto-resolution
PawelPeczek-Roboflow Jul 8, 2025
69eb9bd
Expose hooks
PawelPeczek-Roboflow Jul 8, 2025
1312c5c
Run tests in parallel
grzegorz-roboflow Jul 9, 2025
ccd188c
clean-up
grzegorz-roboflow Jul 9, 2025
ae46898
Add integration tests for cpu
grzegorz-roboflow Jul 9, 2025
58ea92b
Naming
grzegorz-roboflow Jul 9, 2025
b5255ee
Add CI for running tests on GPU
grzegorz-roboflow Jul 9, 2025
7fd93c7
Add ability to externalise authorization and fix other issues
PawelPeczek-Roboflow Jul 9, 2025
353753d
Merge branch 'feature/inference-v1-models' of https://github.com/robo…
hansent Jul 9, 2025
7026ced
add argument for explicit colorformat specification on input image
hansent Jul 9, 2025
47e25d5
Fix bugs in reporting dependent files in auto-loading cache and add c…
PawelPeczek-Roboflow Jul 10, 2025
b3b4102
Fix bug with rename of file creation hook
PawelPeczek-Roboflow Jul 10, 2025
8a58e9e
code review
grzegorz-roboflow Jul 10, 2025
5b58674
code review
grzegorz-roboflow Jul 10, 2025
1309c29
Add test target in pyproject.toml
grzegorz-roboflow Jul 10, 2025
07434ae
Update caching strategy
grzegorz-roboflow Jul 10, 2025
be68d7b
Merge pull request #1411 from roboflow/unit-tests-ci/inference-v1-models
grzegorz-roboflow Jul 10, 2025
bf43ec9
Fix issues with memory management for MD5 sums calculated on-line in …
PawelPeczek-Roboflow Jul 10, 2025
3233de5
Fix builds to take context of inefrence_experimental dir
PawelPeczek-Roboflow Jul 10, 2025
3fc3726
Add more unit tests on auto-loading
PawelPeczek-Roboflow Jul 10, 2025
74e1abe
Merge pull request #1399 from roboflow/inference-exp/add-perception-e…
hansent Jul 10, 2025
7f4d474
Add tests covering base e2e cases for auto-loading with API responses…
PawelPeczek-Roboflow Jul 10, 2025
820d011
Merge branch 'main' into feature/inference-v1-models
PawelPeczek-Roboflow Jul 10, 2025
038dc1c
Fix tests
PawelPeczek-Roboflow Jul 11, 2025
da88e7d
Try to fix CI
PawelPeczek-Roboflow Jul 11, 2025
2753c8c
Make linters happy
PawelPeczek-Roboflow Jul 11, 2025
d13f8b5
Add requestmock to the pyproject toml
PawelPeczek-Roboflow Jul 11, 2025
413eea9
Exclude TRT tests temporairly
PawelPeczek-Roboflow Jul 11, 2025
7925bd0
Try to fix CI
PawelPeczek-Roboflow Jul 11, 2025
5f4d17e
Fix unit test dependency on runtime environment
PawelPeczek-Roboflow Jul 11, 2025
07d2b4a
Temporary disable of integration tests on GPU until the runner is ready
PawelPeczek-Roboflow Jul 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions inference/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# PUBLIC INTERFACE LISTED BELOW
from .models.base.classification import (
ClassificationModel,
ClassificationPrediction,
MultiLabelClassificationModel,
MultiLabelClassificationPrediction,
)
from .models.base.instance_segmentation import (
InstanceDetections,
InstanceSegmentationModel,
)
from .models.base.keypoints_detection import KeyPoints, KeyPointsDetectionModel
from .models.base.object_detection import Detections, ObjectDetectionModel
13 changes: 13 additions & 0 deletions inference/v1/configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os

import torch

from inference.v1.utils.environment import parse_comma_separated_values

ONNXRUNTIME_EXECUTION_PROVIDERS = parse_comma_separated_values(
values=os.getenv(
"ONNXRUNTIME_EXECUTION_PROVIDERS",
"CUDAExecutionProvider,OpenVINOExecutionProvider,CoreMLExecutionProvider,CPUExecutionProvider",
)
)
DEFAULT_DEVICE = torch.get_default_device()
Empty file added inference/v1/constants.py
Empty file.
5 changes: 5 additions & 0 deletions inference/v1/entities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from collections import namedtuple
from typing import Literal

ImageDimensions = namedtuple("ImageDimensions", ["height", "width"])
ColorFormat = Literal["rgb", "bgr"]
14 changes: 14 additions & 0 deletions inference/v1/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class BaseInferenceError(Exception):
pass


class CorruptedModelPackageError(BaseInferenceError):
pass


class EnvironmentConfigurationError(BaseInferenceError):
pass


class ModelRuntimeError(BaseInferenceError):
pass
Empty file added inference/v1/models/__init__.py
Empty file.
Empty file.
Empty file.
109 changes: 109 additions & 0 deletions inference/v1/models/base/classification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any, List, Optional, Tuple, Union

import torch


@dataclass
class ClassificationPrediction:
class_ids: torch.Tensor # (bs, )
confidence: torch.Tensor # (bs, )
images_metadata: Optional[List[dict]] = None # if given, list of size equal to bs


class ClassificationModel(ABC):

@classmethod
def from_pretrained(
cls, model_name_or_path: str, *args, **kwargs
) -> "ClassificationModel":
pass

@property
@abstractmethod
def class_names(self) -> List[str]:
pass

def infer(
self, images: Union[torch.Tensor, List[torch.Tensor]], *args, **kwargs
) -> ClassificationPrediction:
pre_processed_images, pre_processing_meta = self.pre_process(
images, *args, **kwargs
)
model_results = self.forward(pre_processed_images, *args, **kwargs)
return self.post_process(model_results, *args, **kwargs)

@abstractmethod
def pre_process(
self, images: Union[torch.Tensor, List[torch.Tensor]], *args, **kwargs
) -> Tuple[torch.Tensor, Any]:
pass

@abstractmethod
def forward(
self, pre_processed_images: torch.Tensor, *args, **kwargs
) -> torch.Tensor:
pass

@abstractmethod
def post_process(
self, model_results: torch.Tensor, *args, **kwargs
) -> ClassificationPrediction:
pass

def __call__(
self, images: torch.Tensor, *args, **kwargs
) -> ClassificationPrediction:
return self.infer(images, *args, **kwargs)


@dataclass
class MultiLabelClassificationPrediction:
class_ids: torch.Tensor # (predicted_labels_ids, )
confidence: torch.Tensor # (predicted_labels_confidence, )
image_metadata: Optional[dict] = None


class MultiLabelClassificationModel(ABC):

@classmethod
def from_pretrained(
cls, model_name_or_path: str, *args, **kwargs
) -> "MultiLabelClassificationModel":
pass

@property
@abstractmethod
def class_names(self) -> List[str]:
pass

def infer(
self, images: Union[torch.Tensor, List[torch.Tensor]], *args, **kwargs
) -> List[MultiLabelClassificationPrediction]:
pre_processed_images = self.pre_process(images, *args, **kwargs)
model_results = self.forward(pre_processed_images, *args, **kwargs)
return self.post_process(model_results, *args, **kwargs)

@abstractmethod
def pre_process(
self, images: Union[torch.Tensor, List[torch.Tensor]], *args, **kwargs
) -> Tuple[torch.Tensor, Any]:
pass

@abstractmethod
def forward(
self, pre_processed_images: torch.Tensor, *args, **kwargs
) -> torch.Tensor:
pass

@abstractmethod
def post_process(
self, model_results: torch.Tensor, *args, **kwargs
) -> List[MultiLabelClassificationPrediction]:
pass

def __call__(
self, images: torch.Tensor, *args, **kwargs
) -> List[MultiLabelClassificationPrediction]:
return self.infer(images, *args, **kwargs)
63 changes: 63 additions & 0 deletions inference/v1/models/base/instance_segmentation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any, List, Optional, Tuple, Union

import torch


@dataclass
class InstanceDetections:
xyxy: torch.Tensor # (n_boxes, 4)
class_ids: torch.Tensor # (n_boxes, )
confidence: torch.Tensor # (n_boxes, )
masks: torch.Tensor # (n_boxes, mask_height, mask_width)
image_metadata: Optional[dict] = None
bboxes_metadata: Optional[List[dict]] = (
None # if given, list of size equal to # of bboxes
)


class InstanceSegmentationModel(ABC):

@classmethod
def from_pretrained(
cls, model_name_or_path: str, *args, **kwargs
) -> "InstanceSegmentationModel":
pass

@property
@abstractmethod
def class_names(self) -> List[str]:
pass

def infer(
self, images: Union[torch.Tensor, List[torch.Tensor]], *args, **kwargs
) -> List[InstanceDetections]:
pre_processed_images, pre_processing_meta = self.pre_process(
images, *args, **kwargs
)
model_results = self.forward(pre_processed_images, *args, **kwargs)
return self.post_process(model_results, pre_processing_meta, *args, **kwargs)

@abstractmethod
def pre_process(
self, images: Union[torch.Tensor, List[torch.Tensor]], *args, **kwargs
) -> Tuple[torch.Tensor, Any]:
pass

@abstractmethod
def forward(
self, pre_processed_images: torch.Tensor, *args, **kwargs
) -> torch.Tensor:
pass

@abstractmethod
def post_process(
self, model_results: torch.Tensor, pre_processing_meta: Any, *args, **kwargs
) -> List[InstanceDetections]:
pass

def __call__(
self, images: torch.Tensor, *args, **kwargs
) -> List[InstanceDetections]:
return self.infer(images, *args, **kwargs)
64 changes: 64 additions & 0 deletions inference/v1/models/base/keypoints_detection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any, List, Optional, Tuple, Union

import torch

from inference.v1.models.base.object_detection import Detections


@dataclass
class KeyPoints:
xy: torch.Tensor # (instances, instance_key_points, 2)
class_id: torch.Tensor # (instances, instance_key_points)
confidence: torch.Tensor # (instances, instance_key_points)
image_metadata: Optional[dict] = None
key_points_metadata: Optional[List[dict]] = (
None # if given, list of size equal to # of instances
)


class KeyPointsDetectionModel(ABC):

@classmethod
def from_pretrained(
cls, model_name_or_path: str, *args, **kwargs
) -> "KeyPointsDetectionModel":
pass

@property
@abstractmethod
def class_names(self) -> List[str]:
pass

def infer(
self, images: Union[torch.Tensor, List[torch.Tensor]], *args, **kwargs
) -> Tuple[List[KeyPoints], Optional[List[Detections]]]:
pre_processed_images, pre_processing_meta = self.pre_process(
images, *args, **kwargs
)
model_results = self.forward(pre_processed_images, *args, **kwargs)
return self.post_process(model_results, pre_processing_meta, *args, **kwargs)

@abstractmethod
def pre_process(
self, images: Union[torch.Tensor, List[torch.Tensor]], *args, **kwargs
) -> Tuple[torch.Tensor, Any]:
pass

@abstractmethod
def forward(
self, pre_processed_images: torch.Tensor, *args, **kwargs
) -> torch.Tensor:
pass

@abstractmethod
def post_process(
self, model_results: torch.Tensor, pre_processing_meta: Any, *args, **kwargs
) -> Tuple[List[KeyPoints], Optional[List[Detections]]]:
pass

def __call__(
self, images: torch.Tensor, *args, **kwargs
) -> Tuple[List[KeyPoints], Optional[List[Detections]]]:
return self.infer(images, *args, **kwargs)
56 changes: 56 additions & 0 deletions inference/v1/models/base/object_detection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any, List, Optional, Tuple, Union

import torch


@dataclass
class Detections:
xyxy: torch.Tensor # (n_boxes, 4)
class_ids: torch.Tensor # (n_boxes, )
confidence: torch.Tensor # (n_boxes, )
image_metadata: Optional[dict] = None
bboxes_metadata: Optional[List[dict]] = (
None # if given, list of size equal to # of bboxes
)


class ObjectDetectionModel(ABC):

@classmethod
def from_pretrained(
cls, model_name_or_path: str, *args, **kwargs
) -> "ObjectDetectionModel":
pass

@property
@abstractmethod
def class_names(self) -> List[str]:
pass

def infer(
self, images: Union[torch.Tensor, List[torch.Tensor]], **kwargs
) -> List[Detections]:
pre_processed_images, pre_processing_meta = self.pre_process(images, **kwargs)
model_results = self.forward(pre_processed_images, **kwargs)
return self.post_process(model_results, pre_processing_meta, **kwargs)

@abstractmethod
def pre_process(
self, images: Union[torch.Tensor, List[torch.Tensor]], **kwargs
) -> Tuple[torch.Tensor, Any]:
pass

@abstractmethod
def forward(self, pre_processed_images: torch.Tensor, **kwargs) -> torch.Tensor:
pass

@abstractmethod
def post_process(
self, model_results: torch.Tensor, pre_processing_meta: Any, **kwargs
) -> List[Detections]:
pass

def __call__(self, images: torch.Tensor, **kwargs) -> List[Detections]:
return self.infer(images, **kwargs)
Empty file.
Empty file.
Empty file.
Empty file.
Loading
Loading