This commit is contained in:
2026-03-07 11:37:37 -05:00
parent aa5ad8327e
commit 32f63fe43b
32 changed files with 2470 additions and 328 deletions

BIN
SearchScratch/out.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 KiB

View File

@@ -0,0 +1,40 @@
from pprint import pprint
import pickle
import os
with open('/home/thebears/Web/Nuggets/SearchInterface/SearchBackend/crap.p','rb') as ff:
cc = pickle.load(ff)
tstamp, folder_scores = cc[1],cc[0]
for i in range(100):
target_tstamp = tstamp + i
matching_file = None
next_file = None
for video_file in folder_scores['videos']:
start_time = video_file['start_time']
end_time = video_file['end_time']
if target_tstamp > start_time and target_tstamp < end_time:
matching_file = video_file
if start_time > target_tstamp and next_file is None:
next_file = video_file
if matching_file is not None:
fname = matching_file['file_name']
offset = target_tstamp - matching_file['start_time']
else:
fname = 'None Found'
offset = -1
if next_file is not None:
fname = next_file['file_name']
offset = 0
web_name = 'media/'+os.path.basename(fname)
ret_val = dict(full_path = fname, path=web_name, timeoffset = offset)
pprint(ret_val)
pprint('-----------------------------------')

View File

@@ -0,0 +1,65 @@
import sys, os
sys.path.append("/home/thebears/Web/Nuggets/SearchInterface/SearchUtil")
sys.path.append("/home/thebears/Web/Nuggets/SearchInterface/VectorService/util")
import embed_scores as ES
import numpy as np
import time
from CommonCode import kwq
# %%
from CommonCode.video_meta import FTPVide
o
video_path = '/home/thebears/temp/dog.mp4'
prompt = 'hello'
video_embeds = ES.get_embeddings_for_a_file(video_path)
prompt_embeds = ES.get_query_vector(prompt)
video_norm_embeds = FTPVideo.vec_norm(video_embeds['embeds'])
prompt_norm_embed = FTPVideo.vec_norm(prompt_embeds)
scores = np.dot(video_norm_embeds, prompt_norm_embed.T).squeeze().tolist()
ff = FTPVideo(file_path, ignore_filename = True)
res = ff.embeddings
results = np.asarray([res['frame_offsets'], scores])
results.T.tolist()
# %%
def get_embed_cache_file_search_path(file_path):
return os.path.splitext(file_path)[0]+'.oclip_embeds.npz'
file_search_path = get_embed_cache_file_search_path(file_path)
force_score = False
llvec = None
if os.path.exists(file_search_path):
llvec = np.load(file_search_path)
frs = llvec['frame_numbers']
if set(np.unique(np.diff(frs))) != {1}:
force_score = True
llvec = None
if not os.path.exists(file_search_path) or force_score:
kwq.publish(kwq.TOPICS.enter_60_videos_embed_priority, file_path, {'push_to_db':False, 'frame_interval':1, 'force_score':force_score})
if llvec is None:
for i in range(120):
print('waiting')
if os.path.exists(file_search_path):
print('Found embedding path!')
llvec = np.load(file_search_path)
break
else:
time.sleep(1)

View File

@@ -2,8 +2,11 @@ import sys, os
sys.path.append("/home/thebears/Web/Nuggets/SearchInterface/SearchUtil")
sys.path.append("/home/thebears/Web/Nuggets/SearchInterface/VectorService/util")
import embed_scores as ES
cd = '/srv/ftp_tcc/leopards1/2025/09/13/'
# %%
#cd = '/srv/ftp_tcc/leopards1/2025/09/25/'
cd = '/mnt/hdd_24tb_1/videos/ftp/leopards1/2025/09/24'
xx = ES.get_vector_representation(cd)
g
o = ES.calculate_embedding_score_in_folder(cd, 0.1, query='Two cats');
# %%
@@ -11,3 +14,15 @@ from CommonCode.video_meta import FTPVideo
f='/srv/ftp_tcc/leopards1/2025/09/13/Leopards1_00_20250913135952.mp4'
c = FTPVideo(f)
c.embeddings
# %%
cd = '/srv/ftp_tcc/leopards1/2025/08/15'
o = ES.calculate_embedding_score_in_folder(cd, 0.1, query='Two cats');
# %%
cd = '/srv/ftp_tcc/leopards1/2025/10/01'
vecreo = ES.get_vector_representation(cd, force_compute = True)
print(vecreo)
# %%
o = ES.calculate_embedding_score_in_folder(cd, 0.1, query='Two cats');
# %%