Skip to content

Added Confidence Argument to keypoint detection model #354

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
583818f
Added "confidence" as argument for keypoint detection model
Greenstan Jan 20, 2025
00c1a11
Revert "Added "confidence" as argument for keypoint detection model"
Greenstan Jan 20, 2025
8b1b604
Reapply "Added "confidence" as argument for keypoint detection model"
Greenstan Jan 20, 2025
535257a
Added Tests for the Keypoint detection model
Greenstan Jan 20, 2025
6bc4ce9
Merge branch 'main' into confidence-to-keypoint-detection
Greenstan May 3, 2025
1788c48
Merge branch 'main' into confidence-to-keypoint-detection
SolomonLake Jun 4, 2025
b232f45
Merge branch 'main' into confidence-to-keypoint-detection
Greenstan Jun 5, 2025
dc49936
Fixed String concatenation and removed unnecessary dependabot file
Greenstan Jun 5, 2025
1ec6360
Merge branch 'main' into confidence-to-keypoint-detection
Greenstan Jun 8, 2025
9be4ad4
Merge branch 'main' into confidence-to-keypoint-detection
Greenstan Jul 4, 2025
b70a9e4
Fixed Unit-tests for Keypoint Detection Model
Greenstan Jul 4, 2025
b603e42
Fixed confidence kwarg in Keypoint-detection model
Greenstan Jul 4, 2025
f5c18f5
Update tests/models/test_keypoint_detection.py
Greenstan Aug 8, 2025
478daae
Update tests/models/test_keypoint_detection.py
Greenstan Aug 8, 2025
fcbf509
Update tests/models/test_keypoint_detection.py
Greenstan Aug 8, 2025
eeb496a
Update tests/models/test_keypoint_detection.py
Greenstan Aug 8, 2025
7fe0619
Merge branch 'main' into confidence-to-keypoint-detection
Greenstan Aug 8, 2025
245649f
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Aug 8, 2025
97d59d7
Changed some file paths to relative paths
Greenstan Aug 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions roboflow/models/keypoint_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(
id: str,
name: Optional[str] = None,
version: Optional[str] = None,
confidence: Optional[int] = 40,
local: Optional[str] = None,
):
"""
Expand All @@ -37,6 +38,7 @@ def __init__(
name (str): is the name of the project
version (str): version number
local (str): localhost address and port if pointing towards local inference engine
confidence (int): A threshold for the returned predictions on a scale of 0-100.
colors (dict): colors to use for the image
preprocessing (dict): preprocessing to use for the image

Expand All @@ -48,6 +50,7 @@ def __init__(
self.__api_key = api_key
self.id = id
self.name = name
self.confidence = confidence
self.version = version
self.base_url = "https://detect.roboflow.com/"

Expand All @@ -58,7 +61,7 @@ def __init__(
print(f"initalizing local keypoint detection model hosted at : {local}")
self.base_url = local

def predict(self, image_path, hosted=False): # type: ignore[override]
def predict(self, image_path, hosted=False, confidence=None): # type: ignore[override]
"""
Run inference on an image.

Expand All @@ -80,7 +83,10 @@ def predict(self, image_path, hosted=False): # type: ignore[override]

>>> prediction = model.predict("YOUR_IMAGE.jpg")
"""
self.__generate_url()
if confidence is not None:
self.confidence = confidence

self.__generate_url(confidence=confidence)
self.__exception_check(image_path_check=image_path)
# If image is local image
if not hosted:
Expand Down Expand Up @@ -130,7 +136,7 @@ def load_model(self, name, version):
self.version = version
self.__generate_url()

def __generate_url(self):
def __generate_url(self, confidence=None):
"""
Generate a Roboflow API URL on which to run inference.

Expand All @@ -145,11 +151,15 @@ def __generate_url(self):
if not version and len(splitted) > 2:
version = splitted[2]

if confidence is not None:
self.confidence = confidence

self.api_url = "".join(
[
self.base_url + without_workspace + "/" + str(version),
"?api_key=" + self.__api_key,
"&name=YOUR_IMAGE.jpg",
"&confidence=" + str(self.confidence),
]
)

Expand All @@ -175,6 +185,7 @@ def __str__(self):
json_value = {
"name": self.name,
"version": self.version,
"confidence": self.confidence,
"base_url": self.base_url,
}

Expand Down
Loading