mirror of
https://github.com/deepinsight/insightface.git
synced 2026-07-17 11:07:50 +00:00
Fixed failed db file creation under Python-Native
This commit is contained in:
1
cpp-package/inspireface/python/.gitignore
vendored
1
cpp-package/inspireface/python/.gitignore
vendored
@@ -28,3 +28,4 @@ share/python-wheels/
|
||||
|
||||
|
||||
.idea/
|
||||
*.db
|
||||
@@ -622,7 +622,7 @@ class FeatureHubConfiguration:
|
||||
HFFeatureHubConfiguration: A C-structure for feature hub configuration.
|
||||
"""
|
||||
return HFFeatureHubConfiguration(
|
||||
enableUseDb=int(self.enable_use_db),
|
||||
enablePersistence=int(self.enable_use_db),
|
||||
dbPath=String(bytes(self.db_path, encoding="utf8")),
|
||||
featureBlockNum=self.feature_block_num,
|
||||
searchThreshold=self.search_threshold,
|
||||
|
||||
32
cpp-package/inspireface/python/sample_feature_hub.py
Normal file
32
cpp-package/inspireface/python/sample_feature_hub.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import os
|
||||
import cv2
|
||||
import inspireface as ifac
|
||||
from inspireface.param import *
|
||||
import numpy as np
|
||||
import os
|
||||
|
||||
def case_feature_hub():
|
||||
db_path = "test.db"
|
||||
if os.path.exists(db_path):
|
||||
os.remove(db_path)
|
||||
# Configure the feature management system.
|
||||
feature_hub_config = ifac.FeatureHubConfiguration(
|
||||
feature_block_num=10,
|
||||
enable_use_db=True,
|
||||
db_path=db_path,
|
||||
search_threshold=0.48,
|
||||
search_mode=HF_SEARCH_MODE_EAGER,
|
||||
)
|
||||
ret = ifac.feature_hub_enable(feature_hub_config)
|
||||
assert ret, "Failed to enable FeatureHub."
|
||||
print(ifac.feature_hub_get_face_count())
|
||||
for i in range(10):
|
||||
feature = ifac.FaceIdentity(np.random.rand(512), i, "test")
|
||||
ifac.feature_hub_face_insert(feature)
|
||||
print(ifac.feature_hub_get_face_count())
|
||||
|
||||
assert os.path.exists(db_path), "FeatureHub database file not found."
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
case_feature_hub()
|
||||
Reference in New Issue
Block a user