yolo_test_docker.py 995 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # -*- coding: utf-8 -*-
  2. # @Time : 2022/3/2 9:25
  3. # @Author : MaochengHu
  4. # @Email : wojiaohumaocheng@gmail.com
  5. # @File : yolo_test_docker.py
  6. # @Project : server_develop
  7. import os
  8. from server_utils.image_convert import path2base64
  9. from server_utils.read_properties import get_properties_dict
  10. import requests
  11. headers = {"Content-Type": "application/json"}
  12. properties_dict = get_properties_dict()
  13. inference_address = properties_dict.get("inference_address")
  14. def single_test(input_source):
  15. request_url = "{}/predictions/yolov5".format(inference_address)
  16. image_base64 = path2base64(input_source)
  17. payload = {"data": image_base64,
  18. "output_methods": str(["pd_xywh_json"]),
  19. "base64_bool": True}
  20. print(request_url)
  21. req = requests.post(url=request_url, data=payload)
  22. print(eval(req.text))
  23. def main():
  24. input_source = os.path.join(os.getcwd(), "../test_images/test1.jpg")
  25. single_test(input_source)
  26. if __name__ == "__main__":
  27. main()