日日行,不怕千万里;常常做,不怕千万事|

__username

园龄:2年4个月粉丝:12关注:2

📂python
🔖Python
2023-08-28 16:10阅读: 54评论: 0推荐: 0

服务器访问yolov5接口

import time
import requests, base64, cv2
# url = 'http://127.0.0.1:5555/yolov5'
url = 'http://43.139.184.232:5555/yolov5'
def image_to_base64(image_path):
import base64
with open(image_path, "rb") as image_file:
image_data = image_file.read()
base64_encoded = base64.b64encode(image_data).decode("utf-8")
return base64_encoded
image_path = r"E:\Code\Python\yolotest0823\datasets\coco128\images\train2017\000000000009.jpg"
base64_image = image_to_base64(image_path)
# print(base64_image)
dic = {
"image_data": base64_image
}
t1 = time.time()
res = requests.post(url=url, json=dic)
t2 = time.time()
print(res.status_code)
print(res.json())
print(f'时间{t2-t1}')
posted @   __username  阅读(54)  评论(0编辑  收藏  举报

本文作者:DIVMonster

本文链接:https://www.cnblogs.com/guangzan/p/12886111.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起