-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
showing annotated images for detect target message bug fix #230
Open
arpanroy18
wants to merge
6
commits into
main
Choose a base branch
from
detect-target-annoation-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1ad8ba8
showing annotated images for detect target message bug fix
arpanroy18 7315197
formatting attempt fix
arpanroy18 c5fc431
reviewed changes
arpanroy18 100919c
formatting fix
arpanroy18 915d367
formatting fixes again
arpanroy18 4dc6f99
removed ds_store files
arpanroy18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,10 @@ def create_detect_target( | |
save_name: str, | ||
) -> tuple[bool, base_detect_target.BaseDetectTarget | None]: | ||
""" | ||
Construct detect target class at runtime. | ||
Factory function to create a detection target object. | ||
|
||
Returns: | ||
Success, detect target object. | ||
""" | ||
match detect_target_option: | ||
case DetectTargetOption.ML_ULTRALYTICS: | ||
|
@@ -39,5 +42,4 @@ def create_detect_target( | |
show_annotations, | ||
save_name, | ||
) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restore empty line. |
||
return False, None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import time | ||
|
||
import cv2 | ||
arpanroy18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import torch | ||
arpanroy18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import ultralytics | ||
|
||
from . import base_detect_target | ||
|
@@ -37,14 +38,17 @@ def __init__( | |
self.__device = device | ||
self.__model = ultralytics.YOLO(model_path) | ||
self.__counter = 0 | ||
self.__enable_half_precision = not self.__device == "cpu" | ||
self.__enable_half_precision = self.__device != "cpu" | ||
self.__local_logger = local_logger | ||
self.__show_annotations = show_annotations | ||
if override_full: | ||
self.__enable_half_precision = False | ||
self.__filename_prefix = "" | ||
if save_name != "": | ||
self.__filename_prefix = save_name + "_" + str(int(time.time())) + "_" | ||
if self.__device != "cpu" and not torch.cuda.is_available(): | ||
self.__local_logger.warning("CUDA not available. Falling back to CPU.") | ||
self.__device = "cpu" | ||
Comment on lines
+49
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add empty line above this line. |
||
|
||
def run( | ||
self, data: image_and_time.ImageAndTime | ||
|
@@ -111,6 +115,11 @@ def run( | |
self.__counter += 1 | ||
|
||
if self.__show_annotations: | ||
cv2.imshow("Annotated", image_annotated) # type: ignore | ||
if image_annotated is not None: | ||
# Display the annotated image in a named window | ||
cv2.imshow("Annotated", image_annotated) | ||
cv2.waitKey(1) # Short delay to process GUI events | ||
else: | ||
self.__local_logger.warning("Annotated image is invalid.") | ||
|
||
return True, detections |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return: Success, detect target object.