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.

track.py 2.4 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # !/usr/bin/env python
  2. # -*- coding:utf-8 -*-
  3. """
  4. Copyright 2020 Tianshu AI Platform. All Rights Reserved.
  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. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================
  15. """
  16. import sched
  17. from abc import ABC
  18. from program.abstract.algorithm import Algorithm
  19. from program.exec.track.track_only.hog_track import *
  20. schedule = sched.scheduler(time.time, time.sleep)
  21. delayId = ""
  22. class Track(Algorithm, ABC):
  23. def __init__(self):
  24. pass
  25. def execute(task):
  26. return Track.trackProcess(task)
  27. def trackProcess(task):
  28. """Track task method.
  29. Args:
  30. task: dataset id.
  31. key: video file path.
  32. Returns:
  33. True: track success
  34. False: track failed
  35. """
  36. global delayId
  37. image_list = []
  38. label_list = []
  39. images_data = task['images']
  40. path = task['path']
  41. dataset_id = task['id']
  42. result = True
  43. for file in images_data:
  44. filePath = path + "/origin/" + file
  45. annotationPath = path + "/annotation/" + file.split('.')[0]
  46. if not os.path.exists(filePath):
  47. continue
  48. if not os.path.exists(annotationPath):
  49. continue
  50. image_list.append(filePath)
  51. label_list.append(annotationPath)
  52. image_num = len(label_list)
  53. track_det = Detector(
  54. 'xxx.avi',
  55. min_confidence=0.35,
  56. max_cosine_distance=0.2,
  57. max_iou_distance=0.7,
  58. max_age=30,
  59. out_dir='results/')
  60. track_det.write_img = False
  61. RET = track_det.run_track(image_list, label_list)
  62. finished_json = {'id': dataset_id}
  63. if RET == 'OK':
  64. return finished_json, result
  65. else:
  66. return finished_json, result

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