sciveo 0.1.52__tar.gz → 0.1.54__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 (157) hide show
  1. {sciveo-0.1.52 → sciveo-0.1.54}/PKG-INFO +2 -2
  2. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/api/predictors.py +21 -0
  3. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/api/server.py +7 -4
  4. sciveo-0.1.54/sciveo/media/tools/video_interactive.py +138 -0
  5. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/timers.py +13 -2
  6. sciveo-0.1.54/sciveo/version.py +2 -0
  7. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo.egg-info/PKG-INFO +2 -2
  8. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo.egg-info/SOURCES.txt +1 -0
  9. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo.egg-info/requires.txt +21 -17
  10. {sciveo-0.1.52 → sciveo-0.1.54}/setup.py +2 -2
  11. sciveo-0.1.52/sciveo/version.py +0 -2
  12. {sciveo-0.1.52 → sciveo-0.1.54}/README.md +0 -0
  13. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/__init__.py +0 -0
  14. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/api/__init__.py +0 -0
  15. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/api/base.py +0 -0
  16. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/api/upload.py +0 -0
  17. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/cli.py +0 -0
  18. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/common/__init__.py +0 -0
  19. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/common/configuration.py +0 -0
  20. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/common/model.py +0 -0
  21. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/common/optimizers.py +0 -0
  22. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/common/sampling.py +0 -0
  23. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/content/__init__.py +0 -0
  24. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/content/dataset.py +0 -0
  25. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/content/experiment.py +0 -0
  26. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/content/project.py +0 -0
  27. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/content/runner.py +0 -0
  28. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/__init__.py +0 -0
  29. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/ml/__init__.py +0 -0
  30. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/ml/base.py +0 -0
  31. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/ml/encoders/__init__.py +0 -0
  32. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/ml/encoders/base.py +0 -0
  33. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/ml/encoders/normalizer.py +0 -0
  34. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/ml/nlp/__init__.py +0 -0
  35. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/ml/nlp/search.py +0 -0
  36. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/ml/time_series/__init__.py +0 -0
  37. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/ml/time_series/dataset.py +0 -0
  38. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/ml/time_series/predictor.py +0 -0
  39. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/ml/time_series/trainer.py +0 -0
  40. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/ml/time_series/window_generator.py +0 -0
  41. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/__init__.py +0 -0
  42. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/base.py +0 -0
  43. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/job_daemon.py +0 -0
  44. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/layouts/__init__.py +0 -0
  45. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/layouts/base.py +0 -0
  46. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/pipeline.py +0 -0
  47. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/postprocessors/__init__.py +0 -0
  48. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/postprocessors/base.py +0 -0
  49. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/postprocessors/default.py +0 -0
  50. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/__init__.py +0 -0
  51. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/audio/__init__.py +0 -0
  52. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/audio/audio.py +0 -0
  53. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/audio/audio_extractor_process.py +0 -0
  54. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/aws.py +0 -0
  55. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/base.py +0 -0
  56. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/file/__init__.py +0 -0
  57. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/file/archive.py +0 -0
  58. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/__init__.py +0 -0
  59. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/album.py +0 -0
  60. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/album_in_image.py +0 -0
  61. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/depth_esimation.py +0 -0
  62. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/embeddings.py +0 -0
  63. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/filters.py +0 -0
  64. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/generators.py +0 -0
  65. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/histogram.py +0 -0
  66. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/mask.py +0 -0
  67. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/object_detection.py +0 -0
  68. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/resize.py +0 -0
  69. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/segmentation.py +0 -0
  70. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/image/watermark.py +0 -0
  71. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/media_info.py +0 -0
  72. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/nlp/__init__.py +0 -0
  73. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/nlp/address.py +0 -0
  74. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/qr.py +0 -0
  75. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/sci/__init__.py +0 -0
  76. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/sci/base.py +0 -0
  77. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/sci/dataset.py +0 -0
  78. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/sci/time_series/__init__.py +0 -0
  79. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/sci/time_series/predictor.py +0 -0
  80. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/sci/time_series/trainer.py +0 -0
  81. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/tpu_base.py +0 -0
  82. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/video/__init__.py +0 -0
  83. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/video/generators.py +0 -0
  84. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/video/motion_detection.py +0 -0
  85. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/video/resize.py +0 -0
  86. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/video/video_album.py +0 -0
  87. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/video/video_frames.py +0 -0
  88. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/processors/video/video_resample.py +0 -0
  89. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/queues.py +0 -0
  90. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/server.py +0 -0
  91. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/web/__init__.py +0 -0
  92. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/pipelines/web/server.py +0 -0
  93. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/tools/__init__.py +0 -0
  94. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/media/tools/nvr.py +0 -0
  95. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/__init__.py +0 -0
  96. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/base.py +0 -0
  97. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/dataset/__init__.py +0 -0
  98. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/dataset/object_detection.py +0 -0
  99. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/evaluation/__init__.py +0 -0
  100. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/evaluation/object_detection.py +0 -0
  101. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/images/__init__.py +0 -0
  102. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/images/base.py +0 -0
  103. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/images/description.py +0 -0
  104. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/images/embeddings.py +0 -0
  105. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/images/object_detection.py +0 -0
  106. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/images/segmentation.py +0 -0
  107. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/images/tools.py +0 -0
  108. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/images/transformers.py +0 -0
  109. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/nlp/__init__.py +0 -0
  110. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/nlp/embeddings.py +0 -0
  111. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/nlp/tokenizers/__init__.py +0 -0
  112. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/nlp/tokenizers/bpe.py +0 -0
  113. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/video/__init__.py +0 -0
  114. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/ml/video/description.py +0 -0
  115. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/monitoring/__init__.py +0 -0
  116. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/monitoring/monitor.py +0 -0
  117. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/monitoring/start.py +0 -0
  118. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/monitoring/watchdog/__init__.py +0 -0
  119. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/monitoring/watchdog/memory.py +0 -0
  120. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/network/__init__.py +0 -0
  121. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/network/camera.py +0 -0
  122. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/network/sniffer.py +0 -0
  123. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/network/tools.py +0 -0
  124. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/__init__.py +0 -0
  125. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/array.py +0 -0
  126. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/aws/__init__.py +0 -0
  127. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/aws/priority_queue.py +0 -0
  128. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/aws/s3.py +0 -0
  129. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/common.py +0 -0
  130. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/complexity.py +0 -0
  131. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/compress.py +0 -0
  132. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/configuration.py +0 -0
  133. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/crypto.py +0 -0
  134. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/daemon.py +0 -0
  135. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/formating.py +0 -0
  136. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/hardware.py +0 -0
  137. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/http.py +0 -0
  138. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/logger.py +0 -0
  139. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/os.py +0 -0
  140. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/queue.py +0 -0
  141. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/random.py +0 -0
  142. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/remote.py +0 -0
  143. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/simple_counter.py +0 -0
  144. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo/tools/synchronized.py +0 -0
  145. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo.egg-info/dependency_links.txt +0 -0
  146. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo.egg-info/entry_points.txt +0 -0
  147. {sciveo-0.1.52 → sciveo-0.1.54}/sciveo.egg-info/top_level.txt +0 -0
  148. {sciveo-0.1.52 → sciveo-0.1.54}/setup.cfg +0 -0
  149. {sciveo-0.1.52 → sciveo-0.1.54}/test/test_complexity.py +0 -0
  150. {sciveo-0.1.52 → sciveo-0.1.54}/test/test_compress.py +0 -0
  151. {sciveo-0.1.52 → sciveo-0.1.54}/test/test_configuration.py +0 -0
  152. {sciveo-0.1.52 → sciveo-0.1.54}/test/test_crypto.py +0 -0
  153. {sciveo-0.1.52 → sciveo-0.1.54}/test/test_ml_datasets.py +0 -0
  154. {sciveo-0.1.52 → sciveo-0.1.54}/test/test_monitoring.py +0 -0
  155. {sciveo-0.1.52 → sciveo-0.1.54}/test/test_runner.py +0 -0
  156. {sciveo-0.1.52 → sciveo-0.1.54}/test/test_sampling.py +0 -0
  157. {sciveo-0.1.52 → sciveo-0.1.54}/test/test_tokenizers.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciveo
3
- Version: 0.1.52
3
+ Version: 0.1.54
4
4
  Description-Content-Type: text/markdown
5
5
  Provides-Extra: mon
6
6
  Provides-Extra: net
@@ -8,7 +8,7 @@ Provides-Extra: server
8
8
  Provides-Extra: media
9
9
  Provides-Extra: media-ml
10
10
  Provides-Extra: all
11
- Provides-Extra: media-all
11
+ Provides-Extra: ml
12
12
 
13
13
  # SCIVEO - ML/AI and Scientific tools
14
14
 
@@ -11,9 +11,12 @@
11
11
 
12
12
  from sciveo.tools.logger import *
13
13
  from sciveo.tools.timers import Timer
14
+ from sciveo.tools.configuration import GlobalConfiguration
14
15
 
15
16
 
16
17
  class Predictors:
18
+ instance = None
19
+
17
20
  def __init__(self, predictors=None):
18
21
  if predictors is not None:
19
22
  self.list_predictors = predictors
@@ -27,6 +30,16 @@ class Predictors:
27
30
 
28
31
  self.stats = {}
29
32
 
33
+ @staticmethod
34
+ def get():
35
+ if Predictors.instance is None:
36
+ Predictors.instance = Predictors(GlobalConfiguration.get().data.get("API_PREDICTORS", None))
37
+ return Predictors.instance
38
+
39
+ @staticmethod
40
+ def set(predictors):
41
+ Predictors.instance = predictors
42
+
30
43
  def predict(self, predictor_name, X):
31
44
  t = Timer()
32
45
  predicted = self.list_predictors[predictor_name].predict(X)
@@ -35,6 +48,14 @@ class Predictors:
35
48
  self.stats[predictor_name]["count"] += len(X)
36
49
  return predicted
37
50
 
51
+ def train(self, predictor_name, X, Y_true=None):
52
+ t = Timer()
53
+ result = self.list_predictors[predictor_name].train(X, Y_true)
54
+ self.stats.setdefault(predictor_name, {"elapsed": 0.0, "count": 0})
55
+ self.stats[predictor_name]["elapsed"] += t.stop()
56
+ self.stats[predictor_name]["count"] += len(X)
57
+ return result
58
+
38
59
  def describe(self):
39
60
  result = []
40
61
  for k, v in self.list_predictors.items():
@@ -26,8 +26,6 @@ CONFIG = GlobalConfiguration.get()
26
26
  SCI_API_AUTH_TOKEN = CONFIG["api_auth_token"]
27
27
  SCI_API_PREFIX = CONFIG["api_prefix"]
28
28
 
29
- API_PREDICTORS = Predictors(CONFIG.data.get("API_PREDICTORS", None))
30
- API_PREDICTORS.print()
31
29
 
32
30
  app = Flask(__name__)
33
31
 
@@ -49,7 +47,7 @@ def predict_endpoint():
49
47
  data = request.json
50
48
  if "predictor" in data and "X" in data:
51
49
  t = Timer()
52
- predicted = API_PREDICTORS.predict(data["predictor"], data["X"])
50
+ predicted = Predictors.get().predict(data["predictor"], data["X"])
53
51
 
54
52
  if data.get("compressed", 0) > 0:
55
53
  predicted = CompressJsonData().compress(predicted)
@@ -67,11 +65,16 @@ def predict_endpoint():
67
65
 
68
66
 
69
67
  class WebServerDaemon(DaemonBase):
70
- def __init__(self, host="0.0.0.0", port=8901):
68
+ def __init__(self, host="0.0.0.0", port=8901, predictors=None):
71
69
  super().__init__()
72
70
  self.host = host
73
71
  self.port = port
74
72
 
73
+ if predictors is not None:
74
+ Predictors.set(predictors)
75
+
75
76
  def run(self):
76
77
  info("run", [self.host, self.port])
78
+ Predictors.get().print()
79
+
77
80
  serve(app, host=self.host, port=self.port)
@@ -0,0 +1,138 @@
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 os
13
+ import time
14
+ import cv2
15
+ import threading
16
+ import numpy as np
17
+
18
+ from sciveo.tools.logger import *
19
+ from sciveo.tools.timers import FPSCounter
20
+
21
+
22
+ class BaseInteractiveVideoPlayer:
23
+ def __init__(self, path_video, tag):
24
+ self.path_video = path_video
25
+ self.file_name = os.path.basename(self.path_video)
26
+ self.file_name_base = filename_without_ext = os.path.splitext(self.file_name)[0]
27
+ self.path_base = os.path.dirname(self.path_video)
28
+ self.tag = tag
29
+ self.frame_tag = f"Video {tag}"
30
+
31
+ self.cap = None
32
+ self.frame = None
33
+ self.frame_id = 0
34
+ self.result = None
35
+ self.progress_lock = threading.Lock()
36
+ self.frame_lock = threading.Lock()
37
+ self.ui_video_progress_tag = "video time progress"
38
+
39
+ self.fps_ui = FPSCounter(tag="ui", period=1, print_period=600)
40
+ self.fps_read = FPSCounter(tag="read", period=1, print_period=600)
41
+
42
+ self.stop_threads = False
43
+ self.threads = [
44
+ threading.Thread(target=self.read, daemon=True)
45
+ ]
46
+
47
+ def callback_video_progress(self, x):
48
+ # debug("callback_video_progress", x)
49
+ with self.frame_lock:
50
+ # self.frame_id = cv2.getTrackbarPos(self.ui_video_progress_tag, self.frame_tag)
51
+ self.frame_id = x
52
+
53
+ def ui_controls(self, min_val, max_val):
54
+ cv2.createTrackbar(self.ui_video_progress_tag, self.frame_tag, min_val, max_val, self.callback_video_progress)
55
+
56
+ def process_frame(self, frame):
57
+ return {}
58
+
59
+ def read(self):
60
+ while not self.stop_threads:
61
+ self.fps_read.update()
62
+ with self.progress_lock:
63
+ current_frame_id = self.frame_id
64
+ self.cap.set(cv2.CAP_PROP_POS_FRAMES, int(current_frame_id + 1))
65
+ ret, current_frame = self.cap.read()
66
+ if not ret:
67
+ break
68
+
69
+ current_result = self.process_frame(current_frame)
70
+
71
+ with self.frame_lock:
72
+ self.frame = current_frame.copy()
73
+ self.result = current_result
74
+
75
+ with self.progress_lock:
76
+ self.frame_id += 1
77
+ if self.frame_id >= self.video_frame_count:
78
+ self.frame_id = 0
79
+ cv2.setTrackbarPos(self.ui_video_progress_tag, self.frame_tag, self.frame_id)
80
+
81
+ def draw(self, frame, result):
82
+ cv2.putText(frame, f"R[{result}]", (30, 80), cv2.FONT_HERSHEY_SIMPLEX, 1.3, (0, 255, 255), 2)
83
+
84
+ def run(self, max_display_width=1024):
85
+ cv2.namedWindow(self.frame_tag, cv2.WINDOW_NORMAL)
86
+
87
+ self.cap = cv2.VideoCapture(self.path_video)
88
+
89
+ self.video_fps = self.cap.get(cv2.CAP_PROP_FPS)
90
+ self.video_frame_count = int(self.cap.get(cv2.CAP_PROP_FRAME_COUNT))
91
+ self.video_duration_sec = self.video_frame_count / self.video_fps
92
+ debug("run", self.path_video, self.tag, "fps", self.video_fps, "count", self.video_frame_count, "duration", self.video_duration_sec)
93
+
94
+ self.ui_controls(0, self.video_frame_count)
95
+
96
+ for thread in self.threads:
97
+ thread.start()
98
+
99
+ while self.cap.isOpened():
100
+ self.fps_ui.update()
101
+ current_frame = None
102
+ original_current_frame = None
103
+ current_result = None
104
+ with self.frame_lock:
105
+ if self.frame is not None:
106
+ current_frame = self.frame.copy()
107
+ original_current_frame = self.frame.copy()
108
+ current_result = self.result.copy()
109
+
110
+ if current_frame is not None:
111
+ cv2.putText(current_frame, f"FPS read {round(self.fps_read.value, 1)} ui {round(self.fps_ui.value, 1)} T {round(self.frame_id / self.video_fps, 3)}s", (30, 40), cv2.FONT_HERSHEY_SIMPLEX, 1.3, (0, 255, 0), 4)
112
+ self.draw(current_frame, current_result)
113
+ height, width = current_frame.shape[:2]
114
+ if width > max_display_width:
115
+ display_width = max_display_width
116
+ display_height = int(height * (max_display_width / width))
117
+ cv2.resizeWindow(self.frame_tag, display_width, display_height)
118
+ cv2.imshow(self.frame_tag, current_frame)
119
+
120
+ key = cv2.waitKey(1) & 0xFF
121
+ if key == ord("q"):
122
+ self.stop_threads = True
123
+ for thread in self.threads:
124
+ thread.join()
125
+ break
126
+ elif key == ord("p"):
127
+ if original_current_frame is not None:
128
+ frame_path = os.path.join(self.path_base, f"{self.file_name_base}-{self.frame_id}.png")
129
+ cv2.imwrite(frame_path, original_current_frame)
130
+ debug(f"saved frame {self.frame_id} to {frame_path}")
131
+
132
+ self.cap.release()
133
+ cv2.destroyAllWindows()
134
+
135
+
136
+ if __name__ == "__main__":
137
+ video_player = BaseInteractiveVideoPlayer(os.environ["PATH_VIDEO_FILE"], "base video player")
138
+ video_player.run()
@@ -15,19 +15,30 @@ from sciveo.tools.logger import *
15
15
 
16
16
 
17
17
  class FPSCounter:
18
- def __init__(self, period=10, tag=""):
18
+ def __init__(self, period=1, tag="", print_period=1, printer=debug):
19
19
  self.period = period
20
+ self.print_period = print_period
21
+ self.printer = printer
22
+ self.print_n = 0
20
23
  self.tag = tag
21
24
  self.n = 0
22
25
  self.t1 = time.time()
26
+ self.value = 0
27
+
28
+ def print(self):
29
+ self.print_n += 1
30
+ if self.print_n > self.print_period:
31
+ self.printer(self.tag, "FPS", self.value)
32
+ self.print_n = 0
23
33
 
24
34
  def update(self):
25
35
  self.n += 1
26
36
  t2 = time.time()
27
37
  if t2 - self.t1 > self.period:
28
- debug(self.tag, "FPS", self.n / (t2 - self.t1))
38
+ self.value = self.n / (t2 - self.t1)
29
39
  self.n = 0
30
40
  self.t1 = time.time()
41
+ self.print()
31
42
 
32
43
 
33
44
  class TimerExec:
@@ -0,0 +1,2 @@
1
+
2
+ __version__ = '0.1.54'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciveo
3
- Version: 0.1.52
3
+ Version: 0.1.54
4
4
  Description-Content-Type: text/markdown
5
5
  Provides-Extra: mon
6
6
  Provides-Extra: net
@@ -8,7 +8,7 @@ Provides-Extra: server
8
8
  Provides-Extra: media
9
9
  Provides-Extra: media-ml
10
10
  Provides-Extra: all
11
- Provides-Extra: media-all
11
+ Provides-Extra: ml
12
12
 
13
13
  # SCIVEO - ML/AI and Scientific tools
14
14
 
@@ -91,6 +91,7 @@ sciveo/media/pipelines/web/__init__.py
91
91
  sciveo/media/pipelines/web/server.py
92
92
  sciveo/media/tools/__init__.py
93
93
  sciveo/media/tools/nvr.py
94
+ sciveo/media/tools/video_interactive.py
94
95
  sciveo/ml/__init__.py
95
96
  sciveo/ml/base.py
96
97
  sciveo/ml/dataset/__init__.py
@@ -5,6 +5,10 @@ requests>=0.0.0
5
5
  psutil>=0.0.0
6
6
  netifaces>=0.0.0
7
7
  scapy>=0.0.0
8
+ fastapi>=0.0.0
9
+ uvicorn[standard]>=0.0.0
10
+ flask>=0.0.0
11
+ waitress>=0.0.0
8
12
 
9
13
  [media]
10
14
  scikit-learn>=0.0.0
@@ -25,10 +29,26 @@ ffmpeg-python>=0.0.0
25
29
  opencv-python-headless>=0.0.0
26
30
  opencv-contrib-python-headless>=0.0.0
27
31
 
28
- [media-all]
32
+ [media-ml]
33
+ tensorflow>=0.0.0
34
+ keras>=0.0.0
35
+ torch>=0.0.0
36
+ torchvision>=0.0.0
37
+ diffusers>=0.0.0
38
+ transformers>=0.0.0
39
+ sentence_transformers>=0.0.0
40
+ accelerate>=0.0.0
41
+ annoy>=0.0.0
42
+ ultralytics>=0.0.0
43
+
44
+ [ml]
29
45
  psutil>=0.0.0
30
46
  netifaces>=0.0.0
31
47
  scapy>=0.0.0
48
+ fastapi>=0.0.0
49
+ uvicorn[standard]>=0.0.0
50
+ flask>=0.0.0
51
+ waitress>=0.0.0
32
52
  scikit-learn>=0.0.0
33
53
  scipy>=0.0.0
34
54
  scikit-video>=0.0.0
@@ -46,22 +66,6 @@ tqdm>=0.0.0
46
66
  ffmpeg-python>=0.0.0
47
67
  opencv-python-headless>=0.0.0
48
68
  opencv-contrib-python-headless>=0.0.0
49
- fastapi>=0.0.0
50
- uvicorn[standard]>=0.0.0
51
- flask>=0.0.0
52
- waitress>=0.0.0
53
- tensorflow>=0.0.0
54
- keras>=0.0.0
55
- torch>=0.0.0
56
- torchvision>=0.0.0
57
- diffusers>=0.0.0
58
- transformers>=0.0.0
59
- sentence_transformers>=0.0.0
60
- accelerate>=0.0.0
61
- annoy>=0.0.0
62
- ultralytics>=0.0.0
63
-
64
- [media-ml]
65
69
  tensorflow>=0.0.0
66
70
  keras>=0.0.0
67
71
  torch>=0.0.0
@@ -39,8 +39,8 @@ extras_require = {
39
39
  ]
40
40
  }
41
41
 
42
- extras_require['all'] = extras_require['mon'] + extras_require['net']
43
- extras_require['media-all'] = extras_require['all'] + extras_require['media'] + extras_require['server'] + extras_require['media-ml']
42
+ extras_require['all'] = extras_require['mon'] + extras_require['net'] + extras_require['server']
43
+ extras_require['ml'] = extras_require['all'] + extras_require['media'] + extras_require['media-ml']
44
44
 
45
45
  setup(
46
46
  name='sciveo',
@@ -1,2 +0,0 @@
1
-
2
- __version__ = '0.1.52'
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
File without changes
File without changes
File without changes
File without changes
File without changes