Skip to content

Commit

Permalink
Added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
honeytung committed Jul 3, 2024
1 parent fb53c5e commit a0f2523
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/api/test_motdet.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,13 @@ def test_motion_detection_not_sufficient_if_doesnt_meet_conf_threshold(gl: Groun
detector = gl.get_detector(id=detector_id)

original_image = Image.open("test/assets/dog.jpeg")

# Set wait time to be 130s
wait_time = 30.0

# Set up opportunity for motion detection
base_iq_response = gl.submit_image_query(
detector=detector.id, image=original_image, wait=10, confidence_threshold=0.5
detector=detector.id, image=original_image, wait=wait_time, confidence_threshold=0.5
)
if (
base_iq_response.result is None
Expand All @@ -258,17 +261,18 @@ def test_motion_detection_not_sufficient_if_doesnt_meet_conf_threshold(gl: Groun
new_response = gl.submit_image_query(
detector=detector.id,
image=original_image,
wait=10,
wait=wait_time,
confidence_threshold=base_iq_response.result.confidence + 1e-3, # Require a higher confidence than before
)

time_diff = time.time() - current_time

assert new_response.id != base_iq_response.id, "ImageQuery id should be different whether or not motion det is run"

if time_diff < 9.9:
# If the time difference exceeded the wait time, that means the ML has time out and will just return the previous
# result
if time_diff < wait_time:
assert new_response.id.startswith("iq_"), (
"ImageQuery id should start with 'iq_' because it was created on the cloud, because the cached mot det response"
" did not meet the confidence threshold"
f" Detector Confidence: {detector.confidence_threshold}. Old IQ Confidence: {base_iq_response.result.confidence}. New IQ Confidence: {new_response.result.confidence}. New Requirement: {new_response.confidence_threshold}"
"ImageQuery id should start with 'iq_' because it was created on the cloud, because the cached mot det "
"response did not meet the confidence threshold"
)

0 comments on commit a0f2523

Please sign in to comment.