How to set confidence and overlap threshold in Hosted Image Inference

I am using following code from hosted image inference. How to set/specify confidence and overlap threshold?

from inference_sdk import InferenceHTTPClient

CLIENT = InferenceHTTPClient(
    api_url="https://detect.roboflow.com",
    api_key="API_KEY"
)

# infer on a local image
result = CLIENT.infer("YOUR_IMAGE.jpg", model_id="hand-control-vyoij/1")

Hi @Timothy_Malche :wave:

The infer method can accept arguments controlling the behaviour of the Model. In this case, you can try the following:

CLIENT.infer(
    "YOUR_IMAGE.jpg",
    model_id="hand-control-vyoij/1",
    confidence=0.4,
    iou_threshold=0.3
)

I believe the full list is here: Inference SDK - Roboflow Inference

@linas I am getting error

TypeError: InferenceHTTPClient.infer() got an unexpected keyword argument 'confidence'

@linas since the above code giving error, I used following code following the tutorial on the page you shared. here’s my code.

from inference_sdk import InferenceHTTPClient, InferenceConfiguration

    custom_configuration = InferenceConfiguration(confidence_threshold=0.5, iou_threshold=0.5)

    with CLIENT.use_configuration(custom_configuration):
        result = CLIENT.infer(image_path, model_id="hand-control-vyoij/1")

Indeed, confidence_threshold seems like the correct parameter. Apologies for the confusion!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.