Spaces:
Runtime error
Runtime error
Fangrui Liu
commited on
Commit
•
0921a90
1
Parent(s):
0fc1cb9
upgrade to latest myscale saas
Browse files- query_model.py +5 -5
query_model.py
CHANGED
@@ -19,10 +19,10 @@ def topk_obj_query(client, xq, IMG_DB_NAME, OBJ_DB_NAME,
|
|
19 |
FROM {OBJ_DB_NAME}
|
20 |
JOIN {IMG_DB_NAME}
|
21 |
ON {IMG_DB_NAME}.img_id = {OBJ_DB_NAME}.img_id
|
22 |
-
|
23 |
SELECT obj_id FROM (
|
24 |
-
SELECT obj_id, distance(
|
25 |
-
ORDER BY dist DESC
|
26 |
) {_cond} LIMIT 10
|
27 |
)
|
28 |
""")
|
@@ -88,11 +88,11 @@ def simple_query(client, xq, IMG_DB_NAME, OBJ_DB_NAME, thresh=0.08, topk=10):
|
|
88 |
subq_str.append(
|
89 |
f"""
|
90 |
SELECT {OBJ_DB_NAME}.img_id AS img_id, img_url, img_w, img_h, prelogit,
|
91 |
-
obj_id, box_cx, box_cy, box_w, box_h, {_l} AS l, distance(
|
92 |
FROM {OBJ_DB_NAME}
|
93 |
JOIN {IMG_DB_NAME}
|
94 |
ON {IMG_DB_NAME}.img_id = {OBJ_DB_NAME}.img_id
|
95 |
-
{_thresh} LIMIT
|
96 |
""")
|
97 |
subq_str = " UNION ALL ".join(subq_str)
|
98 |
q_str = f"""
|
|
|
19 |
FROM {OBJ_DB_NAME}
|
20 |
JOIN {IMG_DB_NAME}
|
21 |
ON {IMG_DB_NAME}.img_id = {OBJ_DB_NAME}.img_id
|
22 |
+
WHERE obj_id IN (
|
23 |
SELECT obj_id FROM (
|
24 |
+
SELECT obj_id, distance(prelogit, {_xq}) AS dist FROM {OBJ_DB_NAME}
|
25 |
+
ORDER BY dist DESC LIMIT {topk}
|
26 |
) {_cond} LIMIT 10
|
27 |
)
|
28 |
""")
|
|
|
88 |
subq_str.append(
|
89 |
f"""
|
90 |
SELECT {OBJ_DB_NAME}.img_id AS img_id, img_url, img_w, img_h, prelogit,
|
91 |
+
obj_id, box_cx, box_cy, box_w, box_h, {_l} AS l, distance(prelogit, {_xq}) AS dist
|
92 |
FROM {OBJ_DB_NAME}
|
93 |
JOIN {IMG_DB_NAME}
|
94 |
ON {IMG_DB_NAME}.img_id = {OBJ_DB_NAME}.img_id
|
95 |
+
{_thresh} LIMIT {topk}
|
96 |
""")
|
97 |
subq_str = " UNION ALL ".join(subq_str)
|
98 |
q_str = f"""
|