You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi team! I'm testing out the Groundlight API and came across a crash in my basic proof-of-concept script that I wanted to report. The core problem I found was when doing async analysis, I'm able to submit images fine, but then when I want to await the results, I'm hit with a type checking error:
edit: pip freeze shows me at version groundlight==0.21.3
Traceback (most recent call last):
File "C:\path\to\my\groundlight_ws\groundlight_demo.py", line 40, in <module>
results.append(gl.wait_for_confident_result(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\path\to\my\groundlight_ws\venv\Lib\site-packages\groundlight\client.py", line 1002, in wait_for_confident_result
return self._wait_for_result(image_query, condition=confidence_above_thresh, timeout_sec=timeout_sec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\path\to\my\groundlight_ws\venv\Lib\site-packages\groundlight\client.py", line 1065, in _wait_for_result
if condition(image_query):
^^^^^^^^^^^^^^^^^^^^^^
File "C:\path\to\my\groundlight_ws\venv\Lib\site-packages\groundlight\internalapi.py", line 70, in iq_is_confident
return iq.result.confidence >= confidence_threshold # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '>=' not supported between instances of 'float' and 'NoneType'
To get here, a barebones sample of what I've done is here:
importosfromgroundlightimportGroundlight, DetectorAPI_TOKEN="mytoken"os.environ["GROUNDLIGHT_API_TOKEN"] =API_TOKENgl=Groundlight()
det: Detector=gl.get_or_create_detector(
name="my_binary_detector",
query="Is the door open?"
)
queries= []
foriinrange(1,5): # submit 4 images to the detectorprint(f"submitting image s{i}.png") # just using local filenames as stringsqueries.append(gl.ask_async(detector=det, image=f"s{i}.png"))
results= []
forqinqueries:
results.append(gl.wait_for_confident_result(
#### PROBLEM HERE ### I'm not specifying a confidence value, which should default to the detector's value,#### and I am using the image query object instead of the query string ID.image_query=q
))
# <... further processing / not needed for issue replication ...>
Based on function signatures, the iq_is_confident function does not expect a None type in the confidence_value, and the wait_for_confident_result method will supply a None if the confidence_threshold is omitted and when the type of the image_query is not a string, as in it's an ImageQuery object.
After looking at the code more, it also looks like this method will override the user's confidence_threshold in the case that the string version of the ImageQuery is provided since that variable gets overridden here - I only bring that up because it runs counter to the docstring
Expected behavior
For my main bug: My anticipated behavior for this would be that my detector's threshold of 0.9 is used if I didn't specify a threshold
For the secondary one: Anticipated behavior is that the confidence threshold provided to wait_for_confident_result would be used instead of my detector's 0.9 threshold value if I provided the detector's string ID.
Thanks!
The text was updated successfully, but these errors were encountered:
Issue and replication
Hi team! I'm testing out the Groundlight API and came across a crash in my basic proof-of-concept script that I wanted to report. The core problem I found was when doing async analysis, I'm able to submit images fine, but then when I want to await the results, I'm hit with a type checking error:
edit:
pip freeze
shows me at versiongroundlight==0.21.3
To get here, a barebones sample of what I've done is here:
Based on function signatures, the iq_is_confident function does not expect a
None
type in theconfidence_value
, and the wait_for_confident_result method will supply a None if theconfidence_threshold
is omitted and when the type of theimage_query
is not a string, as in it's anImageQuery
object.After looking at the code more, it also looks like this method will override the user's
confidence_threshold
in the case that the string version of the ImageQuery is provided since that variable gets overridden here - I only bring that up because it runs counter to the docstringExpected behavior
For my main bug: My anticipated behavior for this would be that my detector's threshold of 0.9 is used if I didn't specify a threshold
For the secondary one: Anticipated behavior is that the confidence threshold provided to
wait_for_confident_result
would be used instead of my detector's 0.9 threshold value if I provided the detector's string ID.Thanks!
The text was updated successfully, but these errors were encountered: