Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

405 rindas
9.3KB

  1. # -*- coding: utf-8 -*-
  2. BASE_DIR = 'base_dir'
  3. GPU_CODES = ['3090', '2080', '4090', 'A10']
  4. GPU_NAME = 'gpu_name'
  5. GPU_2080 = '2080'
  6. GPU_2080_Ti = '2080Ti'
  7. KAFKA_ACKS = "acks"
  8. KAFKA_RETRIES = "retries"
  9. KAFKA_LINGER_MS = "linger_ms"
  10. KAFKA_RETRY_BACKOFF_MS = "retry_backoff_ms"
  11. KAFKA_MAX_IN_FLIGHT_REQUESTS = "max_in_flight_requests_per_connection"
  12. KAFKA_CLIENT_ID = "client_id"
  13. KAFKA_GROUP_ID = "group_id"
  14. KAFKA_AUTO_OFFSET_RESET = "auto_offset_reset"
  15. KAFKA_ENABLE_AUTO_COMMIT = "enable_auto_commit"
  16. KAFKA_MAX_POLL_RECORDS = "max_poll_records"
  17. REQUEST_IDREQUEST_ID = "request_id"
  18. FEEDBACK = "feedback"
  19. RECORDING = "recording"
  20. FBQUEUE = "fbQueue"
  21. CONTEXT = "context"
  22. MODEL = 'model'
  23. MSG = "msg"
  24. GPU_IDS = "gpu_ids"
  25. ANALYSE_TYPE = "analyse_type"
  26. COMMAND = "command"
  27. START = "start"
  28. STOP = "stop"
  29. SERVICE = "service"
  30. FRAME_SCORE = "frame_score"
  31. PULL_URL = "pull_url"
  32. PUSH_URL = "push_url"
  33. ORIGINAL_URL = "original_url"
  34. ORIGINAL_TYPE = "original_type"
  35. IMAGE_URLS = "image_urls"
  36. RESULTS_BASE_DIR = "results_base_dir"
  37. MODELS = "models"
  38. CODE = 'code'
  39. CATEGORIES = "categories"
  40. ID = 'id'
  41. CONFIG = "config"
  42. VIDEO = "video"
  43. FILE_PATH = "file_path"
  44. KAFKA = "kafka"
  45. TOPIC = "topic"
  46. DSP_ALG_ONLINE_TASKS_TOPIC = "dsp-alg-online-tasks-topic"
  47. DSP_ALG_OFFLINE_TASKS_TOPIC = "dsp-alg-offline-tasks-topic"
  48. DSP_ALG_IMAGE_TASKS_TOPI = "dsp-alg-image-tasks-topic"
  49. DSP_RECORDING_TASKS_TOPI = "dsp-recording-task-topic"
  50. DSP_ALG_RESULTS_TOPIC = "dsp-alg-results-topic"
  51. DSP_RECORDING_RESULTS_TOPIC = "dsp-recording-result-topic"
  52. DSP = "dsp"
  53. ACTIVE = "active"
  54. PRODUCER = "producer"
  55. CONSUMER = "consumer"
  56. BOOTSTRAP_SERVERS = "bootstrap_servers"
  57. ALIYUN = "aliyun"
  58. ACCESS_KEY = "access_key"
  59. ACCESS_SECRET = "access_secret"
  60. OSS = "oss"
  61. ENDPOINT = "endpoint"
  62. BUCKET = "bucket"
  63. CONNECT_TIMEOUT = "connect_timeout"
  64. VOD = "vod"
  65. ECSREGIONID = "ecsRegionId"
  66. CATEID = "CateId"
  67. GPU = "gpu"
  68. ORDER = "order"
  69. LIMIT = "limit"
  70. MAXLOAD = "maxLoad"
  71. MAXMEMORY = "maxMemory"
  72. INCLUDENAN = "includeNan"
  73. EXCLUDEID = "excludeID"
  74. EXCLUDEUUID = "excludeUUID"
  75. BAIDU = "baidu"
  76. VEHICLE = "vehicle"
  77. APP_ID = "APP_ID"
  78. API_KEY = "API_KEY"
  79. SECRET_KEY = "SECRET_KEY"
  80. PERSON = "person"
  81. ORC = "orc"
  82. LOG = 'log'
  83. IS_VIDEO = "is_video"
  84. IS_IMAGE = "is_image"
  85. # 校验schema规则定义
  86. SCHEMA = {
  87. "request_id": {
  88. 'type': 'string',
  89. 'required': True,
  90. 'empty': False,
  91. 'regex': r'^[a-zA-Z0-9]{1,36}$'
  92. },
  93. COMMAND: {
  94. 'type': 'string',
  95. 'required': True,
  96. 'allowed': [START, STOP]
  97. },
  98. PULL_URL: {
  99. 'type': 'string',
  100. 'required': False,
  101. 'nullable': True,
  102. 'maxlength': 255
  103. },
  104. PUSH_URL: {
  105. 'type': 'string',
  106. 'required': False,
  107. 'nullable': True,
  108. 'maxlength': 255
  109. },
  110. ORIGINAL_URL: {
  111. 'type': 'string',
  112. 'required': False,
  113. 'nullable': True,
  114. 'maxlength': 255
  115. },
  116. ORIGINAL_TYPE: {
  117. 'type': 'string',
  118. 'required': False,
  119. 'nullable': True,
  120. 'maxlength': 255
  121. },
  122. "logo_url": {
  123. 'type': 'string',
  124. 'required': False,
  125. 'nullable': True,
  126. 'maxlength': 255
  127. },
  128. IMAGE_URLS: {
  129. 'type': 'list',
  130. 'required': False,
  131. 'schema': {
  132. 'type': 'string',
  133. 'empty': False,
  134. 'maxlength': 5000
  135. }
  136. },
  137. RESULTS_BASE_DIR: {
  138. 'type': 'string',
  139. 'required': False,
  140. 'nullable': True,
  141. 'regex': r'^[a-zA-Z0-9]{0,36}$'
  142. },
  143. MODELS: {
  144. 'type': 'list',
  145. 'required': False,
  146. 'nullable': True,
  147. 'schema': {
  148. 'type': 'dict',
  149. 'required': True,
  150. 'schema': {
  151. CODE: {
  152. 'type': 'string',
  153. 'required': True,
  154. 'empty': False,
  155. 'dependencies': CATEGORIES,
  156. 'regex': r'^[a-zA-Z0-9]{1,255}$'
  157. },
  158. IS_VIDEO: {
  159. 'type': 'string',
  160. 'required': True,
  161. 'empty': False,
  162. 'dependencies': CODE,
  163. 'allowed': ["0", "1"]
  164. },
  165. IS_IMAGE: {
  166. 'type': 'string',
  167. 'required': True,
  168. 'empty': False,
  169. 'dependencies': CODE,
  170. 'allowed': ["0", "1"]
  171. },
  172. CATEGORIES: {
  173. 'type': 'list',
  174. 'required': True,
  175. 'dependencies': CODE,
  176. 'schema': {
  177. 'type': 'dict',
  178. 'required': True,
  179. 'schema': {
  180. ID: {
  181. 'type': 'string',
  182. 'required': True,
  183. 'empty': False,
  184. 'regex': r'^[a-zA-Z0-9]{0,255}$'},
  185. CONFIG: {
  186. 'type': 'dict',
  187. 'required': False,
  188. 'dependencies': ID,
  189. }
  190. }
  191. }
  192. }
  193. }
  194. }
  195. }
  196. }
  197. def get_file_path(context):
  198. return context[VIDEO][FILE_PATH]
  199. def get_video_add_water(context):
  200. return context[VIDEO]["video_add_water"]
  201. def get_online_tasks_topic(context):
  202. return context["kafka"]["topic"]["dsp-alg-online-tasks-topic"]
  203. def get_offline_tasks_topic(context):
  204. return context[KAFKA][TOPIC][DSP_ALG_OFFLINE_TASKS_TOPIC]
  205. def get_image_tasks_topic(context):
  206. return context[KAFKA][TOPIC][DSP_ALG_IMAGE_TASKS_TOPI]
  207. def get_recording_tasks_topic(context):
  208. return context[KAFKA][TOPIC][DSP_RECORDING_TASKS_TOPI]
  209. def get_kafka_producer_config(context):
  210. return context[KAFKA][context[DSP][ACTIVE]][PRODUCER]
  211. def get_kafka_consumer_config(context):
  212. return context[KAFKA][context[DSP][ACTIVE]][CONSUMER]
  213. def get_kafka_bootstrap_servers(context):
  214. return context[KAFKA][context[DSP][ACTIVE]][BOOTSTRAP_SERVERS]
  215. def get_kafka_results_topic(context):
  216. return context[KAFKA][TOPIC][DSP_ALG_RESULTS_TOPIC]
  217. def get_kafka_recording_result_topic(context):
  218. return context[KAFKA][TOPIC][DSP_RECORDING_RESULTS_TOPIC]
  219. def get_aliyun_access_key(context):
  220. return context[ALIYUN][ACCESS_KEY]
  221. def get_aliyun_access_secret(context):
  222. return context[ALIYUN][ACCESS_SECRET]
  223. def get_aliyun_oss_endpoint(context):
  224. return context[ALIYUN][OSS][ENDPOINT]
  225. def get_aliyun_oss_bucket(context):
  226. return context[ALIYUN][OSS][BUCKET]
  227. def get_aliyun_oss_connect_timeout(context):
  228. return context[ALIYUN][OSS][CONNECT_TIMEOUT]
  229. def get_aliyun_vod_ecsRegionId(context):
  230. return context[ALIYUN][VOD][ECSREGIONID]
  231. def get_aliyun_vod_cateId(context):
  232. return context[ALIYUN][VOD][context[DSP][ACTIVE]][CATEID]
  233. def get_gpu_order(context):
  234. return context[GPU][ORDER]
  235. def get_gpu_limit(context):
  236. return context[GPU][LIMIT]
  237. def get_gpu_maxLoad(context):
  238. return context[GPU][MAXLOAD]
  239. def get_gpu_maxMemory(context):
  240. return context[GPU][MAXMEMORY]
  241. def get_gpu_includeNan(context):
  242. return context[GPU][INCLUDENAN]
  243. def get_gpu_excludeID(context):
  244. return context[GPU][EXCLUDEID]
  245. def get_gpu_excludeUUID(context):
  246. return context[GPU][EXCLUDEUUID]
  247. def get_baidu_vehicle_APP_ID(context):
  248. return context[BAIDU][VEHICLE][APP_ID]
  249. def get_baidu_vehicle_API_KEY(context):
  250. return context[BAIDU][VEHICLE][API_KEY]
  251. def get_baidu_vehicle_SECRET_KEY(context):
  252. return context[BAIDU][VEHICLE][SECRET_KEY]
  253. def get_baidu_person_APP_ID(context):
  254. return context[BAIDU][PERSON][APP_ID]
  255. def get_baidu_person_API_KEY(context):
  256. return context[BAIDU][PERSON][API_KEY]
  257. def get_baidu_person_SECRET_KEY(context):
  258. return context[BAIDU][PERSON][SECRET_KEY]
  259. def get_baidu_ocr_APP_ID(context):
  260. return context[BAIDU][ORC][APP_ID]
  261. def get_baidu_ocr_API_KEY(context):
  262. return context[BAIDU][ORC][API_KEY]
  263. def get_baidu_ocr_SECRET_KEY(context):
  264. return context[BAIDU][ORC][SECRET_KEY]
  265. def get_log_base_path(context):
  266. return context[LOG]["base_path"]
  267. def get_log_enable_file(context):
  268. return context[LOG]["enable_file_log"]
  269. def get_log_log_name(context):
  270. return context[LOG]["log_name"]
  271. def get_log_rotation(context):
  272. return context[LOG]["rotation"]
  273. def get_log_retention(context):
  274. return context[LOG]["retention"]
  275. def get_log_log_fmt(context):
  276. return context[LOG]["log_fmt"]
  277. def get_log_level(context):
  278. return context[LOG]["level"]
  279. def get_log_enqueue(context):
  280. return context[LOG]["enqueue"]
  281. def get_log_encoding(context):
  282. return context[LOG]["encoding"]
  283. def get_log_enable_stderr(context):
  284. return context[LOG]["enable_stderr"]
  285. CV2_PULL_STREAM_TIMEOUT = "cv2_pull_stream_timeout"
  286. CV2_READ_STREAM_TIMEOUT = "cv2_read_stream_timeout"
  287. def get_pull_stream_timeout(context):
  288. return int(context[SERVICE][CV2_PULL_STREAM_TIMEOUT])
  289. def get_read_stream_timeout(context):
  290. return int(context[SERVICE][CV2_READ_STREAM_TIMEOUT])
  291. def get_service_timeout(context):
  292. return int(context[SERVICE]["timeout"])
  293. FILTER = "filter"
  294. def get_similarity(context):
  295. return context[SERVICE][FILTER]["similarity"]
  296. def get_picture_similarity(context):
  297. return context[SERVICE][FILTER]["picture_similarity"]
  298. def get_frame_step(context):
  299. return int(context[SERVICE][FILTER]["frame_step"])