未验证 提交 95e17ef3 编写于 作者: 郑博培 提交者: GitHub

Upload New Module——Digital dial segmentation of Watermeter (#1309)

* Digital dial segmentation of Watermeter
上级 8f13d8ca
DriverStatusRecognition
类别 图像 - 图像分类
网络 MobileNetV3_small_ssld
数据集 分心司机检测数据集
# 模型概述
驾驶员状态识别(DriverStatusRecognition),该模型可挖掘出人在疲劳状态下的表情特征,然后将这些定性的表情特征进行量化,提取出面部特征点及特征指标作为判断依据,再结合实验数据总结出基于这些参数的识别方法,最后输入获取到的状态数据进行识别和判断。该PaddleHub Module支持API预测及命令行预测。
# 选择模型版本进行安装
$ hub install DriverStatusRecognition==1.0.0
# 在线体验
[AI Studio快速体验](https://aistudio.baidu.com/aistudio/projectdetail/1649513)
# 命令行预测示例
$ hub run DriverStatusRecognition --image 1.png --use_gpu True
# Module API说明
## def predict(data)
驾驶员状态识别预测接口,输入一张图像,输出该图像上驾驶员的状态
### 参数
- data:dict类型,key为image,str类型,value为待检测的图片路径,list类型。
### 返回
- result:list类型,每个元素为对应输入图片的预测结果。预测结果为dict类型,key为该图片分类结果label,value为该label对应的概率
# 代码示例
## API调用
~~~
import cv2
import paddlehub as hub
module = hub.Module(directory='DriverStatusRecognition') # 一行代码实现模型调用
images = [cv2.imread('work/imgs/test/img_1622.jpg'), cv2.imread('work/imgs/test/img_14165.jpg'), cv2.imread('work/imgs/test/img_47183.jpg')]
results = module.predict(images=images)
for result in results:
print(result)
~~~
## 命令行调用
~~~
$ hub run DriverStatusRecognition --image 1.png --use_gpu True
~~~
# 效果展示
## 原图
<img src="/docs/imgs/Readme_Related/Image_Classification_Drivers.png">
## 输出结果
~~~
[{'category_id': 5, 'category': 'ch5', 'score': 0.47390476}]
[{'category_id': 2, 'category': 'ch2', 'score': 0.99997914}]
[{'category_id': 1, 'category': 'ch1', 'score': 0.99996376}]
~~~
# 贡献者
郑博培、彭兆帅
# 依赖
paddlepaddle >= 2.0.0<br>
paddlehub >= 2.0.0
Model: MobileNetV3_small_ssld
Transforms:
- ResizeByShort:
max_size: -1
short_size: 256
- CenterCrop:
crop_size: 224
- Normalize:
mean:
- 0.485
- 0.456
- 0.406
std:
- 0.229
- 0.224
- 0.225
TransformsMode: RGB
_Attributes:
eval_metrics:
acc1: 0.9888542131074454
fixed_input_shape: null
labels:
- ch0
- ch1
- ch2
- ch3
- ch4
- ch5
- ch6
- ch7
- ch8
- ch9
model_type: classifier
num_classes: 10
_ModelInputsOutputs:
test_inputs:
- - image
- image
test_outputs:
- - predict
- softmax_0.tmp_0
_init_params:
num_classes: 10
completed_epochs: 0
status: Infer
version: 1.3.7
from __future__ import absolute_import
from __future__ import division
import os
import cv2
import argparse
import base64
import paddlex as pdx
import numpy as np
import paddlehub as hub
from paddlehub.module.module import moduleinfo, runnable, serving
def base64_to_cv2(b64str):
data = base64.b64decode(b64str.encode('utf8'))
data = np.fromstring(data, np.uint8)
data = cv2.imdecode(data, cv2.IMREAD_COLOR)
return data
def cv2_to_base64(image):
# return base64.b64encode(image)
data = cv2.imencode('.jpg', image)[1]
return base64.b64encode(data.tostring()).decode('utf8')
def read_images(paths):
images = []
for path in paths:
images.append(cv2.imread(path))
return images
@moduleinfo(
name='DriverStatusRecognition',
type='cv/classification',
author='郑博培、彭兆帅',
author_email='2733821739@qq.com',
summary="Distinguish the driver's normal driving, making a phone call, drinking water and other different actions",
version='1.0.0')
class MODULE(hub.Module):
def _initialize(self, **kwargs):
self.default_pretrained_model_path = os.path.join(
self.directory, 'assets')
self.model = pdx.deploy.Predictor(self.default_pretrained_model_path,
**kwargs)
def predict(self,
images=None,
paths=None,
data=None,
batch_size=1,
use_gpu=False,
**kwargs):
all_data = images if images is not None else read_images(paths)
total_num = len(all_data)
loop_num = int(np.ceil(total_num / batch_size))
res = []
for iter_id in range(loop_num):
batch_data = list()
handle_id = iter_id * batch_size
for image_id in range(batch_size):
try:
batch_data.append(all_data[handle_id + image_id])
except IndexError:
break
out = self.model.batch_predict(batch_data, **kwargs)
res.extend(out)
return res
@serving
def serving_method(self, images, **kwargs):
"""
Run as a service.
"""
images_decode = [base64_to_cv2(image) for image in images]
results = self.predict(images_decode, **kwargs)
res = []
for result in results:
if isinstance(result, dict):
# result_new = dict()
for key, value in result.items():
if isinstance(value, np.ndarray):
result[key] = cv2_to_base64(value)
elif isinstance(value, np.generic):
result[key] = np.asscalar(value)
elif isinstance(result, list):
for index in range(len(result)):
for key, value in result[index].items():
if isinstance(value, np.ndarray):
result[index][key] = cv2_to_base64(value)
elif isinstance(value, np.generic):
result[index][key] = np.asscalar(value)
else:
raise RuntimeError('The result cannot be used in serving.')
res.append(result)
return res
@runnable
def run_cmd(self, argvs):
"""
Run as a command.
"""
self.parser = argparse.ArgumentParser(
description="Run the {} module.".format(self.name),
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
self.arg_input_group = self.parser.add_argument_group(
title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
title="Config options",
description=
"Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
results = self.predict(
paths=[args.input_path],
use_gpu=args.use_gpu)
return results
def add_module_config_arg(self):
"""
Add the command config options.
"""
self.arg_config_group.add_argument(
'--use_gpu',
type=bool,
default=False,
help="whether use GPU or not")
def add_module_input_arg(self):
"""
Add the command input options.
"""
self.arg_input_group.add_argument(
'--input_path', type=str, help="path to image.")
if __name__ == '__main__':
module = MODULE(directory='./new_model')
images = [cv2.imread('./cat.jpg'), cv2.imread('./cat.jpg'), cv2.imread('./cat.jpg')]
res = module.predict(images=images)
# coding: utf8
import requests
import json
import cv2
import base64
def cv2_to_base64(image):
data = cv2.imencode('.jpg', image)[1]
return base64.b64encode(data.tostring()).decode('utf8')
if __name__ == '__main__':
# 获取图片的base64编码格式
img1 = cv2_to_base64(cv2.imread("IMAGE_PATH1"))
img2 = cv2_to_base64(cv2.imread("IMAGE_PATH2"))
data = {'images': [img1, img2]}
# 指定content-type
headers = {"Content-type": "application/json"}
# 发送HTTP请求
url = "http://127.0.0.1:8866/predict/DriverStatusRecognition"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# 打印预测结果
print(r.json()["results"])
SnakeIdentification
类别 图像 - 图像分类
网络 ResNet50_vd_ssld
数据集 蛇种数据集
# 模型概述
蛇种识别(SnakeIdentification),该模型可准确识别蛇的种类,并精准判断蛇的毒性。该PaddleHub Module支持API预测及命令行预测。
# 选择模型版本进行安装
$ hub install SnakeIdentification==1.0.0
# 在线体验
[AI Studio快速体验](https://aistudio.baidu.com/aistudio/projectdetail/1646951)
# 命令行预测示例
$ hub run SnakeIdentification --image 1.png --use_gpu True
# Module API说明
## def predict(data)
蛇种识别预测接口,输入一张图像,输出该图像上蛇的类别
### 参数
- data:dict类型,key为image,str类型,value为待检测的图片路径,list类型。
### 返回
- result:list类型,每个元素为对应输入图片的预测结果。预测结果为dict类型,key为该图片分类结果label,value为该label对应的概率
# 代码示例
## API调用
~~~
import cv2
import paddlehub as hub
module = hub.Module(name="SnakeIdentification")
images = [cv2.imread('snake_data/class_1/2421.jpg')]
# execute predict and print the result
results = module.predict(images=images)
for result in results:
print(result)
~~~
## 命令行调用
~~~
$ hub run SnakeIdentification --image 1.png --use_gpu True
~~~
# 效果展示
## 原图
<img src="/docs/imgs/Readme_Related/Image_Classification_Snake.png">
## 输出结果
~~~
[{'category_id': 0, 'category': '水蛇', 'score': 0.9999205}]
~~~
# 贡献者
郑博培、彭兆帅
# 依赖
paddlepaddle >= 2.0.0<br>
paddlehub >= 2.0.0
Model: ResNet50_vd_ssld
Transforms:
- ResizeByShort:
max_size: -1
short_size: 256
- CenterCrop:
crop_size: 224
- Normalize:
mean:
- 0.485
- 0.456
- 0.406
std:
- 0.229
- 0.224
- 0.225
TransformsMode: RGB
_Attributes:
eval_metrics:
acc1: 1.0
fixed_input_shape: null
labels:
- "\u6C34\u86C7"
- "\u5251\u7EB9\u5E26\u86C7"
- "\u5FB7\u51EF\u65AF\u6C0F\u86C7"
- "\u9ED1\u9F20\u86C7"
- "\u897F\u90E8\u83F1\u6591\u54CD\u5C3E\u86C7"
model_type: classifier
num_classes: 5
_ModelInputsOutputs:
test_inputs:
- - image
- image
test_outputs:
- - predict
- softmax_0.tmp_0
_init_params:
num_classes: 5
completed_epochs: 0
status: Infer
version: 1.1.0
from __future__ import absolute_import
from __future__ import division
import os
import cv2
import argparse
import base64
import paddlex as pdx
import numpy as np
import paddlehub as hub
from paddlehub.module.module import moduleinfo, runnable, serving
def base64_to_cv2(b64str):
data = base64.b64decode(b64str.encode('utf8'))
data = np.fromstring(data, np.uint8)
data = cv2.imdecode(data, cv2.IMREAD_COLOR)
return data
def cv2_to_base64(image):
# return base64.b64encode(image)
data = cv2.imencode('.jpg', image)[1]
return base64.b64encode(data.tostring()).decode('utf8')
def read_images(paths):
images = []
for path in paths:
images.append(cv2.imread(path))
return images
@moduleinfo(
name='SnakeIdentification',
type='cv/classification',
author='郑博培',
author_email='2733821739@qq.com',
summary='Identify snake species',
version='1.0.0')
class MODULE(hub.Module):
def _initialize(self, **kwargs):
self.default_pretrained_model_path = os.path.join(
self.directory, 'assets')
self.model = pdx.deploy.Predictor(self.default_pretrained_model_path,
**kwargs)
def predict(self,
images=None,
paths=None,
data=None,
batch_size=1,
use_gpu=False,
**kwargs):
all_data = images if images is not None else read_images(paths)
total_num = len(all_data)
loop_num = int(np.ceil(total_num / batch_size))
res = []
for iter_id in range(loop_num):
batch_data = list()
handle_id = iter_id * batch_size
for image_id in range(batch_size):
try:
batch_data.append(all_data[handle_id + image_id])
except IndexError:
break
out = self.model.batch_predict(batch_data, **kwargs)
res.extend(out)
return res
@serving
def serving_method(self, images, **kwargs):
"""
Run as a service.
"""
images_decode = [base64_to_cv2(image) for image in images]
results = self.predict(images_decode, **kwargs)
res = []
for result in results:
if isinstance(result, dict):
# result_new = dict()
for key, value in result.items():
if isinstance(value, np.ndarray):
result[key] = cv2_to_base64(value)
elif isinstance(value, np.generic):
result[key] = np.asscalar(value)
elif isinstance(result, list):
for index in range(len(result)):
for key, value in result[index].items():
if isinstance(value, np.ndarray):
result[index][key] = cv2_to_base64(value)
elif isinstance(value, np.generic):
result[index][key] = np.asscalar(value)
else:
raise RuntimeError('The result cannot be used in serving.')
res.append(result)
return res
@runnable
def run_cmd(self, argvs):
"""
Run as a command.
"""
self.parser = argparse.ArgumentParser(
description="Run the {} module.".format(self.name),
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
self.arg_input_group = self.parser.add_argument_group(
title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
title="Config options",
description=
"Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
results = self.predict(
paths=[args.input_path],
use_gpu=args.use_gpu)
return results
def add_module_config_arg(self):
"""
Add the command config options.
"""
self.arg_config_group.add_argument(
'--use_gpu',
type=bool,
default=False,
help="whether use GPU or not")
def add_module_input_arg(self):
"""
Add the command input options.
"""
self.arg_input_group.add_argument(
'--input_path', type=str, help="path to image.")
if __name__ == '__main__':
module = MODULE(directory='./new_model')
images = [cv2.imread('./cat.jpg'), cv2.imread('./cat.jpg'), cv2.imread('./cat.jpg')]
res = module.predict(images=images)
# coding: utf8
import requests
import json
import cv2
import base64
def cv2_to_base64(image):
data = cv2.imencode('.jpg', image)[1]
return base64.b64encode(data.tostring()).decode('utf8')
if __name__ == '__main__':
# 获取图片的base64编码格式
img1 = cv2_to_base64(cv2.imread("IMAGE_PATH1"))
img2 = cv2_to_base64(cv2.imread("IMAGE_PATH2"))
data = {'images': [img1, img2]}
# 指定content-type
headers = {"Content-type": "application/json"}
# 发送HTTP请求
url = "http://127.0.0.1:8866/predict/SnakeIdentification"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# 打印预测结果
print(r.json()["results"])
WatermeterSegmentation
类别 图像 - 图像分割
网络 DeepLabV3
数据集 水表的数字表盘分割数据集
# 模型概述
水表的数字表盘分割(WatermeterSegmentation),该模型可自动提取水表上的数字。该PaddleHub Module支持API预测及命令行预测。
# 选择模型版本进行安装
$ hub install WatermeterSegmentation==1.0.0
# 在线体验
[AI Studio快速体验](https://aistudio.baidu.com/aistudio/projectdetail/1643214)
# 命令行预测示例
$ hub run WatermeterSegmentation --image 1.png --use_gpu True
# Module API说明
## def cutPic(picUrl)
水表的数字表盘分割预测接口,输入一张图像,输出该图像上水表记录的数字
### 参数
- picUrl(str): 待检测的图片路径
# 代码示例
## API调用
~~~
import cv2
import paddlehub as hub
seg = hub.Module(name='WatermeterSegmentation')
res = seg.cutPic(picUrl="1.png")
~~~
## 命令行调用
~~~
$ hub run WatermeterSegmentation --image 1.png --use_gpu True
~~~
# 效果展示
## 原图
<img src="/docs/imgs/Readme_Related/ImageSeg_WaterInput.png">
## 输出结果
<img src="/docs/imgs/Readme_Related/ImageSeg_WaterOutput.png">
# 贡献者
郑博培、彭兆帅
# 依赖
paddlepaddle >= 2.0.0<br>
paddlehub >= 2.0.0
Model: DeepLabv3p
Transforms:
- Resize:
interp: LINEAR
target_size: 512
- Normalize:
max_val:
- 255.0
- 255.0
- 255.0
mean:
- 0.5
- 0.5
- 0.5
min_val:
- 0
- 0
- 0
std:
- 0.5
- 0.5
- 0.5
TransformsMode: BGR
_Attributes:
eval_metrics:
miou: 0.8284633456567256
fixed_input_shape: null
labels:
- _background_
- number
model_type: segmenter
num_classes: 2
_ModelInputsOutputs:
test_inputs:
- - image
- image
test_outputs:
- - pred
- unsqueeze2_0.tmp_0
- - logit
- softmax_0.tmp_0
_init_params:
aspp_with_sep_conv: true
backbone: MobileNetV2_x1.0
class_weight: null
decoder_use_sep_conv: true
enable_decoder: true
encoder_with_aspp: true
ignore_index: 255
input_channel: 3
num_classes: 2
output_stride: 16
pooling_crop_size: null
use_bce_loss: false
use_dice_loss: false
completed_epochs: 0
status: Infer
version: 1.3.7
from __future__ import absolute_import
from __future__ import division
import os
import cv2
import argparse
import base64
import paddlex as pdx
from math import *
import time, math, re
import numpy as np
import paddlehub as hub
from paddlehub.module.module import moduleinfo, runnable, serving
def base64_to_cv2(b64str):
data = base64.b64decode(b64str.encode('utf8'))
data = np.fromstring(data, np.uint8)
data = cv2.imdecode(data, cv2.IMREAD_COLOR)
return data
def cv2_to_base64(image):
# return base64.b64encode(image)
data = cv2.imencode('.jpg', image)[1]
return base64.b64encode(data.tostring()).decode('utf8')
def read_images(paths):
images = []
for path in paths:
images.append(cv2.imread(path))
return images
'''旋转图像并剪裁'''
def rotate(
img, # 图片
pt1, pt2, pt3, pt4,
imgOutSrc):
# print(pt1,pt2,pt3,pt4)
withRect = math.sqrt((pt4[0] - pt1[0]) ** 2 + (pt4[1] - pt1[1]) ** 2) # 矩形框的宽度
heightRect = math.sqrt((pt1[0] - pt2[0]) ** 2 + (pt1[1] - pt2[1]) **2)
# print("矩形的宽度",withRect, "矩形的高度", heightRect)
angle = acos((pt4[0] - pt1[0]) / withRect) * (180 / math.pi) # 矩形框旋转角度
# print("矩形框旋转角度", angle)
if withRect > heightRect:
if pt4[1]>pt1[1]:
pass
# print("顺时针旋转")
else:
# print("逆时针旋转")
angle=-angle
else:
# print("逆时针旋转")
angle=90 - angle
height = img.shape[0] # 原始图像高度
width = img.shape[1] # 原始图像宽度
rotateMat = cv2.getRotationMatrix2D((width / 2, height / 2), angle, 1) # 按angle角度旋转图像
heightNew = int(width * fabs(sin(radians(angle))) + height * fabs(cos(radians(angle))))
widthNew = int(height * fabs(sin(radians(angle))) + width * fabs(cos(radians(angle))))
rotateMat[0, 2] += (widthNew - width) / 2
rotateMat[1, 2] += (heightNew - height) / 2
imgRotation = cv2.warpAffine(img, rotateMat, (widthNew, heightNew), borderValue=(255, 255, 255))
# cv2.imwrite("imgRotation.jpg", imgRotation)
# 旋转后图像的四点坐标
[[pt1[0]], [pt1[1]]] = np.dot(rotateMat, np.array([[pt1[0]], [pt1[1]], [1]]))
[[pt3[0]], [pt3[1]]] = np.dot(rotateMat, np.array([[pt3[0]], [pt3[1]], [1]]))
[[pt2[0]], [pt2[1]]] = np.dot(rotateMat, np.array([[pt2[0]], [pt2[1]], [1]]))
[[pt4[0]], [pt4[1]]] = np.dot(rotateMat, np.array([[pt4[0]], [pt4[1]], [1]]))
# 处理反转的情况
if pt2[1]>pt4[1]:
pt2[1],pt4[1]=pt4[1],pt2[1]
if pt1[0]>pt3[0]:
pt1[0],pt3[0]=pt3[0],pt1[0]
imgOut = imgRotation[int(pt2[1]):int(pt4[1]), int(pt1[0]):int(pt3[0])]
cv2.imwrite(imgOutSrc, imgOut) # 裁减得到的旋转矩形框
@moduleinfo(
name='WatermeterSegmentation',
type='CV/semantic_segmentatio',
author='郑博培、彭兆帅',
author_email='2733821739@qq.com',
summary='Digital dial segmentation of water meter',
version='1.0.0')
class MODULE(hub.Module):
def _initialize(self, **kwargs):
self.default_pretrained_model_path = os.path.join(
self.directory, 'assets')
self.model = pdx.deploy.Predictor(self.default_pretrained_model_path,
**kwargs)
def predict(self,
images=None,
paths=None,
data=None,
batch_size=1,
use_gpu=False,
**kwargs):
all_data = images if images is not None else read_images(paths)
total_num = len(all_data)
loop_num = int(np.ceil(total_num / batch_size))
res = []
for iter_id in range(loop_num):
batch_data = list()
handle_id = iter_id * batch_size
for image_id in range(batch_size):
try:
batch_data.append(all_data[handle_id + image_id])
except IndexError:
break
out = self.model.batch_predict(batch_data, **kwargs)
res.extend(out)
return res
def cutPic(self, picUrl):
# seg = hub.Module(name='WatermeterSegmentation')
image_name = picUrl
im = cv2.imread(image_name)
result = self.predict(images=[im])
# 将多边形polygon转矩形
contours, hier = cv2.findContours(result[0]['label_map'], cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
print(type(contours[0]))
n = 0
m = 0
for index,contour in enumerate(contours):
if len(contour) > n:
n = len(contour)
m = index
image = cv2.imread(image_name)
# 获取最小的矩形
rect = cv2.minAreaRect(contours[m])
box = np.int0(cv2.boxPoints(rect))
# 获取到矩形的四个点
tmp = cv2.drawContours(image, [box], 0, (0, 0, 255), 3)
imgOutSrc = 'result.jpg'
rotate(image, box[0], box[1], box[2], box[3], imgOutSrc)
res = []
res.append(imgOutSrc)
return res
@serving
def serving_method(self, images, **kwargs):
"""
Run as a service.
"""
images_decode = [base64_to_cv2(image) for image in images]
results = self.predict(images_decode, **kwargs)
res = []
for result in results:
if isinstance(result, dict):
# result_new = dict()
for key, value in result.items():
if isinstance(value, np.ndarray):
result[key] = cv2_to_base64(value)
elif isinstance(value, np.generic):
result[key] = np.asscalar(value)
elif isinstance(result, list):
for index in range(len(result)):
for key, value in result[index].items():
if isinstance(value, np.ndarray):
result[index][key] = cv2_to_base64(value)
elif isinstance(value, np.generic):
result[index][key] = np.asscalar(value)
else:
raise RuntimeError('The result cannot be used in serving.')
res.append(result)
return res
@runnable
def run_cmd(self, argvs):
"""
Run as a command.
"""
self.parser = argparse.ArgumentParser(
description="Run the {} module.".format(self.name),
prog='hub run {}'.format(self.name),
usage='%(prog)s',
add_help=True)
self.arg_input_group = self.parser.add_argument_group(
title="Input options", description="Input data. Required")
self.arg_config_group = self.parser.add_argument_group(
title="Config options",
description=
"Run configuration for controlling module behavior, not required.")
self.add_module_config_arg()
self.add_module_input_arg()
args = self.parser.parse_args(argvs)
results = self.predict(
paths=[args.input_path],
use_gpu=args.use_gpu)
return results
def add_module_config_arg(self):
"""
Add the command config options.
"""
self.arg_config_group.add_argument(
'--use_gpu',
type=bool,
default=False,
help="whether use GPU or not")
def add_module_input_arg(self):
"""
Add the command input options.
"""
self.arg_input_group.add_argument(
'--input_path', type=str, help="path to image.")
if __name__ == '__main__':
module = MODULE(directory='./new_model')
images = [cv2.imread('./cat.jpg'), cv2.imread('./cat.jpg'), cv2.imread('./cat.jpg')]
res = module.predict(images=images)
# coding: utf8
import requests
import json
import cv2
import base64
def cv2_to_base64(image):
data = cv2.imencode('.jpg', image)[1]
return base64.b64encode(data.tostring()).decode('utf8')
if __name__ == '__main__':
# 获取图片的base64编码格式
img1 = cv2_to_base64(cv2.imread("IMAGE_PATH1"))
img2 = cv2_to_base64(cv2.imread("IMAGE_PATH2"))
data = {'images': [img1, img2]}
# 指定content-type
headers = {"Content-type": "application/json"}
# 发送HTTP请求
url = "http://127.0.0.1:8866/predict/WatermeterSegmentation"
r = requests.post(url=url, headers=headers, data=json.dumps(data))
# 打印预测结果
print(r.json()["results"])
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册