You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

algorithm-annotation.py 2.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. """
  2. /**
  3. * Copyright 2020 Tianshu AI Platform. All Rights Reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. * =============================================================
  17. */
  18. """
  19. # coding:utf-8
  20. import threading
  21. import time
  22. import sys
  23. sys.path.append("../")
  24. import common.RedisUtil as f
  25. from common import config as config
  26. from entrance.executor import annotation as annotation, taskexecutor
  27. import luascript.starttaskscript as start_script
  28. import logging
  29. from common import select_gpu as gpu
  30. logging.basicConfig(format='%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s',
  31. level=logging.DEBUG)
  32. if __name__ == '__main__':
  33. """Automatic annotation algorithm entry."""
  34. gpu.select_gpu()
  35. jsonData = config.loadJsonData(config.configPath)
  36. redisClient = f.getRedisConnection(jsonData["ip"], jsonData["port"], jsonData["database"], jsonData["password"])
  37. logging.info('init redis client %s', redisClient)
  38. t = threading.Thread(target=taskexecutor.delayKeyThread, args=(redisClient,))
  39. t.setDaemon(True)
  40. t.start()
  41. annotation._init()
  42. while 1:
  43. try:
  44. if config.loadJsonData(config.sign) == 0:
  45. logging.info('not to execute new task')
  46. time.sleep(1)
  47. else:
  48. logging.info('get one task')
  49. element = redisClient.eval(start_script.startTaskLua, 1, config.queue,
  50. config.annotationStartQueue, int(time.time()))
  51. if len(element) > 0:
  52. taskexecutor.annotationExecutor(redisClient, element[0]);
  53. else:
  54. logging.info('task queue is empty.')
  55. time.sleep(1)
  56. except Exception as e:
  57. logging.error('except:', e)
  58. time.sleep(1)

一站式算法开发平台、高性能分布式深度学习框架、先进算法模型库、视觉模型炼知平台、数据可视化分析平台等一系列平台及工具,在模型高效分布式训练、数据处理和可视分析、模型炼知和轻量化等技术上形成独特优势,目前已在产学研等各领域近千家单位及个人提供AI应用赋能

Contributors (1)