Move Khoj image results into a child images/ directory

This commit is contained in:
Debanjum Singh Solanky 2022-07-28 20:45:12 +04:00
parent a71253e137
commit a12eaa4ce0
3 changed files with 5 additions and 5 deletions

View file

@ -117,7 +117,7 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Opti
# query images
query_start = time.time()
hits = image_search.query(user_query, results_count, model.image_search)
output_directory = f'{os.getcwd()}/{web_directory}'
output_directory = f'{os.getcwd()}/{web_directory}/images'
query_end = time.time()
# collate and return results
@ -126,7 +126,7 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Opti
hits,
image_names=model.image_search.image_names,
output_directory=output_directory,
static_files_url='/static',
image_files_url='/static/images',
count=results_count)
collate_end = time.time()

View file

@ -181,7 +181,7 @@ def render_results(hits, image_names, image_directory, count):
img.show()
def collate_results(hits, image_names, output_directory, static_files_url, count=5):
def collate_results(hits, image_names, output_directory, image_files_url, count=5):
results = []
for index, hit in enumerate(hits[:count]):
@ -195,7 +195,7 @@ def collate_results(hits, image_names, output_directory, static_files_url, count
# Add the image metadata to the results
results += [{
"entry": f'{static_files_url}/{target_image_name}',
"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}",

View file

@ -45,7 +45,7 @@ def test_image_search(content_config: ContentConfig, search_config: SearchConfig
hits,
model.image_search.image_names,
output_directory=output_directory,
static_files_url='/static',
image_files_url='/static/images',
count=1)
actual_image = Image.open(output_directory.joinpath(Path(results[0]["entry"]).name))