Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f77a1d5
Added logger to detect target script
wdan31 Oct 31, 2024
fd080c4
Added logger to more detect target files
wdan31 Oct 31, 2024
fb29611
Reverted changed to abstract class
wdan31 Oct 31, 2024
f625bc9
Added logger to detect target worker
wdan31 Oct 31, 2024
2c725a3
Added logger to detect target
wdan31 Nov 3, 2024
f1752ff
Rounded time taken logs to 3 decimal places
wdan31 Nov 3, 2024
2573c60
Added logger to factory and worker
wdan31 Nov 3, 2024
cf66adb
Linted python
wdan31 Nov 3, 2024
1e65647
Changed time formatting in logs
wdan31 Nov 3, 2024
213f814
updated common
wdan31 Nov 3, 2024
051427f
Merge branch 'main' into detect-target-worker
wdan31 Nov 3, 2024
7e975a8
Formatted python
wdan31 Nov 3, 2024
6d8ff62
Added logger to detect target script
wdan31 Oct 31, 2024
2770962
Added logger to more detect target files
wdan31 Oct 31, 2024
c18c393
Reverted changed to abstract class
wdan31 Oct 31, 2024
e98a8e8
Added logger to detect target worker
wdan31 Oct 31, 2024
ea17935
Rounded time taken logs to 3 decimal places
wdan31 Nov 3, 2024
453ddc2
Added logger to factory and worker
wdan31 Nov 3, 2024
715d0fa
Linted python
wdan31 Nov 3, 2024
1ef8fb6
Changed time formatting in logs
wdan31 Nov 3, 2024
40b6d4e
updated common
wdan31 Nov 3, 2024
700be6f
Added logger to detect target
wdan31 Nov 3, 2024
f1b0cc2
Formatted python
wdan31 Nov 3, 2024
f364ea2
Fixed logger implementation
wdan31 Nov 7, 2024
1c1b6ee
Fixed model attributes
wdan31 Nov 7, 2024
48a6568
Fixed logger attribute
wdan31 Nov 7, 2024
582c88c
Merge branch 'detect-target-worker' of https://github.com/UWARG/compu…
wdan31 Nov 7, 2024
e560438
Fixed logger implementation (again)
wdan31 Nov 7, 2024
0ed8f29
Formatted python
wdan31 Nov 7, 2024
412b89d
common
wdan31 Nov 14, 2024
8037cd4
common
wdan31 Nov 14, 2024
a3b89bf
Merge branch 'main' of https://github.com/UWARG/computer-vision-pytho…
wdan31 Nov 14, 2024
7c51eb9
updated common
wdan31 Nov 14, 2024
8261e09
Added detect target logger to main_2024
wdan31 Nov 15, 2024
94005d0
Removed detect target logger from the worker properties, logger alrea…
wdan31 Nov 15, 2024
3da1017
Updated detect target logs
wdan31 Nov 15, 2024
9cf15d2
Formatted python
wdan31 Nov 15, 2024
0893c78
Removed text file logging
wdan31 Nov 15, 2024
e7d6974
Added string repr for detectionInWorld
wdan31 Nov 15, 2024
5ee53de
Added repr for Detections class
wdan31 Nov 15, 2024
60f51e7
Formatted python
wdan31 Nov 15, 2024
0ddd7e1
Changed python formatting and test logger implementation
wdan31 Nov 15, 2024
8912617
formatted python
wdan31 Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/detect_target/detect_target_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from . import base_detect_target
from . import detect_target_ultralytics
from ..common.logger.modules import logger


class DetectTargetOption(enum.Enum):
Expand All @@ -23,6 +24,7 @@ def create_detect_target(
override_full: bool,
show_annotations: bool,
save_name: str,
local_logger: logger.Logger,
) -> tuple[bool, base_detect_target.BaseDetectTarget | None]:
"""
Construct detect target class at runtime.
Expand All @@ -33,6 +35,7 @@ def create_detect_target(
device,
model_path,
override_full,
local_logger,
show_annotations,
save_name,
)
Expand Down
9 changes: 9 additions & 0 deletions modules/detect_target/detect_target_ultralytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from . import base_detect_target
from .. import image_and_time
from .. import detections_and_time
from ..common.logger.modules import logger


class DetectTargetUltralytics(base_detect_target.BaseDetectTarget):
Expand All @@ -22,6 +23,7 @@ def __init__(
device: "str | int",
model_path: str,
override_full: bool,
local_logger: logger.Logger,
show_annotations: bool = False,
save_name: str = "",
) -> None:
Expand All @@ -37,6 +39,8 @@ def __init__(
self.__counter = 0
self.__enable_half_precision = not self.__device == "cpu"
self.__show_annotations = show_annotations
self.__logger = local_logger

if override_full:
self.__enable_half_precision = False
self.__filename_prefix = ""
Expand All @@ -54,6 +58,7 @@ def run(
Return: Success and the detections.
"""
image = data.image
start_time = time.time()
predictions = self.__model.predict(
source=image,
half=self.__enable_half_precision,
Expand Down Expand Up @@ -108,4 +113,8 @@ def run(
if self.__show_annotations:
cv2.imshow("Annotated", image_annotated) # type: ignore

end_time = time.time()
self.__logger.info(
f"{time.localtime()}: Target detection took {round(end_time - start_time, 3)} seconds"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For time, it's fine to just use time.time() (logger automatically puts a timestamp with a proper format like hh:mm:ss), and there's no need to round it since we would rather have more precision. (these tasks usually take much less than 1 second, so more precision is required)

)
return True, detections
1 change: 1 addition & 0 deletions modules/detect_target/detect_target_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def detect_target_worker(
override_full,
show_annotations,
save_name,
local_logger,
)

if not result:
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/test_detect_target_ultralytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from modules.detect_target import detect_target_ultralytics
from modules import image_and_time
from modules import detections_and_time
from modules.common.logger.modules import logger


TEST_PATH = pathlib.Path("tests", "model_example")
Expand Down Expand Up @@ -108,8 +109,13 @@ def detector() -> detect_target_ultralytics.DetectTargetUltralytics: # type: ig
"""
Construct DetectTargetUltralytics.
"""

_, test_logger = logger.Logger.create("test_logger", False)

assert test_logger is not None

detection = detect_target_ultralytics.DetectTargetUltralytics(
DEVICE, str(MODEL_PATH), OVERRIDE_FULL
DEVICE, str(MODEL_PATH), OVERRIDE_FULL, test_logger
)
yield detection # type: ignore

Expand Down