-
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
Detect target precision profile #167
base: main
Are you sure you want to change the base?
Conversation
storage and parameters
…UWARG/computer-vision-python into detect_target_precision_profile
* Data merge worker added in - logging not in main loop yet * Going back to original temporarily * Changes add to updated main branch * Updated queue names * Structure should be complete. Just need to adjust main loop * Main loop adjusted and print statments correctly grab object data * All PR comments accounted for
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.
Added some comments.
elapsed_time = stop_time - start_time | ||
|
||
for pred in predictions: | ||
with open('profiler.txt', 'a') as file: | ||
speeds = pred.speed |
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.
We don't want to add logic within the detect_target.py
class for profiling. Rather we could time the worker outside of the call to detect target.
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.
The worker isn't the thing to test, something like this:
# profiling_or_whatever_file_name.py
def profile_detector(detector: detect_target.DetectTarget, images: "list[np.ndarray]") -> ...:
for image in images:
gc.disable() # This disables the garbage collector
start = time.time_ns()
result, value = detector.run(image) # Might or might not want to keep the bounding boxes
end = time.time_ns()
gc.enable() # This enables the garbage collector
if not result:
# Handle error
# Save results somewhere
time_ns = end - start
...
def main() -> int:
images = load_many_images()
detector_half = detect_target.DetectTarget(...)
detector_full = detect_target.DetectTarget(...)
# Initial run just to warm up CUDA
_ = profile_detector(detector_full, images[:10])
time_half = profile_detector(detector_half, images)
time_full = profile_detector(detector_full, images)
# Record the results
...
self.__enable_half_precision = False if self.__device == "cpu" else False | ||
#modified so override_full controls if its half or full - FOR PROFILING ONLY |
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.
Instead of modifying the logic here, when profiling why not just specify the device type and the current logic will handle if half or full precision should be used?
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.
As another PR, it might be worth updating this interface to a create()
method that takes a settings object as argument. The settings class could have a is_setting_valid()
method, which can push the responsibility of ensuring a valid setting to the caller. This also increases transparency because there won't be any fallthrough logic (the setting is applied as is).
profiler_detect_target_2024.py
Outdated
def main() -> int: | ||
""" | ||
copied from airside code main function | ||
""" | ||
# Open config file |
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.
Do you think you could explain what the difference between this file is and profile_detect_target.py
? Just trying to understand what the difference is.
It would also be better to use a dataset that are not all identical images. Perhaps the same as used in repository profile-encode. |
Created profiler_detect_target_2024.py and modified detect_target.py to add timing functionality.
profiler_detect_target_2024.py
detect_target.py
config.yaml