Ease access to image result for given query by image_search

- Copy images to accessible directory
- Return URL paths to them to ease access
- This is to be used in the web interface to render image results
  directly in browser
- Return image, metadata scores for each image in response as well
  This should help get a better sense of image scores along both
  XMP metadata and whole image axis
This commit is contained in:
Debanjum Singh Solanky
2022-07-15 23:20:19 +04:00
parent 801e59a20d
commit 4e27ae0577
2 changed files with 44 additions and 14 deletions

View File

@@ -82,13 +82,16 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None):
if (t == SearchType.Image or t == None) and model.image_search:
# query transactions
hits = image_search.query(user_query, results_count, model.image_search)
output_directory = f'{os.getcwd()}/{web_directory}'
# collate and return results
return image_search.collate_results(
hits,
model.image_search.image_names,
config.content_type.image.input_directory,
results_count)
image_names=model.image_search.image_names,
image_directory=config.content_type.image.input_directory,
output_directory=output_directory,
static_files_url='/static',
count=results_count)
else:
return {}