hjxdl 0.1.75__py3-none-any.whl → 0.1.77__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 -10
- {hjxdl-0.1.75.dist-info → hjxdl-0.1.77.dist-info}/METADATA +1 -1
- {hjxdl-0.1.75.dist-info → hjxdl-0.1.77.dist-info}/RECORD +6 -6
- {hjxdl-0.1.75.dist-info → hjxdl-0.1.77.dist-info}/WHEEL +0 -0
- {hjxdl-0.1.75.dist-info → hjxdl-0.1.77.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,
|
@@ -336,13 +339,17 @@ class ImgHandler:
|
|
336
339
|
if print_idx_info:
|
337
340
|
print(self.pic_idx_info)
|
338
341
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
+
def get_pic_idx_info(
|
343
|
+
self,
|
344
|
+
conn=None
|
345
|
+
):
|
346
|
+
if conn is None:
|
347
|
+
conn = self.db_conn
|
348
|
+
res = conn.ping()
|
342
349
|
print("redis connected:", res)
|
343
350
|
# vector_idx_name = "idx:pic_idx"
|
344
351
|
# 从 Redis 数据库中读取索引状态
|
345
|
-
info =
|
352
|
+
info = conn.ft(self.pic_idx_name).info()
|
346
353
|
# 获取索引状态中的 num_docs 和 hash_indexing_failures
|
347
354
|
num_docs = info["num_docs"]
|
348
355
|
indexing_failures = info["hash_indexing_failures"]
|
@@ -355,6 +362,7 @@ class ImgHandler:
|
|
355
362
|
emb_query,
|
356
363
|
num_max: int = 3,
|
357
364
|
extra_params: dict = None,
|
365
|
+
conn=None
|
358
366
|
):
|
359
367
|
"""Search for similar embeddings in the database.
|
360
368
|
|
@@ -376,8 +384,10 @@ class ImgHandler:
|
|
376
384
|
)
|
377
385
|
if extra_params is None:
|
378
386
|
extra_params = {}
|
387
|
+
if conn is None:
|
388
|
+
conn = self.db_conn
|
379
389
|
result_docs = (
|
380
|
-
|
390
|
+
conn.ft("idx:pic_idx")
|
381
391
|
.search(
|
382
392
|
query,
|
383
393
|
{
|
@@ -397,7 +407,8 @@ class ImgHandler:
|
|
397
407
|
self,
|
398
408
|
img,
|
399
409
|
num_max: int = 3,
|
400
|
-
extra_params: dict = None
|
410
|
+
extra_params: dict = None,
|
411
|
+
conn=None
|
401
412
|
):
|
402
413
|
"""Search for similar images in the database based on the input image.
|
403
414
|
|
@@ -412,10 +423,13 @@ class ImgHandler:
|
|
412
423
|
emb_query = self.get_img_features(
|
413
424
|
[img], to_numpy=True
|
414
425
|
).astype(np.float32)[0].tobytes()
|
426
|
+
if conn is None:
|
427
|
+
conn = self.db_conn
|
415
428
|
results = self.emb_search(
|
416
429
|
emb_query=emb_query,
|
417
430
|
num_max=num_max,
|
418
|
-
extra_params=extra_params
|
431
|
+
extra_params=extra_params,
|
432
|
+
conn=conn
|
419
433
|
)
|
420
434
|
return results
|
421
435
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
hdl/__init__.py,sha256=GffnD0jLJdhkd-vo989v40N90sQbofkayRBwxc6TVhQ,72
|
2
|
-
hdl/_version.py,sha256=
|
2
|
+
hdl/_version.py,sha256=pR69cAAhBeiBIiq1R2ZPiBkmG1Vpk9Y8EREnxa0bNng,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=Ic93BK7AlXnp0mjkiyI62L5tIrYqdDPI6ER_YQXd38g,14095
|
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.77.dist-info/METADATA,sha256=RFpKc78NCBvxs-GYSupQRem_h-0SNtZSxq7s0m4VaCk,903
|
140
|
+
hjxdl-0.1.77.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
141
|
+
hjxdl-0.1.77.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
|
142
|
+
hjxdl-0.1.77.dist-info/RECORD,,
|
File without changes
|
File without changes
|