【问题标题】:Text Detection using tensorflowjs使用 tensorflowjs 进行文本检测
【发布时间】:2021-09-04 03:43:19
【问题描述】:

我想只使用 tensorfow.js 或 opencv.js 在图像中进行文本检测,我已经在 keras 上构建了 EAST 模型并转换为 tensorflowjs 模型

谁能帮我解决这个问题,任何资源都会很棒

谢谢。

【问题讨论】:

    标签: tensorflow.js tensorflowjs-converter


    【解决方案1】:

    所以,最初您需要下载 East freeze 模型,然后使用以下命令将其转换为 tensorflow.js 模型

    tensorflowjs_converter --input_format=tf_frozen_model --output_node_names='feature_fusion/Conv_7/Sigmoid,feature_fusion/concat_3' /path_to_model  /path_to_where_you_want_save_converted_model.
    
    

    接下来在获取输入图像并加载模型后,下面的代码将检测文本是否存在

     $("#predict-button").click(async function () {
            let image = $("#selected-image").get(0);
            let tensor = tf.browser.fromPixels(image)
                .resizeNearestNeighbor([640, 320])
                .expandDims(0);
                
    
        tensor = tf.cast(tensor, 'float32')
        const [output1, output2] = await model.predict(tensor);
        const data1 = await output1.data();
        const data2 = await output2.data();
    

    由于东部模型提供两个输出,即分数和几何。所以这里 data1 将给出几何图形(我忽略了它,因为我的最终目标是检测文本是否存在而不是对其进行本地化),而 data2 将给出分数。

    接下来,我设置了 0.5 的阈值来区分文本是否存在。如果概率大于 0.5 则文本存在,如果小于 0.5 则文本不存在于文本中。

    注意:目前,我跳过了预处理步骤(调整大小除外),他们从输入图像的 RGB 值中减去平均 RGB 值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-06
      • 2011-04-12
      • 1970-01-01
      • 2021-12-07
      • 2011-05-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多