This commit is contained in:
tunm
2025-05-22 16:07:26 +08:00
parent efb5639ec6
commit 7e25e4e482
168 changed files with 6434 additions and 2527 deletions

View File

@@ -2,7 +2,7 @@ from .inspireface import ImageStream, FaceExtended, FaceInformation, SessionCust
launch, FeatureHubConfiguration, feature_hub_enable, feature_hub_disable, feature_comparison, \
FaceIdentity, feature_hub_set_search_threshold, feature_hub_face_insert, SearchResult, \
feature_hub_face_search, feature_hub_face_search_top_k, feature_hub_face_update, feature_hub_face_remove, \
feature_hub_get_face_identity, feature_hub_get_face_count, view_table_in_terminal, version, query_launch_status, reload, set_expansive_pack_path, \
feature_hub_get_face_identity, feature_hub_get_face_count, view_table_in_terminal, version, query_launch_status, reload, \
set_logging_level, disable_logging, show_system_resource_statistics, get_recommended_cosine_threshold, cosine_similarity_convert_to_percentage, \
get_similarity_converter_config, set_similarity_converter_config, pull_latest_model, \
HF_PK_AUTO_INCREMENT, HF_PK_MANUAL_INPUT, HF_SEARCH_MODE_EAGER, HF_SEARCH_MODE_EXHAUSTIVE
get_similarity_converter_config, set_similarity_converter_config, pull_latest_model, switch_landmark_engine, \
HF_PK_AUTO_INCREMENT, HF_PK_MANUAL_INPUT, HF_SEARCH_MODE_EAGER, HF_SEARCH_MODE_EXHAUSTIVE

View File

@@ -99,6 +99,14 @@ class ImageStream(object):
if ret != 0:
raise Exception("Error in creating ImageStream")
def write_to_file(self, file_path: str):
"""
Write the image stream to a file. Like PATH/image.jpg
"""
ret = HFDeBugImageStreamDecodeSave(self._handle, file_path)
if ret != 0:
logger.error(f"Write ImageStream to file error: {ret}")
def release(self):
"""
Release the resources associated with the ImageStream.
@@ -365,6 +373,16 @@ class InspireFaceSession(object):
return np.asarray(landmark).reshape(-1, 2)
def print_track_cost_spend(self):
ret = HFSessionPrintTrackCostSpend(self._sess)
if ret != 0:
logger.error(f"Print track cost spend error: {ret}")
def set_enable_track_cost_spend(self, enable: bool):
ret = HFSessionSetEnableTrackCostSpend(self._sess, enable)
if ret != 0:
logger.error(f"Set enable track cost spend error: {ret}")
def set_detection_confidence_threshold(self, threshold: float):
"""
Sets the detection confidence threshold for the face detection session.
@@ -633,13 +651,6 @@ def launch(model_name: str = "Pikachu", resource_path: str = None) -> bool:
return False
return True
def set_expansive_pack_path(path: str):
path_c = String(bytes(path, encoding="utf8"))
ret = HFSetExpansiveHardwareAppleCoreMLModelPath(path_c)
if ret != 0:
logger.error(f"Set expansive pack path error: {ret}")
return False
return True
def pull_latest_model(model_name: str = "Pikachu") -> str:
sm = ResourceManager()
@@ -676,6 +687,13 @@ def query_launch_status() -> bool:
return False
return status.value == 1
def switch_landmark_engine(engine: int):
ret = HFSwitchLandmarkEngine(engine)
if ret != 0:
logger.error(f"Switch landmark engine error: {ret}")
return False
return True
@dataclass
class FeatureHubConfiguration:
"""
@@ -840,7 +858,7 @@ class FaceIdentity(object):
feature.size = HInt32(self.feature.size)
feature.data = data_ptr
return HFFaceFeatureIdentity(
customId=HFaceId(self.id),
id=HFaceId(self.id),
feature=PHFFaceFeature(feature)
)
@@ -1109,7 +1127,6 @@ def set_logging_level(level: int) -> None:
"""
HFSetLogLevel(level)
def disable_logging() -> None:
"""
Disables all logging from the InspireFace library.
@@ -1122,3 +1139,34 @@ def show_system_resource_statistics():
"""
HFDeBugShowResourceStatistics()
def switch_apple_coreml_inference_mode(mode: int):
"""
Switches the Apple CoreML inference mode.
"""
ret = HFSetAppleCoreMLInferenceMode(mode)
if ret != 0:
logger.error(f"Failed to set Apple CoreML inference mode: {ret}")
return False
return True
def set_expansive_hardware_rockchip_dma_heap_path(path: str):
"""
Sets the path to the expansive hardware Rockchip DMA heap.
"""
ret = HFSetExpansiveHardwareRockchipDmaHeapPath(path)
if ret != 0:
logger.error(f"Failed to set expansive hardware Rockchip DMA heap path: {ret}")
return False
return True
def query_expansive_hardware_rockchip_dma_heap_path() -> str:
"""
Queries the path to the expansive hardware Rockchip DMA heap.
"""
path = HString()
ret = HFQueryExpansiveHardwareRockchipDmaHeapPath(path)
if ret != 0:
logger.error(f"Failed to query expansive hardware Rockchip DMA heap path: {ret}")
return None
return str(path.value)

View File

@@ -34,7 +34,22 @@ class ResourceManager:
"url": "https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Megatron",
"filename": "Megatron",
"md5": "28f2284c5e7cf53b0e152ff524a416c966ab21e724002643b1304aedc4af6b06"
}
},
"Megatron_TRT": {
"url": "https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Megatron_TRT",
"filename": "Megatron_TRT",
"md5": "25fb4a585b73b0114ff0d64c2bc4071bd005a32a77149b66c474985077dc8f8a"
},
"Gundam_RK356X": {
"url": "https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Gundam_RK356X",
"filename": "Gundam_RK356X",
"md5": "69ea23b89851a38c729b32bb0ed33cf62ebd3c891ea5d596afeadeb1f1c79c69"
},
"Gundam_RK3588": {
"url": "https://github.com/HyperInspire/InspireFace/releases/download/v1.x/Gundam_RK3588",
"filename": "Gundam_RK3588",
"md5": "030965798c5257aef11640657f85b89d82e9d170c3798d0b4f2b62ee6aa245ea"
},
}
def get_model(self, name: str, re_download: bool = False) -> str:

View File

@@ -2,7 +2,8 @@
# Session option
from inspireface.modules.core.native import HF_ENABLE_NONE, HF_ENABLE_FACE_RECOGNITION, HF_ENABLE_LIVENESS, HF_ENABLE_IR_LIVENESS, \
HF_ENABLE_MASK_DETECT, HF_ENABLE_FACE_ATTRIBUTE, HF_ENABLE_QUALITY, HF_ENABLE_INTERACTION, HF_PK_AUTO_INCREMENT, HF_PK_MANUAL_INPUT
HF_ENABLE_MASK_DETECT, HF_ENABLE_FACE_ATTRIBUTE, HF_ENABLE_QUALITY, HF_ENABLE_INTERACTION, HF_ENABLE_FACE_POSE, HF_PK_AUTO_INCREMENT, HF_PK_MANUAL_INPUT, \
HF_LANDMARK_HYPLMV2_0_25, HF_LANDMARK_HYPLMV2_0_50, HF_LANDMARK_INSIGHTFACE_2D106_TRACK
# Face track mode
from inspireface.modules.core.native import HF_DETECT_MODE_ALWAYS_DETECT, HF_DETECT_MODE_LIGHT_TRACK, HF_DETECT_MODE_TRACK_BY_DETECTION