From 7947b09bd94d76dd3f29a09fd0b96b339188e6a7 Mon Sep 17 00:00:00 2001 From: mykola Date: Tue, 18 Nov 2025 09:33:11 +0300 Subject: [PATCH 1/3] feat: Enable support GPU in YoloOnnxDetector.py --- scaledp/models/detectors/yolo/yolo.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scaledp/models/detectors/yolo/yolo.py b/scaledp/models/detectors/yolo/yolo.py index fc14b73..23c52cf 100644 --- a/scaledp/models/detectors/yolo/yolo.py +++ b/scaledp/models/detectors/yolo/yolo.py @@ -5,12 +5,13 @@ import numpy as np import onnxruntime +from scaledp.enums import Device from scaledp.models.detectors.yolo.utils import multiclass_nms, xywh2xyxy class YOLO: - def __init__(self, path, conf_thres=0.7, iou_thres=0.5) -> None: + def __init__(self, path, device=Device.CPU, conf_thres=0.7, iou_thres=0.5) -> None: self.conf_threshold = conf_thres self.iou_threshold = iou_thres @@ -22,15 +23,24 @@ def __init__(self, path, conf_thres=0.7, iou_thres=0.5) -> None: self.pad_y = None # Initialize model - self.initialize_model(path) + self.initialize_model(path, device) def __call__(self, image) -> Any: return self.detect_objects(image) - def initialize_model(self, path): - self.session = onnxruntime.InferenceSession( - path, providers=onnxruntime.get_available_providers() + def initialize_model(self, path, device): + provider = ( + "CUDAExecutionProvider" if device == Device.CUDA else "CPUExecutionProvider" ) + + if provider in onnxruntime.get_available_providers(): + providers = [provider] + else: + logging.warning( + f"{provider} is not available. Falling back to CPUExecutionProvider." + ) + providers = ["CPUExecutionProvider"] + self.session = onnxruntime.InferenceSession(path, providers=providers) # Get model info self.get_input_details() self.get_output_details() From a7dd2f447dadb786f61f807c7e8e685940dd5ee8 Mon Sep 17 00:00:00 2001 From: mykola Date: Tue, 18 Nov 2025 09:36:14 +0300 Subject: [PATCH 2/3] update: Change default values for detectors --- cliff.toml | 1 + scaledp/models/detectors/FaceDetector.py | 4 ++-- scaledp/models/detectors/SignatureDetector.py | 4 ++-- scaledp/models/detectors/YoloOnnxDetector.py | 10 +++++++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cliff.toml b/cliff.toml index 2c172e9..1c12bdb 100644 --- a/cliff.toml +++ b/cliff.toml @@ -61,6 +61,7 @@ protect_breaking_commits = false commit_parsers = [ { message = "^feat", group = "🚀 Features" }, { message = "^fix", group = "🐛 Bug Fixes" }, + { message = "^update", group = "🔄 Updates" }, { message = "^doc", group = "📚 Documentation" }, { message = "^perf", group = "⚡ Performance" }, { message = "^maint", group = "🧰 Maintenance" }, diff --git a/scaledp/models/detectors/FaceDetector.py b/scaledp/models/detectors/FaceDetector.py index 85909a0..dddbdec 100644 --- a/scaledp/models/detectors/FaceDetector.py +++ b/scaledp/models/detectors/FaceDetector.py @@ -18,8 +18,8 @@ class FaceDetector(YoloOnnxDetector): "batchSize": 2, "partitionMap": False, "numPartitions": 0, - "pageCol": "page", - "pathCol": "path", + "pageCol": "", + "pathCol": "", "propagateError": False, "task": "detect", "onlyRotated": False, diff --git a/scaledp/models/detectors/SignatureDetector.py b/scaledp/models/detectors/SignatureDetector.py index 4e5bf98..6449aa4 100644 --- a/scaledp/models/detectors/SignatureDetector.py +++ b/scaledp/models/detectors/SignatureDetector.py @@ -16,8 +16,8 @@ class SignatureDetector(YoloOnnxDetector): "batchSize": 2, "partitionMap": False, "numPartitions": 0, - "pageCol": "page", - "pathCol": "path", + "pageCol": "", + "pathCol": "", "propagateError": False, "task": "detect", "onlyRotated": False, diff --git a/scaledp/models/detectors/YoloOnnxDetector.py b/scaledp/models/detectors/YoloOnnxDetector.py index 44d94b6..456018f 100644 --- a/scaledp/models/detectors/YoloOnnxDetector.py +++ b/scaledp/models/detectors/YoloOnnxDetector.py @@ -48,8 +48,8 @@ class YoloOnnxDetector(BaseDetector, HasDevice, HasBatchSize, HasLabels): "batchSize": 2, "partitionMap": False, "numPartitions": 0, - "pageCol": "page", - "pathCol": "path", + "pageCol": "", + "pathCol": "", "propagateError": False, "task": "detect", "onlyRotated": False, @@ -83,7 +83,11 @@ def get_model(cls, params): logging.info("Model downloaded") - detector = YOLO(model_path_final, conf_thres=params["scoreThreshold"]) + detector = YOLO( + model_path_final, + conf_thres=params["scoreThreshold"], + device=params["device"], + ) cls._model[model_path] = detector return cls._model[model_path] From dbb6cd2b5428a1e1174b788a8129f369a3b14283 Mon Sep 17 00:00:00 2001 From: mykola Date: Wed, 19 Nov 2025 09:00:52 +0300 Subject: [PATCH 3/3] Updated release notes --- CHANGELOG.md | 16 ++++++++++++++++ docs/source/release_notes.md | 15 +++++++++++++++ pyproject.toml | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a4d7d1..bbe7d69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,21 @@ - Added TextEmbeddings transformer, for compute embedding using SentenceTransformers +## [0.2.6] - 19.11.2025 + +### 🚀 Features + +- Enable support GPU in [YoloOnnxDetector](https://scaledp.stabrise.com/en/latest/models/detectors/yolo_onnx_detector.html) + +### 🔄 Updates + +- Change default values for detectors + +### 📘 Jupyter Notebooks + +- [YoloOnnxDetectorBenchamrks.ipynb](https://github.com/StabRise/ScaleDP-Tutorials/blob/master/object-detection/4.YoloOnnxDetectorBenchmarks.ipynb) - Benchmarking YOLO model with different parameters configurations on CPU and GPU + + ## [0.2.5] - 10.11.2025 ### 🚀 Features @@ -14,6 +29,7 @@ - Improve displaying labels in [ImageDrawBoxes](https://scaledp.stabrise.com/en/latest/image/image_draw_boxes.html) ### 🧰 Maintenance + - Updated versions of dependencies (Pandas, Numpy, OpenCV) ### 🐛 Bug Fixes diff --git a/docs/source/release_notes.md b/docs/source/release_notes.md index 33d612f..dd76234 100644 --- a/docs/source/release_notes.md +++ b/docs/source/release_notes.md @@ -11,6 +11,21 @@ This document outlines the release notes for the ScaledP project. It includes in - Added [TextEmbeddings](#TextEmbeddings) transformer, for compute embedding using SentenceTransformers +## [0.2.6] - 19.11.2025 + +### 🚀 Features + +- Enable support GPU in [YoloOnnxDetector](#YoloOnnxDetector) + +### 🔄 Updates + +- Change default values for detectors + +### 📘 Jupyter Notebooks + +- [YoloOnnxDetectorBenchamrks.ipynb](https://github.com/StabRise/ScaleDP-Tutorials/blob/master/object-detection/4.YoloOnnxDetectorBenchmarks.ipynb) - Benchmarking YOLO model with different parameters configurations on CPU and GPU + + ## [0.2.5] - 10.11.2025 ### 🚀 Features diff --git a/pyproject.toml b/pyproject.toml index c00b631..d6ce981 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "scaledp" -version = "0.3.0rc1" +version = "0.2.6" description = "ScaleDP is a library for processing documents and images using Apache Spark and LLMs" authors = ["Mykola Melnyk "] repository = "https://github.com/StabRise/scaledp"