hjxdl 0.1.63__py3-none-any.whl → 0.1.65__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 +38 -26
- {hjxdl-0.1.63.dist-info → hjxdl-0.1.65.dist-info}/METADATA +1 -1
- {hjxdl-0.1.63.dist-info → hjxdl-0.1.65.dist-info}/RECORD +6 -6
- {hjxdl-0.1.63.dist-info → hjxdl-0.1.65.dist-info}/WHEEL +0 -0
- {hjxdl-0.1.63.dist-info → hjxdl-0.1.65.dist-info}/top_level.txt +0 -0
hdl/_version.py
CHANGED
hdl/utils/llm/vis.py
CHANGED
@@ -20,27 +20,43 @@ class ImgHandler:
|
|
20
20
|
def __init__(
|
21
21
|
self,
|
22
22
|
model_path,
|
23
|
-
|
24
|
-
|
23
|
+
db_host,
|
24
|
+
db_port,
|
25
25
|
model_name: str = None,
|
26
|
-
device: str =
|
26
|
+
device: str = "cpu",
|
27
|
+
num_vec_dim: int = None,
|
28
|
+
load_model: bool = True,
|
27
29
|
) -> None:
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
|
31
|
+
self.device = torch.device(device)
|
32
|
+
self.model_path = model_path
|
33
|
+
self.model_name = model_name
|
34
|
+
|
35
|
+
self.db_host = db_host
|
36
|
+
self.db_port = db_port
|
37
|
+
self._db_conn = None
|
38
|
+
self.num_vec_dim = num_vec_dim
|
39
|
+
if load_model:
|
40
|
+
self.load_model()
|
41
|
+
|
42
|
+
def load_model(self):
|
43
|
+
"""Load the OpenCLIP model and related configurations.
|
44
|
+
|
45
|
+
This function loads the OpenCLIP model from the specified model path
|
46
|
+
and initializes the necessary components such as the model,
|
47
|
+
preprocessors for training and validation data, tokenizer, etc.
|
48
|
+
|
49
|
+
Returns:
|
50
|
+
None
|
51
|
+
"""
|
34
52
|
ckpt_file = (
|
35
|
-
Path(model_path) / Path("open_clip_pytorch_model.bin")
|
53
|
+
Path(self.model_path) / Path("open_clip_pytorch_model.bin")
|
36
54
|
).as_posix()
|
37
|
-
|
38
55
|
self.open_clip_cfg = json.load(
|
39
|
-
open(Path(model_path) / Path("open_clip_config.json"))
|
56
|
+
open(Path(self.model_path) / Path("open_clip_config.json"))
|
40
57
|
)
|
41
|
-
|
42
|
-
|
43
|
-
else:
|
58
|
+
|
59
|
+
if self.model_name is None:
|
44
60
|
self.model_name = (
|
45
61
|
self.open_clip_cfg['model_cfg']['text_cfg']['hf_tokenizer_name']
|
46
62
|
.split('/')[-1]
|
@@ -54,26 +70,22 @@ class ImgHandler:
|
|
54
70
|
# precision=precision
|
55
71
|
)
|
56
72
|
)
|
73
|
+
if self.num_vec_dim is None:
|
74
|
+
self.num_vec_dim = self.open_clip_cfg["model_cfg"]["embed_dim"]
|
57
75
|
self.tokenizer = open_clip.get_tokenizer(
|
58
|
-
HF_HUB_PREFIX + model_path
|
76
|
+
HF_HUB_PREFIX + self.model_path
|
59
77
|
)
|
60
|
-
# self.model = ChineseCLIPModel.from_pretrained(model_path).to(self.device)
|
61
|
-
# self.processor = ChineseCLIPProcessor.from_pretrained(model_path)
|
62
|
-
self.redis_host = redis_host
|
63
|
-
self.redis_port = redis_port
|
64
|
-
self._redis_conn = None
|
65
|
-
|
66
78
|
|
67
79
|
@property
|
68
|
-
def
|
80
|
+
def db_conn(self):
|
69
81
|
"""Establishes a connection to Redis server if not already connected.
|
70
82
|
|
71
83
|
Returns:
|
72
84
|
Redis connection object: A connection to the Redis server.
|
73
85
|
"""
|
74
|
-
if self.
|
75
|
-
self.
|
76
|
-
return self.
|
86
|
+
if self._db_conn is None:
|
87
|
+
self._db_conn = conn_redis(self.db_host, self.db_port)
|
88
|
+
return self._db_conn
|
77
89
|
|
78
90
|
def get_img_features(
|
79
91
|
self,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
hdl/__init__.py,sha256=GffnD0jLJdhkd-vo989v40N90sQbofkayRBwxc6TVhQ,72
|
2
|
-
hdl/_version.py,sha256=
|
2
|
+
hdl/_version.py,sha256=dWes_pejilDszHY1ei6MxbFy7H_tVhepnPnoJG50ueY,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=4bIzsCAOlkIscc_u6j2NkyV30_uGb6hMEhs3QGSUvj0,6736
|
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.65.dist-info/METADATA,sha256=lXWFTci94OQLioRQkmta01nK-cK_zZBsqPxFBr2Aa6E,880
|
140
|
+
hjxdl-0.1.65.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
141
|
+
hjxdl-0.1.65.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
|
142
|
+
hjxdl-0.1.65.dist-info/RECORD,,
|
File without changes
|
File without changes
|