hjxdl 0.1.75__py3-none-any.whl → 0.1.76__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hdl/_version.py +2 -2
- hdl/utils/llm/vis.py +24 -9
- {hjxdl-0.1.75.dist-info → hjxdl-0.1.76.dist-info}/METADATA +1 -1
- {hjxdl-0.1.75.dist-info → hjxdl-0.1.76.dist-info}/RECORD +6 -6
- {hjxdl-0.1.75.dist-info → hjxdl-0.1.76.dist-info}/WHEEL +0 -0
- {hjxdl-0.1.75.dist-info → hjxdl-0.1.76.dist-info}/top_level.txt +0 -0
hdl/_version.py
CHANGED
hdl/utils/llm/vis.py
CHANGED
@@ -280,7 +280,8 @@ class ImgHandler:
|
|
280
280
|
def vec_pics_todb(
|
281
281
|
self,
|
282
282
|
images: list[str],
|
283
|
-
|
283
|
+
conn=None,
|
284
|
+
print_idx_info: bool = False,
|
284
285
|
):
|
285
286
|
"""Save image features to a Redis database.
|
286
287
|
|
@@ -296,7 +297,9 @@ class ImgHandler:
|
|
296
297
|
# sorted_imgs = natsort.natsorted(images)
|
297
298
|
sorted_imgs = images
|
298
299
|
img_feats = self.get_img_features(sorted_imgs, to_numpy=True)
|
299
|
-
|
300
|
+
if conn is None:
|
301
|
+
conn = self.db_conn
|
302
|
+
pipeline = conn.pipeline()
|
300
303
|
for img_file, emb in tqdm(zip(sorted_imgs, img_feats)):
|
301
304
|
# 初始化 Redis,先使用 img 文件名作为 Key 和 Value,后续再更新为图片特征向量
|
302
305
|
# pipeline.json().set(img_file, "$", img_file)
|
@@ -326,7 +329,7 @@ class ImgHandler:
|
|
326
329
|
prefix=["pic-"],
|
327
330
|
index_type=IndexType.JSON
|
328
331
|
)
|
329
|
-
res =
|
332
|
+
res = conn.ft(
|
330
333
|
self.pic_idx_name
|
331
334
|
).create_index(
|
332
335
|
fields=schema,
|
@@ -337,12 +340,17 @@ class ImgHandler:
|
|
337
340
|
print(self.pic_idx_info)
|
338
341
|
|
339
342
|
@property
|
340
|
-
def pic_idx_info(
|
341
|
-
|
343
|
+
def pic_idx_info(
|
344
|
+
self,
|
345
|
+
conn=None
|
346
|
+
):
|
347
|
+
if conn is None:
|
348
|
+
conn = self.db_conn
|
349
|
+
res = conn.ping()
|
342
350
|
print("redis connected:", res)
|
343
351
|
# vector_idx_name = "idx:pic_idx"
|
344
352
|
# 从 Redis 数据库中读取索引状态
|
345
|
-
info =
|
353
|
+
info = conn.ft(self.pic_idx_name).info()
|
346
354
|
# 获取索引状态中的 num_docs 和 hash_indexing_failures
|
347
355
|
num_docs = info["num_docs"]
|
348
356
|
indexing_failures = info["hash_indexing_failures"]
|
@@ -355,6 +363,7 @@ class ImgHandler:
|
|
355
363
|
emb_query,
|
356
364
|
num_max: int = 3,
|
357
365
|
extra_params: dict = None,
|
366
|
+
conn=None
|
358
367
|
):
|
359
368
|
"""Search for similar embeddings in the database.
|
360
369
|
|
@@ -376,8 +385,10 @@ class ImgHandler:
|
|
376
385
|
)
|
377
386
|
if extra_params is None:
|
378
387
|
extra_params = {}
|
388
|
+
if conn is None:
|
389
|
+
conn = self.db_conn
|
379
390
|
result_docs = (
|
380
|
-
|
391
|
+
conn.ft("idx:pic_idx")
|
381
392
|
.search(
|
382
393
|
query,
|
383
394
|
{
|
@@ -397,7 +408,8 @@ class ImgHandler:
|
|
397
408
|
self,
|
398
409
|
img,
|
399
410
|
num_max: int = 3,
|
400
|
-
extra_params: dict = None
|
411
|
+
extra_params: dict = None,
|
412
|
+
conn=None
|
401
413
|
):
|
402
414
|
"""Search for similar images in the database based on the input image.
|
403
415
|
|
@@ -412,10 +424,13 @@ class ImgHandler:
|
|
412
424
|
emb_query = self.get_img_features(
|
413
425
|
[img], to_numpy=True
|
414
426
|
).astype(np.float32)[0].tobytes()
|
427
|
+
if conn is None:
|
428
|
+
conn = self.db_conn
|
415
429
|
results = self.emb_search(
|
416
430
|
emb_query=emb_query,
|
417
431
|
num_max=num_max,
|
418
|
-
extra_params=extra_params
|
432
|
+
extra_params=extra_params,
|
433
|
+
conn=conn
|
419
434
|
)
|
420
435
|
return results
|
421
436
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
hdl/__init__.py,sha256=GffnD0jLJdhkd-vo989v40N90sQbofkayRBwxc6TVhQ,72
|
2
|
-
hdl/_version.py,sha256=
|
2
|
+
hdl/_version.py,sha256=XDO16ALCEfcHVQNkdeFRVlrPkVueFpt5S-psvPJP1Sc,413
|
3
3
|
hdl/args/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
hdl/args/loss_args.py,sha256=s7YzSdd7IjD24rZvvOrxLLFqMZQb9YylxKeyelSdrTk,70
|
5
5
|
hdl/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -131,12 +131,12 @@ hdl/utils/llm/chat.py,sha256=sk7Lw5Oa30k-l2fnJknkMmTc5zkBeEKsR981aeFhH5s,11907
|
|
131
131
|
hdl/utils/llm/embs.py,sha256=Tf0FOYrOFZp7qQpEPiSCXzlgyHH0X9HVTUtsup74a9E,7174
|
132
132
|
hdl/utils/llm/extract.py,sha256=2sK_WJzmYIc8iuWaM9DA6Nw3_6q1O4lJ5pKpcZo-bBA,6512
|
133
133
|
hdl/utils/llm/llama_chat.py,sha256=watcHGOaz-bv3x-yDucYlGk5f8FiqfFhwWogrl334fk,4387
|
134
|
-
hdl/utils/llm/vis.py,sha256=
|
134
|
+
hdl/utils/llm/vis.py,sha256=2s0U9wR9K1jSS8jtLGUliA4C_NGULoy5aayAxU6MN_o,14105
|
135
135
|
hdl/utils/schedulers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
136
136
|
hdl/utils/schedulers/norm_lr.py,sha256=bDwCmdEK-WkgxQMFBiMuchv8Mm7C0-GZJ6usm-PQk14,4461
|
137
137
|
hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
138
138
|
hdl/utils/weather/weather.py,sha256=k11o6wM15kF8b9NMlEfrg68ak-SfSYLN3nOOflFUv-I,4381
|
139
|
-
hjxdl-0.1.
|
140
|
-
hjxdl-0.1.
|
141
|
-
hjxdl-0.1.
|
142
|
-
hjxdl-0.1.
|
139
|
+
hjxdl-0.1.76.dist-info/METADATA,sha256=ff40qi9oE0kcWS2gSj0I3aHbaQZOEp64U3hCAZoekQs,903
|
140
|
+
hjxdl-0.1.76.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
141
|
+
hjxdl-0.1.76.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
|
142
|
+
hjxdl-0.1.76.dist-info/RECORD,,
|
File without changes
|
File without changes
|