tips:python:detectron2:start
差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
| tips:python:detectron2:start [2022/01/13 05:13] – [モデルデータベース Registry] yuuho | tips:python:detectron2:start [2022/02/01 01:37] (現在) – [自作データセット定義方法] yuuho | ||
|---|---|---|---|
| 行 75: | 行 75: | ||
| TrainerBase | TrainerBase | ||
| DefaultTrainer: | DefaultTrainer: | ||
| + | ... | ||
| + | DefaultTrainer: | ||
| + | ... | ||
| + | DefaultTrainer: | ||
| </ | </ | ||
| 行 106: | 行 110: | ||
| | '' | | '' | ||
| | '' | | '' | ||
| + | |||
| + | |||
| + | === Trainer の重要メンバ === | ||
| + | |||
| + | '' | ||
| + | |||
| + | * '' | ||
| + | |||
| + | TrainerBase を継承して DefaultTrainer が作成されている。 | ||
| + | 同じように SimpleTrainer も TrainerBase を継承して作成されている。 | ||
| + | なので DefaultTrainer と SimpleTrainer は親子関係はないが、DefaultTrainer の '' | ||
| + | SimpleTrainer なことがある。 | ||
| + | |||
| + | * SimpleTrainer のメンバが直接触るべきモデル | ||
| + | * '' | ||
| + | * '' | ||
| ==== モデルデータベース Registry ==== | ==== モデルデータベース Registry ==== | ||
| 行 124: | 行 144: | ||
| コードから登録されているアーキテクチャを追跡することは面倒だが、 '' | コードから登録されているアーキテクチャを追跡することは面倒だが、 '' | ||
| < | < | ||
| - | ./detectron2/ | + | detectron2/ |
| - | ./detectron2/ | + | detectron2/ |
| - | ./detectron2/ | + | detectron2/ |
| - | ./detectron2/ | + | detectron2/ |
| - | | + | |
| + | </ | ||
| + | '' | ||
| + | < | ||
| + | detectron2/ | ||
| + | detectron2/ | ||
| + | | ||
| </ | </ | ||
| 行 140: | 行 166: | ||
| # detectron2/ | # detectron2/ | ||
| # class DefaultTrainer method build_model | # class DefaultTrainer method build_model | ||
| - | model = build_model() | + | model = build_model(cfg) |
| # detectron2/ | # detectron2/ | ||
| 行 152: | 行 178: | ||
| # | # | ||
| ret = self._obj_map.get(name) # _obj_map はただの dict、 ret は nn.Module | ret = self._obj_map.get(name) # _obj_map はただの dict、 ret は nn.Module | ||
| + | |||
| + | # detectron2/ | ||
| + | # class GeneralizedRCNN method __init__ with @configurable | ||
| + | |||
| + | # detectron2/ | ||
| + | # | ||
| + | from_config_func = type(self).from_config | ||
| + | |||
| + | explicit_args = _get_args_from_config(from_config_func, | ||
| + | |||
| + | # detectron2/ | ||
| + | # | ||
| + | ret = from_config_func(*args, | ||
| + | |||
| + | # detectron2/ | ||
| + | # class GeneralizedRCNN method from_config | ||
| + | backbone = build_backbone(cfg) | ||
| + | |||
| + | # detectron2/ | ||
| + | # | ||
| + | backbone_name = cfg.MODEL.BACKBONE.NAME | ||
| + | backbone = BACKBONE_REGISTRY.get(backbone_name)(cfg, | ||
| </ | </ | ||
| + | |||
| + | |||
| + | ==== R-CNN ==== | ||
| + | |||
| + | '' | ||
| + | |||
| + | だいたいこんな感じ | ||
| + | <code python> | ||
| + | GeneralizedRCNN | ||
| + | images <- self.preprocess_image( batched_inputs ) | ||
| + | features <- self.backbone( images.tensor ) | ||
| + | proposals, proposal_losses <- self.proposal_generator( images, features, | ||
| + | _, | ||
| + | </ | ||
| + | |||
| + | ===== データセット ===== | ||
| + | |||
| + | ==== 自作データセット定義方法 ==== | ||
| + | |||
| + | === 完全自作の形式 === | ||
| + | <code python> | ||
| + | from detectron2.data import DatasetCatalog | ||
| + | |||
| + | DatasetCatalog.register(' | ||
| + | </ | ||
| + | |||
| + | === 特定の形式で登録する === | ||
| + | '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | === 取り出し === | ||
| + | '' | ||
| + | <code python> | ||
| + | |||
| + | </ | ||
| + | |||
| + | === カスタムなデータローダーの定義 === | ||
| + | |||
| + | デフォルトでは '' | ||
| + | データセットに合った特定の読み込み方を指定するには custom dataloader を作成する必要がある。 | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | これらを見る限り、 '' | ||
| + | |||
tips/python/detectron2/start.1642050784.txt.gz · 最終更新: 2022/01/13 05:13 by yuuho
