SageMaker Ground Truth をチュートリアルレベルで試してみた
Training data labeling using humans with Amazon SageMaker Ground Truth - Amazon SageMaker AI
To train a machine learning model, you need a large, high-quality, labeled dataset. Ground Truth helps you build high-quality training datasets for your machine learning models. With Ground Truth, you can use workers from either Amazon Mechanical Turk, a vendor company that you choose, or an internal, private workforce along with machine learning to enable you to create a labeled dataset.
Ground Truth でデータセットである画像にラベル付けをやってみました。
1. データの準備
今回は画像にラベル付けするので、任意の画像を 3 枚用意しました。
2. S3 バケットの作成
デフォルト設定で S3 バケットを作成します。
S3 バケットに手順 1 の画像をアップロードします。
S3 バケットに output フォルダを作成します。
3. マニフェストファイルの作成
A manifest file contains information about the images and image labels that you can use to train and test a model. You can store a manifest file in an Amazon S3 bucket and use it to create a dataset.
マニフェストファイルはトレーニングで使用する画像情報などを定義するファイルです。
今回は以下のようなファイルを作成しました。
{"source-ref":"s3://sagemaker-groundtruth-tutorial-20241227/01.jpg"}
{"source-ref":"s3://sagemaker-groundtruth-tutorial-20241227/02.jpg"}
{"source-ref":"s3://sagemaker-groundtruth-tutorial-20241227/03.jpg"}
source-ref には 2 で S3 バケットにアップロードした画像の S3 URI を指定します。
マニフェストファイルも S3 バケットにアップロードします。
4. Ground Truth でラベリングジョブを作成
SageMaker AI のコンソールから Ground Truth > ラベリングジョブを選択します。
「ラベリングジョブの作成」をクリックして設定を行います。
-
ジョブ名: 任意のジョブ名
-
入力データのセットアップ: 手動によるデータのセットアップ
-
入力データセットの場所: マニフェストファイルの S3 パス
-
出力データセットの場所: 2 の S3 バケットの output フォルダ
-
IAM ロール: Create a new role
- S3 バケットの指定はなし
-
タスクのタイプ: Image
-
ワーカータイプ: プライベート
-
チーム名: 任意のチーム名
-
プライベートな注釈者の招待: 自分のメールアドレス
-
企業・団体名: 任意の名称
-
連絡先 E メール: 自分のメールアドレス
-
画像分類 (単一ラベル) ラベル付けツール
- 説明: 任意の内容
- オプション: 写真にマッチするような分類項目
ジョブの作成直後は以下のような画面が表示されます。
5. ラベリングジョブを行う
4 で指定したメールアドレス宛てに以下のようなメールが届いているはずです。
You are invited by xxx from test to work on a labeling project
Hi,
You are invited by xxx from test to work on a labeling project
Click on the link below to log into your labeling project.
https://xxx.labeling.ap-northeast-1.sagemaker.aws
You will need the following username and temporary password provided below to login for the first time.
User name: xxx
Temporary password: xxx
メール内のリンクをクリックするとログイン画面が表示されるので、メールに記載されているユーザー名とパスワードを入力します。
パスワードを変更します。
ログイン後にジョブが表示されるので、「Start working」をクリックします。
なお、ジョブ作成直後だとログイン後にジョブが表示されない場合もあるため、ジョブが表示されない場合は数分待ってください。
手順 2 でアップロードした画像を分類する画面が表示されるので、適切なラベルを付けます。
すべての画像へのラベル付けが終わればラベリングジョブは完了です。
ジョブ一覧からもジョブが消えました。
ラベリングジョブの完了後、数分待つと SageMaker コンソールでもステータスが完了になります。
おまけ
ラベリングジョブの作成後、S3 バケットの output フォルダにはラベリングに関するデータが出力されていました。
- S3 バケットのパス
- ラベリングジョブの UI に関する定義
- 分類結果に関する情報
また、Ground Truth でワーカータイプをプライベートにした場合、Cognito で認証する仕様のためユーザープールが自動作成されていました。
Create a Private Workforce (Amazon SageMaker AI Console) - Amazon SageMaker AI
If you haven't created a private workforce when you create your labeling job and you choose to use private workers, you are prompted to create a work team. This will create a private workforce using Amazon Cognito.
なお、ラベリングジョブは現時点では削除ができない仕様のようです。
amazon web services - How to delete a Sagemaker Ground Truth Labeling Job? - Stack Overflow
At the moment it is not possible to delete a Labeling Job from
console, CLI or SDK. If the Job is "In Progress" you can stop the job
to avoid further labeling and charges associated with it.
まとめ
今回は SageMaker Ground Truth をチュートリアルレベルで試してみました。
どなたかの参考になれば幸いです。
参考資料
- Training data labeling using humans with Amazon SageMaker Ground Truth - Amazon SageMaker AI
- Creating a dataset using an Amazon SageMaker AI Ground Truth manifest file - Amazon Lookout for Vision
- Create a Private Workforce (Amazon SageMaker AI Console) - Amazon SageMaker AI
- amazon web services - How to delete a Sagemaker Ground Truth Labeling Job? - Stack Overflow
Discussion