bump
This commit is contained in:
+24
-23
@@ -8,51 +8,54 @@ import traceback
|
||||
from bottle import route, run, template, request, debug
|
||||
import time
|
||||
import prettyprinter
|
||||
# %%
|
||||
|
||||
TIMEOUT=2
|
||||
# %%
|
||||
TIMEOUT=10
|
||||
|
||||
#collection_name = "nuggets_{camera}_so400m_siglip2"
|
||||
collection_name = "nuggets_{camera}_so400m"
|
||||
|
||||
collection_name = "nuggets_{camera}_so400m_siglip2"
|
||||
client = MilvusClient(
|
||||
uri="http://localhost:19530"
|
||||
)
|
||||
# %%
|
||||
|
||||
|
||||
|
||||
from bottle import route, run, template
|
||||
|
||||
|
||||
@route('/get_collection_count')
|
||||
def get_collection_count():
|
||||
coll_count = dict()
|
||||
for c in sorted(client.list_collections()):
|
||||
coll_count[c] = client.get_collection_stats(c)['row_count']
|
||||
return coll_count
|
||||
|
||||
|
||||
@route('/get_text_match')
|
||||
def get_matches():
|
||||
# %%
|
||||
valid_cameras = {'sidefeeder','ptz','railing','hummingbird','pond'}
|
||||
query = request.query.get('query','A large bird eating corn')
|
||||
cameras = request.query.get('cameras','sidefeeder')
|
||||
num_videos = int(request.query.get('num_videos',5))
|
||||
|
||||
cams = set(cameras.split(',')).intersection(valid_cameras)
|
||||
|
||||
cams = set(cameras.split(","))
|
||||
max_age = int(request.query.get('age',5));
|
||||
print({'Cameras':cams,'Max Age':max_age,'Query':query})
|
||||
max_date = datetime.now()
|
||||
min_date = max_date - timedelta(days=(max_age))
|
||||
min_date = max_date - timedelta(days=(max_age-1))
|
||||
days_step = (max_date- min_date).days
|
||||
day_strs = list()
|
||||
# %%
|
||||
for x in range(days_step):
|
||||
# pass
|
||||
day_strs.append( (min_date + timedelta(days=x)).strftime('%Y%m%d') )
|
||||
# if days_step > 0:
|
||||
# day_strs.append( (min_date + timedelta(days=0)).strftime('%Y%m%d') )
|
||||
|
||||
day_strs.append( max_date.strftime('%Y%m%d'))
|
||||
str_insert = ','.join([f'"{x}"'for x in day_strs])
|
||||
filter_string = 'date in [' + str_insert + ']'
|
||||
|
||||
if max_age == 0:
|
||||
filter_string = ''
|
||||
# %%
|
||||
vec_form = requests.get('http://192.168.1.242:53004/encode',params={'query':query}).json()['vector'][0]
|
||||
vec_search = np.asarray(vec_form).astype(np.float16)
|
||||
|
||||
|
||||
print(f'Doing query for {query}!')
|
||||
print('Filter string:',filter_string)
|
||||
all_results=list()
|
||||
try:
|
||||
error = ''
|
||||
@@ -73,11 +76,10 @@ def get_matches():
|
||||
all_results.extend(results[0])
|
||||
|
||||
except Exception as e:
|
||||
print(traceback.format_exc())
|
||||
error = traceback.format_exc()
|
||||
print(error)
|
||||
results = []
|
||||
|
||||
# %%
|
||||
|
||||
def linux_to_win_path(form):
|
||||
form = form.replace('/srv','file://192.168.1.242/thebears/Videos/merged/')
|
||||
return form
|
||||
@@ -96,9 +98,8 @@ def get_matches():
|
||||
pload['winpath'] = linux_to_win_path(pload['filepath'])
|
||||
pload['frame'] = pload['frame_number']
|
||||
resul.append(pload)
|
||||
# %%
|
||||
|
||||
return_this = {'query':query,'num_videos':num_videos,'results':resul,'error':error}
|
||||
prettyprinter.pprint(return_this)
|
||||
return return_this
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user