6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Amazon SageMaker 物体検出モデルの構築 ~Honey Bees~

Last updated at Posted at 2019-12-09

Amazon AI by ナレコム Advent Calendar 2019の8日目の記事です。

AWS公式機械学習トレーニングAmazon SageMaker: Build an Object Detection Model Using Images Labeled with Ground Truth (Japanese) (Ground Truth のラベルが付いたイメージを使用して、オブジェクト検出モデルを構築) を参考に、物体検出のモデル構築についてまとめてみました。

物体検出とは

今回は画像からミツバチの検出を行います。

クラスタリング(分類)・・・1枚の画像がどのタグに分類できるか
物体検出・・・1枚の画像の中から特定の物体の境界ボックス(BoundingBox)を検出
セグメンテーション・・・ピクセル単位での分類

データのダウンロード

iNaturalist.org から CC0 ライセンスに基づくミツバチの画像500枚を使用します。
ここからダウンロードしてください。

学習画像500枚、テスト画像10枚、アノテーションデータ(.manifest)で構成されています。
honey03.PNG

ラベリングの実施

output.manifest は GroundTruth を使ってラベリングされた結果です。
各行が各学習画像のアノテーション結果になっています。

{"source-ref":"s3://sagemaker-remars/datasets/na-bees/500/10006450.jpg","bees-500":{"annotations":[{"class_id":0,"width":95.39999999999998,"top":256.2,"height":86.80000000000001,"left":177}],"image_size":[{"width":500,"depth":3,"height":500}]},"bees-500-metadata":{"job-name":"labeling-job/bees-500","class-map":{"0":"bee"},"human-annotated":"yes","objects":[{"confidence":0.75}],"creation-date":"2019-05-16T00:15:58.914553","type":"groundtruth/object-detection"}}
{"source-ref":"s3://sagemaker-remars/datasets/na-bees/500/10022723.jpg","bees-500":{"annotations":[{"class_id":0,"width":93.8,"top":228.8,"height":135,"left":126.8}],"image_size":[{"width":375,"depth":3,"height":500}]},"bees-500-metadata":{"job-name":"labeling-job/bees-500","class-map":{"0":"bee"},"human-annotated":"yes","objects":[{"confidence":0.82}],"creation-date":"2019-05-16T00:41:33.384412","type":"groundtruth/object-detection"}}
{"source-ref":"s3://sagemaker-remars/datasets/na-bees/500/10059108.jpg","bees-500":{"annotations":[{"class_id":0,"width":157.39999999999998,"top":188.60000000000002,"height":131.2,"left":110.8}],"image_size":[{"width":375,"depth":3,"height":500}]},"bees-500-metadata":{"job-name":"labeling-job/bees-500","class-map":{"0":"bee"},"human-annotated":"yes","objects":[{"confidence":0.8}],"creation-date":"2019-05-16T00:57:28.636681","type":"groundtruth/object-detection"}}
・・・

output.manifestを編集するか、ラベリングツールは好きなもの(VoTTなど)を使用し、下記のようなをフォーマットでアノテーションデータを作成します。

{"source-ref": "s3://{bucketname}/{foldername}/train/{root}.{exts}", "train/validation": {"annotations": [{"class_id": {class_id}, "width": {width}, "top": {top}, "height": {height}, "left": {left}}], "image_size": [{"width": {width}, "depth": {depth}, "height": {height}}]}}
  • "source-ref":画像のS3パス
  • "train/validation":学習(Train)もしくは検証(Validation)
    • "annotations":アノテーションデータ
      • "class_id":検出するタグ(タグごとに0から順につける番号)
      • "width", "top", "height", "left":タグの境界ボックスの左上の点(top, left)とボックスのサイズ(width, height)
    • "image_size":画像幅(width)、チャンネル数(depth)、画像高さ(height)

今回は学習画像(Train)を400枚、残りの100枚を検証画像(Validation)とし、train.manifest、validation.manifest の2つを作成します。対応する画像のファイル形式はJPGとPNGになります。

train.manifest

{"source-ref": "s3://sagemaker-mlbees/20191208/train/10006450.jpg", "train": {"annotations": [{"class_id": 0, "width": 95, "top": 256, "height": 86, "left": 177}], "image_size": [{"width": 500, "depth": 3, "height": 500}]}}
{"source-ref": "s3://sagemaker-mlbees/20191208/train/10022723.jpg", "train": {"annotations": [{"class_id": 0, "width": 93, "top": 228, "height": 135, "left": 126}], "image_size": [{"width": 375, "depth": 3, "height": 500}]}}
{"source-ref": "s3://sagemaker-mlbees/20191208/train/10059108.jpg", "train": {"annotations": [{"class_id": 0, "width": 157, "top": 188, "height": 131, "left": 110}], "image_size": [{"width": 375, "depth": 3, "height": 500}]}}
・・・
{"source-ref": "s3://sagemaker-mlbees/20191208/train/10437385.jpg", "train": {"annotations": [{"class_id": 0, "width": 38, "top": 306, "height": 31, "left": 73}, {"class_id": 0, "width": 40, "top": 281, "height": 24, "left": 214}, {"class_id": 0, "width": 37, "top": 283, "height": 24, "left": 281}, {"class_id": 0, "width": 40, "top": 236, "height": 26, "left": 360}, {"class_id": 0, "width": 25, "top": 192, "height": 24, "left": 300}, {"class_id": 0, "width": 36, "top": 193, "height": 29, "left": 144}, {"class_id": 0, "width": 19, "top": 146, "height": 23, "left": 224}, {"class_id": 0, "width": 20, "top": 105, "height": 23, "left": 418}, {"class_id": 0, "width": 30, "top": 340, "height": 29, "left": 20}, {"class_id": 0, "width": 27, "top": 162, "height": 18, "left": 211}, {"class_id": 0, "width": 20, "top": 104, "height": 23, "left": 226}, {"class_id": 0, "width": 34, "top": 208, "height": 38, "left": 451}, {"class_id": 0, "width": 35, "top": 331, "height": 24, "left": 52}, {"class_id": 0, "width": 37, "top": 278, "height": 25, "left": 312}, {"class_id": 0, "width": 31, "top": 171, "height": 17, "left": 175}, {"class_id": 0, "width": 26, "top": 152, "height": 16, "left": 177}, {"class_id": 0, "width": 15, "top": 166, "height": 24, "left": 375}, {"class_id": 0, "width": 25, "top": 177, "height": 17, "left": 408}, {"class_id": 0, "width": 22, "top": 160, "height": 18, "left": 395}, {"class_id": 0, "width": 20, "top": 126, "height": 16, "left": 375}, {"class_id": 0, "width": 17, "top": 141, "height": 17, "left": 319}, {"class_id": 0, "width": 16, "top": 135, "height": 17, "left": 349}, {"class_id": 0, "width": 17, "top": 137, "height": 17, "left": 302}, {"class_id": 0, "width": 18, "top": 135, "height": 19, "left": 279}, {"class_id": 0, "width": 26, "top": 101, "height": 22, "left": 470}, {"class_id": 0, "width": 19, "top": 78, "height": 13, "left": 397}, {"class_id": 0, "width": 15, "top": 96, "height": 18, "left": 366}, {"class_id": 0, "width": 21, "top": 101, "height": 19, "left": 171}, {"class_id": 0, "width": 21, "top": 47, "height": 17, "left": 173}, {"class_id": 0, "width": 11, "top": 54, "height": 15, "left": 232}, {"class_id": 0, "width": 16, "top": 66, "height": 13, "left": 241}, {"class_id": 0, "width": 23, "top": 89, "height": 17, "left": 244}, {"class_id": 0, "width": 13, "top": 80, "height": 18, "left": 275}, {"class_id": 0, "width": 19, "top": 74, "height": 14, "left": 329}, {"class_id": 0, "width": 17, "top": 76, "height": 14, "left": 365}, {"class_id": 0, "width": 18, "top": 80, "height": 17, "left": 312}, {"class_id": 0, "width": 15, "top": 22, "height": 25, "left": 401}, {"class_id": 0, "width": 19, "top": 39, "height": 17, "left": 347}, {"class_id": 0, "width": 16, "top": 42, "height": 15, "left": 309}, {"class_id": 0, "width": 16, "top": 53, "height": 12, "left": 281}, {"class_id": 0, "width": 15, "top": 59, "height": 14, "left": 284}, {"class_id": 0, "width": 12, "top": 20, "height": 15, "left": 181}, 

validation.manifest
validation.manifest は "train" の部分を "validation" に置換してください。

{"source-ref": "s3://sagemaker-mlbees/20191208/train/6381998.jpg", "validation": {"annotations": [{"class_id": 0, "width": 215, "top": 70, "height": 196, "left": 104}], "image_size": [{"width": 416, "depth": 3, "height": 369}]}}
{"source-ref": "s3://sagemaker-mlbees/20191208/train/6415127.jpg", "validation": {"annotations": [{"class_id": 0, "width": 121, "top": 94, "height": 100, "left": 73}], "image_size": [{"width": 484, "depth": 3, "height": 500}]}}
{"source-ref": "s3://sagemaker-mlbees/20191208/train/6415462.jpg", "validation": {"annotations": [{"class_id": 0, "width": 52, "top": 187, "height": 56, "left": 71}, {"class_id": 0, "width": 50, "top": 173, "height": 59, "left": 197}, {"class_id": 0, "width": 65, "top": 316, "height": 48, "left": 363}, {"class_id": 0, "width": 66, "top": 112, "height": 45, "left": 244}], "image_size": [{"width": 500, "depth": 3, "height": 452}]}}

アノテーションデータに指定したS3のパス(この例では s3://sagemaker-mlbees/20191208/train/ )へ500枚の学習および検証画像をアップロードします。
s3://sagemaker-mlbees/20191208/ へアノテーションデータ( train.manifest, validation.manifest )をアップロードします。
次のトレーニングジョブ作成時にこれらのパスを使うのでメモっておいてください。

honey15.PNG

モデルをトレーニングしてデプロイする

トレーニングジョブの作成

SageMaker を開き、トレーニングジョブを作成します。

ジョブ設定

ジョブ名 mlbees-20191208
IAMロール 新しいロールの作成(AmazonSageMaker-ExecutionRole-20191208Txxxxxx)
アルゴリズムのソース AmazonSageMaker組み込みアルゴリズム
アルゴリズムの選択 ObjectDetection
コンテナ 825641698319.dkr.ecr.us-east-2.amazonaws.com/object-detection:1
入力モード Pipe
インスタンスタイプ ml.p2.xlarge
インスタンス数 1
インスタンスあたりの追加のストレージボリューム(GB) 50
最大ランタイム 360000 seconds

ネットワーク

ネットワーク分離の有効化 false

ハイパーパラメータ

base_network resnet-50
use_pretrained_model 1
num_classes 1
epochs 30
larning_rate 0.001
lr_scheduler_factor 0.1
optimizer sgd
momentum 0.9
weight_decay 0.0005
mini_batch_size 8
image_shape 300
label_width 350
num_training_samples 400
nms_threshold 0.45
overlap_threshold 0.5
freeze_layer_pattern false
early_stopping false
early_stopping_min_epochs 10
early_stopping_patience 5
early_stopping_tolerance 0.0

入力データ設定

train

チャンネル名 train
入力モードオプション Pipe
コンテンツタイプ application/x-recordio
圧縮タイプ None
レコードラッパー RecordIO
Data source S3
S3データタイプ AugmentedManifestFile
S3データディストリビューションタイプ FullyReplicated
AugmentedManifestFile 属性名 (パイプ入力モード必須) source-ref, train
S3の場所 s3://sagemaker-mlbees/20191208/train.manifest

validation

チャンネル名 validation
入力モードオプション Pipe
コンテンツタイプ application/x-recordio
圧縮タイプ None
レコードラッパー RecordIO
Data source S3
S3データタイプ AugmentedManifestFile
S3データディストリビューションタイプ FullyReplicated
AugmentedManifestFile 属性名 (パイプ入力モード必須) source-ref, validation
S3の場所 s3://sagemaker-mlbees/20191208/validation.manifest

出力データ設定

S3出力パス s3://sagemaker-mlbees/20191208/

マネージド型スポットのトレーニング

マネージド型スポットトレーニングの有効化 True
ジョブが終了するまでの最大待機時間 オプション停止条件 360000 seconds

トレーニングジョブがInProgressからCompletedになったら学習が完了です。

モデルの作成

モデルを作成します。

モデル設定

モデル名 mlbees-20191208
IAMロール トレーニングジョブと同じもの

コンテナの定義1

コンテナ入力オプション モデルアーティファクトと推論イメージの場所を指定します。
モデルアーティファクトと推論イメージの場所を指定します。 単一のモデルを使用する
推論コードイメージの場所 825641698319.dkr.ecr.us-east-2.amazonaws.com/object-detection:1
アーティファクトの場所 s3://sagemaker-mlbees/20191208/mlbees-20191208/output/model.tar.gz

ネットワーク

ネットワーク分離の有効化 False

エンドポイントの作成と設定

エンドポイント設定を作成します。

Endpoint

エンドポイント名 mlbees-20191208

エンドポイント設定のアタッチ

新しいエンドポイント設定の作成

新しいエンドポイント設定

エンドポイント設定名 mlbees-20191208

エンドポイント設定の作成が完了したら、エンドポイントを作成します。
Creating からInService になったら使えます。

推論

作成したエンドポイントを用いてテスト画像を推論します。
AWS CLIを設定して、下記のPythonコードを実行しましょう!

import boto3
import json

with open("dataset/test/22971237.jpg", "rb") as f:
    image = f.read()

response = boto3.client('sagemaker-runtime').invoke_endpoint(
    EndpointName="mlbees-20191208",
    Body=image,
    ContentType='image/jpeg'
)

predictions = json.loads(response['Body'].read())
print(predictions)

推論結果は、(class_id, score, xmin, ymin, xmax, ymax)の順で格納されており、それぞれ
class_id:タグID
score:推論スコア
xmin:境界ボックスの左上のx値(※画像サイズで正規化してあるので注意)
ymin:境界ボックスの左上のy値(※画像サイズで正規化してあるので注意)
xmax:境界ボックスの右下のx値(※画像サイズで正規化してあるので注意)
ymax:境界ボックスの右下のy値 (※画像サイズで正規化してあるので注意)
になっています

{'prediction': [[0.0, 0.4678894877433777, 0.30429762601852417, 0.24999865889549255, 0.6138879060745239, 0.6268823146820068], [0.0, 0.42358464002609253, 0.06584984064102173, 0.06060954928398132, 0.9343515038490295, 0.9401313066482544], [0.0, 0.41352295875549316, 0.30878573656082153, 0.10083526372909546, 0.6731508374214172, 0.5129770636558533], [0.0, 0.39709046483039856, 0.33817505836486816, 0.4873414635658264, 0.6675703525543213, 0.9277041554450989], [0.0, 0.378907710313797, 0.0, 0.0, 0.3687918484210968, 0.5197888016700745], [0.0, 0.37673383951187134, 0.07746218144893646, 0.0, 0.5161272287368774, 0.3293883800506592], [0.0, 0.3741675913333893, 0.0, 0.460550993680954, 0.36986619234085083, 1.0], [0.0, 0.37143221497535706, 0.5950260162353516, 0.0, 1.0, 0.21253566443920135], [0.0, 0.3708018660545349, 0.3493179380893707, 0.0, 1.0, 0.6512178182601929], [0.0, 0.3700588643550873, 0.27566099166870117, 0.0, 0.713475227355957, 0.3211899995803833], [0.0, 0.3692185580730438, 0.39444130659103394, 0.3983367681503296, 1.0, 1.0], [0.0, 0.36762967705726624, 0.2224271595478058, 0.21391180157661438, 0.7647933959960938, 0.7966573238372803], [0.0, 0.3665901720523834, 0.0, 0.31598204374313354, 0.5442211627960205, 0.7052187323570251], [0.0, 0.36615416407585144, 0.0, 0.7466477751731873, 0.3294963836669922, 1.0], [0.0, 0.3645714223384857, 0.78152996301651, 0.0, 1.0, 0.38953807950019836], [0.0, 0.3632708489894867, 0.6367571353912354, 0.14908206462860107, 1.0, 0.8790770769119263], [0.0, 0.3581337630748749, 0.0, 0.7736784815788269, 0.11148740351200104, 1.0], [0.0, 0.35730576515197754, 0.18405702710151672, 0.5357580184936523, 0.8030450344085693, 1.0], [0.0, 0.35632744431495667, 0.4812198281288147, 0.0, 0.9089540839195251, 0.32849448919296265], [0.0, 0.35606932640075684, 0.4814307987689972, 0.3763745427131653, 0.6160391569137573, 0.5194752216339111], [0.0, 0.35529276728630066, 0.0, 0.0, 0.08277034014463425, 0.051912762224674225], [0.0, 0.35219448804855347, 0.5505965352058411, 0.33695971965789795, 0.7397928833961487, 0.5715459585189819], [0.0, 0.3487113118171692, 0.42075949907302856, 0.844500720500946, 0.47111785411834717, 0.8974922299385071], [0.0, 0.3482074737548828, 0.0, 0.0, 0.3503129482269287, 0.24298378825187683], [0.0, 0.3474455773830414, 0.5203220844268799, 0.2931615710258484, 0.8834731578826904, 0.7036521434783936], [0.0, 0.3472687304019928, 0.0, 0.0, 0.10882196575403214, 0.22120940685272217], [0.0, 0.3466414511203766, 0.4666988253593445, 0.6249315142631531, 0.5282527804374695, 0.6908530592918396], [0.0, 0.3453116714954376, 0.31746411323547363, 0.8423987627029419, 0.3688467741012573, 0.8994448184967041], [0.0, 0.3440929353237152, 0.7796421647071838, 0.6209114789962769, 1.0, 1.0], [0.0, 0.34316927194595337, 0.6643545031547546, 0.0558457225561142, 1.0, 0.535685122013092], [0.0, 0.3427833914756775, 0.544445812702179, 0.08242097496986389, 0.8637402653694153, 0.5203053951263428], [0.0, 0.3418370485305786, 0.0, 0.6646335124969482, 0.6075617074966431, 0.987572431564331], [0.0, 0.341707706451416, 0.07544617354869843, 0.1437387317419052, 0.5128083229064941, 0.4533810019493103], [0.0, 0.3399723768234253, 0.5327222943305969, 0.4944736957550049, 0.8722519278526306, 0.9193394184112549], [0.0, 0.3384418189525604, 0.35905712842941284, 0.4564792513847351, 0.5525619983673096, 0.6246435046195984], [0.0, 0.33811572194099426, 0.0, 0.8843855261802673, 0.20716631412506104, 1.0], [0.0, 0.3380047082901001, 0.6239446997642517, 6.010197103023529e-05, 0.7040519118309021, 0.05022969841957092], [0.0, 0.33621808886528015, 0.526395320892334, 0.35611313581466675, 0.5769199132919312, 0.4400783181190491], [0.0, 0.33464792370796204, 0.7893296480178833, 0.1616135984659195, 0.8427752256393433, 0.2122565656900406], [0.0, 0.3313765525817871, 0.0, 0.21833011507987976, 0.23080405592918396, 0.7796567678451538], [0.0, 0.3295021951198578, 0.6871658563613892, 0.16251946985721588, 0.7505543231964111, 0.20261342823505402], [0.0, 0.32939413189888, 0.8877862691879272, 0.0, 1.0, 0.21754144132137299], [0.0, 0.3280572295188904, 0.683427095413208, 0.05675225332379341, 0.7324377298355103, 0.1061081737279892], [0.0, 0.3280175030231476, 0.7337505221366882, 0.21456307172775269, 0.7870777249336243, 0.26403456926345825], [0.0, 0.32741934061050415, 0.7871232628822327, 0.0, 1.0, 0.11095887422561646], [0.0, 0.32711800932884216, 0.6125258207321167, 0.7707194089889526, 1.0, 1.0], [0.0, 0.3256891369819641, 0.0, 0.9203382730484009, 0.0562296137213707, 1.0], [0.0, 0.32530954480171204, 0.35250425338745117, 0.0, 0.5488604307174683, 0.1449427455663681], [0.0, 0.324715256690979, 0.45405250787734985, 0.0, 0.6479468941688538, 0.14573422074317932], [0.0, 0.3244691491127014, 0.5747636556625366, 0.6804345846176147, 0.6344759464263916, 0.7449156045913696], [0.0, 0.3242606818675995, 0.0, 0.7802523374557495, 0.060774143785238266, 0.8526475429534912], [0.0, 0.3231322765350342, 0.4211777150630951, 0.7901055216789246, 0.4736692011356354, 0.8448881506919861], [0.0, 0.3225260376930237, 0.6855562329292297, 0.2695790231227875, 0.7485852837562561, 0.3097873032093048], [0.0, 0.3223261833190918, 0.5165964961051941, 0.30369797348976135, 0.5838491320610046, 0.37661054730415344], [0.0, 0.3190132975578308, 0.6840611696243286, 0.11031299084424973, 0.7345172166824341, 0.15836459398269653], [0.0, 0.31880688667297363, 0.5868977308273315, 0.7858849167823792, 0.6264750957489014, 0.8554143309593201], [0.0, 0.318799763917923, 0.10135529190301895, 0.6273577213287354, 0.16216304898262024, 0.6878644227981567], [0.0, 0.3178630471229553, 0.2491334080696106, 0.0, 0.4503113031387329, 0.1459662914276123], [0.0, 0.31764253973960876, 0.0, 0.729369044303894, 0.06217200309038162, 0.8002824783325195], [0.0, 0.316314160823822, 0.13572518527507782, 0.4907791018486023, 0.4709596633911133, 0.918556272983551], [0.0, 0.31614798307418823, 0.7361401319503784, 0.161359503865242, 0.7889970541000366, 0.21088607609272003], [0.0, 0.3158923387527466, 0.36976388096809387, 0.7920727729797363, 0.42588844895362854, 0.8462352752685547], [0.0, 0.3157651722431183, 0.36776894330978394, 0.8443600535392761, 0.4184507131576538, 0.8987955451011658], [0.0, 0.3152107894420624, 0.9517414569854736, 0.5720713138580322, 0.9960393905639648, 0.6536024808883667], [0.0, 0.31452468037605286, 0.6303567886352539, 0.056085046380758286, 0.6810942888259888, 0.10801681876182556], [0.0, 0.31429141759872437, 0.3200715184211731, 0.09504622220993042, 0.3662959933280945, 0.1773381233215332], [0.0, 0.314095675945282, 0.5308109521865845, 0.6801299452781677, 0.5753098726272583, 0.7513325810432434], [0.0, 0.3140608072280884, 0.6809313297271729, 0.2178284078836441, 0.7347820997238159, 0.26759111881256104], [0.0, 0.31373119354248047, 0.5221344232559204, 0.7350226640701294, 0.5814639329910278, 0.7973107099533081], [0.0, 0.3117356598377228, 0.4218320846557617, 0.20239503681659698, 0.4763789772987366, 0.28319358825683594], [0.0, 0.31127995252609253, 0.42516055703163147, 0.3630872070789337, 0.47294357419013977, 0.429222971200943], [0.0, 0.31101304292678833, 0.8473232388496399, 0.8993422389030457, 0.8852854371070862, 0.9573569893836975], [0.0, 0.30946406722068787, 0.5220901370048523, 0.7896288633346558, 0.575954258441925, 0.8456448316574097], [0.0, 0.3092215061187744, 0.5670506954193115, 0.9440076947212219, 0.639283299446106, 1.0], [0.0, 0.30905911326408386, 0.9063401818275452, 0.9130138158798218, 1.0, 1.0], [0.0, 0.3090510964393616, 0.5135889053344727, 0.5722286701202393, 0.578898549079895, 0.6422014236450195], [0.0, 0.30885469913482666, 0.5250933170318604, 0.8471934795379639, 0.5761620998382568, 0.9015847444534302], [0.0, 0.30866655707359314, 0.951046884059906, 0.35804468393325806, 0.997364342212677, 0.4444500803947449], [0.0, 0.3081985414028168, 0.16665951907634735, 0.052841365337371826, 0.44393396377563477, 0.5633533000946045], [0.0, 0.30809155106544495, 0.8756505250930786, 0.8173004388809204, 1.0, 1.0], [0.0, 0.30627647042274475, 0.4542831778526306, 0.4180346727371216, 0.6407758593559265, 0.6615869998931885], [0.0, 0.30577099323272705, 0.36145180463790894, 0.21161268651485443, 0.43976718187332153, 0.26231950521469116], [0.0, 0.3056153357028961, 0.950568675994873, 0.6223926544189453, 0.9963271617889404, 0.7067312002182007], [0.0, 0.3048050105571747, 0.7901118397712708, 0.3691854476928711, 0.8498157858848572, 0.4268338680267334], [0.0, 0.3046548366546631, 0.4767646789550781, 0.6647834181785583, 0.9210307598114014, 1.0], [0.0, 0.3040694296360016, 0.9493268132209778, 0.7254079580307007, 0.9974527955055237, 0.8113071918487549], [0.0, 0.3036992847919464, 0.7842162847518921, 0.522617757320404, 0.8383376598358154, 0.5814014077186584], [0.0, 0.3035878539085388, 0.0, 0.5602916479110718, 0.15254323184490204, 0.7438892126083374], [0.0, 0.3035617172718048, 0.9525880217552185, 0.41422122716903687, 0.9983840584754944, 0.49657273292541504], [0.0, 0.3034290373325348, 0.09489327669143677, 0.9379873275756836, 0.168815016746521, 1.0], [0.0, 0.30334362387657166, 0.3615919351577759, 0.9473257064819336, 0.42423540353775024, 1.0], [0.0, 0.302979052066803, 0.4229004383087158, 0.1517314910888672, 0.4750792980194092, 0.2332150936126709], [0.0, 0.30288878083229065, 0.5509763360023499, 0.16333407163619995, 0.7436758875846863, 0.3406045436859131], [0.0, 0.302875816822052, 0.5253306031227112, 0.41257160902023315, 0.5755682587623596, 0.4916040897369385], [0.0, 0.3023538291454315, 0.7781322598457336, 0.9446988105773926, 0.8505274653434753, 1.0], [0.0, 0.3018416464328766, 0.04201468452811241, 0.0, 0.12768010795116425, 0.05132518336176872], [0.0, 0.3018025755882263, 0.638735294342041, 0.11266299337148666, 0.700247049331665, 0.15081219375133514], [0.0, 0.3017869293689728, 0.8701384663581848, 0.22678041458129883, 1.0, 0.47191929817199707], [0.0, 0.30173516273498535, 0.46991971135139465, 0.5788829326629639, 0.5528373718261719, 0.6279313564300537], [0.0, 0.3015425503253937, 0.702499508857727, 0.4966621398925781, 1.0, 0.8961905241012573], [0.0, 0.30097973346710205, 0.0, 0.6766150593757629, 0.062443431466817856, 0.7492969632148743], [0.0, 0.2999502122402191, 0.46926426887512207, 0.7879582643508911, 0.5222427248954773, 0.8441793918609619], [0.0, 0.2998069226741791, 0.8383838534355164, 0.7387928366661072, 0.9041901230812073, 0.7820411324501038], [0.0, 0.2997302711009979, 0.6266809701919556, 0.6829532384872437, 0.687191367149353, 0.7437620162963867], [0.0, 0.29922932386398315, 0.2766895890235901, 0.7345049381256104, 0.7165694832801819, 1.0], [0.0, 0.29915371537208557, 0.6280661225318909, 0.37325695157051086, 0.701719343662262, 0.41669437289237976], [0.0, 0.2988787591457367, 0.9512851238250732, 0.521103024482727, 0.9948536157608032, 0.6019420623779297], [0.0, 0.2982707619667053, 0.0020293742418289185, 0.5068413615226746, 0.05407947301864624, 0.5978963971138], [0.0, 0.2981034517288208, 0.8889434337615967, 0.6884158253669739, 0.9598939418792725, 0.731789767742157], [0.0, 0.29724669456481934, 0.7976745367050171, 0.5782050490379333, 0.8368011713027954, 0.6447365880012512], [0.0, 0.29685869812965393, 0.9411171078681946, 0.785904049873352, 1.0, 0.8544464111328125], [0.0, 0.29628944396972656, 0.25656986236572266, 0.0014236383140087128, 0.3422602415084839, 0.05571365728974342], [0.0, 0.29552161693573, 0.11159392446279526, 0.10173332691192627, 0.1531572937965393, 0.17168718576431274], [0.0, 0.2954811751842499, 0.0, 0.21423587203025818, 0.0765061229467392, 0.2614700198173523], [0.0, 0.2952989935874939, 0.15916989743709564, 0.32192519307136536, 0.3372461199760437, 0.5637787580490112], [0.0, 0.2952832579612732, 0.5180695056915283, 0.6282444000244141, 0.5831331014633179, 0.6977766752243042], [0.0, 0.2950413227081299, 0.8828567266464233, 0.939605712890625, 0.9554505348205566, 1.0], [0.0, 0.2945857346057892, 0.32042452692985535, 0.37924274802207947, 0.3600386679172516, 0.43792232871055603], [0.0, 0.2944544851779938, 0.373241662979126, 0.37452229857444763, 0.41563618183135986, 0.4352876842021942], [0.0, 0.2942132353782654, 0.8290576934814453, 0.9420439600944519, 0.902672529220581, 1.0], [0.0, 0.2941124439239502, 0.5380184054374695, 0.37435197830200195, 0.6709570288658142, 0.5188630819320679], [0.0, 0.2940295338630676, 0.7430799603462219, 0.11170899868011475, 0.8037078976631165, 0.15102824568748474], [0.0, 0.293331116437912, 0.35394763946533203, 0.34981769323349, 0.5498237609863281, 0.5380789637565613], [0.0, 0.29332756996154785, 0.4114592671394348, 0.9471758604049683, 0.4766947627067566, 1.0], [0.0, 0.29272541403770447, 0.5713214874267578, 0.0004309359937906265, 0.6492958068847656, 0.05033056437969208], [0.0, 0.2925208806991577, 0.7396335005760193, 0.05556988716125488, 0.7874881625175476, 0.10414917767047882], [0.0, 0.29249969124794006, 0.47896528244018555, 0.7397496700286865, 0.5195545554161072, 0.8028196096420288], [0.0, 0.2924167215824127, 0.933567464351654, 0.0, 1.0, 0.05580366402864456], [0.0, 0.29215577244758606, 0.4724491238594055, 0.84593665599823, 0.5229489803314209, 0.8991013765335083], [0.0, 0.2921390235424042, 0.4273237884044647, 0.6821130514144897, 0.47838541865348816, 0.7363201379776001], [0.0, 0.2918897867202759, 0.9429163932800293, 0.8406599760055542, 1.0, 0.9075591564178467], [0.0, 0.2918473780155182, 0.5128514170646667, 0.9449970126152039, 0.5849166512489319, 1.0], [0.0, 0.2911980152130127, 0.3602719008922577, 0.0, 0.4299685060977936, 0.06602838635444641], [0.0, 0.29032817482948303, 0.4254702925682068, 0.3083078861236572, 0.47212082147598267, 0.3808460235595703], [0.0, 0.2898170053958893, 0.7874332666397095, 0.2158052623271942, 0.8402680158615112, 0.26326441764831543], [0.0, 0.28945106267929077, 0.0, 0.0, 0.20739901065826416, 0.11667156964540482], [0.0, 0.2893337309360504, 0.4705773890018463, 0.4750300943851471, 0.5540667772293091, 0.5243601202964783], [0.0, 0.289265900850296, 0.6800929307937622, 0.0, 0.7377841472625732, 0.06092862784862518], [0.0, 0.2889595627784729, 0.8434596657752991, 0.31377309560775757, 0.8996695876121521, 0.370649516582489], [0.0, 0.2888559401035309, 0.37120816111564636, 0.04520254209637642, 0.4176694452762604, 0.1255854219198227], [0.0, 0.28823786973953247, 0.4785866141319275, 0.9381502866744995, 0.5244562029838562, 1.0], [0.0, 0.2881348431110382, 0.20553499460220337, 0.8335792422294617, 0.26337143778800964, 0.8998133540153503], [0.0, 0.28776055574417114, 0.848702073097229, 0.7896995544433594, 0.8853460550308228, 0.8488997220993042], [0.0, 0.28757259249687195, 0.8688817024230957, 0.12569433450698853, 1.0, 0.37085333466529846], [0.0, 0.2872491776943207, 0.5691465735435486, 0.25578054785728455, 0.6365798115730286, 0.32962414622306824], [0.0, 0.28710606694221497, 0.20785976946353912, 0.3741651475429535, 0.2643526792526245, 0.42936912178993225], [0.0, 0.287015825510025, 0.6081342697143555, 0.3686332702636719, 1.0, 0.6216212511062622], [0.0, 0.28659290075302124, 0.3108674883842468, 0.2117319256067276, 0.3869855999946594, 0.2622150182723999], [0.0, 0.28577154874801636, 0.3714808523654938, 0.09464675933122635, 0.41979309916496277, 0.17836514115333557], [0.0, 0.28570878505706787, 0.8963097929954529, 0.05641122907400131, 0.9497058987617493, 0.11036554723978043], [0.0, 0.28569257259368896, 0.9403613209724426, 0.2626246213912964, 1.0, 0.3157275915145874], [0.0, 0.2856108546257019, 0.5140482783317566, 0.26451432704925537, 0.5973600745201111, 0.3160684108734131], [0.0, 0.2852841019630432, 0.6335992217063904, 0.0, 0.679035484790802, 0.07775532454252243], [0.0, 0.28523746132850647, 0.57380610704422, 0.7360888123512268, 0.6322826743125916, 0.7948341965675354], [0.0, 0.2850608825683594, 0.2614211142063141, 0.4769710600376129, 0.3177346885204315, 0.5308374166488647], [0.0, 0.2847842574119568, 0.7914046049118042, 0.05570163577795029, 0.8404449224472046, 0.10548176616430283], [0.0, 0.2846382260322571, 0.25523650646209717, 0.9453313946723938, 0.318317174911499, 1.0], [0.0, 0.2845005393028259, 0.8596287369728088, 0.35657915472984314, 1.0, 0.5540792346000671], [0.0, 0.2843627333641052, 0.41853857040405273, 0.5140296220779419, 0.4780052900314331, 0.5822768211364746], [0.0, 0.28411853313446045, 0.7431882619857788, 0.5747441649436951, 0.7822370529174805, 0.6451032757759094], [0.0, 0.2838780879974365, 0.48433569073677063, 0.7505739331245422, 0.6222746968269348, 0.8824090361595154], [0.0, 0.28370994329452515, 0.5477281808853149, 0.4361770451068878, 0.740065336227417, 0.6665181517601013], [0.0, 0.28352266550064087, 0.0, 0.6035395860671997, 0.19002968072891235, 0.9050962924957275], [0.0, 0.28339964151382446, 0.5550472736358643, 0.06040928512811661, 0.7510890960693359, 0.2383417785167694], [0.0, 0.28322362899780273, 0.8587049245834351, 0.4579421281814575, 1.0, 0.655707836151123], [0.0, 0.2831907868385315, 0.6806806325912476, 0.3685862123966217, 0.7362295389175415, 0.4201270043849945], [0.0, 0.28298673033714294, 0.4577640891075134, 0.9509414434432983, 0.5475930571556091, 0.9990087747573853], [0.0, 0.2825695276260376, 0.6534325480461121, 0.0, 0.8546033501625061, 0.1414952278137207], [0.0, 0.2825687825679779, 0.32393306493759155, 0.0, 0.46664130687713623, 0.0958959311246872], [0.0, 0.28248947858810425, 0.7344797849655151, 0.0, 0.792578935623169, 0.059951916337013245], [0.0, 0.2822904884815216, 0.25265052914619446, 0.25429606437683105, 0.4493076503276825, 0.44751179218292236], [0.0, 0.2821846306324005, 0.3152012228965759, 0.7858959436416626, 0.37233418226242065, 0.8456672430038452]]}

ベストスコアの境界ボックスを可視化します。
honey16.png

まとめ

トレーニングビデオを参考に、ミツバチの物体検出モデルを作成しました。画像をアノテーションしてファイルをアップロードし、GUI上でちょちょいと設定を書いて学習するだけで、物体検出ができます。今後は、ハイパーパラメータの設定やチューニング方法、再学習して運用する方法などについて学んでいきましょう。

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?