質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Keras

Kerasは、TheanoやTensorFlow/CNTK対応のラッパーライブラリです。DeepLearningの数学的部分を短いコードでネットワークとして表現することが可能。DeepLearningの最新手法を迅速に試すことができます。

YOLO

YOLOとは、画像検出および認識用ニューラルネットワークです。CベースのDarknetというフレームワークを用いて、画像や動画からオブジェクトを検出。リアルタイムでそれが何になるのかを認識し、分類することができます。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

0回答

2053閲覧

keras-yolo3でグラフを出したい

sankasatetu

総合スコア6

Keras

Kerasは、TheanoやTensorFlow/CNTK対応のラッパーライブラリです。DeepLearningの数学的部分を短いコードでネットワークとして表現することが可能。DeepLearningの最新手法を迅速に試すことができます。

YOLO

YOLOとは、画像検出および認識用ニューラルネットワークです。CベースのDarknetというフレームワークを用いて、画像や動画からオブジェクトを検出。リアルタイムでそれが何になるのかを認識し、分類することができます。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2020/05/13 06:47

keras-yolo3で学習をさせています。
その際にlossやaccをグラフとして出力したいです。

TensorBoardがインポートされているので
これを使えばグラフを出せるのではないかと思うのですが使い方がよく分かりません。
グラフを画像として出力または画像として出力されなくてもよいので
グラフの表示の仕方を知っている方がいましたらご教授お願い致します。

また学習させた際に「.CLNT-PC-097」という形式のファイルが出力されます。
これについても何か知っている方がいましたらよろしくお願い致します。

python

1""" 2Retrain the YOLO model for your own dataset. 3""" 4 5import numpy as np 6import keras.backend as K 7from keras.layers import Input, Lambda 8from keras.models import Model 9from keras.optimizers import Adam 10from keras.callbacks import TensorBoard, ModelCheckpoint, ReduceLROnPlateau, EarlyStopping 11 12from yolo3.model import preprocess_true_boxes, yolo_body, tiny_yolo_body, yolo_loss 13from yolo3.utils import get_random_data 14import sys 15 16def _main(): 17 annotation_path = 'model_data/2007_train.txt' 18 log_dir = 'logs/000/' 19 classes_path = 'model_data/voc_classes.txt' 20 anchors_path = 'model_data/yolo_anchors.txt' 21 class_names = get_classes(classes_path) 22 num_classes = len(class_names) 23 anchors = get_anchors(anchors_path) 24 25 input_shape = (32,32) # multiple of 32, hw 26 if len(sys.argv) > 1: 27 input_shape = (int(sys.argv[1]),int(sys.argv[1])) 28 29 is_tiny_version = len(anchors)==6 # default setting 30 if is_tiny_version: 31 model = create_tiny_model(input_shape, anchors, num_classes, 32 freeze_body=2, weights_path='model_data/tiny_yolo_weights.h5') 33 else: 34 model = create_model(input_shape, anchors, num_classes, 35 freeze_body=2, weights_path='model_data/yolo_weights.h5') # make sure you know what you freeze 36 37 logging = TensorBoard(log_dir=log_dir, histogram_freq=0, write_graph=True, write_images = True) 38 checkpoint = ModelCheckpoint(log_dir + 'ep{epoch:03d}-loss{loss:.3f}-val_loss{val_loss:.3f}.h5', 39 monitor='val_loss', save_weights_only=True, save_best_only=True, period=3) 40 reduce_lr = ReduceLROnPlateau(monitor='val_loss', factor=0.1, patience=3, verbose=1) 41 early_stopping = EarlyStopping(monitor='val_loss', min_delta=0, patience=10, verbose=1) 42 43 val_split = 0.1 44 with open(annotation_path) as f: 45 lines = f.readlines() 46 np.random.seed(10101) 47 np.random.shuffle(lines) 48 np.random.seed(None) 49 num_val = int(len(lines)*val_split) 50 num_train = len(lines) - num_val 51 52 # Train with frozen layers first, to get a stable loss. 53 # Adjust num epochs to your dataset. This step is enough to obtain a not bad model. 54 if True: 55 model.compile(optimizer=Adam(lr=1e-3), loss={ 56 # use custom yolo_loss Lambda layer. 57 'yolo_loss': lambda y_true, y_pred: y_pred}) 58 59 batch_size = 32 60 if len(sys.argv) > 2: 61 batch_size = int(sys.argv[2]) 62 63 print('Train on {} samples, val on {} samples, with batch size {}.'.format(num_train, num_val, batch_size)) 64 model.fit_generator(data_generator_wrapper(lines[:num_train], batch_size, input_shape, anchors, num_classes), 65 steps_per_epoch=max(1, num_train//batch_size), 66 validation_data=data_generator_wrapper(lines[num_train:], batch_size, input_shape, anchors, num_classes), 67 validation_steps=max(1, num_val//batch_size), 68 epochs=50, 69 initial_epoch=0, 70 callbacks=[logging, checkpoint]) 71 model.save_weights(log_dir + 'trained_weights_stage_1.h5') 72 73 # Unfreeze and continue training, to fine-tune.凍結を解除してトレーニングを継続し、微調整します。 74 # Train longer if the result is not good.(結果が良くない場合は、より長くトレーニング) 75 if True: 76 for i in range(len(model.layers)): 77 model.layers[i].trainable = True 78 model.compile(optimizer=Adam(lr=1e-4), loss={'yolo_loss': lambda y_true, y_pred: y_pred}) # recompile to apply the change(変更を適用するために再コンパイルする) 79 print('Unfreeze all of the layers.') 80 81 batch_size = 32 # note that more GPU memory is required after unfreezing the body 82 print('Train on {} samples, val on {} samples, with batch size {}.'.format(num_train, num_val, batch_size)) 83 model.fit_generator(data_generator_wrapper(lines[:num_train], batch_size, input_shape, anchors, num_classes), 84 steps_per_epoch=max(1, num_train//batch_size), 85 validation_data=data_generator_wrapper(lines[num_train:], batch_size, input_shape, anchors, num_classes), 86 validation_steps=max(1, num_val//batch_size), 87 epochs=100, 88 initial_epoch=50, 89 callbacks=[logging, checkpoint, reduce_lr, early_stopping]) 90 model.save_weights(log_dir + 'trained_weights_final.h5') 91 92 # Further training if needed.

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問