mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Move Khoj image results into a child images/ directory
This commit is contained in:
parent
a71253e137
commit
a12eaa4ce0
3 changed files with 5 additions and 5 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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}",
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue