Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blip2 #2

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Update blip2.py
lenguyen2592004 authored Aug 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 284fb46cd79af91e363c103c20a1b9c72e90904a
4 changes: 2 additions & 2 deletions image_retrieval/blip2.py
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ def subimage_score_embedding(image, text):
image_inputs = processor(images=image, return_tensors="pt")
image_input = model.get_image_features(**image_inputs).cuda(device)
text_inputs = tokenizer(caption, padding=True, return_tensors="pt")
text_input= = model.get_text_features(**text_inputs).cuda(device)
text_input = model.get_text_features(**text_inputs).cuda(device)
with torch.no_grad():
original_image_embed = image_input.float()
original_text_embed = text_input.float()
@@ -51,7 +51,7 @@ def comclip_one_pair(row_id, caption, image_id):
image_inputs = processor(images=image, return_tensors="pt")
image_input = model.get_image_features(**image_inputs).cuda(device)
text_inputs = tokenizer(caption, padding=True, return_tensors="pt")
text_input= = model.get_text_features(**text_inputs).cuda(device)
text_input = model.get_text_features(**text_inputs).cuda(device)
with torch.no_grad():
original_image_embed = image_input.float()
original_text_embed = text_input.float()