前提・実現したいこと
ディープラーニングの勉強をしている、python初学者です。
何冊か本を読んで写経的なことはしたのですが、実際に自作データでチャレンジ中です。
そこで、今回、物体検出を勉強しようとR-CNNのプログラムを理解しようと挑戦しているのですが、プログラムの内容がいきなりわからず困っています。
初めての質問なので、失礼もあるかもしれませんがよろしくお願い致します。
発生している問題・エラーメッセージ
そのわからないプログラムの箇所が以下のようになっています。
with open('config.pickle', 'rb') as f_in: cfg = pickle.load(f_in) cfg.use_horizontal_flips = False cfg.use_vertical_flips = False cfg.rot_90 = False
この、
.use_horizontal_flips
.use_vertical_flips
.rot_90
の部分が一体何者なのかもわからない状態です。
もしかしたら、オリジナルのメソッドか何かなのか?とも思ったのですが、そうでもなさそうだし。。。
該当のソースコード
下記コードの5行目〜7行目です。
ソースコード
python
1def predict(args_): 2 path = args_.path 3 with open('config.pickle', 'rb') as f_in: 4 cfg = pickle.load(f_in) 5 cfg.use_horizontal_flips = False 6 cfg.use_vertical_flips = False 7 cfg.rot_90 = False 8 9 class_mapping = cfg.class_mapping 10 if 'bg' not in class_mapping: 11 class_mapping['bg'] = len(class_mapping) 12 13 class_mapping = {v: k for k, v in class_mapping.items()} 14 input_shape_img = (None, None, 3) 15 input_shape_features = (None, None, 1024) 16 17 img_input = Input(shape=input_shape_img) 18 roi_input = Input(shape=(cfg.num_rois, 4)) 19 feature_map_input = Input(shape=input_shape_features) 20 21 shared_layers = nn.nn_base(img_input, trainable=True) 22 23 # define the RPN, built on the base layers 24 num_anchors = len(cfg.anchor_box_scales) * len(cfg.anchor_box_ratios) 25 rpn_layers = nn.rpn(shared_layers, num_anchors) 26 classifier = nn.classifier(feature_map_input, roi_input, cfg.num_rois, nb_classes=len(class_mapping), 27 trainable=True) 28 model_rpn = Model(img_input, rpn_layers) 29 model_classifier_only = Model([feature_map_input, roi_input], classifier) 30 31 model_classifier = Model([feature_map_input, roi_input], classifier) 32 33 print('Loading weights from {}'.format(cfg.model_path)) 34 model_rpn.load_weights(cfg.model_path, by_name=True) 35 model_classifier.load_weights(cfg.model_path, by_name=True) 36 37 model_rpn.compile(optimizer='sgd', loss='mse') 38 model_classifier.compile(optimizer='sgd', loss='mse') 39 40 if os.path.isdir(path): 41 for idx, img_name in enumerate(sorted(os.listdir(path))): 42 if not img_name.lower().endswith(('.bmp', '.jpeg', '.jpg', '.png', '.tif', '.tiff')): 43 continue 44 print(img_name) 45 predict_single_image(os.path.join(path, img_name), model_rpn, 46 model_classifier_only, cfg, class_mapping) 47 elif os.path.isfile(path): 48 print('predict image from {}'.format(path)) 49 predict_single_image(path, model_rpn, model_classifier_only, cfg, class_mapping) 50
試したこと
「use_horizontal_flips」で検索をかけてみたり、cfgがインスタンス?なのかと思い、pickleから調べてみたりしたのですが、わかりません。
補足情報(FW/ツールのバージョンなど)
このプログラムはgithubからダウンロードしたものです。
(githubもよくわかっていないので、cloneをしたというのかな?)
https://github.com/jinfagang/keras_frcnn
の
”test_frcnn_kitti.py”
というファイルの一部になります。
どうぞよろしくお願い致します。
あなたの回答
tips
プレビュー