learning-loop-node 0.18.2__tar.gz → 0.18.4__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 (112) hide show
  1. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/PKG-INFO +31 -36
  2. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/detector_node.py +2 -7
  3. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/rest/detect.py +1 -6
  4. learning_loop_node-0.18.4/learning_loop_node.egg-info/PKG-INFO +278 -0
  5. learning_loop_node-0.18.4/learning_loop_node.egg-info/SOURCES.txt +64 -0
  6. learning_loop_node-0.18.4/learning_loop_node.egg-info/dependency_links.txt +1 -0
  7. learning_loop_node-0.18.4/learning_loop_node.egg-info/requires.txt +27 -0
  8. learning_loop_node-0.18.4/learning_loop_node.egg-info/top_level.txt +1 -0
  9. learning_loop_node-0.18.4/pyproject.toml +50 -0
  10. learning_loop_node-0.18.4/setup.cfg +4 -0
  11. learning_loop_node-0.18.2/learning_loop_node/examples/novelty_score_updater.py +0 -70
  12. learning_loop_node-0.18.2/learning_loop_node/tests/annotator/conftest.py +0 -55
  13. learning_loop_node-0.18.2/learning_loop_node/tests/annotator/pytest.ini +0 -10
  14. learning_loop_node-0.18.2/learning_loop_node/tests/annotator/test_annotator_node.py +0 -60
  15. learning_loop_node-0.18.2/learning_loop_node/tests/detector/__init__.py +0 -0
  16. learning_loop_node-0.18.2/learning_loop_node/tests/detector/conftest.py +0 -174
  17. learning_loop_node-0.18.2/learning_loop_node/tests/detector/inbox_filter/__init__.py +0 -0
  18. learning_loop_node-0.18.2/learning_loop_node/tests/detector/inbox_filter/test_observation.py +0 -31
  19. learning_loop_node-0.18.2/learning_loop_node/tests/detector/inbox_filter/test_relevance_group.py +0 -162
  20. learning_loop_node-0.18.2/learning_loop_node/tests/detector/inbox_filter/test_unexpected_observations_count.py +0 -35
  21. learning_loop_node-0.18.2/learning_loop_node/tests/detector/pytest.ini +0 -10
  22. learning_loop_node-0.18.2/learning_loop_node/tests/detector/test.jpg +0 -0
  23. learning_loop_node-0.18.2/learning_loop_node/tests/detector/test_client_communication.py +0 -177
  24. learning_loop_node-0.18.2/learning_loop_node/tests/detector/test_detector_node.py +0 -98
  25. learning_loop_node-0.18.2/learning_loop_node/tests/detector/test_outbox.py +0 -77
  26. learning_loop_node-0.18.2/learning_loop_node/tests/detector/test_relevance_filter.py +0 -43
  27. learning_loop_node-0.18.2/learning_loop_node/tests/detector/testing_detector.py +0 -28
  28. learning_loop_node-0.18.2/learning_loop_node/tests/general/__init__.py +0 -0
  29. learning_loop_node-0.18.2/learning_loop_node/tests/general/conftest.py +0 -68
  30. learning_loop_node-0.18.2/learning_loop_node/tests/general/pytest.ini +0 -10
  31. learning_loop_node-0.18.2/learning_loop_node/tests/general/test_data/file_1.txt +0 -1
  32. learning_loop_node-0.18.2/learning_loop_node/tests/general/test_data/file_2.txt +0 -1
  33. learning_loop_node-0.18.2/learning_loop_node/tests/general/test_data/model.json +0 -6
  34. learning_loop_node-0.18.2/learning_loop_node/tests/general/test_data_classes.py +0 -22
  35. learning_loop_node-0.18.2/learning_loop_node/tests/general/test_downloader.py +0 -84
  36. learning_loop_node-0.18.2/learning_loop_node/tests/general/test_learning_loop_node.py +0 -20
  37. learning_loop_node-0.18.2/learning_loop_node/tests/test_helper.py +0 -96
  38. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/__init__.py +0 -0
  39. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/conftest.py +0 -101
  40. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/pytest.ini +0 -10
  41. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/state_helper.py +0 -22
  42. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/states/__init__.py +0 -0
  43. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/states/test_state_cleanup.py +0 -27
  44. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/states/test_state_detecting.py +0 -83
  45. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/states/test_state_download_train_model.py +0 -67
  46. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/states/test_state_prepare.py +0 -55
  47. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/states/test_state_sync_confusion_matrix.py +0 -117
  48. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/states/test_state_train.py +0 -65
  49. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/states/test_state_upload_detections.py +0 -164
  50. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/states/test_state_upload_model.py +0 -88
  51. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/test_errors.py +0 -45
  52. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/test_trainer_states.py +0 -39
  53. learning_loop_node-0.18.2/learning_loop_node/tests/trainer/testing_trainer_logic.py +0 -94
  54. learning_loop_node-0.18.2/learning_loop_node/trainer/__init__.py +0 -0
  55. learning_loop_node-0.18.2/learning_loop_node/trainer/rest/__init__.py +0 -0
  56. learning_loop_node-0.18.2/pyproject.toml +0 -47
  57. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/README.md +0 -0
  58. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/__init__.py +0 -0
  59. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/annotation/__init__.py +0 -0
  60. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/annotation/annotator_logic.py +0 -0
  61. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/annotation/annotator_node.py +0 -0
  62. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/data_classes/__init__.py +0 -0
  63. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/data_classes/annotation_data.py +0 -0
  64. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/data_classes/annotations.py +0 -0
  65. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/data_classes/detections.py +0 -0
  66. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/data_classes/general.py +0 -0
  67. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/data_classes/image_metadata.py +0 -0
  68. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/data_classes/socket_response.py +0 -0
  69. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/data_classes/training.py +0 -0
  70. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/data_exchanger.py +0 -0
  71. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/__init__.py +0 -0
  72. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/detector_logic.py +0 -0
  73. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/exceptions.py +0 -0
  74. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/inbox_filter/__init__.py +0 -0
  75. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/inbox_filter/cam_observation_history.py +0 -0
  76. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/inbox_filter/relevance_filter.py +0 -0
  77. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/outbox.py +0 -0
  78. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/rest/__init__.py +0 -0
  79. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/rest/about.py +0 -0
  80. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/rest/backdoor_controls.py +0 -0
  81. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/rest/model_version_control.py +0 -0
  82. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/rest/operation_mode.py +0 -0
  83. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/rest/outbox_mode.py +0 -0
  84. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/detector/rest/upload.py +0 -0
  85. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/enums/__init__.py +0 -0
  86. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/enums/annotator.py +0 -0
  87. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/enums/detector.py +0 -0
  88. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/enums/general.py +0 -0
  89. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/enums/trainer.py +0 -0
  90. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/globals.py +0 -0
  91. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/helpers/__init__.py +0 -0
  92. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/helpers/background_tasks.py +0 -0
  93. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/helpers/environment_reader.py +0 -0
  94. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/helpers/gdrive_downloader.py +0 -0
  95. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/helpers/log_conf.py +0 -0
  96. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/helpers/misc.py +0 -0
  97. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/helpers/run.py +0 -0
  98. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/loop_communication.py +0 -0
  99. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/node.py +0 -0
  100. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/py.typed +0 -0
  101. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/rest.py +0 -0
  102. {learning_loop_node-0.18.2/learning_loop_node/tests → learning_loop_node-0.18.4/learning_loop_node/trainer}/__init__.py +0 -0
  103. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/trainer/downloader.py +0 -0
  104. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/trainer/exceptions.py +0 -0
  105. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/trainer/executor.py +0 -0
  106. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/trainer/io_helpers.py +0 -0
  107. {learning_loop_node-0.18.2/learning_loop_node/tests/annotator → learning_loop_node-0.18.4/learning_loop_node/trainer/rest}/__init__.py +0 -0
  108. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/trainer/rest/backdoor_controls.py +0 -0
  109. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/trainer/test_executor.py +0 -0
  110. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/trainer/trainer_logic.py +0 -0
  111. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/trainer/trainer_logic_generic.py +0 -0
  112. {learning_loop_node-0.18.2 → learning_loop_node-0.18.4}/learning_loop_node/trainer/trainer_node.py +0 -0
@@ -1,42 +1,38 @@
1
- Metadata-Version: 2.1
2
- Name: learning-loop-node
3
- Version: 0.18.2
1
+ Metadata-Version: 2.4
2
+ Name: learning_loop_node
3
+ Version: 0.18.4
4
4
  Summary: Python Library for Nodes which connect to the Zauberzeug Learning Loop
5
- Home-page: https://github.com/zauberzeug/learning_loop_node
5
+ Author-email: Zauberzeug GmbH <info@zauberzeug.com>
6
6
  License: MIT
7
- Author: Zauberzeug GmbH
8
- Author-email: info@zauberzeug.com
9
- Requires-Python: >=3.8,<4.0
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Programming Language :: Python :: 3.11
16
- Requires-Dist: Pillow (>=10.0.0,<11.0.0)
17
- Requires-Dist: aiofiles (>=0.7.0,<0.8.0)
18
- Requires-Dist: aiohttp (>=3.8.4,<4.0.0)
19
- Requires-Dist: async_generator (>=1.10,<2.0)
20
- Requires-Dist: dacite (>=1.8.1,<2.0.0)
21
- Requires-Dist: fastapi (>=0.93,<0.109)
22
- Requires-Dist: fastapi-socketio (>=0.0.10,<0.0.11)
23
- Requires-Dist: fastapi-utils (>=0.2.1,<0.3.0)
24
- Requires-Dist: httpx (>=0.28.1,<0.29.0)
25
- Requires-Dist: icecream (>=2.1.0,<3.0.0)
26
- Requires-Dist: numpy (>=1.13.3,<2.0.0)
27
- Requires-Dist: psutil (>=5.8.0,<6.0.0)
28
- Requires-Dist: pynvml (>=11.4.1,<12.0.0)
29
- Requires-Dist: pytest-mock (==3.6.1)
30
- Requires-Dist: pytest-watch (>=4.2.0,<5.0.0)
31
- Requires-Dist: python-multipart (>=0.0.5,<0.0.6)
32
- Requires-Dist: python-socketio (>=5.7.2,<6.0.0)
33
- Requires-Dist: requests (>=2.25.1,<3.0.0)
34
- Requires-Dist: simplejson (>=3.17.2,<4.0.0)
35
- Requires-Dist: tqdm (>=4.63.0,<5.0.0)
36
- Requires-Dist: uvicorn[standard] (>=0.22.0,<0.23.0)
37
- Requires-Dist: werkzeug (>=2.0.1,<3.0.0)
38
7
  Project-URL: Repository, https://github.com/zauberzeug/learning_loop_node
8
+ Requires-Python: >=3.9
39
9
  Description-Content-Type: text/markdown
10
+ Requires-Dist: fastapi<1.0,>=0.128
11
+ Requires-Dist: uvicorn[standard]<0.23.0,>=0.22.0
12
+ Requires-Dist: fastapi-utils<0.9.0,>=0.8.0
13
+ Requires-Dist: requests<3.0.0,>=2.25.1
14
+ Requires-Dist: python-socketio<6.0.0,>=5.7.2
15
+ Requires-Dist: simplejson<4.0.0,>=3.17.2
16
+ Requires-Dist: icecream<3.0.0,>=2.1.0
17
+ Requires-Dist: aiofiles<0.8.0,>=0.7.0
18
+ Requires-Dist: async_generator<2.0.0,>=1.10
19
+ Requires-Dist: pytest-watch<5.0.0,>=4.2.0
20
+ Requires-Dist: python-multipart<0.0.19,>=0.0.18
21
+ Requires-Dist: psutil<6.0.0,>=5.8.0
22
+ Requires-Dist: numpy<3.0,>=2.0
23
+ Requires-Dist: Pillow<12.0.0,>=11.0.0
24
+ Requires-Dist: tqdm<5.0.0,>=4.66.3
25
+ Requires-Dist: pytest-mock<4.0.0,>=3.6.1
26
+ Requires-Dist: pynvml<12.0.0,>=11.4.1
27
+ Requires-Dist: aiohttp<4.0.0,>=3.13.3
28
+ Requires-Dist: httpx<0.29.0,>=0.28.1
29
+ Requires-Dist: dacite<2.0.0,>=1.8.1
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest-flakefinder<2.0.0,>=1.1.0; extra == "dev"
32
+ Requires-Dist: retry<0.10.0,>=0.9.2; extra == "dev"
33
+ Requires-Dist: debugpy<2.0.0,>=1.6.7.post1; extra == "dev"
34
+ Requires-Dist: pytest-asyncio<0.22.0,>=0.21.1; extra == "dev"
35
+ Requires-Dist: autopep8<3.0.0,>=2.0.2; extra == "dev"
40
36
 
41
37
  # Learning Loop Node
42
38
 
@@ -280,4 +276,3 @@ After a short time the converted model should be available as well.
280
276
  - Nodes add properties to `model.json`, which contains all the information which are needed by subsequent nodes. These are typically the properties:
281
277
  - `resolution`: resolution in which the model expects images (as `int`, since the resolution is mostly square - later, ` resolution_x`` resolution_y ` would also be conceivable or `resolutions` to give a list of possible resolutions)
282
278
  - `categories`: list of categories with name, id, (later also type), in the order in which they are used by the model -- this is neccessary to be robust about renamings
283
-
@@ -6,15 +6,10 @@ import subprocess
6
6
  import sys
7
7
  from dataclasses import asdict
8
8
  from datetime import datetime
9
- from typing import Dict, List, Optional
9
+ from typing import Dict, List, Literal, Optional
10
10
 
11
11
  import numpy as np
12
12
 
13
- try:
14
- from typing import Literal
15
- except ImportError: # Python <= 3.8
16
- from typing_extensions import Literal # type: ignore
17
-
18
13
  import socketio
19
14
  from dacite import from_dict
20
15
  from fastapi.encoders import jsonable_encoder
@@ -220,7 +215,7 @@ class DetectorNode(Node):
220
215
  max_http_buffer_size=64 * 1024 * 1024, # 64 MiB
221
216
  )
222
217
  # Initialize and mount the ASGI app
223
- self.sio_app = socketio.ASGIApp(self.sio, socketio_path='/socket.io')
218
+ self.sio_app = socketio.ASGIApp(self.sio, socketio_path='/ws/socket.io')
224
219
  self.mount('/ws', self.sio_app)
225
220
  # Register event handlers
226
221
 
@@ -1,10 +1,5 @@
1
1
  import logging
2
- from typing import TYPE_CHECKING, Optional
3
-
4
- try:
5
- from typing import Literal
6
- except ImportError: # Python <= 3.8
7
- from typing_extensions import Literal # type: ignore
2
+ from typing import TYPE_CHECKING, Literal, Optional
8
3
 
9
4
  from fastapi import APIRouter, File, Header, Request, UploadFile
10
5
 
@@ -0,0 +1,278 @@
1
+ Metadata-Version: 2.4
2
+ Name: learning_loop_node
3
+ Version: 0.18.4
4
+ Summary: Python Library for Nodes which connect to the Zauberzeug Learning Loop
5
+ Author-email: Zauberzeug GmbH <info@zauberzeug.com>
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/zauberzeug/learning_loop_node
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: fastapi<1.0,>=0.128
11
+ Requires-Dist: uvicorn[standard]<0.23.0,>=0.22.0
12
+ Requires-Dist: fastapi-utils<0.9.0,>=0.8.0
13
+ Requires-Dist: requests<3.0.0,>=2.25.1
14
+ Requires-Dist: python-socketio<6.0.0,>=5.7.2
15
+ Requires-Dist: simplejson<4.0.0,>=3.17.2
16
+ Requires-Dist: icecream<3.0.0,>=2.1.0
17
+ Requires-Dist: aiofiles<0.8.0,>=0.7.0
18
+ Requires-Dist: async_generator<2.0.0,>=1.10
19
+ Requires-Dist: pytest-watch<5.0.0,>=4.2.0
20
+ Requires-Dist: python-multipart<0.0.19,>=0.0.18
21
+ Requires-Dist: psutil<6.0.0,>=5.8.0
22
+ Requires-Dist: numpy<3.0,>=2.0
23
+ Requires-Dist: Pillow<12.0.0,>=11.0.0
24
+ Requires-Dist: tqdm<5.0.0,>=4.66.3
25
+ Requires-Dist: pytest-mock<4.0.0,>=3.6.1
26
+ Requires-Dist: pynvml<12.0.0,>=11.4.1
27
+ Requires-Dist: aiohttp<4.0.0,>=3.13.3
28
+ Requires-Dist: httpx<0.29.0,>=0.28.1
29
+ Requires-Dist: dacite<2.0.0,>=1.8.1
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest-flakefinder<2.0.0,>=1.1.0; extra == "dev"
32
+ Requires-Dist: retry<0.10.0,>=0.9.2; extra == "dev"
33
+ Requires-Dist: debugpy<2.0.0,>=1.6.7.post1; extra == "dev"
34
+ Requires-Dist: pytest-asyncio<0.22.0,>=0.21.1; extra == "dev"
35
+ Requires-Dist: autopep8<3.0.0,>=2.0.2; extra == "dev"
36
+
37
+ # Learning Loop Node
38
+
39
+ This Python library helps to write Nodes that interact with the Zauberzeug Learning Loop. There are 4 types of Nodes:
40
+
41
+ | Type | Purpose |
42
+ | --------- | ---------------------------------------------------- |
43
+ | Trainer | Runs training using the latest training data |
44
+ | Detector | Loads latest models from Loop and performs inference |
45
+ | Annotator | Used for custom annotation inside the Loop |
46
+ | Converter | Converts between different model formats |
47
+
48
+ ## General Usage
49
+
50
+ To start a node you have to implement the logic by inheriting from the corresponding base logic class. We provide samples in the 'mock' folders and recommend to follow that scheme. A complete trainer and detector example can be found [here](https://github.com/zauberzeug/yolov5_node).
51
+
52
+ #### Environment variables
53
+
54
+ You can configure connection to our Learning Loop by specifying the following environment variables before starting:
55
+
56
+ | Name | Alias | Purpose | Required by |
57
+ | ------------------------ | ------------ | ------------------------------------------------------------ | ------------------------- |
58
+ | LOOP_HOST | HOST | Learning Loop address (e.g. learning-loop.ai) | all |
59
+ | LOOP_USERNAME | USERNAME | Learning Loop user name | all besides Detector |
60
+ | LOOP_PASSWORD | PASSWORD | Learning Loop password | all besides Detector |
61
+ | LOOP_SSL_CERT_PATH | - | Path to the SSL certificate | all (opt.) |
62
+ | LOOP_ORGANIZATION | ORGANIZATION | Organization ID | Detector |
63
+ | LOOP_PROJECT | PROJECT | Project ID | Detector (opt.) |
64
+ | MIN_UNCERTAIN_THRESHOLD | - | smallest confidence (float) at which auto-upload will happen | Detector (opt.) |
65
+ | MAX_UNCERTAIN_THRESHOLD | - | largest confidence (float) at which auto-upload will happen | Detector (opt.) |
66
+ | INFERENCE_BATCH_SIZE | - | Batch size of trainer when calculating detections | Trainer (opt.) |
67
+ | RESTART_AFTER_TRAINING | - | Restart the trainer after training (set to 1) | Trainer (opt.) |
68
+ | KEEP_OLD_TRAININGS | - | Do not delete old trainings (set to 1) | Trainer (opt.) |
69
+ | TRAINER_IDLE_TIMEOUT_SEC | - | Automatically shutdown trainer after timeout (in seconds) | Trainer (opt.) |
70
+ | USE_BACKDOOR_CONTROLS | - | Always enable backdoor controls (set to 1) | Trainer / Detector (opt.) |
71
+
72
+ Note that organization and project IDs are always lower case and may differ from the names in the Learning Loop which can have uppercase letters.
73
+
74
+ #### Testing
75
+
76
+ We use github actions for CI. Tests can also be executed locally by running
77
+ `LOOP_HOST=XXXXXXXX LOOP_USERNAME=XXXXXXXX LOOP_PASSWORD=XXXXXXXX python -m pytest -v`
78
+ from learning_loop_node/learning_loop_node
79
+
80
+ ## Detector Node
81
+
82
+ Detector Nodes are normally deployed on edge devices like robots or machinery but can also run in the cloud to provide backend services for an app or similar. These nodes register themself at the Learning Loop. They provide REST and Socket.io APIs to run inference on images. The processed images can automatically be used for active learning: e.g. uncertain predictions will be send to the Learning Loop.
83
+
84
+ ### Inference API
85
+
86
+ Images can be send to the detector node via socketio or rest.
87
+ Via **REST** you may provide the following parameters:
88
+
89
+ - `camera_id`: a camera identifier (string) used to improve the autoupload filtering
90
+ - `tags`: comma separated list of tags to add to the image in the learning loop to add to the image in the learning loop
91
+ - `source`: optional source identifier (str) for the image (e.g. a robot id)
92
+ - `autoupload`: configures auto-submission to the learning loop; `filtered` (default), `all`, `disabled`
93
+ - `creation_date`: optional creation date (str) for the image in isoformat (e.g. `2023-01-30T12:34:56`)
94
+
95
+ Example usage:
96
+
97
+ `curl --request POST -F 'file=@test.jpg' -H 'autoupload: all' -H 'camera_id: front_cam' localhost:8004/detect`
98
+
99
+ To use the **SocketIO** inference EPs, the caller needs to connect to the detector node's SocketIO server and emit the `detect` or `batch_detect` event with the image data and image metadata. The `detect` endpoint receives a dictionary, with the following entries:
100
+
101
+ - `image`: The image data as dictionary with the following keys:
102
+ - `bytes`: bytes of the ndarray (retrieved via `ndarray.tobytes(order='C')`)
103
+ - `dtype`: data type of the ndarray as string (e.g. `uint8`, `float32`, etc.)
104
+ - `shape`: shape of the ndarray as tuple of ints (e.g. `(480, 640, 3)`)
105
+ - `camera_id`: optional camera identifier (string) used to improve the autoupload filtering
106
+ - `tags`: optional list of tags to add to the image in the learning loop
107
+ - `source`: optional source string
108
+ - `autoupload`: configures auto-submission to the learning loop; `filtered` (default), `all`, `disabled`
109
+ - `creation_date`: optional creation date (str) for the image in isoformat (e.g. `2023-01-30T12:34:56`)
110
+
111
+ The `batch_detect` endpoint receives a dictionary, with the same entries as the `detect` endpoint, except that the `image` entry is replaced by:
112
+
113
+ - `images`: List of image data dictionaries, each with the same structure as the `image` entry in the `detect` endpoint
114
+
115
+ Example code can be found [in the rosys implementation](https://github.com/zauberzeug/rosys/blob/main/rosys/vision/detector_hardware.py).
116
+
117
+ ### Upload API
118
+
119
+ The detector has a **REST** endpoint to upload images (and detections) to the Learning Loop. The endpoint takes a POST request with one or multiple images. The images are expected to be in jpg format. The following optional parameters may be set via headers:
120
+
121
+ - `source`: optional source identifier (str) for the image (e.g. a robot id)
122
+ - `creation_date`: optional creation date (str) for the image in isoformat (e.g. `2023-01-30T12:34:56`)
123
+ - `upload_priority`: A boolean flag to prioritize the upload (defaults to False)
124
+
125
+ Example:
126
+
127
+ `curl -X POST -F 'files=@test.jpg' "http://localhost:/upload"`
128
+
129
+ The detector also has a **SocketIO** upload endpoint that can be used to upload images and detections to the learning loop. The function receives a dictionary, with the following entries:
130
+
131
+ - `image`: the image data as dictionary with the following keys:
132
+ - `bytes`: bytes of the ndarray (retrieved via `ndarray.tobytes(order='C')`)
133
+ - `dtype`: data type of the ndarray as string (e.g. `uint8`, `float32`, etc.)
134
+ - `shape`: shape of the ndarray as tuple of ints (e.g. `(480, 640, 3)`)
135
+ - `metadata`: a dictionary representing the image metadata. If metadata contains detections and/or annotations, UUIDs for the classes are automatically determined based on the category names. Metadata should follow the schema of the `ImageMetadata` data class.
136
+ - `upload_priority`: Optional boolean flag to prioritize the upload (defaults to False)
137
+
138
+ The endpoint returns None if the upload was successful and an error message otherwise.
139
+
140
+ For both ways to upload an image, the tag `picked_by_system` is automatically added to the image metadata.
141
+
142
+ ### Changing the model versioning mode
143
+
144
+ The detector can be configured to one of the following behaviors:
145
+
146
+ - use a specific model version
147
+ - automatically update the model version according to the learning loop deployment target
148
+ - pause the model updates and use the version that was last loaded
149
+
150
+ The model versioning configuration can be accessed/changed via a REST endpoint. Example Usage:
151
+
152
+ - Fetch the current model versioning configuration: `curl http://localhost/model_version`
153
+ - Configure the detector to use a specific model version: `curl -X PUT -d "1.0" http://localhost/model_version`
154
+ - Configure the detector to automatically update the model version: `curl -X PUT -d "follow_loop" http://localhost/model_version`
155
+ - Pause the model updates: `curl -X PUT -d "pause" http://localhost/model_version`
156
+
157
+ Note that the configuration is not persistent, however, the default behavior on startup can be configured via the environment variable `VERSION_CONTROL_DEFAULT`.
158
+ If the environment variable is set to `VERSION_CONTROL_DEFAULT=PAUSE`, the detector will pause the model updates on startup. Otherwise, the detector will automatically follow the loop deployment target.
159
+
160
+ The model versioning configuration can also be changed via a socketio event:
161
+
162
+ - Configure the detector to use a specific model version: `sio.emit('set_model_version_mode', '1.0')`
163
+ - Configure the detector to automatically update the model version: `sio.emit('set_model_version_mode', 'follow_loop')`
164
+ - Pause the model updates: `sio.emit('set_model_version_mode', 'pause')`
165
+
166
+ There is also a GET endpoint to fetch the current model versioning configuration:
167
+ `sio.emit('get_model_version')` or `curl http://localhost/model_version`
168
+
169
+ ### Changing the outbox mode
170
+
171
+ If the autoupload is set to `all` or `filtered` (selected) images and the corresponding detections are saved on HDD (the outbox). A background thread will upload the images and detections to the Learning Loop. The outbox is located in the `outbox` folder in the root directory of the node. The outbox can be cleared by deleting the files in the folder.
172
+
173
+ The continuous upload can be stopped/started via a REST enpoint:
174
+
175
+ Example Usage:
176
+
177
+ - Enable upload: `curl -X PUT -d "continuous_upload" http://localhost/outbox_mode`
178
+ - Disable upload: `curl -X PUT -d "stopped" http://localhost/outbox_mode`
179
+
180
+ The current state can be queried via a GET request:
181
+ `curl http://localhost/outbox_mode`
182
+
183
+ Alternatively, the outbox mode can be changed via a socketio event:
184
+
185
+ - Enable upload: `sio.emit('set_outbox_mode', 'continuous_upload')`
186
+ - Disable upload: `sio.emit('set_outbox_mode', 'stopped')`
187
+
188
+ The outbox mode can also be queried via:
189
+
190
+ - HTTP: `curl http://localhost/outbox_mode`
191
+ - SocketIO: `sio.emit('get_outbox_mode')`
192
+
193
+ ## Trainer Node
194
+
195
+ Trainers fetch the images and anntoations from the Learning Loop to train new models.
196
+
197
+ - if the command line tool "jpeginfo" is installed, the downloader will drop corrupted images automatically
198
+
199
+ ## Converter Node
200
+
201
+ A Conveter Node converts models from one format into another.
202
+
203
+ ## Annotator Node
204
+
205
+ ...
206
+
207
+ ### Test operability
208
+
209
+ Assumend there is a Converter Node which converts models of format 'format_a' into 'format_b'.
210
+ Upload a model with
211
+ `curl --request POST -F 'files=@my_model.zip' https://learning-loop.ai/api/zauberzeug/projects/demo/format_a`
212
+ The model should now be available for the format 'format_a'
213
+ `curl "https://learning-loop.ai/api/zauberzeug/projects/demo/models?format=format_a"`
214
+
215
+ ```json
216
+ {
217
+ "models": [
218
+ {
219
+ "id": "3c20d807-f71c-40dc-a996-8a8968aa5431",
220
+ "version": "4.0",
221
+ "formats": [
222
+ "format_a"
223
+ ],
224
+ "created": "2021-06-01T06:28:21.289092",
225
+ "comment": "uploaded at 2021-06-01 06:28:21.288442",
226
+ ...
227
+ }
228
+ ]
229
+ }
230
+ ```
231
+
232
+ but not in the format_b
233
+ `curl "https://learning-loop.ai/api/zauberzeug/projects/demo/models?format=format_b"`
234
+
235
+ ```json
236
+ {
237
+ "models": []
238
+ }
239
+ ```
240
+
241
+ Connect the Node to the Learning Loop by simply starting the container.
242
+ After a short time the converted model should be available as well.
243
+ `curl https://learning-loop.ai/api/zauberzeug/projects/demo/models?format=format_b`
244
+
245
+ ```json
246
+ {
247
+ "models": [
248
+ {
249
+ "id": "3c20d807-f71c-40dc-a996-8a8968aa5431",
250
+ "version": "4.0",
251
+ "formats": [
252
+ "format_a",
253
+ "format_b",
254
+ ],
255
+ "created": "2021-06-01T06:28:21.289092",
256
+ "comment": "uploaded at 2021-06-01 06:28:21.288442",
257
+ ...
258
+ }
259
+ ]
260
+ }
261
+ ```
262
+
263
+ ## About Models (the currency between Nodes)
264
+
265
+ - Models are packed in zips and saved on the Learning Loop (one for each format)
266
+ - Nodes and users can upload and download models with which they want to work
267
+ - In each zip there is a file called `model.json` which contains the metadata to interpret the other files in the package
268
+ - for base models (pretrained models from external sources) no `model.json` has to be sent, ie. these models should simply be zipped in such a way that the respective trainer can work with them.
269
+ - the loop adds or corrects the following properties in the `model.json` after receiving; it also creates the file if it is missing:
270
+ - `host`: uri to the loop
271
+ - `organization`: the ID of the organization
272
+ - `project`: the id of the project
273
+ - `version`: the version number that the loop assigned for this model (e.g. 1.3)
274
+ - `id`: the model UUID (currently not needed by anyone, since host, org, project, version clearly identify the model)
275
+ - `format`: the format e.g. yolo, tkdnn, yolor etc.
276
+ - Nodes add properties to `model.json`, which contains all the information which are needed by subsequent nodes. These are typically the properties:
277
+ - `resolution`: resolution in which the model expects images (as `int`, since the resolution is mostly square - later, ` resolution_x`` resolution_y ` would also be conceivable or `resolutions` to give a list of possible resolutions)
278
+ - `categories`: list of categories with name, id, (later also type), in the order in which they are used by the model -- this is neccessary to be robust about renamings
@@ -0,0 +1,64 @@
1
+ README.md
2
+ pyproject.toml
3
+ learning_loop_node/__init__.py
4
+ learning_loop_node/data_exchanger.py
5
+ learning_loop_node/globals.py
6
+ learning_loop_node/loop_communication.py
7
+ learning_loop_node/node.py
8
+ learning_loop_node/py.typed
9
+ learning_loop_node/rest.py
10
+ learning_loop_node.egg-info/PKG-INFO
11
+ learning_loop_node.egg-info/SOURCES.txt
12
+ learning_loop_node.egg-info/dependency_links.txt
13
+ learning_loop_node.egg-info/requires.txt
14
+ learning_loop_node.egg-info/top_level.txt
15
+ learning_loop_node/annotation/__init__.py
16
+ learning_loop_node/annotation/annotator_logic.py
17
+ learning_loop_node/annotation/annotator_node.py
18
+ learning_loop_node/data_classes/__init__.py
19
+ learning_loop_node/data_classes/annotation_data.py
20
+ learning_loop_node/data_classes/annotations.py
21
+ learning_loop_node/data_classes/detections.py
22
+ learning_loop_node/data_classes/general.py
23
+ learning_loop_node/data_classes/image_metadata.py
24
+ learning_loop_node/data_classes/socket_response.py
25
+ learning_loop_node/data_classes/training.py
26
+ learning_loop_node/detector/__init__.py
27
+ learning_loop_node/detector/detector_logic.py
28
+ learning_loop_node/detector/detector_node.py
29
+ learning_loop_node/detector/exceptions.py
30
+ learning_loop_node/detector/outbox.py
31
+ learning_loop_node/detector/inbox_filter/__init__.py
32
+ learning_loop_node/detector/inbox_filter/cam_observation_history.py
33
+ learning_loop_node/detector/inbox_filter/relevance_filter.py
34
+ learning_loop_node/detector/rest/__init__.py
35
+ learning_loop_node/detector/rest/about.py
36
+ learning_loop_node/detector/rest/backdoor_controls.py
37
+ learning_loop_node/detector/rest/detect.py
38
+ learning_loop_node/detector/rest/model_version_control.py
39
+ learning_loop_node/detector/rest/operation_mode.py
40
+ learning_loop_node/detector/rest/outbox_mode.py
41
+ learning_loop_node/detector/rest/upload.py
42
+ learning_loop_node/enums/__init__.py
43
+ learning_loop_node/enums/annotator.py
44
+ learning_loop_node/enums/detector.py
45
+ learning_loop_node/enums/general.py
46
+ learning_loop_node/enums/trainer.py
47
+ learning_loop_node/helpers/__init__.py
48
+ learning_loop_node/helpers/background_tasks.py
49
+ learning_loop_node/helpers/environment_reader.py
50
+ learning_loop_node/helpers/gdrive_downloader.py
51
+ learning_loop_node/helpers/log_conf.py
52
+ learning_loop_node/helpers/misc.py
53
+ learning_loop_node/helpers/run.py
54
+ learning_loop_node/trainer/__init__.py
55
+ learning_loop_node/trainer/downloader.py
56
+ learning_loop_node/trainer/exceptions.py
57
+ learning_loop_node/trainer/executor.py
58
+ learning_loop_node/trainer/io_helpers.py
59
+ learning_loop_node/trainer/test_executor.py
60
+ learning_loop_node/trainer/trainer_logic.py
61
+ learning_loop_node/trainer/trainer_logic_generic.py
62
+ learning_loop_node/trainer/trainer_node.py
63
+ learning_loop_node/trainer/rest/__init__.py
64
+ learning_loop_node/trainer/rest/backdoor_controls.py
@@ -0,0 +1,27 @@
1
+ fastapi<1.0,>=0.128
2
+ uvicorn[standard]<0.23.0,>=0.22.0
3
+ fastapi-utils<0.9.0,>=0.8.0
4
+ requests<3.0.0,>=2.25.1
5
+ python-socketio<6.0.0,>=5.7.2
6
+ simplejson<4.0.0,>=3.17.2
7
+ icecream<3.0.0,>=2.1.0
8
+ aiofiles<0.8.0,>=0.7.0
9
+ async_generator<2.0.0,>=1.10
10
+ pytest-watch<5.0.0,>=4.2.0
11
+ python-multipart<0.0.19,>=0.0.18
12
+ psutil<6.0.0,>=5.8.0
13
+ numpy<3.0,>=2.0
14
+ Pillow<12.0.0,>=11.0.0
15
+ tqdm<5.0.0,>=4.66.3
16
+ pytest-mock<4.0.0,>=3.6.1
17
+ pynvml<12.0.0,>=11.4.1
18
+ aiohttp<4.0.0,>=3.13.3
19
+ httpx<0.29.0,>=0.28.1
20
+ dacite<2.0.0,>=1.8.1
21
+
22
+ [dev]
23
+ pytest-flakefinder<2.0.0,>=1.1.0
24
+ retry<0.10.0,>=0.9.2
25
+ debugpy<2.0.0,>=1.6.7.post1
26
+ pytest-asyncio<0.22.0,>=0.21.1
27
+ autopep8<3.0.0,>=2.0.2
@@ -0,0 +1 @@
1
+ learning_loop_node
@@ -0,0 +1,50 @@
1
+ [project]
2
+ name = "learning_loop_node"
3
+ version = "0.18.4"
4
+ description = "Python Library for Nodes which connect to the Zauberzeug Learning Loop"
5
+ authors = [{ name = "Zauberzeug GmbH", email = "info@zauberzeug.com" }]
6
+ license = { text = "MIT" }
7
+ readme = "README.md"
8
+ requires-python = ">=3.9"
9
+ dependencies = [
10
+ "fastapi>=0.128,<1.0",
11
+ "uvicorn[standard]>=0.22.0,<0.23.0",
12
+ "fastapi-utils>=0.8.0,<0.9.0",
13
+ "requests>=2.25.1,<3.0.0",
14
+ "python-socketio>=5.7.2,<6.0.0",
15
+ "simplejson>=3.17.2,<4.0.0",
16
+ "icecream>=2.1.0,<3.0.0",
17
+ "aiofiles>=0.7.0,<0.8.0",
18
+ "async_generator>=1.10,<2.0.0",
19
+ "pytest-watch>=4.2.0,<5.0.0",
20
+ "python-multipart>=0.0.18,<0.0.19",
21
+ "psutil>=5.8.0,<6.0.0",
22
+ "numpy>=2.0,<3.0",
23
+ "Pillow>=11.0.0,<12.0.0",
24
+ "tqdm>=4.66.3,<5.0.0",
25
+ "pytest-mock>=3.6.1,<4.0.0",
26
+ "pynvml>=11.4.1,<12.0.0",
27
+ "aiohttp>=3.13.3,<4.0.0",
28
+ "httpx>=0.28.1,<0.29.0",
29
+ "dacite>=1.8.1,<2.0.0",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ dev = [
34
+ "pytest-flakefinder>=1.1.0,<2.0.0",
35
+ "retry>=0.9.2,<0.10.0",
36
+ "debugpy>=1.6.7.post1,<2.0.0",
37
+ "pytest-asyncio>=0.21.1,<0.22.0",
38
+ "autopep8>=2.0.2,<3.0.0",
39
+ ]
40
+
41
+ [project.urls]
42
+ Repository = "https://github.com/zauberzeug/learning_loop_node"
43
+
44
+ [tool.setuptools.packages.find]
45
+ where = ["."]
46
+ include = ["learning_loop_node", "learning_loop_node.*"]
47
+ exclude = ["learning_loop_node.tests*", "learning_loop_node.examples*"]
48
+
49
+ [tool.mypy]
50
+ ignore_missing_imports = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -1,70 +0,0 @@
1
- import asyncio
2
- import logging
3
- import os
4
- from typing import Dict
5
-
6
- from tqdm import tqdm
7
-
8
- from learning_loop_node.loop_communication import LoopCommunicator
9
-
10
- os.environ['LOOP_HOST'] = 'preview.learning-loop.ai'
11
- os.environ['LOOP_ORGANIZATION'] = 'zauberzeug'
12
- os.environ['LOOP_PROJECT'] = 'demo'
13
-
14
- logging.info('Starting novelty_score_updater')
15
- glc = LoopCommunicator()
16
-
17
- project_path = f'/{glc.organization}/projects/{glc.project}'
18
-
19
-
20
- async def get_json_async(path) -> Dict:
21
- url = f'{project_path}{path}'
22
- response = await glc.get(url)
23
- if response.status_code != 200:
24
- raise Exception('bad response: ' + str(response))
25
- return response.json()
26
-
27
-
28
- def get_json(path):
29
- return asyncio.get_event_loop().run_until_complete(get_json_async(path))
30
-
31
-
32
- async def put_json_async(path, json) -> Dict:
33
- response = await glc.async_client.put(path, json=json)
34
- if response.status_code != 200:
35
- raise Exception(f'bad response: {str(response)} \n {response.json()}')
36
- return response.json()
37
-
38
-
39
- def put_json(path, json):
40
- return asyncio.get_event_loop().run_until_complete(put_json_async(path, json))
41
-
42
-
43
- data = get_json(f'{project_path}/data')
44
- categories = data['categories']
45
- image_ids = data['image_ids'][0:1] # use only one image for testing
46
- chunk_size = 50
47
-
48
- images_data = []
49
- for i in tqdm(range(0, len(image_ids), chunk_size), position=0, leave=True):
50
- chunk_ids = image_ids[i:i+chunk_size]
51
- chunk_data = get_json(f'{project_path}/images?ids={",".join(chunk_ids)}&model_version=1.1')
52
- images_data += chunk_data['images']
53
-
54
- novelty_scores = {}
55
- for image_data in images_data:
56
- image_id = image_data['id']
57
- detections = image_data['box_detections']
58
- novelty_score = 0
59
- for d in detections:
60
- if d['confidence'] > 20 and d['confidence'] < 80:
61
- novelty_score += 1
62
- novelty_scores[image_id] = novelty_score
63
-
64
-
65
- put_json('/images/novelty_scores', json=novelty_scores)
66
-
67
- loop = asyncio.get_event_loop()
68
- loop.run_until_complete(glc.shutdown())
69
-
70
- logging.info('novelty_score_updater stopped')