Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.
Gen1 DocsLegacy

Page updated Mar 26, 2026

テキストの識別

注: 必ず最初に入門セクションを完了してください。ここでは、適切なポリシーアクションを持つIAMロールを設定します。

APIの操作

入力画像内のテキストを検出します。入力はブラウザから直接送信することも、プロジェクトバケットからAmazon S3キーとして送信することもできます。

import { Predictions } from '@aws-amplify/predictions';
const response = await Predictions.identify({
text: {
source: {
file
}
}
});

Amazon S3に保存された画像を識別

import { Predictions } from '@aws-amplify/predictions';
const response = await Predictions.identify({
text: {
source: {
key: pathToPhoto,
}
}
})

以下のオプションは、指定されたsourceに関係なく独立しています。デモンストレーションの目的でfileを参照しますが、S3キーにすることもできます。Predictions.identify({text : {...}})は、構造化されていないテキストPLAIN、テーブルからの構造化テキストTABLE、またはフォームからのテキストFORMを検出できます。

プレーンテキストを識別

プレーンテキストを検出する場合、検出されたテキスト全体、検出された行、各テキスト行の位置、および各単語を確認できます。

import { Predictions } from '@aws-amplify/predictions';
const response = await Predictions.identify({
text: {
source: {
file
},
format: 'PLAIN'
}
});
const {
text: {
fullText, // String
lines, // Array of String ordered from top to bottom
linesDetailed /* Array of objects that contains
text, // String
boundingBox: {
width, // ratio of overall image width
height, // ratio of overall image height
left, // left coordinate as a ratio of overall image width
top // top coordinate as a ratio of overall image height
},
polygon // Array of { x, y } coordinates as a ratio of overall image width and height
*/,
words // Array of objects that contains { text, boundingBox, polygon}
}
} = response;

構造化されたフォームを識別

画像から構造化されたフォーム(ドキュメント、テーブルなど)を検出する場合、keyValuesは画像内で見つかったエンティティの文字列を返します。また、チェックボックスの選択状態やboundingBoxを使用した画像内の相対位置などのメタデータも返します。

import { Predictions } from '@aws-amplify/predictions';
const response = await Predictions.identify({
text: {
source: {
file
},
format: 'FORM'
}
});
const {
text: {
// same as PLAIN +
keyValues // Array of { key: string, value: { text: string, selected: boolean}, polygon, boundingBox }
}
} = response;

例えば、以下の画像は、キーとして「Test」または「Checked」を持つkeyValuesを返し、選択されているためtrueの値を返します。これらの要素の位置はboundingBox値に返されます。

キーと値を含むテーブルの画像。「Test」または「Checked」がキーとして含まれ、選択状態を示す値がtrueです。これらの要素の位置はboundingBoxパラメータ内に提供されます

構造化されたテーブルを識別

画像から構造化されたテーブルを検出する場合

import { Predictions } from '@aws-amplify/predictions';
const response = await Predictions.identify({
text: {
source: {
file
},
format: 'TABLE'
}
});
const {
text: {
// same as PLAIN +
tables: [
{
size: { rows, columns },
table // Matrix Array[ Array ] of size rows
// each element of the array contains { text, boundingBox, polygon, selected, rowSpan, columnSpan}
}
]
}
} = response;

画像上のテーブルとフォームを検出するには、フォーマット「ALL」を選択してください。

import { Predictions } from '@aws-amplify/predictions';
const { text } = await Predictions.identify({
text: {
source: {
file
},
format: 'ALL'
}
});