Skip to content

Commit 780030e

Browse files
authored
Merge pull request #84 from C4dynamics/dev
1. replaced the yolo cfg with importtools. 2. generated a toml file.
2 parents 95de6de + ec29212 commit 780030e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+94
-1044
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
21-
python-version: ["3.9", "3.10", "3.11", "3.12"] # update also in setup.py install_requires and readme.md requirements
21+
python-version: ["3.9", "3.10", "3.11", "3.12"] # update also in setup.py, pyprogect.yaml, readme.md
2222

2323
steps:
2424
- name: Checkout repository

c4dynamics/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
#
8484
# version
8585
##
86-
__version__ = '2.1.0'
86+
__version__ = '2.1.0' # update also in pyproject.toml
8787

8888

8989
#

c4dynamics/detectors/__init__.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,6 @@
1919

2020
if __name__ == "__main__":
2121

22-
# import doctest, contextlib
23-
# from c4dynamics import IgnoreOutputChecker, cprint
24-
25-
# # Register the custom OutputChecker
26-
# doctest.OutputChecker = IgnoreOutputChecker
27-
28-
# tofile = False
29-
# optionflags = doctest.FAIL_FAST
30-
31-
# if tofile:
32-
# with open(os.path.join('tests', '_out', 'output.txt'), 'w') as f:
33-
# with contextlib.redirect_stdout(f), contextlib.redirect_stderr(f):
34-
# result = doctest.testmod(optionflags = optionflags)
35-
# else:
36-
# result = doctest.testmod(optionflags = optionflags)
37-
38-
# if result.failed == 0:
39-
# cprint(os.path.basename(__file__) + ": all tests passed!", 'g')
40-
# else:
41-
# print(f"{result.failed}")
4222
from c4dynamics import rundoctests
4323
rundoctests(sys.modules[__name__])
4424

c4dynamics/detectors/yolo3_opencv.py

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from c4dynamics import c4d
77
from c4dynamics import pixelpoint
88
from typing import Optional
9+
import importlib.resources as resources
910

1011
MODEL_SIZE = (416, 416, 3)
1112

@@ -217,18 +218,13 @@ def __init__(self, weights_path: Optional[str] = None) -> None:
217218
weights_path = c4d.datasets.nn_model('YOLOv3')
218219
errormsg = "Try to clear the cache by 'c4dynamics.datasets.clear_cache()'"
219220

220-
221-
222221
if not os.path.exists(weights_path):
223222
raise FileNotFoundError(f"The file 'yolov3.weights' does not "
224223
f"exist in: '{weights_path}'. {errormsg}")
225224

226-
227-
cfg_path = os.path.join(os.path.dirname(__file__), 'yolov3.cfg')
228-
# cfg_path = 'yolov3.cfg'
229-
# coconames = os.path.join(yolodir, 'coco.names')
230-
231-
self.net = cv2.dnn.readNetFromDarknet(cfg_path, weights_path)
225+
with resources.path('c4dynamics.detectors', 'yolov3.cfg') as cfgpath:
226+
self.net = cv2.dnn.readNetFromDarknet(str(cfgpath), weights_path)
227+
232228
self.net.setPreferableBackend(cv2.dnn.DNN_BACKEND_OPENCV)
233229
ln = self.net.getLayerNames()
234230
self.ln = [ln[i - 1] for i in self.net.getUnconnectedOutLayers()]
@@ -661,26 +657,6 @@ def detect(self, frame: np.ndarray) -> list[pixelpoint]:
661657

662658
if __name__ == "__main__":
663659

664-
# import doctest, contextlib
665-
# from c4dynamics import IgnoreOutputChecker, cprint
666-
667-
# # Register the custom OutputChecker
668-
# doctest.OutputChecker = IgnoreOutputChecker
669-
670-
# tofile = False
671-
# optionflags = doctest.FAIL_FAST
672-
673-
# if tofile:
674-
# with open(os.path.join('tests', '_out', 'output.txt'), 'w') as f:
675-
# with contextlib.redirect_stdout(f), contextlib.redirect_stderr(f):
676-
# result = doctest.testmod(optionflags = optionflags)
677-
# else:
678-
# result = doctest.testmod(optionflags = optionflags)
679-
680-
# if result.failed == 0:
681-
# cprint(os.path.basename(__file__) + ": all tests passed!", 'g')
682-
# else:
683-
# print(f"{result.failed}")
684660
from c4dynamics import rundoctests
685661
rundoctests(sys.modules[__name__])
686662

c4dynamics/detectors/yolo3_tf.py

Lines changed: 0 additions & 124 deletions
This file was deleted.

c4dynamics/envs/__init__.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,6 @@
77

88
if __name__ == "__main__":
99

10-
# import doctest, contextlib, os
11-
# from c4dynamics import IgnoreOutputChecker, cprint
12-
13-
# # Register the custom OutputChecker
14-
# doctest.OutputChecker = IgnoreOutputChecker
15-
16-
# tofile = False
17-
# optionflags = doctest.FAIL_FAST
18-
19-
# if tofile:
20-
# with open(os.path.join('tests', '_out', 'output.txt'), 'w') as f:
21-
# with contextlib.redirect_stdout(f), contextlib.redirect_stderr(f):
22-
# result = doctest.testmod(optionflags = optionflags)
23-
# else:
24-
# result = doctest.testmod(optionflags = optionflags)
25-
26-
# if result.failed == 0:
27-
# cprint(os.path.basename(__file__) + ": all tests passed!", 'g')
28-
# else:
29-
# print(f"{result.failed}")
3010
from c4dynamics import rundoctests
3111
rundoctests(sys.modules[__name__])
3212

c4dynamics/eqm/derivs.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -188,30 +188,6 @@ def eqm6(rb: 'rigidbody', F: Union[np.ndarray, list], M: Union[np.ndarray, list]
188188

189189
if __name__ == "__main__":
190190

191-
192-
# import matplotlib
193-
# matplotlib.use("TkAgg") # keep interactive
194-
# import matplotlib.pyplot as plt
195-
196-
# import doctest, contextlib, os
197-
# from c4dynamics import IgnoreOutputChecker, cprint
198-
# # Register the custom OutputChecker
199-
# doctest.OutputChecker = IgnoreOutputChecker
200-
201-
# tofile = False
202-
# optionflags = doctest.FAIL_FAST
203-
204-
# if tofile:
205-
# with open(os.path.join('tests', '_out', 'output.txt'), 'w') as f:
206-
# with contextlib.redirect_stdout(f), contextlib.redirect_stderr(f):
207-
# result = doctest.testmod(optionflags = optionflags)
208-
# else:
209-
# result = doctest.testmod(optionflags = optionflags)
210-
211-
# if result.failed == 0:
212-
# cprint(os.path.basename(__file__) + ": all tests passed!", 'g')
213-
# else:
214-
# print(f"{result.failed}")
215191
from c4dynamics import rundoctests
216192
rundoctests(sys.modules[__name__])
217193

c4dynamics/eqm/integrate.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -335,26 +335,6 @@ def int6(rb: 'rigidbody', forces: Union[np.ndarray, list], moments: Union[np.nda
335335

336336
if __name__ == "__main__":
337337

338-
# import doctest, contextlib, os
339-
# from c4dynamics import IgnoreOutputChecker, cprint
340-
341-
# # Register the custom OutputChecker
342-
# doctest.OutputChecker = IgnoreOutputChecker
343-
344-
# tofile = False
345-
# optionflags = doctest.FAIL_FAST
346-
347-
# if tofile:
348-
# with open(os.path.join('tests', '_out', 'output.txt'), 'w') as f:
349-
# with contextlib.redirect_stdout(f), contextlib.redirect_stderr(f):
350-
# result = doctest.testmod(optionflags = optionflags)
351-
# else:
352-
# result = doctest.testmod(optionflags = optionflags)
353-
354-
# if result.failed == 0:
355-
# cprint(os.path.basename(__file__) + ": all tests passed!", 'g')
356-
# else:
357-
# print(f"{result.failed}")
358338
from c4dynamics import rundoctests
359339
rundoctests(sys.modules[__name__])
360340

c4dynamics/filters/__init__.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,5 @@
114114

115115
if __name__ == "__main__":
116116

117-
# import doctest, contextlib
118-
# from c4dynamics import IgnoreOutputChecker, cprint
119-
120-
# # Register the custom OutputChecker
121-
# doctest.OutputChecker = IgnoreOutputChecker
122-
123-
# tofile = False
124-
# optionflags = doctest.FAIL_FAST
125-
126-
# if tofile:
127-
# with open(os.path.join('tests', '_out', 'output.txt'), 'w') as f:
128-
# with contextlib.redirect_stdout(f), contextlib.redirect_stderr(f):
129-
# result = doctest.testmod(optionflags = optionflags)
130-
# else:
131-
# result = doctest.testmod(optionflags = optionflags)
132-
133-
# if result.failed == 0:
134-
# cprint(os.path.basename(__file__) + ": all tests passed!", 'g')
135-
# else:
136-
# print(f"{result.failed}")
137-
138-
139117
from c4dynamics import rundoctests
140118
rundoctests(sys.modules[__name__])

c4dynamics/filters/ekf.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -293,26 +293,6 @@ def update(self, z: np.ndarray # type: ignore
293293

294294
if __name__ == "__main__":
295295

296-
# import doctest, contextlib, os
297-
# from c4dynamics import IgnoreOutputChecker, cprint
298-
299-
# # Register the custom OutputChecker
300-
# doctest.OutputChecker = IgnoreOutputChecker
301-
302-
# tofile = False
303-
# optionflags = doctest.FAIL_FAST
304-
305-
# if tofile:
306-
# with open(os.path.join('tests', '_out', 'output.txt'), 'w') as f:
307-
# with contextlib.redirect_stdout(f), contextlib.redirect_stderr(f):
308-
# result = doctest.testmod(optionflags = optionflags)
309-
# else:
310-
# result = doctest.testmod(optionflags = optionflags)
311-
312-
# if result.failed == 0:
313-
# cprint(os.path.basename(__file__) + ": all tests passed!", 'g')
314-
# else:
315-
# print(f"{result.failed}")
316296
from c4dynamics import rundoctests
317297
rundoctests(sys.modules[__name__])
318298

0 commit comments

Comments
 (0)