123456789101112131415161718192021222324252627282930313233343536373839404142 |
- # -*- coding: utf-8 -*-
- # @Time : 2022/2/28 15:06
- # @Author : MaochengHu
- # @Email : wojiaohumaocheng@gmail.com
- # @File : yolo_test_handler.py
- # @Project : server_develop
- import sys
- import os
- root_src = "../../src"
- def import_env(names):
- for name in names:
- sys.path.append(os.path.join(os.getcwd(), name))
- append_path = ["../../src/server_utils", "../../src/", "../../src/model_structure",
- "../../src/model_structure/yolov5_structure/yolov5-master"]
- import_env(append_path)
- from server_utils.image_convert import path2base64
- from object_detector_handler import ObjectDetectionHandler
- def main():
- test_source = "../test_images/test1.jpg"
- base64str = path2base64(test_source)
- context = None
- # , "pd_xywhn", "pd_xyxy", "pd_xyxyn", "tolist", "crop_np", "crop_base64",
- # "detail_time_info", "render_base64"
- output_methods = ["pd_xywh_json"]
- obh = ObjectDetectionHandler()
- data = {"data": base64str, "output_methods": str(output_methods).encode(), "base64_bool": str(True).encode()}
- result = obh.handle([data], context)
- print(result)
- if __name__ == "__main__":
- main()
|