sciveo 0.1.32__tar.gz → 0.1.34__tar.gz

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.
Files changed (133) hide show
  1. {sciveo-0.1.32 → sciveo-0.1.34}/PKG-INFO +1 -1
  2. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/cli.py +3 -3
  3. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/pipeline.py +2 -0
  4. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/base.py +6 -0
  5. sciveo-0.1.34/sciveo/media/pipelines/processors/image/object_detection.py +186 -0
  6. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/monitoring/monitor.py +22 -1
  7. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/monitoring/start.py +3 -2
  8. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/logger.py +2 -2
  9. sciveo-0.1.34/sciveo/version.py +2 -0
  10. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo.egg-info/PKG-INFO +1 -1
  11. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo.egg-info/SOURCES.txt +1 -0
  12. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo.egg-info/requires.txt +2 -0
  13. {sciveo-0.1.32 → sciveo-0.1.34}/setup.py +1 -0
  14. sciveo-0.1.32/sciveo/version.py +0 -2
  15. {sciveo-0.1.32 → sciveo-0.1.34}/README.md +0 -0
  16. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/__init__.py +0 -0
  17. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/api/__init__.py +0 -0
  18. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/api/base.py +0 -0
  19. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/api/upload.py +0 -0
  20. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/common/__init__.py +0 -0
  21. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/common/configuration.py +0 -0
  22. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/common/model.py +0 -0
  23. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/common/optimizers.py +0 -0
  24. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/common/sampling.py +0 -0
  25. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/content/__init__.py +0 -0
  26. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/content/dataset.py +0 -0
  27. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/content/experiment.py +0 -0
  28. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/content/project.py +0 -0
  29. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/content/runner.py +0 -0
  30. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/__init__.py +0 -0
  31. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/ml/__init__.py +0 -0
  32. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/ml/base.py +0 -0
  33. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/ml/encoders/__init__.py +0 -0
  34. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/ml/encoders/base.py +0 -0
  35. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/ml/encoders/normalizer.py +0 -0
  36. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/ml/nlp/__init__.py +0 -0
  37. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/ml/nlp/search.py +0 -0
  38. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/ml/time_series/__init__.py +0 -0
  39. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/ml/time_series/dataset.py +0 -0
  40. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/ml/time_series/predictor.py +0 -0
  41. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/ml/time_series/trainer.py +0 -0
  42. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/ml/time_series/window_generator.py +0 -0
  43. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/__init__.py +0 -0
  44. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/base.py +0 -0
  45. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/job_daemon.py +0 -0
  46. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/layouts/__init__.py +0 -0
  47. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/layouts/base.py +0 -0
  48. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/postprocessors/__init__.py +0 -0
  49. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/postprocessors/base.py +0 -0
  50. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/postprocessors/default.py +0 -0
  51. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/__init__.py +0 -0
  52. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/audio/__init__.py +0 -0
  53. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/audio/audio.py +0 -0
  54. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/audio/audio_extractor_process.py +0 -0
  55. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/aws.py +0 -0
  56. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/file/__init__.py +0 -0
  57. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/file/archive.py +0 -0
  58. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/image/__init__.py +0 -0
  59. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/image/album.py +0 -0
  60. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/image/album_in_image.py +0 -0
  61. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/image/depth_esimation.py +0 -0
  62. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/image/embeddings.py +0 -0
  63. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/image/filters.py +0 -0
  64. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/image/generators.py +0 -0
  65. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/image/histogram.py +0 -0
  66. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/image/mask.py +0 -0
  67. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/image/resize.py +0 -0
  68. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/image/segmentation.py +0 -0
  69. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/image/watermark.py +0 -0
  70. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/media_info.py +0 -0
  71. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/nlp/__init__.py +0 -0
  72. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/nlp/address.py +0 -0
  73. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/qr.py +0 -0
  74. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/sci/__init__.py +0 -0
  75. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/sci/base.py +0 -0
  76. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/sci/dataset.py +0 -0
  77. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/sci/time_series/__init__.py +0 -0
  78. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/sci/time_series/predictor.py +0 -0
  79. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/sci/time_series/trainer.py +0 -0
  80. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/tpu_base.py +0 -0
  81. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/video/__init__.py +0 -0
  82. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/video/generators.py +0 -0
  83. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/video/motion_detection.py +0 -0
  84. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/video/resize.py +0 -0
  85. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/video/video_album.py +0 -0
  86. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/video/video_frames.py +0 -0
  87. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/processors/video/video_resample.py +0 -0
  88. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/queues.py +0 -0
  89. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/server.py +0 -0
  90. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/web/__init__.py +0 -0
  91. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/media/pipelines/web/server.py +0 -0
  92. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/ml/__init__.py +0 -0
  93. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/ml/evaluation/__init__.py +0 -0
  94. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/ml/evaluation/object_detection.py +0 -0
  95. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/ml/images/__init__.py +0 -0
  96. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/ml/images/object_detection.py +0 -0
  97. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/ml/images/tools.py +0 -0
  98. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/ml/images/transforms.py +0 -0
  99. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/ml/nlp/__init__.py +0 -0
  100. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/monitoring/__init__.py +0 -0
  101. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/network/__init__.py +0 -0
  102. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/network/camera.py +0 -0
  103. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/network/sniffer.py +0 -0
  104. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/network/tools.py +0 -0
  105. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/__init__.py +0 -0
  106. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/array.py +0 -0
  107. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/aws/__init__.py +0 -0
  108. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/aws/priority_queue.py +0 -0
  109. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/aws/s3.py +0 -0
  110. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/common.py +0 -0
  111. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/compress.py +0 -0
  112. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/configuration.py +0 -0
  113. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/crypto.py +0 -0
  114. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/daemon.py +0 -0
  115. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/formating.py +0 -0
  116. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/hardware.py +0 -0
  117. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/http.py +0 -0
  118. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/os.py +0 -0
  119. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/random.py +0 -0
  120. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/remote.py +0 -0
  121. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/simple_counter.py +0 -0
  122. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/synchronized.py +0 -0
  123. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo/tools/timers.py +0 -0
  124. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo.egg-info/dependency_links.txt +0 -0
  125. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo.egg-info/entry_points.txt +0 -0
  126. {sciveo-0.1.32 → sciveo-0.1.34}/sciveo.egg-info/top_level.txt +0 -0
  127. {sciveo-0.1.32 → sciveo-0.1.34}/setup.cfg +0 -0
  128. {sciveo-0.1.32 → sciveo-0.1.34}/test/test_compress.py +0 -0
  129. {sciveo-0.1.32 → sciveo-0.1.34}/test/test_configuration.py +0 -0
  130. {sciveo-0.1.32 → sciveo-0.1.34}/test/test_crypto.py +0 -0
  131. {sciveo-0.1.32 → sciveo-0.1.34}/test/test_monitoring.py +0 -0
  132. {sciveo-0.1.32 → sciveo-0.1.34}/test/test_runner.py +0 -0
  133. {sciveo-0.1.32 → sciveo-0.1.34}/test/test_sampling.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciveo
3
- Version: 0.1.32
3
+ Version: 0.1.34
4
4
  Description-Content-Type: text/markdown
5
5
  Provides-Extra: mon
6
6
  Provides-Extra: net
@@ -31,7 +31,7 @@ def main():
31
31
  parser.add_argument('--port', type=int, default=22, help='Host port number, used for network ops')
32
32
  parser.add_argument('--localhost', type=bool, default=False, help='Add localhost to list of hosts')
33
33
  parser.add_argument('--input-path', type=str, help='Input Path')
34
- parser.add_argument('--output-path', type=str, help='Output Path')
34
+ parser.add_argument('--output-path', type=str, default=None, help='Output Path')
35
35
  parser.add_argument('--width', type=str, default=None, help='width')
36
36
  parser.add_argument('--height', type=str, default=None, help='height')
37
37
  parser.add_argument('--rate', type=int, help='Rate number')
@@ -41,7 +41,7 @@ def main():
41
41
 
42
42
  if args.command == 'monitor':
43
43
  from sciveo.monitoring.start import MonitorStart
44
- MonitorStart(period=args.period, block=args.block)()
44
+ MonitorStart(period=args.period, block=args.block, output_path=args.output_path)()
45
45
  elif args.command == 'scan':
46
46
  from sciveo.network.tools import NetworkTools
47
47
  NetworkTools(timeout=args.timeout, localhost=args.localhost).scan_port(port=args.port, network=args.net)
@@ -53,7 +53,7 @@ def main():
53
53
  default_lines = [
54
54
  "secret_access_key=<your secret access key>",
55
55
  "api_base_url=https://sciveo.com",
56
- "log_min_level=DEBUG"
56
+ "sci_log_level=DEBUG"
57
57
  ]
58
58
  with open(os.path.join(base_path, "default"), 'w') as fp:
59
59
  for line in default_lines:
@@ -31,6 +31,7 @@ from sciveo.media.pipelines.processors.image.depth_esimation import *
31
31
  from sciveo.media.pipelines.processors.image.mask import *
32
32
  from sciveo.media.pipelines.processors.image.segmentation import *
33
33
  from sciveo.media.pipelines.processors.image.watermark import *
34
+ from sciveo.media.pipelines.processors.image.object_detection import ImageObjectDetectionProcessor
34
35
 
35
36
  from sciveo.media.pipelines.processors.file.archive import *
36
37
 
@@ -84,6 +85,7 @@ class MediaPipeline:
84
85
  "image-segmentation": ImageSegmentation,
85
86
  "image-depth-estimation": ImageDepthEstimation,
86
87
  "image-embedding": ImageEmbedding,
88
+ "image-object-detection": ImageObjectDetectionProcessor,
87
89
 
88
90
  "sci-timeseries-predictor": TimeSeriesPredictorProcessor,
89
91
  "sci-timeseries-trainer": TimeSeriesTrainerProcessor,
@@ -27,6 +27,9 @@ class BaseProcessor(BaseContentProcessor):
27
27
  def post_process(self):
28
28
  pass
29
29
 
30
+ def init_run(self):
31
+ pass
32
+
30
33
  def run(self, job, input):
31
34
  self.job = job
32
35
  self.job_id = job["id"]
@@ -35,6 +38,9 @@ class BaseProcessor(BaseContentProcessor):
35
38
  return []
36
39
  progress_per_media = self.max_progress / max(1, len(input))
37
40
  debug("run", job["id"], progress_per_media, "input", input)
41
+
42
+ self.init_run()
43
+
38
44
  for i, media in enumerate(input):
39
45
  if self.is_processor_run(job, media):
40
46
  try:
@@ -0,0 +1,186 @@
1
+ #
2
+ # Pavlin Georgiev, Softel Labs
3
+ #
4
+ # This is a proprietary file and may not be copied,
5
+ # distributed, or modified without express permission
6
+ # from the owner. For licensing inquiries, please
7
+ # contact pavlin@softel.bg.
8
+ #
9
+ # 2024
10
+ #
11
+
12
+ import numpy as np
13
+ import cv2
14
+
15
+ from sciveo.tools.logger import *
16
+ from sciveo.tools.simple_counter import Timer
17
+ from sciveo.tools.common import *
18
+ from sciveo.media.pipelines.processors.base import *
19
+
20
+
21
+ class ObjectDetectorBase:
22
+ def __init__(self, model_path, device='cpu', colors=None):
23
+ self.model_path = model_path
24
+ self.device = device
25
+ if colors is None:
26
+ self.colors = [
27
+ (60, 180, 75), # Green
28
+ (255, 255, 255), # White
29
+ (245, 130, 48), # Orange
30
+ (255, 225, 25), # Yellow
31
+ (0, 130, 200), # Blue
32
+ (230, 25, 75), # Red
33
+ (145, 30, 180), # Purple
34
+ (70, 240, 240), # Cyan
35
+ (240, 50, 230), # Magenta
36
+ (210, 245, 60), # Lime
37
+ (250, 190, 212), # Pink
38
+ (0, 128, 128), # Teal
39
+ (220, 190, 255), # Lavender
40
+ (170, 110, 40), # Brown
41
+ (128, 0, 0), # Maroon
42
+ (0, 0, 128), # Navy
43
+ (128, 128, 0), # Olive
44
+ (255, 215, 180), # Peach
45
+ (255, 250, 200), # Ivory
46
+ (170, 255, 195), # Mint
47
+ ]
48
+ else:
49
+ self.colors = colors
50
+
51
+ def resize(self, image, h):
52
+ ratio = max(image.shape[0], image.shape[1]) / h
53
+ h, w = int(image.shape[0] / ratio), int(image.shape[1] / ratio)
54
+ return cv2.resize(image, (w, h))
55
+
56
+ def load(self, image_path):
57
+ image = cv2.imread(image_path)
58
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
59
+ return image
60
+
61
+ def read_images(self, images_paths):
62
+ X = []
63
+ for image_path in images_paths:
64
+ image = self.load(image_path)
65
+ image = self.resize(image)
66
+ X.append(image)
67
+ return X
68
+
69
+ def draw_label_inverted(self, frame, label_text, x_min, y_min, color, font=cv2.FONT_HERSHEY_SIMPLEX, font_scale=0.3, font_thickness=1):
70
+ text_size = cv2.getTextSize(label_text, font, font_scale, font_thickness)[0]
71
+ y_offset = text_size[1] + 4
72
+ x_offset = text_size[0] + 4
73
+ if y_min - y_offset >= 0:
74
+ text_background_top_left = (x_min, y_min - y_offset)
75
+ text_background_bottom_right = (x_min + x_offset, y_min)
76
+ else:
77
+ text_background_top_left = (x_min, y_min)
78
+ text_background_bottom_right = (x_min + x_offset, y_min + y_offset)
79
+
80
+ cv2.rectangle(frame, text_background_top_left, text_background_bottom_right, color, cv2.FILLED)
81
+ cv2.putText(frame, label_text, (x_min + 2, text_background_bottom_right[1] - 2), font, font_scale, (0,0,0), font_thickness)
82
+
83
+ def draw_object_rectangle_xyxy(self, frame, box, label, color, alpha=0.2, filled=True):
84
+ (x1, y1, x2, y2) = box
85
+
86
+ if filled:
87
+ rectangle = np.zeros((y2 - y1, x2 - x1, 3), dtype=np.uint8)
88
+ rectangle[:] = color
89
+ frame[y1:y2, x1:x2] = cv2.addWeighted(rectangle, alpha, frame[y1:y2, x1:x2], 1 - alpha, 0)
90
+
91
+ cv2.rectangle(frame, (x1, y1), (x2, y2), color, thickness=1)
92
+
93
+ self.draw_label_inverted(frame, label, x1, y1, color=color)
94
+
95
+ def draw_object_rectangle_xywh(frame, box, label, color, alpha=0.2, filled=True):
96
+ (x, y, w, h) = box
97
+ (x1, y1, x2, y2) = x, y, x + w, y + h
98
+ self.draw_object_rectangle_xyxy(frame, (x1, y1, x2, y2), label, color, alpha=alpha, filled=filled)
99
+
100
+
101
+ class ObjectDetectorYOLO(ObjectDetectorBase):
102
+ def __init__(self, model_path="yolo11m.pt", device='cpu', colors=None):
103
+ super().__init__(model_path, device=device, colors=colors)
104
+ from ultralytics import YOLO
105
+ self.model = YOLO(self.model_path)
106
+
107
+ def predict_one(self, x, confidence_threshold=0.5):
108
+ return self.model.predict(x, device=self.device, conf=confidence_threshold, verbose=False)
109
+
110
+ def predict(self, X, max_n=64, confidence_threshold=0.5):
111
+ predictions = []
112
+
113
+ num_batches = math.ceil(len(X) / max_n)
114
+
115
+ for batch_idx in range(num_batches):
116
+ timer = Timer()
117
+ start_idx = batch_idx * max_n
118
+ end_idx = min((batch_idx + 1) * max_n, len(X))
119
+
120
+ batch_images = X[start_idx:end_idx]
121
+ batch_predictions = self.model.predict(batch_images, device=self.device, conf=confidence_threshold, verbose=False)
122
+ predictions.extend(batch_predictions)
123
+
124
+ elapsed = timer.stop()
125
+ FPS = len(batch_images) / elapsed
126
+ debug(f"batch {batch_idx} / {num_batches}", "elapsed", elapsed, "FPS", FPS, "len", len(batch_images))
127
+
128
+ return predictions
129
+
130
+ def resize(self, image):
131
+ return super().resize(image, 640)
132
+
133
+ def draw(self, image, detections, colors=None):
134
+ if colors is None:
135
+ colors = self.colors
136
+ height, width = image.shape[:2]
137
+ boxes = detections.boxes
138
+ class_names = detections.names
139
+ for i, box in enumerate(boxes):
140
+ bbox = (np.array(box.xyxyn[0]) * np.array([width, height, width, height])).astype(int).tolist()
141
+
142
+ confidence = box.conf[0].item()
143
+ class_id = int(box.cls[0].item())
144
+ label = class_names[class_id]
145
+ label_text = f"{label} {int(confidence * 100)}%"
146
+
147
+ color = colors[i % len(colors)]
148
+ self.draw_object_rectangle_xyxy(image, bbox, label_text, color)
149
+
150
+
151
+ class ImageObjectDetectionProcessor(BaseProcessor):
152
+ def __init__(self, processor_config, max_progress) -> None:
153
+ super().__init__(processor_config, max_progress)
154
+ self.default.update({"JPEG_QUALITY": 80, "min_confidence": 0.5, "model_type": 0, "height": 720})
155
+
156
+ def init_run(self):
157
+ TPU = os.environ.get("MEDIA_PROCESSING_BACKEND", "cpu")
158
+ self.predictor = ObjectDetectorYOLO(model_path=["yolo11x.pt", "yolo11l.pt", "yolo11m.pt", "yolo11s.pt"][self["model_type"]], device=TPU)
159
+
160
+ def process(self, media):
161
+ try:
162
+ self.media = media
163
+ self.local_path = media["local_path"]
164
+
165
+ tag = "object-detections"
166
+ image = self.predictor.load(self.local_path)
167
+ image_resized = self.predictor.resize(image)
168
+
169
+ detections = self.predictor.predict_one([image_resized], confidence_threshold=self["min_confidence"])
170
+
171
+ # image_resized = self.predictor.super().resize(image, h=self["height"])
172
+ image_resized = cv2.cvtColor(image_resized, cv2.COLOR_RGB2BGR)
173
+ self.predictor.draw(image_resized, detections[0])
174
+ result_image_local_path = self.add_suffix_to_filename(self.local_path, tag)
175
+ cv2.imwrite(result_image_local_path, image_resized, [cv2.IMWRITE_JPEG_QUALITY, self["JPEG_QUALITY"]])
176
+
177
+ self.next_content(self.media, tag, result_image_local_path, w=image_resized.shape[1], h=image_resized.shape[0])
178
+ except Exception as e:
179
+ exception(e, self.media)
180
+ return self.media
181
+
182
+ def content_type(self):
183
+ return "image"
184
+
185
+ def name(self):
186
+ return "image-object-detection"
@@ -12,6 +12,7 @@
12
12
  import os
13
13
  import subprocess
14
14
  import time
15
+ import json
15
16
  import datetime
16
17
  import socket
17
18
  import psutil
@@ -43,8 +44,11 @@ class MonitorTools:
43
44
 
44
45
 
45
46
  class BaseMonitor(DaemonBase):
46
- def __init__(self, period=5):
47
+ def __init__(self, period=5, output_path=None):
47
48
  super().__init__(period=period)
49
+ self.output_path = output_path
50
+ if self.output_path is not None and os.path.isdir(self.output_path):
51
+ self.output_path = os.path.join(self.output_path, "sciveo_monitor.json")
48
52
 
49
53
  self.data = {
50
54
  "CPU": {},
@@ -78,6 +82,17 @@ class BaseMonitor(DaemonBase):
78
82
  def __call__(self):
79
83
  return self.data
80
84
 
85
+ def output_write(self):
86
+ if os.path.isfile(self.output_path):
87
+ with open(self.output_path, "rb+") as fp:
88
+ fp.seek(-2, 2)
89
+ fp.truncate()
90
+ with open(self.output_path, "a") as fp:
91
+ fp.write(f", {json.dumps(self.data)}]\n")
92
+ else:
93
+ with open(self.output_path, "w") as fp:
94
+ fp.write(json.dumps([self.data]) + "\n")
95
+
81
96
  def loop(self):
82
97
  self.get_cpu_usage()
83
98
  self.get_temperatures()
@@ -91,6 +106,12 @@ class BaseMonitor(DaemonBase):
91
106
 
92
107
  api_result = self.api.POST_SCI("monitor", {"data": self.data})
93
108
 
109
+ try:
110
+ if self.output_path is not None:
111
+ self.output_write()
112
+ except Exception as e:
113
+ error(e, "writing failed for", self.output_path)
114
+
94
115
  debug(self(), "api_result", api_result)
95
116
 
96
117
  def tail_logs(self):
@@ -22,7 +22,8 @@ class MonitorStart:
22
22
  "period": 120,
23
23
  "block": True,
24
24
  "fork": False,
25
- "fork_type": 0
25
+ "fork_type": 0,
26
+ "output_path": None,
26
27
  }
27
28
  self.arguments = {}
28
29
  for k, v in self.default_arguments.items():
@@ -59,7 +60,7 @@ class MonitorStart:
59
60
 
60
61
  def start(self):
61
62
  period = max(self.arguments["period"], 5)
62
- mon = BaseMonitor(period=period)
63
+ mon = BaseMonitor(period=period, output_path=self.arguments["output_path"])
63
64
  mon.start()
64
65
  mon.join()
65
66
 
@@ -20,7 +20,7 @@ from sciveo.tools.configuration import GlobalConfiguration
20
20
  SCIVEO_LOGGER_NAME = "sciveo-log"
21
21
 
22
22
  _sciveo_global_config = GlobalConfiguration.get()
23
- _sciveo_log_min_level = _sciveo_global_config["LOG_MIN_LEVEL"]
23
+ _sciveo_log_min_level = _sciveo_global_config["SCI_LOG_LEVEL"]
24
24
  _sciveo_log_lock = Lock()
25
25
 
26
26
  def _sciveo_get_logger(name):
@@ -29,7 +29,7 @@ def _sciveo_get_logger(name):
29
29
  with _sciveo_log_lock:
30
30
  if not logger.hasHandlers():
31
31
  log_min_level = logging.getLevelName(_sciveo_log_min_level)
32
- if log_min_level.startswith("Level"):
32
+ if (isinstance(log_min_level, str) and log_min_level.startswith("Level")) or isinstance(log_min_level, int):
33
33
  log_min_level = "DEBUG"
34
34
  logger.setLevel(log_min_level)
35
35
 
@@ -0,0 +1,2 @@
1
+
2
+ __version__ = '0.1.34'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciveo
3
- Version: 0.1.32
3
+ Version: 0.1.34
4
4
  Description-Content-Type: text/markdown
5
5
  Provides-Extra: mon
6
6
  Provides-Extra: net
@@ -66,6 +66,7 @@ sciveo/media/pipelines/processors/image/filters.py
66
66
  sciveo/media/pipelines/processors/image/generators.py
67
67
  sciveo/media/pipelines/processors/image/histogram.py
68
68
  sciveo/media/pipelines/processors/image/mask.py
69
+ sciveo/media/pipelines/processors/image/object_detection.py
69
70
  sciveo/media/pipelines/processors/image/resize.py
70
71
  sciveo/media/pipelines/processors/image/segmentation.py
71
72
  sciveo/media/pipelines/processors/image/watermark.py
@@ -56,6 +56,7 @@ diffusers>=0.0.0
56
56
  transformers>=0.0.0
57
57
  accelerate>=0.0.0
58
58
  annoy>=0.0.0
59
+ ultralytics
59
60
 
60
61
  [media-ml]
61
62
  tensorflow>=0.0.0
@@ -66,6 +67,7 @@ diffusers>=0.0.0
66
67
  transformers>=0.0.0
67
68
  accelerate>=0.0.0
68
69
  annoy>=0.0.0
70
+ ultralytics
69
71
 
70
72
  [media-server]
71
73
  fastapi
@@ -30,6 +30,7 @@ extras_require = {
30
30
  'tensorflow>=0.0.0', 'keras>=0.0.0',
31
31
  'torch>=0.0.0', 'torchvision>=0.0.0',
32
32
  'diffusers>=0.0.0', 'transformers>=0.0.0', 'accelerate>=0.0.0', 'annoy>=0.0.0',
33
+ 'ultralytics'
33
34
  ]
34
35
  }
35
36
 
@@ -1,2 +0,0 @@
1
-
2
- __version__ = '0.1.32'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes