nedo-vision-worker-core 0.3.2__py3-none-any.whl → 0.3.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of nedo-vision-worker-core might be problematic. Click here for more details.

@@ -0,0 +1,100 @@
1
+ import os
2
+ import platform
3
+ import sys
4
+ import torch
5
+
6
+
7
+ class PlatformDetector:
8
+ """
9
+ Detects platform and multimedia stack capabilities.
10
+ """
11
+
12
+ @staticmethod
13
+ def is_linux() -> bool:
14
+ return sys.platform.startswith("linux")
15
+
16
+ @staticmethod
17
+ def is_windows() -> bool:
18
+ return sys.platform.startswith("win")
19
+
20
+ @staticmethod
21
+ def is_macos() -> bool:
22
+ return sys.platform == "darwin"
23
+
24
+ @staticmethod
25
+ def is_jetson() -> bool:
26
+ """
27
+ Determines if the platform is an NVIDIA Jetson device.
28
+ """
29
+ try:
30
+ # Device-tree model (most reliable)
31
+ if os.path.exists("/proc/device-tree/model"):
32
+ with open("/proc/device-tree/model", "r") as f:
33
+ model = f.read().strip()
34
+ if "NVIDIA Jetson" in model:
35
+ return True
36
+
37
+ # Jetson-specific libs/paths
38
+ jetson_libraries = ["/usr/lib/aarch64-linux-gnu/tegra", "/etc/nv_tegra_release", "/etc/tegra-release"]
39
+ if any(os.path.exists(p) for p in jetson_libraries):
40
+ return True
41
+
42
+ # Arch alone is not definitive, but is a signal
43
+ if platform.machine() == "aarch64" and os.path.exists("/dev/nvhost-ctrl"):
44
+ return True
45
+
46
+ except Exception:
47
+ pass
48
+
49
+ return False
50
+
51
+ @staticmethod
52
+ def get_platform_type() -> str:
53
+ """
54
+ Returns a coarse platform type: 'jetson' | 'mac' | 'windows' | 'linux'
55
+ """
56
+ if PlatformDetector.is_jetson():
57
+ return "jetson"
58
+ if PlatformDetector.is_macos():
59
+ return "mac"
60
+ if PlatformDetector.is_windows():
61
+ return "windows"
62
+ return "linux"
63
+
64
+ @staticmethod
65
+ def has_gstreamer() -> bool:
66
+ """
67
+ Check if OpenCV was built with GStreamer support.
68
+ """
69
+ try:
70
+ import cv2
71
+ info = cv2.getBuildInformation()
72
+ return ("GStreamer: YES" in info) or ("GStreamer: YES" in info)
73
+ except Exception:
74
+ return False
75
+
76
+ @staticmethod
77
+ def has_nvidia_gpu() -> bool:
78
+ """
79
+ Heuristic for NVIDIA dGPU presence (desktop/server).
80
+ """
81
+ if PlatformDetector.is_windows():
82
+ return bool(os.environ.get("NVIDIA_VISIBLE_DEVICES", "")) # WSL/Docker hint
83
+ if PlatformDetector.is_linux():
84
+ if os.path.exists("/proc/driver/nvidia/version"):
85
+ return True
86
+ if os.environ.get("NVIDIA_VISIBLE_DEVICES", "") not in ("", "none"):
87
+ return True
88
+ return False
89
+
90
+ @staticmethod
91
+ def get_device() -> str:
92
+ """
93
+ Check for GPU availability and return the appropriate device.
94
+ """
95
+ if torch.cuda.is_available():
96
+ return "cuda"
97
+ # Add checks for other devices like MPS if needed
98
+ # elif torch.backends.mps.is_available():
99
+ # return "mps"
100
+ return "cpu"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nedo-vision-worker-core
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: Nedo Vision Worker Core Library for AI Vision Processing
5
5
  Author-email: Willy Achmat Fauzi <willy.achmat@gmail.com>
6
6
  Maintainer-email: Willy Achmat Fauzi <willy.achmat@gmail.com>
@@ -1,4 +1,4 @@
1
- nedo_vision_worker_core/__init__.py,sha256=gOVK9WXdcVvRyelxasgOBdnkqE2wbdbRZ3VnuSXgobc,1924
1
+ nedo_vision_worker_core/__init__.py,sha256=0iPoN0eHddv9i7aZ8YJKl2Rn_P_BTsxTJMPggoVd_kc,1924
2
2
  nedo_vision_worker_core/cli.py,sha256=8YuKWsIgICUYXE_QtwyU3WzGhVjTWiAo5uzpFOmjNc8,5766
3
3
  nedo_vision_worker_core/core_service.py,sha256=dnHNjbslOeyeWqHDFnk_yKdfTICYzLyRIcuZNwF0Zf4,11323
4
4
  nedo_vision_worker_core/doctor.py,sha256=K_-hVV2-mdEefZ4Cfu5hMCiOxBiI1aXY8VtkkpK80Lc,10651
@@ -14,8 +14,7 @@ nedo_vision_worker_core/config/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrF
14
14
  nedo_vision_worker_core/database/DatabaseManager.py,sha256=o2e9jcqBbtf0Zd9TYuyQhXyKj9rjnNYbSShr7CxuAPk,9341
15
15
  nedo_vision_worker_core/database/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
16
16
  nedo_vision_worker_core/detection/BaseDetector.py,sha256=bReQCTy4tEA1itvw3kkjBMQnx3Jn4MjnDkzdtPwmNPQ,757
17
- nedo_vision_worker_core/detection/DetectionManager.py,sha256=GSxdXbG6sQXgKEzxsFhi_CQCdy8JK3nytiJPYZUE-xo,3142
18
- nedo_vision_worker_core/detection/RFDETRDetector.py,sha256=FYZX0wh_y9R3wRYz5vratHcx-pCDnZUkeL2YI__UCPI,2908
17
+ nedo_vision_worker_core/detection/RFDETRDetector.py,sha256=3T3zTFZW0pBv9E-pSpY4JP7wI0LOTM4hxzanvrEXMcE,3093
19
18
  nedo_vision_worker_core/detection/YOLODetector.py,sha256=oMCW4KanQCDbtz-ttMiCY5lP1rIgVH_LpfvZvi270j0,2290
20
19
  nedo_vision_worker_core/detection/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
21
20
  nedo_vision_worker_core/detection/detection_processing/DetectionProcessor.py,sha256=wqf4hliR_CPkeoeRbBB3PEpQsmasC4mASJ4WyYjNyPE,948
@@ -58,17 +57,18 @@ nedo_vision_worker_core/models/worker_source_pipeline.py,sha256=xCD4i9pHr8Qy5B_h
58
57
  nedo_vision_worker_core/models/worker_source_pipeline_config.py,sha256=dGYTpcTFFu6pmGBufuWBHjv3Xs4RGAQwZn6jp6Ondvs,876
59
58
  nedo_vision_worker_core/models/worker_source_pipeline_debug.py,sha256=6S7TkN37FrAT4VwsEB38DWSad7QfvNhsOGtSEK8D1Qs,594
60
59
  nedo_vision_worker_core/models/worker_source_pipeline_detection.py,sha256=p6CJsiVCKprTYrNxJsiTB8njXdHkjZKVEyBceRVE6fY,560
60
+ nedo_vision_worker_core/pipeline/ModelManager.py,sha256=K7lmVOo-KL7bnWtyafilZs23bzd6loCgfUz7xuAmlVw,6195
61
61
  nedo_vision_worker_core/pipeline/PipelineConfigManager.py,sha256=X55i9GyXcW9ylO6cj2UMAZFSxxPViacL4H4DZl60CAY,1157
62
- nedo_vision_worker_core/pipeline/PipelineManager.py,sha256=kJslTS1QD7sgmvZ4ZShxW2HI2u_xzmNM5yD0KlpPx_4,5485
62
+ nedo_vision_worker_core/pipeline/PipelineManager.py,sha256=dAYLK5AXXUkfO7cyxLEGGa9SCQTP-9iAO_otffRgVsI,5482
63
63
  nedo_vision_worker_core/pipeline/PipelinePrepocessor.py,sha256=cCiVSHHqsKCtKYURdYoEjHJX2GnT6zd8kQ6ZukjQ3V0,1271
64
- nedo_vision_worker_core/pipeline/PipelineProcessor.py,sha256=Qw8gRk7cOuVBAvS2h12CF0VLkqLrCrIOIGqGQHnzrKk,26262
65
- nedo_vision_worker_core/pipeline/PipelineSyncThread.py,sha256=9eVGsm4rUfr5tpDHRYOshpiaZ5I484AjJdilhffHzls,11692
64
+ nedo_vision_worker_core/pipeline/PipelineProcessor.py,sha256=92ef6fRpibY3VXNeydpD1kprRCRH3fye_cpztAEVrLQ,26350
65
+ nedo_vision_worker_core/pipeline/PipelineSyncThread.py,sha256=LX_LXU9MTdD5rP-ElHcYR431_qTXNaKOWcCsE4E9Gd0,8613
66
66
  nedo_vision_worker_core/pipeline/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
67
67
  nedo_vision_worker_core/preprocessing/ImageResizer.py,sha256=RvOazxe6dJQuiy0ZH4lIGbdFfiu0FLUVCHoMvxkDNT4,1324
68
68
  nedo_vision_worker_core/preprocessing/ImageRoi.py,sha256=iO7oQ-SdUSA_kTIVBuq_mdycXsiJNfiFD3J7-VTxiQ4,2141
69
69
  nedo_vision_worker_core/preprocessing/Preprocessor.py,sha256=uYIh0Ld4T1zEEHtKVLbUVBcF0kUwj5zCfPXn__bKwwU,477
70
70
  nedo_vision_worker_core/preprocessing/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
71
- nedo_vision_worker_core/repositories/AIModelRepository.py,sha256=8DaTcKQK89Nf_xTbAUtJUFuMJV9qiQ0VcInHdVFEjts,952
71
+ nedo_vision_worker_core/repositories/AIModelRepository.py,sha256=SzBLwUrjDnc4QayZOA2zL0Jl8YQ-x6S1rde_zCBu6LQ,1591
72
72
  nedo_vision_worker_core/repositories/PPEDetectionRepository.py,sha256=C_0QL2sHiSlM9rPmhLmfs6hdZk9FDazy-aVLcznN5w0,6623
73
73
  nedo_vision_worker_core/repositories/RestrictedAreaRepository.py,sha256=umZ7IrgoEFqAa9ZZlH7KPUIbmp5yhBc0FSDUOY6UFag,4283
74
74
  nedo_vision_worker_core/repositories/WorkerSourcePipelineDebugRepository.py,sha256=_z-UyaYtg1Q5nqSbs_16ngYesyM3aji4VrP1ZBHm6Jk,2987
@@ -79,11 +79,11 @@ nedo_vision_worker_core/repositories/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8
79
79
  nedo_vision_worker_core/services/SharedVideoStreamServer.py,sha256=rhCineMKPG3GQbrMHlSHP4xhXaGZ6Rn1oqIajW5xpaY,9827
80
80
  nedo_vision_worker_core/services/VideoSharingDaemon.py,sha256=iY6afEKTOsphfHvmZTL0grezka2DS9DDq-1EIpVMy0Y,28524
81
81
  nedo_vision_worker_core/services/VideoSharingDaemonManager.py,sha256=sc8VZo5iwoOdR8uTiel5BKz6-eZ7wwLy3IwV_3tsAu0,10340
82
- nedo_vision_worker_core/streams/RTMPStreamer.py,sha256=GNooWE4V--GiqetqpWSj0TTmOns12DaIpLGy1qHFulc,10167
83
- nedo_vision_worker_core/streams/SharedVideoDeviceManager.py,sha256=N2cvlKfemD3OG4zEW5mnyup4JgqbzS_JvP2rbbHEBE0,16183
82
+ nedo_vision_worker_core/streams/RTMPStreamer.py,sha256=Dblfutc1UVHj159KUHFYZ8xFEVhHVknZn_nAqKR6uCs,8695
83
+ nedo_vision_worker_core/streams/SharedVideoDeviceManager.py,sha256=vSslwxbhKH6FPndR1HcSFIVWtF-iiOQMlSa4VvFa6M4,16265
84
84
  nedo_vision_worker_core/streams/StreamSyncThread.py,sha256=WmYAY9wFiFhLlxGdnvKGIjAqLwCBayNKdmAWzkbU0jM,3763
85
- nedo_vision_worker_core/streams/VideoStream.py,sha256=Mtj5FI4vEy-dhJN2hQZaD9D_OWBbsntVqWMSDfKn4wk,16024
86
- nedo_vision_worker_core/streams/VideoStreamManager.py,sha256=FpTNRS8F1LvLLYBMwwTeaiOPTz5yyX_HDYtcYJ97utU,12269
85
+ nedo_vision_worker_core/streams/VideoStream.py,sha256=nGtJ4FAZ1Ek-8hVRopEt0bLWLpa10OtyUwdDEuXLObQ,13343
86
+ nedo_vision_worker_core/streams/VideoStreamManager.py,sha256=i7uemC3tUdsrAhL8lvoxCYa0fwUh5oAVD6DDaxflXGE,12057
87
87
  nedo_vision_worker_core/streams/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
88
88
  nedo_vision_worker_core/tracker/SFSORT.py,sha256=0kggw0l4yPZ55AKHdqVX6mu9ehHmJed7jcJ3JQoC4sk,14061
89
89
  nedo_vision_worker_core/tracker/TrackerManager.py,sha256=xtDMI657W2s7HM2lMGtwU0x5Hq74BZpLHd-5xk-278I,6152
@@ -93,10 +93,11 @@ nedo_vision_worker_core/util/DrawingUtils.py,sha256=sLptmzVaJakP_ZgbZsLL03RMH_9N
93
93
  nedo_vision_worker_core/util/ModelReadinessChecker.py,sha256=ywHvt_d7UlY3DyFEJrO4Iyl0zx3SaLKb-Qab5l5Q8n4,6548
94
94
  nedo_vision_worker_core/util/PersonAttributeMatcher.py,sha256=PhYTPYSF62Nfuc7dage03K6icw_bBBdpvXvnlzCbS30,2773
95
95
  nedo_vision_worker_core/util/PersonRestrictedAreaMatcher.py,sha256=iuzCU32BQKaZ3dIy0QHNg2yoWJA-XhTRwwYqCvFdDgg,1711
96
+ nedo_vision_worker_core/util/PlatformDetector.py,sha256=GGL8UfeMQITR22EMYIRWnuOEnSqo7Dr5mb0PaFrl8AM,3006
96
97
  nedo_vision_worker_core/util/TablePrinter.py,sha256=wzLGgb1GFMeIbAP6HmKcZD33j4D-IlyqlyeR7C5yD7w,1137
97
98
  nedo_vision_worker_core/util/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
98
- nedo_vision_worker_core-0.3.2.dist-info/METADATA,sha256=ql_lATGf7e9bMoC80qbVUEqTq6IbqUAt7fk62kfcZEI,14370
99
- nedo_vision_worker_core-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
- nedo_vision_worker_core-0.3.2.dist-info/entry_points.txt,sha256=pIPafsvPnBw-fpBKBmc1NQCQ6PQY3ad8mZ6mn8_p5FI,70
101
- nedo_vision_worker_core-0.3.2.dist-info/top_level.txt,sha256=y8kusXjVYqtG8MSHYWTrk8bRrvjOrphKXYyzu943TTQ,24
102
- nedo_vision_worker_core-0.3.2.dist-info/RECORD,,
99
+ nedo_vision_worker_core-0.3.4.dist-info/METADATA,sha256=3_UyMqyQc4m_h1qyECq1k7w3vWnN2Hr-ixnLK_BPEp0,14370
100
+ nedo_vision_worker_core-0.3.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
101
+ nedo_vision_worker_core-0.3.4.dist-info/entry_points.txt,sha256=pIPafsvPnBw-fpBKBmc1NQCQ6PQY3ad8mZ6mn8_p5FI,70
102
+ nedo_vision_worker_core-0.3.4.dist-info/top_level.txt,sha256=y8kusXjVYqtG8MSHYWTrk8bRrvjOrphKXYyzu943TTQ,24
103
+ nedo_vision_worker_core-0.3.4.dist-info/RECORD,,
@@ -1,83 +0,0 @@
1
- import logging
2
- try:
3
- import torch
4
- TORCH_AVAILABLE = True
5
- except ImportError:
6
- TORCH_AVAILABLE = False
7
- from .BaseDetector import BaseDetector
8
- from .RFDETRDetector import RFDETRDetector
9
- from .YOLODetector import YOLODetector
10
-
11
-
12
- class DetectionManager:
13
- def __init__(self, model=None):
14
- self.detector: BaseDetector | None = None
15
- self.model_metadata = None
16
-
17
- if model:
18
- self.load_model(model)
19
-
20
- def load_model(self, model):
21
- """
22
- Loads a new model at runtime and replaces current detector if successful.
23
- Checks download status before attempting to load the model.
24
- """
25
- if not model:
26
- if self.detector:
27
- logging.info("🧹 Model unloaded")
28
- self.detector = None
29
- self.model_metadata = None
30
- return
31
-
32
- # Check download status before loading
33
- if not model.is_ready_for_use():
34
- if model.is_downloading():
35
- logging.warning(f"⏳ Model {model.name} is still downloading. Skipping load.")
36
- self.detector = None
37
- self.model_metadata = None
38
- return
39
- elif model.has_download_failed():
40
- logging.error(f"❌ Model {model.name} download failed: {model.download_error}")
41
- self.detector = None
42
- self.model_metadata = None
43
- return
44
- else:
45
- logging.warning(f"⚠️ Model {model.name} is not ready for use (status: {model.download_status})")
46
- self.detector = None
47
- self.model_metadata = None
48
- return
49
-
50
- detector_type = model.type.lower()
51
-
52
- try:
53
- if detector_type == "yolo":
54
- detector = YOLODetector(model)
55
- elif detector_type == "rf_detr":
56
- detector = RFDETRDetector(model)
57
- else:
58
- raise ValueError(f"Unsupported model type: {detector_type}")
59
-
60
- if detector.model is not None:
61
- self.detector = detector
62
- self.model_metadata = model
63
- # Log device info
64
- if TORCH_AVAILABLE:
65
- device = "GPU" if torch.cuda.is_available() else "CPU"
66
- else:
67
- device = "CPU (torch not installed)"
68
- logging.info(f"🚀 Model {model.name} loaded on {device}")
69
- logging.info(f"📥 Model {model.name} with {detector_type} detector loaded")
70
- else:
71
- logging.error(f"❌ Error loading model: {model.name} with {detector_type} detector")
72
- self.detector = None
73
- self.model_metadata = None
74
-
75
- except Exception as e:
76
- logging.error(f"❌ Error loading model: {model.name} with {detector_type} detector: {e}")
77
- self.detector = None
78
- self.model_metadata = None
79
-
80
- def detect_objects(self, frame, confidence_threshold=0.7, class_thresholds=None):
81
- if not self.detector:
82
- return []
83
- return self.detector.detect_objects(frame, confidence_threshold, class_thresholds)