hjxdl 0.2.96__py3-none-any.whl → 0.2.98__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/desc/func_desc.py +15 -0
- hdl/utils/llm/chat.py +59 -11
- {hjxdl-0.2.96.dist-info → hjxdl-0.2.98.dist-info}/METADATA +2 -1
- {hjxdl-0.2.96.dist-info → hjxdl-0.2.98.dist-info}/RECORD +7 -7
- {hjxdl-0.2.96.dist-info → hjxdl-0.2.98.dist-info}/WHEEL +0 -0
- {hjxdl-0.2.96.dist-info → hjxdl-0.2.98.dist-info}/top_level.txt +0 -0
hdl/_version.py
CHANGED
hdl/utils/desc/func_desc.py
CHANGED
@@ -109,6 +109,21 @@ TOOL_DESC = {
|
|
109
109
|
"""
|
110
110
|
},
|
111
111
|
|
112
|
+
"object_detect": {
|
113
|
+
"desc": """
|
114
|
+
## 函数名:object_detect
|
115
|
+
描述:当用户要求识别图片中的目标位置时,调用此工具,给出具体位置信息。
|
116
|
+
参数 :
|
117
|
+
- image (str): 图片的路径或 url
|
118
|
+
返回值 (str): 图片中目标的位置信息(也可能含有带有标记的渲染图片路径)
|
119
|
+
""",
|
120
|
+
"md": """
|
121
|
+
需要返回的 markdown:
|
122
|
+
- function_name: object_detect
|
123
|
+
- image: <image_path>
|
124
|
+
"""
|
125
|
+
},
|
126
|
+
|
112
127
|
"default": None
|
113
128
|
|
114
129
|
}
|
hdl/utils/llm/chat.py
CHANGED
@@ -513,16 +513,7 @@ class OpenAI_M():
|
|
513
513
|
Returns:
|
514
514
|
str: The result of the tool.
|
515
515
|
"""
|
516
|
-
|
517
|
-
# prompt,
|
518
|
-
# **kwargs
|
519
|
-
# )
|
520
|
-
# try:
|
521
|
-
# decision_dict = parse_fn_markdown(decision_dict_str)
|
522
|
-
# # decision_dict = json.loads(decision_dict_str)
|
523
|
-
# except Exception as e:
|
524
|
-
# print(e)
|
525
|
-
# return ""
|
516
|
+
|
526
517
|
func_name = decision_dict.get("function_name", None)
|
527
518
|
if func_name is None:
|
528
519
|
return ""
|
@@ -532,6 +523,8 @@ class OpenAI_M():
|
|
532
523
|
if tool.__name__ == func_name:
|
533
524
|
tool_final = tool
|
534
525
|
func_kwargs = decision_dict.get("params")
|
526
|
+
if tool_final.__name__ == "object_detect":
|
527
|
+
func_kwargs["llm"] = self
|
535
528
|
return tool_final(**func_kwargs)
|
536
529
|
except Exception as e:
|
537
530
|
print(e)
|
@@ -695,4 +688,59 @@ class MMChatter():
|
|
695
688
|
else:
|
696
689
|
response = output.strip()
|
697
690
|
|
698
|
-
return response
|
691
|
+
return response
|
692
|
+
|
693
|
+
|
694
|
+
def object_detect(
|
695
|
+
image,
|
696
|
+
prompt: str = OD_TEMPLATE,
|
697
|
+
llm = None,
|
698
|
+
cli_dir: str = None,
|
699
|
+
model_dir: str = None,
|
700
|
+
mmproj_dir: str = None,
|
701
|
+
save_dir: str = None,
|
702
|
+
):
|
703
|
+
resp = ""
|
704
|
+
cli_dir = cli_dir if cli_dir is not None else os.getenv(
|
705
|
+
"MM_CLI_DIR",
|
706
|
+
None
|
707
|
+
)
|
708
|
+
if model_dir is None:
|
709
|
+
model_dir = os.getenv(
|
710
|
+
"MM_MODEL_DIR",
|
711
|
+
"/home/jhu/dev/models/MiniCPM-V-2_6-gguf/ggml-model-Q4_K_M.gguf"
|
712
|
+
)
|
713
|
+
if mmproj_dir is None:
|
714
|
+
mmproj_dir = os.getenv(
|
715
|
+
"MM_PROJ_DIR",
|
716
|
+
"/home/jhu/dev/models/MiniCPM-V-2_6-gguf/mmproj-model-f16.gguf"
|
717
|
+
)
|
718
|
+
if llm is None and cli_dir is None:
|
719
|
+
raise ValueError("Either 'llm' or 'cli_dir' must be provided.")
|
720
|
+
# mm_server = os.getenv("LLM_SERVER", "192.168.1.232")
|
721
|
+
# mm_port = int(os.getevn("LLM_PORT", 22299))
|
722
|
+
|
723
|
+
if cli_dir:
|
724
|
+
mm = MMChatter(
|
725
|
+
cli_dir=cli_dir,
|
726
|
+
model_dir=model_dir,
|
727
|
+
mmproj_dir=mmproj_dir
|
728
|
+
)
|
729
|
+
json_data = mm.get_resp(
|
730
|
+
prompt=prompt,
|
731
|
+
image=image
|
732
|
+
)
|
733
|
+
else:
|
734
|
+
json_data = llm.od(image)
|
735
|
+
_, save_dir = draw_and_plot_boxes_from_json(
|
736
|
+
json_data=json_data,
|
737
|
+
image=image,
|
738
|
+
save_path=save_dir
|
739
|
+
)
|
740
|
+
resp += "Detected objects are:\n"
|
741
|
+
resp += json_data
|
742
|
+
resp =+ "\n"
|
743
|
+
if save_dir:
|
744
|
+
resp += "Picture with marks were saved at:\n"
|
745
|
+
resp += save_dir
|
746
|
+
return resp
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: hjxdl
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.98
|
4
4
|
Summary: A collection of functions for Jupyter notebooks
|
5
5
|
Home-page: https://github.com/huluxiaohuowa/hdl
|
6
6
|
Author: Jianxing Hu
|
@@ -22,6 +22,7 @@ Requires-Dist: psycopg[binary]
|
|
22
22
|
Requires-Dist: Pillow
|
23
23
|
Requires-Dist: open_clip_torch
|
24
24
|
Requires-Dist: natsort
|
25
|
+
Requires-Dist: matplotlib
|
25
26
|
|
26
27
|
# DL framework by Jianxing
|
27
28
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
hdl/__init__.py,sha256=GffnD0jLJdhkd-vo989v40N90sQbofkayRBwxc6TVhQ,72
|
2
|
-
hdl/_version.py,sha256=
|
2
|
+
hdl/_version.py,sha256=rXnGuKlRz3b8ob_wArCKVOnw9u7jH84c8oNEr3jDE7I,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
|
@@ -122,13 +122,13 @@ hdl/utils/database_tools/connect.py,sha256=xCacGucKxlQUXs6AsNddpeECvdqT1180V1ZWq
|
|
122
122
|
hdl/utils/database_tools/datetime.py,sha256=xqE2xNiOpADzX-R8_bM0bioJRF3Ay9Jp1CAG6dy6uVI,1202
|
123
123
|
hdl/utils/database_tools/web.py,sha256=awJ8lafL-2KRjf3V1uuij8JIvX9U5fI8fLZKOkOvqtk,5771
|
124
124
|
hdl/utils/desc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
125
|
-
hdl/utils/desc/func_desc.py,sha256=
|
125
|
+
hdl/utils/desc/func_desc.py,sha256=sHmVZZmV7Zgii--gnHqMs6fTb7HVkqTOf8Pl_0F6qlI,3808
|
126
126
|
hdl/utils/desc/template.py,sha256=Kf_tbL-XkDCKNQ3UncbCuYEeUgXEa7kRVCf9TD2b8og,2526
|
127
127
|
hdl/utils/general/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
128
128
|
hdl/utils/general/glob.py,sha256=Zuf7WHU0UdUPOs9UrhxmrCiMC8GrHxQU6n3mTThv6yc,1120
|
129
129
|
hdl/utils/general/runners.py,sha256=x7QBolp3MrqNV6L4rB6Ueybr26bqkRFZTuXhY0SwyLk,3061
|
130
130
|
hdl/utils/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
131
|
-
hdl/utils/llm/chat.py,sha256=
|
131
|
+
hdl/utils/llm/chat.py,sha256=s0L9d_RFQzQoFdPwmPVcvQYMQhpcS-ZpflhBlhh3Qu4,26188
|
132
132
|
hdl/utils/llm/chatgr.py,sha256=5F5PJHe8vz3iCfi4TT54DCLRi1UeJshECdVtgvvvao0,3696
|
133
133
|
hdl/utils/llm/embs.py,sha256=Tf0FOYrOFZp7qQpEPiSCXzlgyHH0X9HVTUtsup74a9E,7174
|
134
134
|
hdl/utils/llm/extract.py,sha256=2sK_WJzmYIc8iuWaM9DA6Nw3_6q1O4lJ5pKpcZo-bBA,6512
|
@@ -139,7 +139,7 @@ hdl/utils/schedulers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
|
|
139
139
|
hdl/utils/schedulers/norm_lr.py,sha256=bDwCmdEK-WkgxQMFBiMuchv8Mm7C0-GZJ6usm-PQk14,4461
|
140
140
|
hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
141
141
|
hdl/utils/weather/weather.py,sha256=k11o6wM15kF8b9NMlEfrg68ak-SfSYLN3nOOflFUv-I,4381
|
142
|
-
hjxdl-0.2.
|
143
|
-
hjxdl-0.2.
|
144
|
-
hjxdl-0.2.
|
145
|
-
hjxdl-0.2.
|
142
|
+
hjxdl-0.2.98.dist-info/METADATA,sha256=Qrkdn1LusABXCpfUnTMiS8K-kVyjfEsI1XncnTme4nA,862
|
143
|
+
hjxdl-0.2.98.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
144
|
+
hjxdl-0.2.98.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
|
145
|
+
hjxdl-0.2.98.dist-info/RECORD,,
|
File without changes
|
File without changes
|