Commit 93a1aba0 authored by Varun's avatar Varun

Added threshold to clustering call

parent 8b48c09c
...@@ -100,7 +100,7 @@ for f in glob.glob(os.path.join(faces_folder_path, "*.jpg")): ...@@ -100,7 +100,7 @@ for f in glob.glob(os.path.join(faces_folder_path, "*.jpg")):
# middle value, such as 10, which is only 10x slower but still gets an # middle value, such as 10, which is only 10x slower but still gets an
# LFW accuracy of 99.3%. # LFW accuracy of 99.3%.
labels = facerec.cluster(descriptors) labels = facerec.cluster(descriptors, 0.5)
label_classes = list(set(labels)) label_classes = list(set(labels))
label_classes.sort() label_classes.sort()
num_classes = len(label_classes) num_classes = len(label_classes)
......
...@@ -39,7 +39,7 @@ public: ...@@ -39,7 +39,7 @@ public:
cropper->set_max_rotation_degrees(3); cropper->set_max_rotation_degrees(3);
} }
boost::python::list cluster(boost::python::list descriptors) boost::python::list cluster(boost::python::list descriptors, float threshold)
{ {
boost::python::list clusters; boost::python::list clusters;
...@@ -61,7 +61,7 @@ public: ...@@ -61,7 +61,7 @@ public:
matrix<double,0,1> first_descriptor = boost::python::extract<matrix<double,0,1>>(descriptors[i]); matrix<double,0,1> first_descriptor = boost::python::extract<matrix<double,0,1>>(descriptors[i]);
matrix<double,0,1> second_descriptor = boost::python::extract<matrix<double,0,1>>(descriptors[j]); matrix<double,0,1> second_descriptor = boost::python::extract<matrix<double,0,1>>(descriptors[j]);
if (length(first_descriptor-second_descriptor) < 0.6) if (length(first_descriptor-second_descriptor) < threshold)
edges.push_back(sample_pair(i,j)); edges.push_back(sample_pair(i,j));
} }
} }
...@@ -237,7 +237,7 @@ void bind_face_recognition() ...@@ -237,7 +237,7 @@ void bind_face_recognition()
.def("save_image_chips", &face_recognition_model_v1::save_image_chips, (arg("img"),arg("faces"),arg("chip_filename")), .def("save_image_chips", &face_recognition_model_v1::save_image_chips, (arg("img"),arg("faces"),arg("chip_filename")),
"Takes an image and a full_object_detections object that reference faces in that image and saves the faces with the specified file name prefix" "Takes an image and a full_object_detections object that reference faces in that image and saves the faces with the specified file name prefix"
) )
.def("cluster", &face_recognition_model_v1::cluster, (arg("descriptors")), .def("cluster", &face_recognition_model_v1::cluster, (arg("descriptors"), arg("threshold")),
"Takes a list of descriptors and returns a list that contains a label for each descriptor. Clustering is done using chinese_whispers." "Takes a list of descriptors and returns a list that contains a label for each descriptor. Clustering is done using chinese_whispers."
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment