Spaces:
Runtime error
Runtime error
yiyixuxu
commited on
Commit
·
78a010b
1
Parent(s):
5f4ce2c
app.py
CHANGED
@@ -129,7 +129,7 @@ def run_inference(url, sampling_interval, search_query, bs=256):
|
|
129 |
bs = min(n_frames,bs)
|
130 |
print(f"extracted {n_frames} frames, now encoding images")
|
131 |
# encoding images one batch at a time, combine all batch outputs -> image_features, size n_frames x 512
|
132 |
-
image_features = torch.empty(size=(n_frames, 512)
|
133 |
print(f"batch size :{bs} ; number of batches: {len(range(0, n_frames,bs))}")
|
134 |
for b in range(0, n_frames,bs):
|
135 |
images = []
|
@@ -148,7 +148,7 @@ def run_inference(url, sampling_interval, search_query, bs=256):
|
|
148 |
with torch.no_grad():
|
149 |
text_features = model.encode_text(clip.tokenize(search_query).to(device))
|
150 |
text_features /= text_features.norm(dim=-1, keepdim=True)
|
151 |
-
|
152 |
similarity = (100.0 * image_features @ text_features.T)
|
153 |
values, indices = similarity.topk(4, dim=0)
|
154 |
|
|
|
129 |
bs = min(n_frames,bs)
|
130 |
print(f"extracted {n_frames} frames, now encoding images")
|
131 |
# encoding images one batch at a time, combine all batch outputs -> image_features, size n_frames x 512
|
132 |
+
image_features = torch.empty(size=(n_frames, 512).to(device)
|
133 |
print(f"batch size :{bs} ; number of batches: {len(range(0, n_frames,bs))}")
|
134 |
for b in range(0, n_frames,bs):
|
135 |
images = []
|
|
|
148 |
with torch.no_grad():
|
149 |
text_features = model.encode_text(clip.tokenize(search_query).to(device))
|
150 |
text_features /= text_features.norm(dim=-1, keepdim=True)
|
151 |
+
print(image_features.dtype, text_features.dtype)
|
152 |
similarity = (100.0 * image_features @ text_features.T)
|
153 |
values, indices = similarity.topk(4, dim=0)
|
154 |
|