Skip to content
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: add missing api options #1447

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

charsleysa
Copy link

Tickets

N/A

What has been done

Added missing options to API endpoints, such as expand_percentage, normalization, and threshold.

How to test

make lint && make test

@charsleysa charsleysa requested a review from serengil March 2, 2025 23:28
align=input_args.get("align", True),
anti_spoofing=input_args.get("anti_spoofing", False),
max_faces=input_args.get("max_faces"),
enforce_detection=
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not clean at all, for boolean arguments you can adopt this approach

enforce_detection = input_args.get("enforce_detection", "true") == "true"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your suggestion will not work for JSON because booleans in JSON are converted to Python booleans, not Python strings

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, there are redudants in your approcah. This would be better imo.

enforce_detection = input_args.get("enforce_detection", True)
if not isinstance(enforce_detection, bool):
    enforce_detection = enforce_detection == "true"

bool(input_args.get("anti_spoofing", False))
if isinstance((input_args.get("anti_spoofing", False)), bool)
else input_args.get("anti_spoofing") == "true",
max_faces=
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for float args, you can adopt this approach

max_faces = int(input_args.get("max_faces", "0"))

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your suggestion will not work for JSON because numbers in JSON are converted to Python numbers, not Python strings

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to call input_args.get("max_faces", None) twice, you may consider to do this as

max_faces = input_args.get("max_faces", 0)
if not isinstance(max_faces, (int, float)):  
    max_faces = float(max_faces) if max_faces.replace(".", "", 1).isdigit() else 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants