-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: adding integration test #23
Merged
Merged
Changes from 39 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
add347d
first try of test to refacto
nmathieufact cc2e60e
tried approach comparing df
nmathieufact da5cd48
revert change on notebook example
nmathieufact e3f660a
clean the python pytest script
nmathieufact ebb3e0e
generating all files and output for second video test
nmathieufact c876fee
added a new test and cleaned a bit
nmathieufact 2c28500
added a new test and cleaned a bit
nmathieufact d453cc2
fix the name of notebook
nmathieufact bea827d
feat added output and input files
nmathieufact 8b7092d
fix: path in python regression script
nmathieufact ac92605
fix paths in notebook
nmathieufact 21904b8
fixed the path static variables
nmathieufact 68d72a6
improved approach
nmathieufact 1fa637f
fix readme adding relevant citation
nmathieufact 2958fc6
Update README.md with common style
nmathieufact bcb9650
adjusted README.md citation style
nmathieufact 5e707f1
adjusted a last output path
nmathieufact 69f7565
simplified title
nmathieufact a8bba90
feat updating files
nmathieufact d7aa71b
feat: applied new columns schema
nmathieufact be0d84f
removed notebook generating the input and output
nmathieufact 9f5b711
changed approach removing pandas
nmathieufact f6154de
fix the bytetracker fixture
nmathieufact 5901a7f
fix corrected path
nmathieufact 772e6be
removed pandas import and usage
nmathieufact df4be2d
feat tried approachh for reseting bt
nmathieufact 5252cb1
fix the path and revert bytetracker reset
nmathieufact d14d5fb
fix the path and revert bytetracker reset
nmathieufact 8d1ec82
updated docstring
nmathieufact b60bfa0
fix update docstring first function
nmathieufact f2dae3f
fix format of docstring
nmathieufact 2a618e0
correcte output docstring
nmathieufact 6ea4782
fix wording of read/reading
nmathieufact 869425a
corrected typing from 1st function
nmathieufact e51fb1f
fix output path
nmathieufact f747f28
removed path being unuseful
nmathieufact d0f3a8c
added tests for CI
nmathieufact a7f6da0
introducing allclose assertion to make it pass
nmathieufact 230c295
fix pytest command with poetry
nmathieufact e5e359e
fix CI trying another approach
nmathieufact 8ec28b2
fix reverted ci
nmathieufact 27c3a50
fix the frame unique sorted
nmathieufact 2496abb
fix test results
nmathieufact 7c7f963
fix the tests
nmathieufact 7f5dd3e
fix output
nmathieufact b37f73d
fix the second video expected output
nmathieufact 611a5de
fix the expected output with new env
nmathieufact 5438b9a
corrected package
nmathieufact 0c26c7f
revert change
nmathieufact fa57efb
feat other approach
nmathieufact fbd69ae
revert change
nmathieufact a8443a5
corrected format
nmathieufact 12c6fde
fixed second format
nmathieufact d50f4b0
fix input format
nmathieufact e505751
fix removed print
nmathieufact 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
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
1,796 changes: 1,796 additions & 0 deletions
1,796
tests/expected_output/objects_detected_and_tracked_video1.txt
Large diffs are not rendered by default.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
tests/expected_output/objects_detected_and_tracked_video2.txt
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
117.0 0.974591305835963 0.5095593273639679 0.9995998740196228 0.742304390668869 142.0 49.0 0.8319151401519775 | ||
118.0 0.9723771181236184 0.5005956317592295 0.9995706969396306 0.745516412561992 142.0 49.0 0.8575639128684998 | ||
119.0 0.9692141222864277 0.4963345558666765 0.9995033249395253 0.7480595143898368 142.0 49.0 0.8860840201377869 | ||
120.0 0.9597183272620015 0.49863389352533755 0.9950719974612193 0.75323887234266 142.0 49.0 0.9059332013130188 | ||
121.0 0.9137051296973745 0.49948144088198765 0.9549359841485002 0.7572477348922191 142.0 49.0 0.9214490652084351 | ||
122.0 0.8638724059525613 0.49995341031172713 0.9114848810392273 0.7600943052013691 142.0 49.0 0.9317426085472107 | ||
123.0 0.8202443010481131 0.5008927321202477 0.8744436588068774 0.7617456617798124 142.0 49.0 0.9288402199745178 | ||
124.0 0.7771122186769683 0.500385486071895 0.8379277714479001 0.7611541221850968 142.0 49.0 0.9290407299995422 | ||
125.0 0.7247772874637586 0.5017298121516314 0.7923321383198036 0.76303004156558 142.0 49.0 0.9264274835586548 | ||
126.0 0.6671303227010921 0.5027124081353996 0.7416950553044594 0.7661639362088702 142.0 49.0 0.9315325617790222 | ||
127.0 0.616663571672274 0.5032080911861249 0.6977953166390259 0.7674052629688627 142.0 49.0 0.9363259673118591 | ||
128.0 0.5704205150806596 0.5034447554058634 0.6576470426224459 0.7674596817474673 142.0 49.0 0.9300203919410706 | ||
129.0 0.5200086795843045 0.5042046723093252 0.6129952764525678 0.7679312663000262 142.0 49.0 0.927420973777771 | ||
130.0 0.46643053919994637 0.5047469314997519 0.5650969063243967 0.7687824676857495 142.0 49.0 0.9283919334411621 | ||
131.0 0.4173761495829712 0.5047965664538961 0.5216674559275042 0.7698882380253113 142.0 49.0 0.9305659532546997 | ||
132.0 0.36950273408788886 0.5046674217427534 0.47893139831600645 0.770454233806388 142.0 49.0 0.922694206237793 | ||
133.0 0.3186225320703163 0.5049336319091298 0.43268114879297337 0.7708076409122564 142.0 49.0 0.9281331896781921 | ||
134.0 0.26800115818737746 0.5048401786190908 0.38642683784144416 0.7709888863166645 142.0 49.0 0.9294517636299133 | ||
135.0 0.22018770537261864 0.5043750340652045 0.3428432549812343 0.770896006411032 142.0 49.0 0.9294649362564087 |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
40 0.21998224 0.5836777 0.3745204 0.7639922 0.16180652 49.0 | ||
116 0.9795788 0.53099704 0.9996632 0.7194981 0.51681966 49.0 | ||
117 0.95138013 0.5041999 0.999584 0.748006 0.83191514 49.0 | ||
118 0.9269222 0.49708003 0.9995592 0.7467762 0.8575639 49.0 | ||
119 0.88959634 0.49609375 0.9994829 0.7485177 0.886084 49.0 | ||
120 0.8366054 0.50106037 0.99332654 0.75461787 0.9059332 49.0 | ||
121 0.7823308 0.5008052 0.93827456 0.7578524 0.92144907 49.0 | ||
122 0.73994255 0.50089943 0.89590263 0.76007366 0.9317426 49.0 | ||
123 0.70718193 0.5019245 0.86416876 0.76115876 0.9288402 49.0 | ||
124 0.6728785 0.5005684 0.8293528 0.75955844 0.92904073 49.0 | ||
125 0.624425 0.50280184 0.78042 0.76286423 0.9264275 49.0 | ||
126 0.5726967 0.5034708 0.72873324 0.7666482 0.93153256 49.0 | ||
127 0.53285456 0.50363165 0.6897488 0.7668706 0.93632597 49.0 | ||
128 0.4952455 0.5036848 0.6524906 0.7663839 0.9300204 49.0 | ||
129 0.44878444 0.50468314 0.60615635 0.7671972 0.927421 49.0 | ||
130 0.39896855 0.5050585 0.5573927 0.76832783 0.92839193 49.0 | ||
131 0.35776815 0.5048203 0.51712275 0.76961535 0.93056595 49.0 | ||
132 0.31567994 0.5045963 0.4752435 0.7699328 0.9226942 49.0 | ||
133 0.26709083 0.5050746 0.4275921 0.7702349 0.9281332 49.0 | ||
134 0.22100373 0.5047798 0.3819117 0.77039224 0.92945176 49.0 | ||
135 0.17729278 0.5041295 0.3402054 0.77022386 0.92946494 49.0 |
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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
from pathlib import Path | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
# bytetracker | ||
from bytetracker import BYTETracker | ||
|
||
# static paths | ||
OUTPUT_FOLDER = Path("tests/output") | ||
TEST_INPUT_FOLDER = Path("tests/test_input") | ||
EXPECTED_OUTPUT_FOLDER = Path("tests/expected_output") | ||
OUTPUT_FOLDER = Path("tests/output") | ||
|
||
OUTPUT_FOLDER.mkdir(parents=True, exist_ok=True) | ||
|
||
|
||
def reading_detections_file(video_number): | ||
"""Read the detections object file from a specific format | ||
|
||
Args: | ||
video_number (string): string representing the video name in folder | ||
|
||
Returns: | ||
df_detection (ndarray): A list of array of the tuples. | ||
""" | ||
df_detection = np.loadtxt( | ||
TEST_INPUT_FOLDER / f"objects_detected_{video_number}.txt", delimiter=" " | ||
) | ||
print(df_detection) | ||
|
||
return df_detection | ||
|
||
|
||
def reading_expected_results_from_txt(video_number): | ||
"""Read the detections and tracked objects frames from Yolo and Bytetrack models | ||
|
||
Args: | ||
video_number (str): Video title to import | ||
|
||
Returns: | ||
expected_results_df (ndarray): array of frames detection and tracking imported from expected results. | ||
""" | ||
expected_results_df = np.loadtxt( | ||
EXPECTED_OUTPUT_FOLDER / f"objects_detected_and_tracked_{video_number}.txt" | ||
) | ||
|
||
return expected_results_df | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"expected_results, test_input, video_number", | ||
[ | ||
( | ||
reading_expected_results_from_txt("video1"), | ||
nmathieufact marked this conversation as resolved.
Show resolved
Hide resolved
|
||
reading_detections_file("video1"), | ||
"video1", | ||
), | ||
( | ||
reading_expected_results_from_txt("video2"), | ||
reading_detections_file("video2"), | ||
"video2", | ||
), | ||
], | ||
) | ||
def test_video_prediction_tracking(expected_results, test_input, video_number): | ||
"""Execute the integration test: performing the tracking of test_input, | ||
whose output is to compare with expected_results | ||
|
||
Args: | ||
expected_result (DataFrame): the dataframe of the results expected to match the test result | ||
test_input (array): dataframe that is the import of prediction frames in test_input folder | ||
video_number (string): string component specific to a video | ||
|
||
Returns: | ||
Test assertion results | ||
""" | ||
tracker = BYTETracker(track_thresh=0.15, track_buffer=3, match_thresh=0.85, frame_rate=12) | ||
test_results = [] | ||
nmathieufact marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# first column of test input is the frame id | ||
frame_idx = np.unique(test_input[:, 0]) | ||
nmathieufact marked this conversation as resolved.
Show resolved
Hide resolved
|
||
test_results = [] | ||
|
||
for frame_id in frame_idx: | ||
detections = test_input[test_input[:, 0] == frame_id][:, 1:] | ||
tracked_objects = tracker.update(detections, frame_id) | ||
if len(tracked_objects) > 0: | ||
tracked_objects = np.insert( | ||
tracked_objects, 0, np.full(len(tracked_objects), frame_id), axis=1 | ||
) | ||
test_results.append(tracked_objects) | ||
|
||
if test_results: # Ensure test_results is not empty to avoid errors | ||
combined_array = np.concatenate(test_results) | ||
else: | ||
combined_array = np.array([]) # Or handle the empty case as needed | ||
|
||
output_file_path = OUTPUT_FOLDER / f"{video_number}_test_results.txt" | ||
np.savetxt(output_file_path, combined_array, delimiter=" ", fmt="%s") | ||
|
||
assert np.allclose(expected_results, combined_array) | ||
tristanpepinartefact marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Remove the file if the test is successful | ||
output_file_path.unlink() |
Oops, something went wrong.
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.
retirer ce print