mirror of
https://github.com/20kaushik02/CSE515_MWDB_Project.git
synced 2025-12-06 07:54:07 +00:00
utils
This commit is contained in:
parent
d8490c7c4b
commit
53e284ae95
@ -998,6 +998,7 @@ def extract_latent_semantics_from_feature_model(
|
||||
) as output_file:
|
||||
json.dump(all_latent_semantics, output_file, ensure_ascii=False)
|
||||
|
||||
|
||||
def extract_latent_semantics_from_sim_matrix(
|
||||
sim_matrix,
|
||||
feature_model,
|
||||
@ -1080,7 +1081,8 @@ def extract_latent_semantics_from_sim_matrix(
|
||||
)
|
||||
model.fit(feature_vectors_shifted)
|
||||
|
||||
W, H = nmf(feature_vectors_shifted, k = k)
|
||||
W = model.transform(feature_vectors_shifted)
|
||||
H = model.components_
|
||||
|
||||
all_latent_semantics = {
|
||||
"image-semantic": W.tolist(),
|
||||
@ -1171,6 +1173,7 @@ def extract_latent_semantics_from_sim_matrix(
|
||||
) as output_file:
|
||||
json.dump(all_latent_semantics, output_file, ensure_ascii=False)
|
||||
|
||||
|
||||
def find_label_label_similarity(fd_collection, feature_model):
|
||||
"""
|
||||
Calculate similarity between labels. Lower values indicate higher similarities
|
||||
@ -1226,4 +1229,4 @@ def find_image_image_similarity(fd_collection, feature_model):
|
||||
image_sim_matrix[i][j] = image_sim_matrix[j][i] = feature_distance_matches[
|
||||
feature_model
|
||||
](np.array(feature_vectors[i]), np.array(feature_vectors[j]))
|
||||
return image_sim_matrix
|
||||
return image_sim_matrix
|
||||
Loading…
x
Reference in New Issue
Block a user