multi_thread_test.py 1.1 KB

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