From d4072974d7cf36d128255583b0e75360fdd4dfcd Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 18 Aug 2022 23:10:33 +0300 Subject: [PATCH] Use of XMP metadata in Khoj Image Search is broken. Disable by default - CLIP Image score and XMP metadata score are not combining well. When combined they give non sensical results. Enable only once figure how best to combine the two. - Show scores with higher precision for image search - Image search scores seem to be mostly be between 0.2 - 0.3 for some reason - Higher precision scores make it easier to understand the quality of returned results perceived by the model itself --- config/khoj_sample.yml | 2 +- src/search_type/image_search.py | 6 +++--- src/utils/constants.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/khoj_sample.yml b/config/khoj_sample.yml index 86894c03..ed1a0591 100644 --- a/config/khoj_sample.yml +++ b/config/khoj_sample.yml @@ -22,7 +22,7 @@ content-type: input-filter: # /path/to/images/*.jpg REQUIRED IF input-directories IS NOT SET embeddings-file: "~/.khoj/content/image/image_embeddings.pt" batch-size: 50 - use-xmp-metadata: true + use-xmp-metadata: false music: input-files: # ["/path/to/music-file.org"] REQUIRED IF input-filter IS NOT SET OR diff --git a/src/search_type/image_search.py b/src/search_type/image_search.py index 23a64459..b57d4f20 100644 --- a/src/search_type/image_search.py +++ b/src/search_type/image_search.py @@ -211,9 +211,9 @@ def collate_results(hits, image_names, output_directory, image_files_url, count= # Add the image metadata to the results results += [{ "entry": f'{image_files_url}/{target_image_name}', - "score": f"{hit['score']:.3f}", - "image_score": f"{hit['image_score']:.3f}", - "metadata_score": f"{hit['metadata_score']:.3f}", + "score": f"{hit['score']:.9f}", + "image_score": f"{hit['image_score']:.9f}", + "metadata_score": f"{hit['metadata_score']:.9f}", }] return results diff --git a/src/utils/constants.py b/src/utils/constants.py index 569c5bcb..84c3dfbb 100644 --- a/src/utils/constants.py +++ b/src/utils/constants.py @@ -30,7 +30,7 @@ default_config = { 'input-filter': None, 'embeddings-file': '~/.khoj/content/image/image_embeddings.pt', 'batch-size': 50, - 'use-xmp-metadata': True + 'use-xmp-metadata': False }, 'music': { 'input-files': None,