Skip to content

Commit

Permalink
#1475 Changes the eps to be a configuration parameter;
Browse files Browse the repository at this point in the history
  • Loading branch information
hauck-jvsh committed Jan 15, 2023
1 parent fb26e06 commit 13cb8a3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
6 changes: 5 additions & 1 deletion iped-app/resources/config/conf/FaceRecognitionConfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ faceDetectionModel = hog

# Number of times the image will be upsampled before recognition. Default is 1x (doubles the image size).
# This improves detection of small faces. But is limited by maxResolution setting.
upSampling = 1
upSampling = 1

# Maximum distance where faces can be grouped together
# If set to 0 disable the clustering
maxClusterDist=0.4
19 changes: 15 additions & 4 deletions iped-app/resources/scripts/tasks/FaceRecognitionTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
maxResolutionProp = 'maxResolution'
faceDetectionModelProp = 'faceDetectionModel'
upSamplingProp = 'upSampling'
maxClusterDistProp = 'maxClusterDist'

# External process script
processScript = 'FaceRecognitionProcess.py'
Expand Down Expand Up @@ -156,6 +157,15 @@ def init(self, configuration):
upSampling = extraProps.getProperty(upSamplingProp)
if upSampling is not None:
up_sampling = int(upSampling)

global maxClusterDist

maxClusterDist = extraProps.getProperty(maxClusterDistProp)

if maxClusterDist is None:
maxClusterDist=0
else:
maxClusterDist=float(maxClusterDist)

createProcessQueue()
return
Expand All @@ -182,9 +192,10 @@ def finish(self):
logger.info('[FaceRecognitionTask] Time(s) to get face features: ' + str(featureTime / maxProcesses))
detectTime = -1
featureTime = -1
global clusterExecuted
global clusterExecuted,maxClusterDist
print("Dist",maxClusterDist)
with clusterLock:
if clusterExecuted==1:
if clusterExecuted==1 or maxClusterDist==0:
return
clusterExecuted=1
searcher.setQuery(ExtraProperties.FACE_COUNT+" :[1 TO *]")
Expand All @@ -197,7 +208,7 @@ def finish(self):
encoding=ipedCase.getItemByID(id).getExtraAttribute(ExtraProperties.FACE_ENCODINGS)
if len(encoding)!=512:
encoding=encoding[0]

#convert bytes to float array
import struct
encoding=struct.unpack(">128f",bytes(np.array(encoding,np.byte)))
encodings.append(encoding)
Expand All @@ -208,7 +219,7 @@ def finish(self):
if len(encodings)==0:
return

clt = DBSCAN(metric="euclidean",n_jobs=-1,eps=0.3)
clt = DBSCAN(metric="euclidean",n_jobs=-1,eps=maxClusterDist)
clt.fit(encodings)
clusters={}
print("labels",clt.labels_)
Expand Down

0 comments on commit 13cb8a3

Please sign in to comment.