cmdbox 0.6.4.2__py3-none-any.whl → 0.6.6__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.

Potentially problematic release.


This version of cmdbox might be problematic. Click here for more details.

Files changed (140) hide show
  1. cmdbox/app/app.py +7 -0
  2. cmdbox/app/client.py +384 -383
  3. cmdbox/app/common.py +85 -7
  4. cmdbox/app/commons/convert.py +3 -1
  5. cmdbox/app/edge.py +12 -12
  6. cmdbox/app/feature.py +1 -1
  7. cmdbox/app/features/cli/{cmdbox_vision_install.py → _cmdbox_vision_install.py} +2 -10
  8. cmdbox/app/features/cli/_cmdbox_vision_predict.py +487 -0
  9. cmdbox/app/features/cli/{cmdbox_vision_start.py → _cmdbox_vision_start.py} +5 -1
  10. cmdbox/app/features/cli/cmdbox_audit_createdb.py +1 -11
  11. cmdbox/app/features/cli/cmdbox_audit_delete.py +0 -9
  12. cmdbox/app/features/cli/cmdbox_audit_search.py +0 -9
  13. cmdbox/app/features/cli/cmdbox_audit_write.py +0 -9
  14. cmdbox/app/features/cli/cmdbox_cmd_list.py +3 -3
  15. cmdbox/app/features/cli/cmdbox_cmd_load.py +3 -3
  16. cmdbox/app/features/cli/cmdbox_excel_cell_details.py +436 -0
  17. cmdbox/app/features/cli/cmdbox_excel_cell_search.py +276 -0
  18. cmdbox/app/features/cli/cmdbox_excel_cell_values.py +258 -0
  19. cmdbox/app/features/cli/cmdbox_excel_sheet_list.py +159 -0
  20. cmdbox/app/features/cli/cmdbox_tts_install.py +4 -11
  21. cmdbox/app/features/cli/cmdbox_tts_say.py +2 -10
  22. cmdbox/app/features/cli/cmdbox_tts_start.py +0 -9
  23. cmdbox/app/features/cli/cmdbox_tts_stop.py +0 -9
  24. cmdbox/app/features/cli/cmdbox_web_apikey_add.py +3 -3
  25. cmdbox/app/features/cli/cmdbox_web_apikey_del.py +3 -3
  26. cmdbox/app/features/cli/cmdbox_web_group_add.py +3 -3
  27. cmdbox/app/features/cli/cmdbox_web_group_del.py +3 -3
  28. cmdbox/app/features/cli/cmdbox_web_group_edit.py +3 -3
  29. cmdbox/app/features/cli/cmdbox_web_group_list.py +3 -3
  30. cmdbox/app/features/cli/cmdbox_web_start.py +10 -10
  31. cmdbox/app/features/cli/cmdbox_web_user_add.py +3 -3
  32. cmdbox/app/features/cli/cmdbox_web_user_del.py +3 -3
  33. cmdbox/app/features/cli/cmdbox_web_user_edit.py +3 -3
  34. cmdbox/app/features/cli/cmdbox_web_user_list.py +3 -3
  35. cmdbox/app/features/cli/excel_base.py +301 -0
  36. cmdbox/app/features/web/cmdbox_web_exec_cmd.py +12 -14
  37. cmdbox/app/filer.py +5 -2
  38. cmdbox/app/mcp.py +4 -3
  39. cmdbox/app/options.py +8 -0
  40. cmdbox/app/web.py +58 -39
  41. cmdbox/extensions/features.yml +3 -0
  42. cmdbox/extensions/sample_project/sample/app/features/cli/sample_server_time.py +0 -9
  43. cmdbox/licenses/LICENSE_Mako_1_3_10_MIT_License.txt +19 -0
  44. cmdbox/licenses/LICENSE_alembic_1_16_5_UNKNOWN.txt +19 -0
  45. cmdbox/licenses/{LICENSE_cffi_1_17_1_MIT_License.txt → LICENSE_cffi_2_0_0_UNKNOWN.txt} +2 -5
  46. cmdbox/licenses/LICENSE_debugpy_1_8_17_MIT_License.txt +24 -0
  47. cmdbox/licenses/LICENSE_et_xmlfile_2_0_0_MIT_License.txt +298 -0
  48. cmdbox/licenses/LICENSE_fastuuid_0_13_5_BSD_License.txt +29 -0
  49. cmdbox/licenses/LICENSE_google-cloud-monitoring_2_27_2_Apache_Software_License.txt +202 -0
  50. cmdbox/licenses/LICENSE_google-cloud-spanner_3_58_0_Apache_Software_License.txt +202 -0
  51. cmdbox/licenses/LICENSE_google-genai_1_40_0_Apache_Software_License.txt +202 -0
  52. cmdbox/licenses/LICENSE_grpc-interceptor_0_15_4_MIT_License.txt +21 -0
  53. cmdbox/licenses/{LICENSE_lazy-object-proxy_1_11_0_BSD_License.txt → LICENSE_lazy-object-proxy_1_12_0_UNKNOWN.txt} +1 -1
  54. cmdbox/licenses/LICENSE_openpyxl_3_1_5_MIT_License.txt +23 -0
  55. cmdbox/licenses/LICENSE_opentelemetry-exporter-otlp-proto-common_1_37_0_UNKNOWN.txt +201 -0
  56. cmdbox/licenses/LICENSE_opentelemetry-exporter-otlp-proto-http_1_37_0_UNKNOWN.txt +201 -0
  57. cmdbox/licenses/LICENSE_opentelemetry-proto_1_37_0_UNKNOWN.txt +201 -0
  58. cmdbox/licenses/LICENSE_opentelemetry-sdk_1_37_0_UNKNOWN.txt +201 -0
  59. cmdbox/licenses/LICENSE_opentelemetry-semantic-conventions_0_58b0_UNKNOWN.txt +201 -0
  60. cmdbox/licenses/LICENSE_sqlalchemy-spanner_1_16_0_Apache_Software_License.txt +202 -0
  61. cmdbox/licenses/LICENSE_sqlparse_0_5_3_BSD_License.txt +25 -0
  62. cmdbox/licenses/{LICENSE_uvicorn_0_35_0_BSD_License.txt → LICENSE_uvicorn_0_37_0_BSD_License.txt} +2 -1
  63. cmdbox/licenses/files.txt +82 -71
  64. cmdbox/version.py +2 -2
  65. cmdbox/web/assets/cmdbox/svgicon.js +9 -0
  66. {cmdbox-0.6.4.2.dist-info → cmdbox-0.6.6.dist-info}/METADATA +29 -29
  67. {cmdbox-0.6.4.2.dist-info → cmdbox-0.6.6.dist-info}/RECORD +133 -117
  68. cmdbox/app/features/cli/cmdbox_vision_predict.py +0 -192
  69. cmdbox/licenses/LICENSE_APScheduler_3_11_0_MIT_License.txt +0 -19
  70. cmdbox/licenses/LICENSE_backoff_2_2_1_MIT_License.txt +0 -21
  71. cmdbox/licenses/LICENSE_fastapi-sso_0_18_0_MIT_License.txt +0 -21
  72. cmdbox/licenses/LICENSE_litellm-enterprise_0_1_19_UNKNOWN.txt +0 -37
  73. cmdbox/licenses/LICENSE_oauthlib_3_3_1_BSD-3-Clause.txt +0 -27
  74. cmdbox/licenses/LICENSE_orjson_3_11_1_Apache_Software_License-MIT_License.txt +0 -201
  75. /cmdbox/licenses/{LICENSE_Authlib_1_6_1_BSD_License.txt → LICENSE_Authlib_1_6_5_BSD_License.txt} +0 -0
  76. /cmdbox/licenses/{LICENSE_MarkupSafe_3_0_2_BSD_License.txt → LICENSE_MarkupSafe_3_0_3_UNKNOWN.txt} +0 -0
  77. /cmdbox/licenses/{LICENSE_PyYAML_6_0_2_MIT_License.txt → LICENSE_PyYAML_6_0_3_MIT_License.txt} +0 -0
  78. /cmdbox/licenses/{LICENSE_anyio_4_10_0_UNKNOWN.txt → LICENSE_anyio_4_11_0_UNKNOWN.txt} +0 -0
  79. /cmdbox/licenses/{LICENSE_cachetools_5_5_2_MIT_License.txt → LICENSE_cachetools_6_2_0_MIT_License.txt} +0 -0
  80. /cmdbox/licenses/{LICENSE_click_8_2_1_UNKNOWN.txt → LICENSE_click_8_3_0_UNKNOWN.txt} +0 -0
  81. /cmdbox/licenses/{LICENSE_cryptography_45_0_6_Apache-2_0_OR_BSD-3-Clause.txt → LICENSE_cryptography_46_0_2_UNKNOWN.txt} +0 -0
  82. /cmdbox/licenses/{LICENSE_cyclopts_3_22_5_Apache_Software_License.txt → LICENSE_cyclopts_3_24_0_Apache_Software_License.txt} +0 -0
  83. /cmdbox/licenses/{LICENSE_dnspython_2_7_0_ISC_License-ISCL.txt → LICENSE_dnspython_2_8_0_ISC_License-ISCL.txt} +0 -0
  84. /cmdbox/licenses/{LICENSE_email_validator_2_2_0_The_Unlicense-Unlicense.txt → LICENSE_email-validator_2_3_0_The_Unlicense-Unlicense.txt} +0 -0
  85. /cmdbox/licenses/{LICENSE_fastapi_0_116_1_MIT_License.txt → LICENSE_fastapi_0_118_0_MIT_License.txt} +0 -0
  86. /cmdbox/licenses/{LICENSE_fastmcp_2_11_3_Apache_Software_License.txt → LICENSE_fastmcp_2_12_4_Apache_Software_License.txt} +0 -0
  87. /cmdbox/licenses/{LICENSE_filelock_3_18_0_The_Unlicense-Unlicense.txt → LICENSE_filelock_3_19_1_The_Unlicense-Unlicense.txt} +0 -0
  88. /cmdbox/licenses/{LICENSE_fsspec_2025_7_0_BSD_License.txt → LICENSE_fsspec_2025_9_0_UNKNOWN.txt} +0 -0
  89. /cmdbox/licenses/{LICENSE_gevent_25_5_1_MIT.txt → LICENSE_gevent_25_9_1_MIT.txt} +0 -0
  90. /cmdbox/licenses/{LICENSE_google-adk_1_10_0_Apache_Software_License.txt → LICENSE_google-adk_1_15_1_Apache_Software_License.txt} +0 -0
  91. /cmdbox/licenses/{LICENSE_google-api-core_2_25_1_Apache_Software_License.txt → LICENSE_google-api-core_2_25_2_Apache_Software_License.txt} +0 -0
  92. /cmdbox/licenses/{LICENSE_google-api-python-client_2_178_0_Apache_Software_License.txt → LICENSE_google-api-python-client_2_184_0_Apache_Software_License.txt} +0 -0
  93. /cmdbox/licenses/{LICENSE_google-auth_2_40_3_Apache_Software_License.txt → LICENSE_google-auth_2_41_1_Apache_Software_License.txt} +0 -0
  94. /cmdbox/licenses/{LICENSE_google-cloud-aiplatform_1_108_0_Apache_2_0.txt → LICENSE_google-cloud-aiplatform_1_119_0_Apache_2_0.txt} +0 -0
  95. /cmdbox/licenses/{LICENSE_google-cloud-bigquery_3_35_1_Apache_Software_License.txt → LICENSE_google-cloud-bigquery_3_38_0_Apache_Software_License.txt} +0 -0
  96. /cmdbox/licenses/{LICENSE_google-genai_1_29_0_Apache_Software_License.txt → LICENSE_google-cloud-bigtable_2_32_0_Apache_Software_License.txt} +0 -0
  97. /cmdbox/licenses/{LICENSE_grpcio-status_1_74_0_Apache_Software_License.txt → LICENSE_grpcio-status_1_75_1_Apache_Software_License.txt} +0 -0
  98. /cmdbox/licenses/{LICENSE_grpcio_1_74_0_Apache_Software_License.txt → LICENSE_grpcio_1_75_1_Apache_Software_License.txt} +0 -0
  99. /cmdbox/licenses/{LICENSE_httplib2_0_22_0_MIT_License.txt → LICENSE_httplib2_0_31_0_MIT_License.txt} +0 -0
  100. /cmdbox/licenses/{LICENSE_huggingface-hub_0_34_4_Apache_Software_License.txt → LICENSE_huggingface-hub_0_35_3_Apache_Software_License.txt} +0 -0
  101. /cmdbox/licenses/{LICENSE_jaraco_functools_4_2_1_UNKNOWN.txt → LICENSE_jaraco_functools_4_3_0_UNKNOWN.txt} +0 -0
  102. /cmdbox/licenses/{LICENSE_jiter_0_10_0_MIT_License.txt → LICENSE_jiter_0_11_0_MIT_License.txt} +0 -0
  103. /cmdbox/licenses/{LICENSE_jsonschema-specifications_2025_4_1_UNKNOWN.txt → LICENSE_jsonschema-specifications_2025_9_1_UNKNOWN.txt} +0 -0
  104. /cmdbox/licenses/{LICENSE_jsonschema_4_25_0_UNKNOWN.txt → LICENSE_jsonschema_4_25_1_UNKNOWN.txt} +0 -0
  105. /cmdbox/licenses/{LICENSE_litellm_1_75_5_post1_MIT_License.txt → LICENSE_litellm_1_77_5_MIT_License.txt} +0 -0
  106. /cmdbox/licenses/{LICENSE_mcp_1_12_4_MIT_License.txt → LICENSE_mcp_1_16_0_MIT_License.txt} +0 -0
  107. /cmdbox/licenses/{LICENSE_more-itertools_10_7_0_MIT_License.txt → LICENSE_more-itertools_10_8_0_UNKNOWN.txt} +0 -0
  108. /cmdbox/licenses/{LICENSE_numpy_2_3_2_BSD_License.txt → LICENSE_numpy_2_3_3_BSD_License.txt} +0 -0
  109. /cmdbox/licenses/{LICENSE_openai_1_99_9_Apache_Software_License.txt → LICENSE_openai_2_1_0_Apache_Software_License.txt} +0 -0
  110. /cmdbox/licenses/{LICENSE_opentelemetry-api_1_36_0_UNKNOWN.txt → LICENSE_opentelemetry-api_1_37_0_UNKNOWN.txt} +0 -0
  111. /cmdbox/licenses/{LICENSE_opentelemetry-sdk_1_36_0_UNKNOWN.txt → LICENSE_opentelemetry-exporter-gcp-logging_1_9_0a0_Apache_Software_License.txt} +0 -0
  112. /cmdbox/licenses/{LICENSE_opentelemetry-semantic-conventions_0_57b0_UNKNOWN.txt → LICENSE_opentelemetry-exporter-gcp-monitoring_1_9_0a0_Apache_Software_License.txt} +0 -0
  113. /cmdbox/licenses/{LICENSE_prompt_toolkit_3_0_51_BSD_License.txt → LICENSE_prompt_toolkit_3_0_52_BSD_License.txt} +0 -0
  114. /cmdbox/licenses/{LICENSE_protobuf_6_31_1_3-Clause_BSD_License.txt → LICENSE_protobuf_6_32_1_3-Clause_BSD_License.txt} +0 -0
  115. /cmdbox/licenses/{LICENSE_psycopg-binary_3_2_9_GNU_Lesser_General_Public_License_v3-LGPLv3.txt → LICENSE_psycopg-binary_3_2_10_GNU_Lesser_General_Public_License_v3-LGPLv3.txt} +0 -0
  116. /cmdbox/licenses/{LICENSE_psycopg_3_2_9_GNU_Lesser_General_Public_License_v3-LGPLv3.txt → LICENSE_psycopg_3_2_10_GNU_Lesser_General_Public_License_v3-LGPLv3.txt} +0 -0
  117. /cmdbox/licenses/{LICENSE_pycparser_2_22_BSD_License.txt → LICENSE_pycparser_2_23_BSD_License.txt} +0 -0
  118. /cmdbox/licenses/{LICENSE_pydantic-settings_2_10_1_MIT_License.txt → LICENSE_pydantic-settings_2_11_0_MIT_License.txt} +0 -0
  119. /cmdbox/licenses/{LICENSE_pydantic_2_11_7_MIT_License.txt → LICENSE_pydantic_2_11_10_MIT_License.txt} +0 -0
  120. /cmdbox/licenses/{LICENSE_pyparsing_3_2_3_MIT_License.txt → LICENSE_pyparsing_3_2_5_UNKNOWN.txt} +0 -0
  121. /cmdbox/licenses/{LICENSE_pyperclip_1_9_0_BSD_License.txt → LICENSE_pyperclip_1_11_0_BSD_License.txt} +0 -0
  122. /cmdbox/licenses/{LICENSE_questionary_2_1_0_MIT_License.txt → LICENSE_questionary_2_1_1_MIT_License.txt} +0 -0
  123. /cmdbox/licenses/{LICENSE_regex_2025_7_34_UNKNOWN.txt → LICENSE_regex_2025_9_18_UNKNOWN.txt} +0 -0
  124. /cmdbox/licenses/{LICENSE_requests_2_32_4_Apache_Software_License.txt → LICENSE_requests_2_32_5_Apache_Software_License.txt} +0 -0
  125. /cmdbox/licenses/{LICENSE_rpds-py_0_27_0_UNKNOWN.txt → LICENSE_rpds-py_0_27_1_UNKNOWN.txt} +0 -0
  126. /cmdbox/licenses/{LICENSE_shapely_2_1_1_BSD_License.txt → LICENSE_shapely_2_1_2_BSD_License.txt} +0 -0
  127. /cmdbox/licenses/{LICENSE_sphinx-sitemap_2_7_2_UNKNOWN.txt → LICENSE_sphinx-sitemap_2_8_0_UNKNOWN.txt} +0 -0
  128. /cmdbox/licenses/{LICENSE_starlette_0_47_2_BSD_License.txt → LICENSE_starlette_0_48_0_BSD_License.txt} +0 -0
  129. /cmdbox/licenses/{LICENSE_tenacity_9_1_2_Apache_Software_License.txt → LICENSE_tenacity_8_5_0_Apache_Software_License.txt} +0 -0
  130. /cmdbox/licenses/{LICENSE_tokenizers_0_21_4_Apache_Software_License.txt → LICENSE_tokenizers_0_22_1_Apache_Software_License.txt} +0 -0
  131. /cmdbox/licenses/{LICENSE_twine_6_1_0_Apache_Software_License.txt → LICENSE_twine_6_2_0_UNKNOWN.txt} +0 -0
  132. /cmdbox/licenses/{LICENSE_typing-inspection_0_4_1_UNKNOWN.txt → LICENSE_typing-inspection_0_4_2_UNKNOWN.txt} +0 -0
  133. /cmdbox/licenses/{LICENSE_typing_extensions_4_14_1_UNKNOWN.txt → LICENSE_typing_extensions_4_15_0_UNKNOWN.txt} +0 -0
  134. /cmdbox/licenses/{LICENSE_wcwidth_0_2_13_MIT_License.txt → LICENSE_wcwidth_0_2_14_MIT_License.txt} +0 -0
  135. /cmdbox/licenses/{LICENSE_zope_event_5_1_1_Zope_Public_License.txt → LICENSE_zope_event_6_0_Zope_Public_License.txt} +0 -0
  136. /cmdbox/licenses/{LICENSE_zope_interface_7_2_Zope_Public_License.txt → LICENSE_zope_interface_8_0_1_Zope_Public_License.txt} +0 -0
  137. {cmdbox-0.6.4.2.dist-info → cmdbox-0.6.6.dist-info}/WHEEL +0 -0
  138. {cmdbox-0.6.4.2.dist-info → cmdbox-0.6.6.dist-info}/entry_points.txt +0 -0
  139. {cmdbox-0.6.4.2.dist-info → cmdbox-0.6.6.dist-info}/licenses/LICENSE +0 -0
  140. {cmdbox-0.6.4.2.dist-info → cmdbox-0.6.6.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,487 @@
1
+ from cmdbox import version
2
+ from cmdbox.app import common, client, feature
3
+ from cmdbox.app.commons import convert, redis_client
4
+ from cmdbox.app.features.cli import cmdbox_vision_start
5
+ from cmdbox.app.options import Options
6
+ from pathlib import Path
7
+ from typing import Dict, Any, Tuple, List, Union
8
+ import argparse
9
+ import datetime
10
+ import logging
11
+ import json
12
+ import numpy as np
13
+ import time
14
+ import sys
15
+
16
+
17
+
18
+ class VisionPredict(cmdbox_vision_start.VisionStart):
19
+
20
+ def get_mode(self) -> Union[str, List[str]]:
21
+ """
22
+ この機能のモードを返します
23
+
24
+ Returns:
25
+ Union[str, List[str]]: モード
26
+ """
27
+ return 'vision'
28
+
29
+ def get_cmd(self):
30
+ """
31
+ この機能のコマンドを返します
32
+
33
+ Returns:
34
+ str: コマンド
35
+ """
36
+ return 'predict'
37
+
38
+ def get_option(self):
39
+ """
40
+ この機能のオプションを返します
41
+
42
+ Returns:
43
+ Dict[str, Any]: オプション
44
+ """
45
+ return dict(
46
+ use_redis=self.USE_REDIS_MEIGHT, nouse_webmode=False, use_agent=True,
47
+ description_ja="画像/動画の推論を実行します。",
48
+ description_en="Executes inference on images/videos.",
49
+ choice=[
50
+ dict(opt="host", type=Options.T_STR, default=self.default_host, required=True, multi=False, hide=True, choice=None, web="mask",
51
+ description_ja="Redisサーバーのサービスホストを指定します。",
52
+ description_en="Specify the service host of the Redis server."),
53
+ dict(opt="port", type=Options.T_INT, default=self.default_port, required=True, multi=False, hide=True, choice=None, web="mask",
54
+ description_ja="Redisサーバーのサービスポートを指定します。",
55
+ description_en="Specify the service port of the Redis server."),
56
+ dict(opt="password", type=Options.T_STR, default=self.default_pass, required=True, multi=False, hide=True, choice=None, web="mask",
57
+ description_ja=f"Redisサーバーのアクセスパスワード(任意)を指定します。省略時は `{self.default_pass}` を使用します。",
58
+ description_en=f"Specify the access password of the Redis server (optional). If omitted, `{self.default_pass}` is used."),
59
+ dict(opt="svname", type=Options.T_STR, default=self.default_svname, required=True, multi=False, hide=True, choice=None, web="readonly",
60
+ description_ja="サーバーのサービス名を指定します。省略時は `server` を使用します。",
61
+ description_en="Specify the service name of the inference server. If omitted, `server` is used."),
62
+ dict(opt="retry_count", type=Options.T_INT, default=3, required=False, multi=False, hide=True, choice=None,
63
+ description_ja="Redisサーバーへの再接続回数を指定します。0以下を指定すると永遠に再接続を行います。",
64
+ description_en="Specifies the number of reconnections to the Redis server.If less than 0 is specified, reconnection is forever."),
65
+ dict(opt="retry_interval", type=Options.T_INT, default=5, required=False, multi=False, hide=True, choice=None,
66
+ description_ja="Redisサーバーに再接続までの秒数を指定します。",
67
+ description_en="Specifies the number of seconds before reconnecting to the Redis server."),
68
+ dict(opt="timeout", type=Options.T_INT, default="60", required=False, multi=False, hide=True, choice=None,
69
+ description_ja="サーバーの応答が返ってくるまでの最大待ち時間を指定。",
70
+ description_en="Specify the maximum waiting time until the server responds."),
71
+ dict(opt="vision_engine", type=Options.T_STR, default="sam2", required=True, multi=False, hide=False,
72
+ choice=["sam2"],
73
+ choice_show=dict(sam2=["sam2_model", "sam2_point"]),
74
+ description_ja="使用するVisionエンジンを指定します。",
75
+ description_en="Specify the Vision engine to use."),
76
+ dict(opt="sam2_model", type=Options.T_STR, default="092824/sam2.1_hiera_tiny.pt", required=True, multi=False, hide=False,
77
+ choice=[k for k in self.VISION_MODEL.keys() if self.VISION_MODEL[k]['type'] == 'sam2'],
78
+ choice_edit=True,
79
+ description_ja="使用するSAM2モデルを指定します。",
80
+ description_en="Specify the SAM2 model to use."),
81
+ dict(opt="sam2_point", type=Options.T_STR, default=None, required=True, multi=True, hide=False, choice=None,
82
+ description_ja="使用するSAM2モデルのポイントを指定します。 `x,y` の形式で指定してください。",
83
+ description_en="Specify the SAM2 model points to use. Please specify in the format `x,y`."),
84
+ dict(opt="sam2_label", type=Options.T_INT, default=1, required=False, multi=True, hide=False, choice=None,
85
+ description_ja="使用するSAM2モデルのラベルを指定します。",
86
+ description_en="Specify the SAM2 model label to use."),
87
+ dict(opt="img_input_file", type=Options.T_FILE, default=None, required=False, multi=False, hide=False, choice=None, fileio="in",
88
+ description_ja="入力画像ファイルを指定します。",
89
+ description_en="Specify the input image file."),
90
+ dict(opt="img_input_type", type=Options.T_STR, default="jpeg", required=True, multi=False, hide=False,
91
+ choice=['bmp', 'png', 'jpeg', 'capture'],
92
+ description_ja="入力画像の形式を指定します。",
93
+ description_en="Specify the format of the input image."),
94
+ dict(opt="img_stdin", type=Options.T_BOOL, default=False, required=False, multi=False, hide=False, choice=[True, False],
95
+ description_ja="標準入力から画像を読み込みます。",
96
+ description_en="Read images from standard input."),
97
+ dict(opt="img_output_file", type=Options.T_FILE, default=None, required=False, multi=False, hide=False, choice=None, fileio="out",
98
+ description_ja="推論結果画像の保存先ファイルを指定します。",
99
+ description_en="Specify the destination file for saving the inference result image.",
100
+ test_true={"yolox":"pred.jpg"}),
101
+ dict(opt="nodraw", type=Options.T_BOOL, default=False, required=False, multi=False, hide=False, choice=[True, False],
102
+ description_ja="指定すると推論結果を画像に描き込みしません。",
103
+ description_en="If specified, inference results will not be drawn on the image."),
104
+ dict(opt="output_json", short="o" , type=Options.T_FILE, default=None, required=False, multi=False, hide=True, choice=None, fileio="out",
105
+ description_ja="処理結果jsonの保存先ファイルを指定。",
106
+ description_en="Specify the destination file for saving the processing result json."),
107
+ dict(opt="output_json_append", short="a" , type=Options.T_BOOL, default=False, required=False, multi=False, hide=True, choice=[True, False],
108
+ description_ja="処理結果jsonファイルを追記保存します。",
109
+ description_en="Save the processing result json file by appending."),
110
+ dict(opt="stdout_log", type=Options.T_BOOL, default=True, required=False, multi=False, hide=True, choice=[True, False],
111
+ description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力をConsole logに出力します。",
112
+ description_en="Available only in GUI mode. Outputs standard output during command execution to Console log."),
113
+ dict(opt="capture_stdout", type=Options.T_BOOL, default=True, required=False, multi=False, hide=True, choice=[True, False],
114
+ description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力をキャプチャーし、実行結果画面に表示します。",
115
+ description_en="Available only in GUI mode. Captures standard output during command execution and displays it on the execution result screen."),
116
+ dict(opt="capture_maxsize", type=Options.T_INT, default=self.DEFAULT_CAPTURE_MAXSIZE, required=False, multi=False, hide=True, choice=None,
117
+ description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力の最大キャプチャーサイズを指定します。",
118
+ description_en="Available only in GUI mode. Specifies the maximum capture size of standard output when executing commands."),
119
+ ]
120
+ )
121
+
122
+ def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
123
+ """
124
+ この機能の実行を行います
125
+
126
+ Args:
127
+ logger (logging.Logger): ロガー
128
+ args (argparse.Namespace): 引数
129
+ tm (float): 実行開始時間
130
+ pf (List[Dict[str, float]]): 呼出元のパフォーマンス情報
131
+
132
+ Returns:
133
+ Tuple[int, Dict[str, Any], Any]: 終了コード, 結果, オブジェクト
134
+ """
135
+ if args.vision_engine is None:
136
+ msg = dict(warn=f"Please specify the --vision_engine option.")
137
+ common.print_format(msg, False, tm, args.output_json, args.output_json_append, pf=pf)
138
+ return self.RESP_WARN, msg, None
139
+ model_param = dict()
140
+ if args.vision_engine == 'sam2':
141
+ if args.sam2_model is None:
142
+ msg = dict(warn=f"Please specify the --sam2_model option.")
143
+ common.print_format(msg, False, tm, args.output_json, args.output_json_append, pf=pf)
144
+ return self.RESP_WARN, msg, None
145
+ try:
146
+ model_param['sam2_model'] = args.sam2_model
147
+ model_param['sam2_point'] = [row.split(',') for row in args.sam2_point]
148
+ model_param['sam2_label'] = args.sam2_label
149
+ except Exception as e:
150
+ msg = dict(warn=f"Invalid --sam2_point option. {str(e)}")
151
+ common.print_format(msg, False, tm, args.output_json, args.output_json_append, pf=pf)
152
+ return self.RESP_WARN, msg, None
153
+ else:
154
+ msg = dict(warn=f"Unsupported vision engine: {args.vision_engine}")
155
+ common.print_format(msg, False, tm, args.output_json, args.output_json_append, pf=pf)
156
+ return self.RESP_WARN, msg, None
157
+
158
+ cl = client.Client(logger, redis_host=args.host, redis_port=args.port, redis_password=args.password, svname=args.svname)
159
+ if args.img_input_file is not None:
160
+ if logger.level == logging.DEBUG:
161
+ logger.debug(f"app.main: args.mode={args.mode}, args.cmd={args.cmd}, args.name={args.name}, args.img_input_file={args.img_input_file}")
162
+ ret = self.predict(cl, args.vision_engine, model_param=model_param, img_input_file=args.img_input_file, img_input_type=args.img_input_type,
163
+ img_output_file=args.img_output_file, nodraw=args.nodraw,
164
+ retry_count=args.retry_count, retry_interval=args.retry_interval, timeout=args.timeout,
165
+ logger=logger)
166
+ if type(ret) is list:
167
+ for r in ret:
168
+ common.print_format(r, args.format, tm, args.output_json, args.output_json_append, pf=pf)
169
+ if logger.level == logging.DEBUG:
170
+ ret_str = common.to_str(r, slise=100)
171
+ logger.debug(f"app.main: args.mode={args.mode}, args.cmd={args.cmd}, ret={ret_str}")
172
+ tm = time.perf_counter()
173
+ args.output_json_append = True
174
+ else:
175
+ common.print_format(ret, args.format, tm, args.output_json, args.output_json_append, pf=pf)
176
+ elif args.stdin:
177
+ if args.img_input_type is None:
178
+ msg = {"warn":f"Please specify the --img_input_type option."}
179
+ common.print_format(msg, args.format, tm, args.output_json, args.output_json_append, pf=pf)
180
+ if logger.level == logging.DEBUG:
181
+ msg_str = common.to_str(msg, slise=100)
182
+ logger.debug(f"app.main: args.mode={args.mode}, args.cmd={args.cmd}, msg={msg_str}")
183
+ return self.RESP_WARN, msg, None
184
+ if args.img_input_type in ['capture']:
185
+ def _pred(args, line, tm):
186
+ if logger.level == logging.DEBUG:
187
+ line_str = common.to_str(line, slise=100)
188
+ logger.debug(f"app.main: args.mode={args.mode}, args.cmd={args.cmd}, args.name={args.name}, image={line_str}")
189
+ ret = self.predict(cl, args.vision_engine, model_param=model_param, image=line, img_input_type=args.img_input_type,
190
+ img_output_file=args.img_output_file, nodraw=args.nodraw,
191
+ retry_count=args.retry_count, retry_interval=args.retry_interval, timeout=args.timeout,
192
+ logger=logger)
193
+ common.print_format(ret, args.format, tm, args.output_json, args.output_json_append, pf=pf)
194
+ if logger.level == logging.DEBUG:
195
+ ret_str = common.to_str(ret, slise=100)
196
+ logger.debug(f"app.main: args.mode={args.mode}, args.cmd={args.cmd}, ret={ret_str}")
197
+ for line in sys.stdin:
198
+ # 標準入力による推論処理は非同期で行う(同名複数serverの場合にスループットを向上させるため)
199
+ #thread = threading.Thread(target=_pred, args=(args, line, tm))
200
+ #thread.start()
201
+ _pred(args, line, tm)
202
+ tm = time.perf_counter()
203
+ args.output_json_append = True
204
+ else:
205
+ if logger.level == logging.DEBUG:
206
+ logger.debug(f"app.main: args.mode={args.mode}, args.cmd={args.cmd}, args.name={args.name}, image=<stdin>")
207
+ ret = self.predict(cl, args.vision_engine, model_param=model_param, image=sys.stdin.buffer.read(), img_input_type=args.img_input_type,
208
+ img_output_file=args.img_output_file, nodraw=args.nodraw,
209
+ retry_count=args.retry_count, retry_interval=args.retry_interval, timeout=args.timeout,
210
+ logger=logger)
211
+ common.print_format(ret, args.format, tm, args.output_json, args.output_json_append, pf=pf)
212
+ if logger.level == logging.DEBUG:
213
+ ret_str = common.to_str(ret, slise=100)
214
+ logger.debug(f"app.main: args.mode={args.mode}, args.cmd={args.cmd}, ret={ret_str}")
215
+ tm = time.perf_counter()
216
+ else:
217
+ msg = {"warn":f"Image file or stdin is empty."}
218
+ common.print_format(msg, args.format, tm, args.output_json, args.output_json_append, pf=pf)
219
+ if logger.level == logging.DEBUG:
220
+ msg_str = common.to_str(msg, slise=100)
221
+ logger.debug(f"app.main: args.mode={args.mode}, args.cmd={args.cmd}, msg={msg_str}")
222
+ return self.RESP_WARN, msg, None
223
+
224
+ common.print_format(ret, False, tm, None, False, pf=pf)
225
+ if 'success' not in ret:
226
+ return self.RESP_WARN, ret, None
227
+ return self.RESP_SUCCESS, ret, None
228
+
229
+ def predict(self, cl:client.Client, vision_engine:str, model_param:Dict[str, Any]=None,
230
+ image=None, img_input_file=None, img_input_file_enable:bool=True, img_input_type:str='jpeg',
231
+ img_output_file:str=None, nodraw:bool=False,
232
+ retry_count:int=3, retry_interval:int=5, timeout:int=60, logger:logging.Logger=None) -> Dict[str, Any]:
233
+ """
234
+ 画像をRedisサーバーに送信し、推論結果を取得する
235
+
236
+ Args:
237
+ cl (client.Client): Redisサーバーへの接続クライアント
238
+ vision_engine (str): 使用するVisionエンジン
239
+ model_param (Dict[str, Any], optional): モデルのパラメータ. Defaults to None.
240
+ image (np.ndarray | bytes, optional): 画像データ. Defaults to None. np.ndarray型の場合はデコードしない(RGBであること).
241
+ img_input_file (str|file-like object, optional): 画像ファイルのパス. Defaults to None.
242
+ img_input_file_enable (bool, optional): 画像ファイルを使用するかどうか. Defaults to True. img_input_fileがNoneでなく、このパラメーターがTrueの場合はimg_input_fileを使用する.
243
+ img_input_type (str, optional): 画像の形式. Defaults to 'jpeg'.
244
+ img_output_file (str, optional): 予測結果の画像ファイルのパス. Defaults to None.
245
+ nodraw (bool, optional): 描画フラグ. Defaults to False.
246
+ retry_count (int, optional): リトライ回数. Defaults to 3.
247
+ retry_interval (int, optional): リトライ間隔. Defaults to 5.
248
+ timeout (int, optional): タイムアウト時間. Defaults to 60.
249
+ logger (logging.Logger, optional): ロガー. Defaults to None.
250
+
251
+ Returns:
252
+ dict: Redisサーバーからの応答
253
+ """
254
+ spredtime = time.perf_counter()
255
+ if vision_engine is None or vision_engine == "":
256
+ logger.warning(f"vision_engine is empty.")
257
+ return {"error": f"vision_engine is empty."}
258
+ if image is None and img_input_file is None:
259
+ logger.warning(f"image and img_input_file is empty.")
260
+ return {"error": f"image and img_input_file is empty."}
261
+ npy_b64 = None
262
+ simgloadtime = time.perf_counter()
263
+ if img_input_file is not None and img_input_file_enable:
264
+ if type(img_input_file) == str:
265
+ if not Path(img_input_file).exists():
266
+ logger.warning(f"Not found img_input_file. {img_input_file}.")
267
+ return {"error": f"Not found img_input_file. {img_input_file}."}
268
+ if img_input_type == 'jpeg' or img_input_type == 'png' or img_input_type == 'bmp':
269
+ f = None
270
+ try:
271
+ f = img_input_file if type(img_input_file) is not str else open(img_input_file, "rb")
272
+ img_npy = convert.imgfile2npy(f)
273
+ finally:
274
+ if f is not None: f.close()
275
+ elif img_input_type == 'capture':
276
+ f = None
277
+ try:
278
+ f = img_input_file if type(img_input_file) is not str else open(img_input_file, "r", encoding='utf-8')
279
+ res_list = []
280
+ for line in f:
281
+ if type(line) is bytes:
282
+ line = line.decode('utf-8')
283
+ capture_data = line.strip().split(',')
284
+ t = capture_data[0]
285
+ img = capture_data[1]
286
+ h = int(capture_data[2])
287
+ w = int(capture_data[3])
288
+ c = int(capture_data[4])
289
+ fn = Path(capture_data[5].strip())
290
+ if t == 'capture':
291
+ img_npy = convert.b64str2npy(img, shape=(h, w, c) if c > 0 else (h, w))
292
+ else:
293
+ img_npy = convert.imgbytes2npy(convert.b64str2bytes(img))
294
+ res_json = self.predict(cl, vision_engine, model_param=model_param,
295
+ image=img_npy, img_input_file=fn, img_input_file_enable=False,
296
+ img_output_file=img_output_file, nodraw=nodraw,
297
+ retry_count=retry_count, retry_interval=retry_interval, timeout=timeout,
298
+ logger=logger)
299
+ res_list.append(res_json)
300
+ if len(res_list) <= 0:
301
+ return {"warn": f"capture file is no data."}
302
+ elif len(res_list) == 1:
303
+ return res_list[0]
304
+ return res_list
305
+ except UnicodeDecodeError as e:
306
+ logger.error(f"capture file or img_input_type setting is invalid. img_input_type={img_input_type}. {e}", exc_info=True)
307
+ return {"error": f"capture file or img_input_type setting is invalid. img_input_type={img_input_type}. {e}"}
308
+ finally:
309
+ if f is not None: f.close()
310
+ else:
311
+ logger.warning(f"img_input_type is invalid. {img_input_type}.")
312
+ return {"error": f"img_input_type is invalid. {img_input_type}."}
313
+ else:
314
+ if type(image) == np.ndarray:
315
+ img_npy = image
316
+ if img_input_file is None: img_input_file = f'{datetime.datetime.now().strftime("%Y%m%d%H%M%S%f")}.capture'
317
+ img_input_file_enable = False
318
+ elif img_input_type == 'capture':
319
+ image = image.decode(encoding="utf-8") if type(image) is bytes else image
320
+ capture_data = image.split(',')
321
+ if len(capture_data) < 6:
322
+ logger.warning(f"capture data is invalid. {image}.")
323
+ return {"error": f"capture data is invalid. {image}."}
324
+ t = capture_data[0]
325
+ img = capture_data[1]
326
+ h = int(capture_data[2])
327
+ w = int(capture_data[3])
328
+ c = int(capture_data[4])
329
+ if img_input_file is None: img_input_file = capture_data[5]
330
+ img_input_file_enable = False
331
+ if t == 'capture':
332
+ img_npy = convert.b64str2npy(img, shape=(h, w, c) if c > 0 else (h, w))
333
+ else:
334
+ img_npy = convert.imgbytes2npy(convert.b64str2bytes(img))
335
+ elif img_input_type == 'output_json':
336
+ res_json = json.loads(image)
337
+ if not ("output_image" in res_json and "output_image_shape" in res_json and "output_image_name" in res_json):
338
+ logger.warning(f"img_input_file data is invalid. Not found output_image or output_image_shape or output_image_name key.")
339
+ return {"error": f"img_input_file data is invalid. Not found output_image or output_image_shape or output_image_name key."}
340
+ if res_json["output_image_name"].endswith(".capture"):
341
+ img_npy = convert.b64str2npy(res_json["output_image"], shape=res_json["output_image_shape"])
342
+ else:
343
+ img_bytes = convert.b64str2bytes(res_json["output_image"])
344
+ img_npy = convert.imgbytes2npy(img_bytes)
345
+ if img_input_file is None: img_input_file = res_json["output_image_name"]
346
+ img_input_file_enable = False
347
+ elif img_input_type == 'jpeg' or img_input_type == 'png' or img_input_type == 'bmp':
348
+ img_npy = convert.imgbytes2npy(image)
349
+ if img_input_file is None: img_input_file = f'{datetime.datetime.now().strftime("%Y%m%d%H%M%S%f")}.{img_input_type}'
350
+ img_input_file_enable = False
351
+ else:
352
+ logger.warning(f"img_input_type is invalid. {img_input_type}.")
353
+ return {"error": f"img_input_type is invalid. {img_input_type}."}
354
+
355
+ eimgloadtime = time.perf_counter()
356
+ img_npy_b64 = convert.npy2b64str(img_npy)
357
+ model_param_b64 = convert.str2b64str(common.to_str(model_param))
358
+ img_input_file_b64 = convert.str2b64str(img_input_file)
359
+ res_json = cl.redis_cli.send_cmd('predict',
360
+ [vision_engine, model_param_b64,
361
+ img_npy_b64, str(img_npy.shape[0]), str(img_npy.shape[1]), str(img_npy.shape[2] if len(img_npy.shape) > 2 else '-1'),
362
+ img_input_file_b64, str(nodraw),],
363
+ retry_count=retry_count, retry_interval=retry_interval, timeout=timeout)
364
+
365
+ soutputtime = time.perf_counter()
366
+ if "output_image" in res_json and "output_image_shape" in res_json:
367
+ img_npy = convert.b64str2npy(res_json["output_image"], res_json["output_image_shape"])
368
+ if img_output_file is not None:
369
+ exp = Path(img_output_file).suffix
370
+ exp = exp[1:] if exp[0] == '.' else exp
371
+ convert.npy2imgfile(img_npy, output_image_file=img_output_file, image_type=exp)
372
+ eoutputtime = time.perf_counter()
373
+ epredtime = time.perf_counter()
374
+ if "success" in res_json:
375
+ if "performance" not in res_json["success"]:
376
+ res_json["success"]["performance"] = []
377
+ performance = res_json["success"]["performance"]
378
+ performance.append(dict(key="cl_imgload", val=f"{eimgloadtime-simgloadtime:.3f}s"))
379
+ performance.append(dict(key="cl_output", val=f"{eoutputtime-soutputtime:.3f}s"))
380
+ performance.append(dict(key="cl_pred", val=f"{epredtime-spredtime:.3f}s"))
381
+ return res_json
382
+
383
+ def is_cluster_redirect(self):
384
+ """
385
+ クラスター宛のメッセージの場合、メッセージを転送するかどうかを返します
386
+
387
+ Returns:
388
+ bool: メッセージを転送する場合はTrue
389
+ """
390
+ return False
391
+
392
+ def svrun(self, data_dir:Path, logger:logging.Logger, redis_cli:redis_client.RedisClient, msg:List[str],
393
+ sessions:Dict[str, Dict[str, Any]]) -> int:
394
+ """
395
+ この機能のサーバー側の実行を行います
396
+
397
+ Args:
398
+ data_dir (Path): データディレクトリ
399
+ logger (logging.Logger): ロガー
400
+ redis_cli (redis_client.RedisClient): Redisクライアント
401
+ msg (List[str]): 受信メッセージ
402
+ sessions (Dict[str, Dict[str, Any]]): セッション情報
403
+
404
+ Returns:
405
+ int: 終了コード
406
+ """
407
+ if logger.level == logging.DEBUG:
408
+ logger.debug(f"audit write svrun msg: {msg}")
409
+ reskey = msg[1]
410
+ vision_engine = convert.b64str2str(msg[2])
411
+ model_param = json.loads(convert.b64str2str(msg[3]))
412
+ shape = [int(msg[5]), int(msg[6])]
413
+ if int(msg[7]) > 0: shape.append(int(msg[7]))
414
+ img_npy = convert.b64str2npy(msg[4], shape=shape)
415
+ img_input_file = convert.b64str2str(msg[8])
416
+ nodraw = convert.b64str2str(msg[9]) == 'True'
417
+
418
+ if vision_engine == 'sam2':
419
+ sam2_model = model_param['sam2_model']
420
+ sam2_point = model_param['sam2_point']
421
+ sam2_label = model_param['sam2_label']
422
+ st = self.sam2_predict(reskey, sam2_model, img_npy, sam2_point, sam2_label, data_dir, logger, redis_cli, sessions)
423
+ raise NotImplementedError("SAM2 model is not implemented yet.")
424
+ else:
425
+ logger.warning(f"Unsupported vision engine: {vision_engine}")
426
+ redis_cli.rpush(reskey, dict(warn=f"Unsupported vision engine: {vision_engine}"))
427
+ return self.RESP_WARN
428
+
429
+ def sam2_predict(self, reskey:str, sam2_model:str, img_npy:np.ndarray, sam2_point:List[List[int]], sam2_label:List[int],
430
+ data_dir:Path, logger:logging.Logger, redis_cli:redis_client.RedisClient, sessions:Dict[str, Dict[str, Any]]) -> Tuple[int, Dict[str, Any]]:
431
+ """
432
+ SAM2のモデルを使用して指定したポイントのマスクを取得します
433
+
434
+ Args:
435
+ reskey (str): レスポンスキー
436
+ vision_engine (str): Visionエンジン
437
+ sam2_model (str): SAM2モデル
438
+ img_npy (np.ndarray): 入力画像
439
+ sam2_point (List[List[int,int]]): SAM2モデルのポイント
440
+ sam2_label (List[int]): SAM2モデルのラベル
441
+ data_dir (Path): データディレクトリ
442
+ logger (logging.Logger): ロガー
443
+ redis_cli (redis_client.RedisClient): Redisクライアント
444
+ sessions (Dict[str, Dict[str, Any]]): セッション情報
445
+
446
+ Returns:
447
+ Tuple[int, Dict[str, Any]]
448
+ """
449
+ if 'vision' not in sessions or 'sam2' not in sessions['vision'] or sam2_model not in sessions['vision']['sam2'] or sessions['vision']['sam2'][sam2_model] is None:
450
+ return self.RESP_WARN, dict(warn=f"The vision session has not started.Unsupported SAM2 model: {sam2_model}")
451
+ session = sessions['vision']['sam2'][sam2_model]
452
+ from sam2.sam2_image_predictor import SAM2ImagePredictor
453
+ info = session.get('info', None)
454
+ predictor:SAM2ImagePredictor = session.get('predictor', None)
455
+ if info is None or predictor is None:
456
+ return self.RESP_WARN, dict(warn=f"The vision session has not started.Unsupported SAM2 model: {sam2_model}")
457
+ predictor.set_image(img_npy)
458
+ input_point = np.array(sam2_point, dtype=np.float32)
459
+ input_label = np.array(sam2_label, dtype=np.int32)
460
+ masks, scores, logits = predictor.predict(
461
+ point_coords=input_point,
462
+ point_labels=input_label,
463
+ multimask_output=True,
464
+ )
465
+ raise NotImplementedError("SAM2 model is not implemented yet.")
466
+
467
+ def draw_mask(img_npy:np.ndarray, mask_npy:np.ndarray):
468
+ """
469
+ マスクを描画する関数
470
+
471
+ """
472
+ from PIL import Image, ImageDraw
473
+ img = convert.npy2img(img_npy)
474
+ img = img.convert("RGBA")
475
+ draw = ImageDraw.Draw(img)
476
+ #h, w = img.size
477
+ #mask_npy = mask_npy.reshape(h, w, 1) * color.reshape(1, 1, -1)
478
+ mask_pil = Image.fromarray((mask_npy * 255).astype(np.uint8)).convert("L")
479
+ mask_img = Image.new("RGBA", img.size, (0, 0, 0, 0))
480
+ mask_color = np.array([*cmap(cmap_idx)[:3], 0.6])
481
+
482
+ for x in range(mask_pil.width):
483
+ for y in range(mask_pil.height):
484
+ if mask_pil.getpixel((x, y)) > 0:
485
+ mask_img.putpixel((x, y), (mask_color[0], mask_color[1], mask_color[2], int(255 * mask_color[3])))
486
+ img_comb = Image.alpha_composite(img, mask_img)
487
+ return img_comb
@@ -187,6 +187,8 @@ class VisionStart(feature.UnsupportEdgeFeature):
187
187
  int: レスポンスコード
188
188
  """
189
189
  try:
190
+ if 'vision' not in sessions:
191
+ sessions['vision'] = {}
190
192
  if vision_engine == 'sam2':
191
193
  #===============================================================
192
194
  # SAM2モデルの初期化
@@ -211,7 +213,9 @@ class VisionStart(feature.UnsupportEdgeFeature):
211
213
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
212
214
  # vvmファイルの読込み
213
215
  predictor = SAM2ImagePredictor(build_sam2(config_file, model_file, device=device))
214
- sessions[sam2_model] = dict(
216
+ if vision_engine not in sessions['vision']:
217
+ sessions['vision'][vision_engine] = {}
218
+ sessions['vision'][vision_engine][sam2_model] = dict(
215
219
  info=self.VISION_MODEL[sam2_model].copy(),
216
220
  predictor=predictor,
217
221
  )
@@ -38,7 +38,7 @@ class AuditCreatedb(feature.UnsupportEdgeFeature):
38
38
  Dict[str, Any]: オプション
39
39
  """
40
40
  return dict(
41
- use_redis=self.USE_REDIS_MEIGHT, nouse_webmode=True,
41
+ use_redis=self.USE_REDIS_MEIGHT, nouse_webmode=True, use_agent=False,
42
42
  description_ja="監査を記録するデータベースを作成します。",
43
43
  description_en="Create a database to record audits.",
44
44
  choice=[
@@ -85,16 +85,6 @@ class AuditCreatedb(feature.UnsupportEdgeFeature):
85
85
  ]
86
86
  )
87
87
 
88
-
89
- def get_svcmd(self):
90
- """
91
- この機能のサーバー側のコマンドを返します
92
-
93
- Returns:
94
- str: サーバー側のコマンド
95
- """
96
- return 'audit_create'
97
-
98
88
  def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
99
89
  """
100
90
  この機能の実行を行います
@@ -80,15 +80,6 @@ class AuditDelete(audit_base.AuditBase):
80
80
  ]
81
81
  return opt
82
82
 
83
- def get_svcmd(self):
84
- """
85
- この機能のサーバー側のコマンドを返します
86
-
87
- Returns:
88
- str: サーバー側のコマンド
89
- """
90
- return 'audit_delete'
91
-
92
83
  def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
93
84
  """
94
85
  この機能の実行を行います
@@ -122,15 +122,6 @@ class AuditSearch(audit_base.AuditBase):
122
122
  ]
123
123
  return opt
124
124
 
125
- def get_svcmd(self):
126
- """
127
- この機能のサーバー側のコマンドを返します
128
-
129
- Returns:
130
- str: サーバー側のコマンド
131
- """
132
- return 'audit_search'
133
-
134
125
  def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
135
126
  """
136
127
  この機能の実行を行います
@@ -73,15 +73,6 @@ class AuditWrite(audit_base.AuditBase):
73
73
  description_en="Specify the number of days to keep the audit. If the number is less than or equal to 0, the audit will be kept indefinitely."),
74
74
  ]
75
75
  return opt
76
-
77
- def get_svcmd(self):
78
- """
79
- この機能のサーバー側のコマンドを返します
80
-
81
- Returns:
82
- str: サーバー側のコマンド
83
- """
84
- return 'audit_write'
85
76
 
86
77
  def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
87
78
  """
@@ -45,9 +45,9 @@ class CmdList(feature.OneshotResultEdgeFeature):
45
45
  dict(opt="kwd", type=Options.T_STR, default=None, required=False, multi=False, hide=False, choice=None,
46
46
  description_ja=f"検索したいコマンド名を指定します。中間マッチで検索します。",
47
47
  description_en=f"Specify the name of the command you want to search. Search with intermediate matches."),
48
- dict(opt="signin_file", type=Options.T_FILE, default=f".{self.ver.__appid__}/user_list.yml", required=False, multi=False, hide=False, choice=None, fileio="in",
49
- description_ja="サインイン可能なユーザーとパスワードを記載したファイルを指定します。",
50
- description_en="Specify a file containing users and passwords with which they can signin."),
48
+ dict(opt="signin_file", type=Options.T_FILE, default=None, required=False, multi=False, hide=False, choice=None, fileio="in",
49
+ description_ja=f"サインイン可能なユーザーとパスワードを記載したファイルを指定します。通常 '.{self.ver.__appid__}/user_list.yml' を指定します。",
50
+ description_en=f"Specify a file containing users and passwords with which they can signin.Typically, specify '.{self.ver.__appid__}/user_list.yml'."),
51
51
  dict(opt="groups", type=Options.T_STR, default=None, required=False, multi=True, hide=False, choice=None,
52
52
  description_ja="`signin_file` を指定した場合に、このユーザーグループに許可されているコマンドリストを返すように指定します。",
53
53
  description_en="Specifies that `signin_file`, if specified, should return the list of commands allowed for this user group."),
@@ -45,9 +45,9 @@ class CmdLoad(feature.OneshotResultEdgeFeature):
45
45
  dict(opt="title", type=Options.T_STR, default=None, required=False, multi=False, hide=False, choice=None,
46
46
  description_ja=f"読込みたいコマンド名を指定します。",
47
47
  description_en=f"Specify the name of the command to be read."),
48
- dict(opt="signin_file", type=Options.T_FILE, default=f".{self.ver.__appid__}/user_list.yml", required=False, multi=False, hide=True, choice=None, fileio="in",
49
- description_ja="サインイン可能なユーザーとパスワードを記載したファイルを指定します。",
50
- description_en="Specify a file containing users and passwords with which they can signin."),
48
+ dict(opt="signin_file", type=Options.T_FILE, default=None, required=False, multi=False, hide=False, choice=None, fileio="in",
49
+ description_ja=f"サインイン可能なユーザーとパスワードを記載したファイルを指定します。通常 '.{self.ver.__appid__}/user_list.yml' を指定します。",
50
+ description_en=f"Specify a file containing users and passwords with which they can signin.Typically, specify '.{self.ver.__appid__}/user_list.yml'."),
51
51
  dict(opt="groups", type=Options.T_STR, default=None, required=False, multi=True, hide=True, choice=None,
52
52
  description_ja="`signin_file` を指定した場合に、このユーザーグループに許可されているコマンドリストを返すように指定します。",
53
53
  description_en="Specifies that `signin_file`, if specified, should return the list of commands allowed for this user group."),