Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Fixing similar context issues as #700 #702

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions cross-modal-search/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,29 @@ def evaluation_generator(num_docs=None, batch_size=8, dataset_type='f8k', mode='
for image, caption in zip(images, captions):
hashed = hashlib.sha1(image).hexdigest()
if mode == 'text2image':
with Document() as document:
document.text = caption
document.modality = 'text'
document.mime_type = 'text/plain'
document.tags['id'] = hashed
with Document() as gt:
match = Document()
match.tags['id'] = hashed
gt.matches.append(match)
document = Document()
document.text = caption
document.modality = 'text'
document.mime_type = 'text/plain'
document.tags['id'] = hashed

gt = Document()
match = Document()
match.tags['id'] = hashed
gt.matches.append(match)
yield document, gt
elif mode == 'image2text':
with Document() as document:
document.buffer = image
document.modality = 'image'
document.mime_type = 'image/jpeg'
document.tags['id'] = hashed
document.convert_buffer_to_uri()
with Document() as gt:
match = Document()
match.tags['id'] = caption
gt.matches.append(match)
document = Document()
document.buffer = image
document.modality = 'image'
document.mime_type = 'image/jpeg'
document.tags['id'] = hashed
document.convert_buffer_to_uri()

gt = Document()
match = Document()
match.tags['id'] = caption
gt.matches.append(match)
yield document, gt
else:
msg = f'Not supported mode {mode}.'
Expand Down