Skip to content

[fix] typo, from 'opt' to 'param' in isf.InspireFaceSession().#338

Open
liuwake wants to merge 1 commit into
HyperInspire:masterfrom
liuwake:master
Open

[fix] typo, from 'opt' to 'param' in isf.InspireFaceSession().#338
liuwake wants to merge 1 commit into
HyperInspire:masterfrom
liuwake:master

Conversation

@liuwake

@liuwake liuwake commented May 12, 2026

Copy link
Copy Markdown
  • get TypeError
    (ifpy38) [iwake@wkarch python]$ LD_LIBRARY_PATH=/opt/tensorrt/lib:$LD_LIBRARY_PATH python demo_official.py 
    Exception ignored in: <function InspireFaceSession.__del__ at 0x7f03cb6131f0>
    Traceback (most recent call last):
      File "/home/iwake/.conda/envs/ifpy38/lib/python3.8/site-packages/inspireface-1.2.3-py3.8.egg/inspireface/modules/inspireface.py", line 711, in __del__
        self.release()
      File "/home/iwake/.conda/envs/ifpy38/lib/python3.8/site-packages/inspireface-1.2.3-py3.8.egg/inspireface/modules/inspireface.py", line 706, in release
        if self._sess is not None:
    AttributeError: 'InspireFaceSession' object has no attribute '_sess'
    Traceback (most recent call last):
      File "demo_official.py", line 5, in <module>
        session = isf.InspireFaceSession(
    TypeError: __init__() got an unexpected keyword argument 'opt'
    
  • I refer
    class InspireFaceSession(object):
    """
    Manages a session for face detection and recognition processes using the InspireFace library.
    Attributes:
    multiple_faces (HFMultipleFaceData): Stores data about multiple detected faces during the session.
    _sess (HFSession): The handle to the underlying library session.
    param (int or SessionCustomParameter): Configuration parameters or flags for the session.
    """
    def __init__(self, param, detect_mode: int = HF_DETECT_MODE_ALWAYS_DETECT,
    max_detect_num: int = 10, detect_pixel_level=-1, track_by_detect_mode_fps=-1):
    """
    Initializes a new session with the provided configuration parameters.
    Args:
    param (int or SessionCustomParameter): Configuration parameters or flags.
    detect_mode (int): Detection mode to be used (e.g., image-based detection).
    max_detect_num (int): Maximum number of faces to detect.
    Raises:
    SystemNotReadyError: If InspireFace is not launched.
    ProcessingError: If session creation fails.
    """
    # Initialize _sess to None first to prevent AttributeError in __del__
    self._sess = None
    self.multiple_faces = None
    self.param = param
    # If InspireFace is not initialized, run launch() use Pikachu model
    if not query_launch_status():
    ret = launch()
    if not ret:
    raise SystemNotReadyError("Failed to launch InspireFace automatically")
    self._sess = HFSession()
  • So
    session = isf.InspireFaceSession(
    -   opt=isf.HF_ENABLE_NONE,  # Optional features
    +   param=isf.HF_ENABLE_NONE,  # Optional features
        detect_mode=isf.HF_DETECT_MODE_ALWAYS_DETECT  # Detection mode
    )

@devloai devloai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PR Summary:

  • Fixes a typo in python/README.md where the keyword argument opt= was incorrectly documented for isf.InspireFaceSession()
  • The correct parameter name is param=, matching the actual __init__ signature in inspireface.py
  • Caused a TypeError for anyone who copied the README example verbatim

Review Summary:

The change is correct and well-targeted. Verified against InspireFaceSession.__init__() (line 301 of python/inspireface/modules/inspireface.py), which clearly defines param as the first positional argument — not opt. The fix is minimal, accurate, and resolves a real user-facing error reproduced in the PR description. No other occurrences of opt= were found in sample files. No issues identified.

Suggestions

  • Search the entire codebase for any other README or sample files that might still reference the old opt= argument pattern. Apply
  • Add a brief docstring or inline comment in the README clarifying that param accepts either an int flag (e.g. HF_ENABLE_NONE) or a SessionCustomParameter object. Apply

@liuwake

liuwake commented May 21, 2026

Copy link
Copy Markdown
Author

@tunmx

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.

1 participant