yuuho.wiki

カオスの欠片を集めて知恵の泉を作る

ユーザ用ツール

サイト用ツール


tips:python:detectron2:start

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
tips:python:detectron2:start [2022/01/27 01:51] – [自作データセット定義方法] yuuhotips:python:detectron2:start [2022/02/01 01:37] (現在) – [自作データセット定義方法] yuuho
行 110: 行 110:
 | ''test''                ^ class |  | | ''test''                ^ class |  |
 | ''auto_scale_workers''  ^ static |  | | ''auto_scale_workers''  ^ static |  |
 +
 +
 +=== Trainer の重要メンバ ===
 +
 +''DefaultTrainer'' のメンバ。
 +
 +  * ''_trainer'' は SimpleTrainerクラス。
 +
 +TrainerBase を継承して DefaultTrainer が作成されている。
 +同じように SimpleTrainer も TrainerBase を継承して作成されている。
 +なので DefaultTrainer と SimpleTrainer は親子関係はないが、DefaultTrainer の ''_trainer'' というメンバは
 +SimpleTrainer なことがある。
 +
 +  * SimpleTrainer のメンバが直接触るべきモデル
 +    * ''model'' : ''GeneralizedRCNN'' とか
 +    * ''model.backbone'' :
  
 ==== モデルデータベース Registry ==== ==== モデルデータベース Registry ====
行 188: 行 204:
 </code> </code>
  
 +
 +==== R-CNN ====
 +
 +''detectron2/modeling/meta_arch/rcnn.py'' の ''forward'' を見る。
 +
 +だいたいこんな感じ
 +<code python>
 +GeneralizedRCNN
 +    images <- self.preprocess_image( batched_inputs )
 +    features <- self.backbone( images.tensor )
 +    proposals, proposal_losses <- self.proposal_generator( images, features,            gt_instances )
 +    _,         detector_losses <- self.roi_heads(          images, features, proposals, gt_instances )
 +</code>
  
 ===== データセット ===== ===== データセット =====
行 207: 行 236:
   * ''register_lvis_instances''   * ''register_lvis_instances''
   * ''register_pascal_voc''   * ''register_pascal_voc''
 +
 +=== 取り出し ===
 +''detectron2.data.common.AspectRatioGroupedDataset'' の ''%%_%%_iter%%_%%_'' を見るべし
 +<code python>
 +
 +</code>
 +
 +=== カスタムなデータローダーの定義 ===
 +
 +デフォルトでは ''detectron2/data/dataset_mapper.py'' の ''DatasetMapper'' が使われるため画像はファイルから読み込むしかできない。
 +データセットに合った特定の読み込み方を指定するには custom dataloader を作成する必要がある。
 +  * [[https://github.com/facebookresearch/detectron2/blob/cbbc1ce26473cb2a5cc8f58e8ada9ae14cb41052/docs/tutorials/datasets.md|custom dataset]]
 +  * [[https://github.com/facebookresearch/detectron2/blob/cbbc1ce26473cb2a5cc8f58e8ada9ae14cb41052/docs/tutorials/data_loading.md|custom data loader]]
 +
 +これらを見る限り、 ''DefaultTrainer'' の ''build_train_loader'' などのメソッドをオーバーライドするのが正攻法。
  
tips/python/detectron2/start.1643248276.txt.gz · 最終更新: 2022/01/27 01:51 by yuuho