PaddlePaddle / PaddleX

Low-code development tool based on PaddlePaddle(飞桨低代码开发工具)
Apache License 2.0
4.76k stars 935 forks source link

工业表计读数错误 #323

Open Zx-rqq opened 3 years ago

Zx-rqq commented 3 years ago

我测试了PaddleX-develop/examples/meter_reader里的代码。METER_CONFIG也根据图片进行了修改,但是读数有问题。请问是否哪里配置有问题。谢谢

======================== visualize_163

捕获

Zx-rqq commented 3 years ago

visualize_IMG20200612112604 捕获

Zx-rqq commented 3 years ago

@FlyingQianMM 您好,可以帮我看一下 指针读数不正确的问题吗?谢谢

jiangjiajun commented 3 years ago

@FlyingQianMM 您好,可以帮我看一下 指针读数不正确的问题吗?谢谢

你好,我们正在问题定位中

FlyingQianMM commented 3 years ago

https://github.com/PaddlePaddle/PaddleX/issues/323#issue-706183858

我们这个案例里面只有两种表,一种刻度根数为50, 另一种刻度根数为32。因此提供的python预测脚本里面,是通过检测出的刻度根数来判断表盘类型。如果刻度根数小于TYPE_THRESHOLD(40),则为第二种表盘。

你提供的这张图片较为模糊,直接使用我们提供的预训练模型分割出来后的结果如下: visualize_1600933069323 此时分割出的刻度根数为39,代码会将其判断为第二种类别。如果修改TYPE_THRESHOLD为35,即可以得到正确的读数: visualize_93860436-b27bd800-fcf1-11ea-9224-499e49f2b4bf

FlyingQianMM commented 3 years ago

https://github.com/PaddlePaddle/PaddleX/issues/323#issuecomment-696586880

读数为负,是因为语义分割没有分割出指针,直接使用我们提供的预训练模型对你这张图片分割出来后的结果如下: visualize_1600932806900

由于没有分割出指针,因此计算得出的scale为默认值-1 (参考https://github.com/PaddlePaddle/PaddleX/blob/98f951054b1722577d34e170c45d709e0c55cbd2/examples/meter_reader/reader_infer.py#L290-L302 ), 而刻度根数小于TYPE_THRESHOLD,判断为第二种表盘,最终读数为scale scale_value = -1 0.05。

我们这个案例提供的训练数据数量有限且变化单一,对于你这样的表盘类型没有覆盖,所以直接使用我们提供的预训练模型对实际场景中各式各样的表盘进行分割时结果可能会不正确,建议针对新的数据重新训练finetune。

表计读数案例的部署代码后续我们也会添加注释,增强代码的可读性和可修改性。

hsl8856 commented 3 years ago

请问能不能提供表盘分割数据标记的实例。语义分割时,数据使用labelme 标记,具体怎么标注呢?

jiangjiajun commented 3 years ago

https://paddlex.readthedocs.io/zh_CN/develop/data/annotation/index.html 数据标注方法参考此文档,你可以下载表计分割的数据下来进行可视化查看相应标注结果 https://aistudio.baidu.com/aistudio/projectdetail/684200

hsl8856 commented 3 years ago

下载的表盘分割数据集中,数据进行和格式转换,从json 格式转换为了SEG 格式(paddlex --data_conversion --source labelme --to SEG),请问这个过程可以逆转回来吗?从seg 格式得到json 格式

jiangjiajun commented 3 years ago

目前不支持

MichaelZhero commented 3 years ago

image 1、有底纹时,分割不准。2、负数情况需要添加字符识别。3、表盘精度过高,识别有误。 image

MichaelZhero commented 3 years ago

image

过程图像监控,通过伽马增强,查看增加分割输出后的结果。

def read_process(self, label_maps): """Get the pointer location relative to the scales. o Args: label_maps (np.array): the label map output from a segmeter for a meter.

    """
    # Convert the circular meter into a rectangular meter
    #保存分割后的图像
    cv2.imwrite('./image/55.bmp', label_maps)

    Cimg = label_maps / 4
    # 伽玛变换
    gamma = 0.5
    Cimg1 = np.power(Cimg, gamma)
    line_images = self.creat_line_image(label_maps)
    # Get two one-dimension data where 0 represents background and >0 represents
    # a scale or a pointer

    cv2.imwrite('./image/Cimg1.bmp', Cimg1)
    cv2.namedWindow('showimg', cv2.WINDOW_KEEPRATIO)
    #显示伽马增强后的图像
    cv2.imshow('showimg', Cimg1)
    cv2.waitKey(0)
    print('show data')
    scale_data, pointer_data = self.convert_1d_data(line_images)

    # Fliter scale data whose value is lower than the mean value
    self.scale_mean_filtration(scale_data)

    # Get the number of scales,the pointer location relative to the scales, the ratio between
    # the distance from the pointer to the starting scale and distance from the ending scale to the
    # starting scale.
    result = self.get_meter_reader(scale_data, pointer_data)
    return result
FlyingQianMM commented 3 years ago

1、有底纹时,分割不准。2、负数情况需要添加字符识别。3、表盘精度过高,识别有误。

  1. 可以增加有底纹的图片到训练集中,增加样本的丰富度
  2. 负数情况需要根据这种表盘类型制定读数的计算方式,例如起始值从-0.1开始
  3. 表盘精度过高时,可以尝试下训练时增大分割器的输入;或者尝试更换分割器为对小像素有更强的特征提取能力的模型,例如hrnet
mafeng199325 commented 1 year ago

图像 1、有底纹时,分割不准。2、负数情况需要添加字符识别。3、表盘浓度过高,识别有错。 图像

存在问题: 1、指针仪表盘为倾斜状态 2、仪表刻度有负数如何解决