def eval_process_image_dir_worker(con): embeddings_with_ids = list(DBManager.get_all_embeddings(with_ids=True)) eval_core_algorithm = EvalCoreAlgorithm(metric=metric, classification_threshold=threshold) # passing result cluster dict already overwrites it clustering_result = eval_core_algorithm.cluster_embeddings_no_split(embeddings_with_ids, existing_clusters_dict=cluster_dict, should_reset_cluster_ids=True, final_clusters_only=False) _, modified_clusters_dict, removed_clusters_dict = clustering_result DBManager.overwrite_clusters_simplified(modified_clusters_dict, removed_clusters_dict, con=con, close_connections=False)
def cluster_processed_faces(con): embeddings_with_ids = list( DBManager.get_all_embeddings(with_ids=True)) # TODO: Call reclassify handler here? # TODO: Clear existing clusters? Issues with ids etc.???? core_algorithm = CoreAlgorithm() # passing result cluster dict already overwrites it clustering_result = core_algorithm.cluster_embeddings( embeddings_with_ids, existing_clusters_dict=cluster_dict, should_reset_cluster_ids=True, final_clusters_only=False) _, modified_clusters_dict, removed_clusters_dict = clustering_result DBManager.overwrite_clusters_simplified(modified_clusters_dict, removed_clusters_dict, con=con, close_connections=False)
def reclassify_worker(con): # all operations in worker, so if any DB operation raises error, it is caught if embeddings_with_ids is not None: local_embeddings_with_ids = embeddings_with_ids else: local_embeddings_with_ids = list(DBManager.get_all_embeddings(with_ids=True)) if not local_embeddings_with_ids: log_error('no embeddings found, nothing to edit') return new_cluster_dict = DBManager.get_certain_clusters() core_algorithm = CoreAlgorithm() clustering_result = core_algorithm.cluster_embeddings(embeddings=local_embeddings_with_ids, existing_clusters_dict=new_cluster_dict, should_reset_cluster_ids=True, final_clusters_only=False) _, modified_clusters_dict, removed_clusters_dict = clustering_result DBManager.overwrite_clusters(new_cluster_dict, removed_clusters_dict, no_new_embs=True, clear_clusters=True, con=con, close_connections=False) overwrite_dict(cluster_dict, new_cluster_dict)