すべてのプロダクト
Search
ドキュメントセンター

Platform For AI:エンドツーエンドのテキスト認識

最終更新日:Jul 22, 2024

EasyVision of Machine Learning Platform for AIを使用すると、エンドツーエンドのテキスト認識でモデルトレーニングと予測を実行できます。 さらに、EasyVisionを使用して、複数のサーバーで分散トレーニングと予測を実行できます。 このトピックでは、EasyVisionを使用して、既存のトレーニングモデルに基づいてエンドツーエンドのテキスト認識でオフライン予測を実現する方法について説明します。

データフォーマット

詳細については、「入力データ形式」をご参照ください。

エンドツーエンドのテキスト認識におけるオフライン予測

次のMachine Learning Platform for AIコマンドを実行して、既存のファイルに基づいてエンドツーエンドのテキスト認識でオフライン予測を開始できます。SQL Scriptコンポーネント、MaxComputeクライアント、またはDataWorksのODPS SQLノードを使用してPAIコマンドを呼び出すことができます。 詳細については、「MaxComputeクライアント (odpscmd) 」または「MaxCompute SQLタスクの開発」をご参照ください。

pai -name ev_predict_ext
             -Dmodel_path='OSS path of your model'
             -Dmodel_type='text_spotter'
             -Dinput_oss_file='oss://path/to/your/filelist.txt'
             -Doutput_oss_file='oss://path/to/your/result.txt'
             -Dimage_type='url'
             -Dnum_worker=2
             -DcpuRequired=800
             -DgpuRequired=100
             -Dbuckets='Your OSS directory'
             -Darn='Alibaba Cloud Resource Name (ARN) of the role that you are assuming'
             -DossHost='Your OSS domain'

詳細については、「パラメーター」をご参照ください。

Output

予測結果は出力ファイルに書き込まれます。 ファイルの各エントリは、Object Storage Service (OSS) パスとJSON文字列で構成されています。 OSSパスは元の画像のパスを示し、JSON文字列は予測結果を示します。 たとえば、出力ファイルには次の情報が含まれています。

oss://path/to/your/image1.jpg,  JSON string
oss://path/to/your/image1.jpg,  JSON string
oss://path/to/your/image1.jpg,  JSON string

JSON文字列の形式は次のとおりです。

{
  "detection_keypoints": [[[243.57516479492188, 198.84210205078125], [243.91038513183594, 247.62425231933594], [385.5513916015625, 246.61660766601562], [385.2197570800781, 197.79345703125]], [[292.2718200683594, 114.44700622558594], [292.2237243652344, 164.684814453125], [571.1962890625, 164.931640625], [571.2444458007812, 114.67433166503906]]],
  "detection_boxes": [[243.5308074951172, 197.69570922851562, 385.59625244140625, 247.7247772216797], [292.1929931640625, 114.28043365478516, 571.2748413085938, 165.09771728515625]],
  "detection_scores": [0.9942291975021362, 0.9940272569656372],
  "detection_classes": [1, 1],
  "detection_classe_names": ["text", "text"],
  "detection_texts_ids" : [[1,2,2008,12], [1,2,2008,12]],
  "detection_texts": ["This is an example.", "This is an example."],
  "detection_texts_scores" : [0.88, 0.88]
 }

次の表に、JSON文字列のパラメーターを示します。

パラメーター

説明

形状

データ型

detection_boxes

検出された座標のテキスト領域は、[top, left, bottom, right] の順です。

[num_detections, 4]

FLOAT

detection_scores

テキストが検出される確率。

num_detections

FLOAT

detection_classes

テキスト領域が属するカテゴリのID。

num_detections

INT

detection_class_names

テキスト領域が属するカテゴリの名前。

num_detections

STRING

detection_keypoints

検出されたテキスト領域の4つの頂点の座標 (y, x)

[num_detections, 4, 2]

FLOAT

detection_texts_ids

認識されたテキストの1行が属するカテゴリのID。

[num_detections、max_text_length]

INT

detection_text

単一行テキストの認識結果。

[num_detections]

STRING

detection_texts_scores

単一行のテキストが認識される確率。

[num_detections]

FLOAT