hjxdl 0.1.70__py3-none-any.whl → 0.1.72__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 CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.1.70'
16
- __version_tuple__ = version_tuple = (0, 1, 70)
15
+ __version__ = version = '0.1.72'
16
+ __version_tuple__ = version_tuple = (0, 1, 72)
hdl/utils/llm/vis.py CHANGED
@@ -68,6 +68,20 @@ class ImgHandler:
68
68
  num_vec_dim: int = None,
69
69
  load_model: bool = True,
70
70
  ) -> None:
71
+ """Initializes the class with the provided parameters.
72
+
73
+ Args:
74
+ model_path (str): Path to the model file.
75
+ db_host (str): Hostname of the database.
76
+ db_port (int): Port number of the database.
77
+ model_name (str, optional): Name of the model. Defaults to None.
78
+ device (str, optional): Device to run the model on. Defaults to "cpu".
79
+ num_vec_dim (int, optional): Number of vector dimensions. Defaults to None.
80
+ load_model (bool, optional): Whether to load the model. Defaults to True.
81
+
82
+ Returns:
83
+ None
84
+ """
71
85
 
72
86
  self.device = torch.device(device)
73
87
  self.model_path = model_path
@@ -333,25 +347,22 @@ class ImgHandler:
333
347
  f"{num_docs} documents indexed with {indexing_failures} failures"
334
348
  )
335
349
 
336
- def img_search(
350
+ def emb_search(
337
351
  self,
338
- img,
352
+ emb_query,
339
353
  num_max: int = 3,
340
- extra_params: dict = None
354
+ extra_params: dict = None,
341
355
  ):
342
- """Search for similar images in the database based on the input image.
356
+ """Search for similar embeddings in the database.
343
357
 
344
358
  Args:
345
- img: Input image to search for similar images.
346
- num_max: Maximum number of similar images to return (default is 3).
347
- extra_params: Additional parameters to include in the search query (default is None).
359
+ emb_query (str): The embedding query to search for.
360
+ num_max (int, optional): The maximum number of results to return. Defaults to 3.
361
+ extra_params (dict, optional): Extra parameters to include in the search query. Defaults to None.
348
362
 
349
363
  Returns:
350
- List of tuples containing the ID and JSON data of similar images found in the database.
364
+ list: A list of tuples containing the document ID and JSON data for each result.
351
365
  """
352
- emb_query = self.get_img_features(
353
- [img], to_numpy=True
354
- ).astype(np.float32)[0].tobytes()
355
366
  query = (
356
367
  Query(
357
368
  f"(*)=>[KNN {str(num_max)} @vector $query_vector AS vector_score]"
@@ -379,5 +390,31 @@ class ImgHandler:
379
390
  ]
380
391
  return results
381
392
 
393
+ def img_search(
394
+ self,
395
+ img,
396
+ num_max: int = 3,
397
+ extra_params: dict = None
398
+ ):
399
+ """Search for similar images in the database based on the input image.
400
+
401
+ Args:
402
+ img: Input image to search for similar images.
403
+ num_max: Maximum number of similar images to return (default is 3).
404
+ extra_params: Additional parameters to include in the search query (default is None).
405
+
406
+ Returns:
407
+ List of tuples containing the ID and JSON data of similar images found in the database.
408
+ """
409
+ emb_query = self.get_img_features(
410
+ [img], to_numpy=True
411
+ ).astype(np.float32)[0].tobytes()
412
+ results = self.emb_search(
413
+ emb_query=emb_query,
414
+ num_max=num_max,
415
+ extra_params=extra_params
416
+ )
417
+ return results
418
+
382
419
 
383
420
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hjxdl
3
- Version: 0.1.70
3
+ Version: 0.1.72
4
4
  Summary: A collection of functions for Jupyter notebooks
5
5
  Home-page: https://github.com/huluxiaohuowa/hdl
6
6
  Author: Jianxing Hu
@@ -1,5 +1,5 @@
1
1
  hdl/__init__.py,sha256=GffnD0jLJdhkd-vo989v40N90sQbofkayRBwxc6TVhQ,72
2
- hdl/_version.py,sha256=AYQNyn783xY6psbpqi7TYW2XK3FmuvjMGND0tFVkkvI,413
2
+ hdl/_version.py,sha256=q-ohSPg6hCd49ZCMCxd2sZVRKz5Qcktg4XZBuNdmSsI,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=8rzJMMmVpMibUvfvGfjwFwWE5xrhZM1pjkwbe5fgmNQ,12352
134
+ hdl/utils/llm/vis.py,sha256=h9zzDP9ADczxvejUlmLGWNjcdRiMS6FZ_PE29oD0SYc,13727
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.70.dist-info/METADATA,sha256=A7kOeOkBy4YNzlalYPnyGE3yCkKoy8xcautLlDF0pkk,903
140
- hjxdl-0.1.70.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
141
- hjxdl-0.1.70.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
142
- hjxdl-0.1.70.dist-info/RECORD,,
139
+ hjxdl-0.1.72.dist-info/METADATA,sha256=wf1HP93Pswqr4_il3n7dWz38gDdkOPEIluEpQdZSAOY,903
140
+ hjxdl-0.1.72.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
141
+ hjxdl-0.1.72.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
142
+ hjxdl-0.1.72.dist-info/RECORD,,
File without changes