diff --git a/tests/config/fixtures/pose/README.md b/tests/config/fixtures/pose/README.md new file mode 100644 index 0000000..b185291 --- /dev/null +++ b/tests/config/fixtures/pose/README.md @@ -0,0 +1,17 @@ +# `pytorch_config.yaml` fixtures + +Frozen: never regenerated. A config DeepLabCut wrote must keep reading, so a fixture is only ever added, never rewritten. + +| Folder | Holds | +| --- | --- | +| `generated/` | `-.yaml`, as DeepLabCut `dev` at `d2bbe028` (3.0.3) wrote them with `PoseConfig.build(..., save=False)` then `to_yaml`, from DeepLabCut's `tests/pose_estimation_pytorch/config/fixtures/` projects at that commit, with `project_path: project` and `pose_config_path: pytorch_config.yaml`. `multi_no_unique` is the multi-animal project with `uniquebodyparts: []`, since DeepLabCut refuses top-down models otherwise | +| `legacy/` | Configs as older releases wrote them, each derived by hand from a generated one; see below | + +`generated/` holds at least one config for each distinct set of typed fields DeepLabCut writes across the models it offers, ignoring `model.backbone`, `model.heads` and `detector.model`, which are untyped; the others are the sources of `legacy/` and of the top-down crop test. Its paths contain no separator, so the fixtures are byte-identical on every OS. + +| File in `legacy/` | Source | Changed | +| --- | --- | --- | +| `dlcrnet_ms5_alias.yaml` | `multi-dlcrnet_stride16_ms5.yaml` | `net_type: dlcrnet_ms5`, the legacy name | +| `top_down_prefix.yaml` | `single-top_down_resnet_50.yaml` | `net_type: top_down_resnet_50`, as written before the prefix moved to `method` | +| `top_down_crop_mismatch.yaml` | `single-rtmpose_s.yaml` | `data.{train,inference}.top_down_crop` 192x256 against a 256x256 head, as DeepLabCut 3.0.1 to 3.0.3 wrote some RTMPose configs (DeepLabCut issue 3592) | +| `weight_init_before_3.0.0rc5.yaml` | `single-resnet_50.yaml` | `train_settings.weight_init` without `snapshot_path`, as written before 3.0.0rc5 | diff --git a/tests/config/fixtures/pose/generated/multi-dekr_w32.yaml b/tests/config/fixtures/pose/generated/multi-dekr_w32.yaml new file mode 100644 index 0000000..0c3dbc6 --- /dev/null +++ b/tests/config/fixtures/pose/generated/multi-dekr_w32.yaml @@ -0,0 +1,224 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: HRNet + model_name: hrnet_w32 + freeze_bn_stats: false + freeze_bn_weights: false + interpolate_branches: true + increased_channel_count: false + heads: + bodypart: + type: DEKRHead + weight_init: dekr + target_generator: + type: DEKRGenerator + num_joints: 2 + pos_dist_thresh: 17 + bg_weight: 0.1 + criterion: + heatmap: + type: DEKRHeatmapLoss + weight: 1 + offset: + type: DEKROffsetLoss + weight: 0.03 + predictor: + type: DEKRPredictor + apply_sigmoid: false + use_heatmap: false + clip_scores: true + num_animals: 2 + keypoint_score_type: combined + max_absorb_distance: 75 + nms_threshold: 0.05 + apply_pose_nms: true + heatmap_config: + channels: + - 480 + - 32 + - 3 + num_blocks: 1 + dilation_rate: 1 + final_conv_kernel: 1 + offset_config: + channels: + - 480 + - 30 + - 2 + num_offset_per_kpt: 15 + num_blocks: 2 + dilation_rate: 1 + final_conv_kernel: 1 + unique_bodypart: + type: HeatmapHead + weight_init: normal + predictor: + type: HeatmapPredictor + apply_sigmoid: false + clip_scores: true + location_refinement: true + locref_std: 7.2801 + target_generator: + type: HeatmapGaussianGenerator + num_heatmaps: 2 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + gradient_masking: false + generate_locref: true + locref_std: 7.2801 + label_keypoint_key: keypoints_unique + criterion: + heatmap: + type: WeightedMSECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + heatmap_config: + channels: + - 480 + - 2 + kernel_size: + - 3 + strides: + - 2 + locref_config: + channels: + - 480 + - 4 + kernel_size: + - 3 + strides: + - 2 + backbone_output_channels: 480 + neck: + pose_model: +net_type: dekr_w32 +method: bu +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - nose + - tail + unique_bodyparts: + - corner1 + - corner2 + individuals: + - mouse1 + - mouse2 + with_identity: false +data: + bbox_margin: 20 + colormode: RGB + gen_sampling: + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + pad_width_divisor: 32 + pad_height_divisor: 32 + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 0.5 + - 1.25 + translation: 0 + random_bbox_transform: + crop_sampling: + width: 448 + height: 448 + max_shift: 0.1 + method: hybrid + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0005 + scheduler: + type: LRListScheduler + params: + lr_list: + - - 0.0001 + - - 1e-05 + milestones: + - 90 + - 120 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 8 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 200 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: true +detector: +resume_training_from: diff --git a/tests/config/fixtures/pose/generated/multi-dlcrnet_stride16_ms5.yaml b/tests/config/fixtures/pose/generated/multi-dlcrnet_stride16_ms5.yaml new file mode 100644 index 0000000..87be787 --- /dev/null +++ b/tests/config/fixtures/pose/generated/multi-dlcrnet_stride16_ms5.yaml @@ -0,0 +1,244 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: DLCRNet + model_name: resnet50 + pretrained: true + output_stride: 16 + heads: + bodypart: + type: DLCRNetHead + predictor: + type: PartAffinityFieldPredictor + num_animals: 2 + num_multibodyparts: 2 + num_uniquebodyparts: 0 + nms_radius: 5 + sigma: 1.0 + locref_stdev: 7.2801 + min_affinity: 0.05 + graph: + - - 0 + - 1 + edges_to_keep: + - 0 + target_generator: + type: SequentialGenerator + generators: + - type: HeatmapPlateauGenerator + num_heatmaps: 2 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + generate_locref: true + locref_std: 7.2801 + - type: PartAffinityFieldGenerator + graph: + - - 0 + - 1 + width: 20 + criterion: + heatmap: + type: WeightedBCECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + paf: + type: WeightedHuberCriterion + weight: 0.1 + heatmap_config: + channels: + - 2304 + - 2 + kernel_size: + - 3 + strides: + - 2 + locref_config: + channels: + - 2304 + - 4 + kernel_size: + - 3 + strides: + - 2 + paf_config: + channels: + - 2304 + - 2 + kernel_size: + - 3 + strides: + - 2 + num_stages: 5 + unique_bodypart: + type: HeatmapHead + weight_init: normal + predictor: + type: HeatmapPredictor + apply_sigmoid: false + clip_scores: true + location_refinement: true + locref_std: 7.2801 + target_generator: + type: HeatmapGaussianGenerator + num_heatmaps: 2 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + gradient_masking: false + generate_locref: true + locref_std: 7.2801 + label_keypoint_key: keypoints_unique + criterion: + heatmap: + type: WeightedMSECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + heatmap_config: + channels: + - 2304 + - 2 + kernel_size: + - 3 + strides: + - 2 + locref_config: + channels: + - 2304 + - 4 + kernel_size: + - 3 + strides: + - 2 + backbone_output_channels: 2304 + neck: + pose_model: + stride: 8 +net_type: dlcrnet_stride16_ms5 +method: bu +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - nose + - tail + unique_bodyparts: + - corner1 + - corner2 + individuals: + - mouse1 + - mouse2 + with_identity: false +data: + bbox_margin: 20 + colormode: RGB + gen_sampling: + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 0.5 + - 1.25 + translation: 0 + random_bbox_transform: + crop_sampling: + width: 448 + height: 448 + max_shift: 0.1 + method: hybrid + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 25 + optimizer: + type: AdamW + params: + lr: 0.0001 + scheduler: + type: LRListScheduler + params: + lr_list: + - - 1e-05 + - - 1e-06 + milestones: + - 160 + - 190 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 8 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 200 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: +resume_training_from: diff --git a/tests/config/fixtures/pose/generated/multi-hrnet_w32.yaml b/tests/config/fixtures/pose/generated/multi-hrnet_w32.yaml new file mode 100644 index 0000000..f08389d --- /dev/null +++ b/tests/config/fixtures/pose/generated/multi-hrnet_w32.yaml @@ -0,0 +1,252 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: HRNet + model_name: hrnet_w32 + freeze_bn_stats: true + freeze_bn_weights: false + interpolate_branches: false + increased_channel_count: false + heads: + bodypart: + type: DLCRNetHead + predictor: + type: PartAffinityFieldPredictor + num_animals: 2 + num_multibodyparts: 2 + num_uniquebodyparts: 0 + nms_radius: 5 + sigma: 1.0 + locref_stdev: 7.2801 + min_affinity: 0.05 + graph: + - - 0 + - 1 + edges_to_keep: + - 0 + apply_sigmoid: true + clip_scores: false + target_generator: + type: SequentialGenerator + generators: + - type: HeatmapPlateauGenerator + num_heatmaps: 2 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + gradient_masking: false + generate_locref: true + locref_std: 7.2801 + - type: PartAffinityFieldGenerator + graph: + - - 0 + - 1 + width: 20 + criterion: + heatmap: + type: WeightedBCECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + paf: + type: WeightedHuberCriterion + weight: 0.1 + heatmap_config: + channels: + - 32 + - 2 + kernel_size: + - 3 + strides: + - 2 + locref_config: + channels: + - 32 + - 4 + kernel_size: + - 3 + strides: + - 2 + paf_config: + channels: + - 32 + - 2 + kernel_size: + - 3 + strides: + - 2 + num_stages: 5 + unique_bodypart: + type: HeatmapHead + weight_init: normal + predictor: + type: HeatmapPredictor + apply_sigmoid: false + clip_scores: true + location_refinement: true + locref_std: 7.2801 + target_generator: + type: HeatmapGaussianGenerator + num_heatmaps: 2 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + gradient_masking: false + generate_locref: true + locref_std: 7.2801 + label_keypoint_key: keypoints_unique + criterion: + heatmap: + type: WeightedMSECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + heatmap_config: + channels: + - 32 + - 2 + kernel_size: + - 3 + strides: + - 2 + locref_config: + channels: + - 32 + - 4 + kernel_size: + - 3 + strides: + - 2 + backbone_output_channels: 32 + neck: + pose_model: +net_type: hrnet_w32 +method: bu +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - nose + - tail + unique_bodyparts: + - corner1 + - corner2 + individuals: + - mouse1 + - mouse2 + with_identity: false +data: + bbox_margin: 20 + colormode: RGB + gen_sampling: + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + pad_width_divisor: 32 + pad_height_divisor: 32 + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 0.5 + - 1.25 + translation: 0 + random_bbox_transform: + crop_sampling: + width: 448 + height: 448 + max_shift: 0.1 + method: hybrid + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + pad_width_divisor: 32 + pad_height_divisor: 32 + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0001 + scheduler: + type: LRListScheduler + params: + lr_list: + - - 1e-05 + - - 1e-06 + milestones: + - 160 + - 190 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 8 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 200 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: +resume_training_from: diff --git a/tests/config/fixtures/pose/generated/multi_no_unique-ctd_prenet_rtmpose_s.yaml b/tests/config/fixtures/pose/generated/multi_no_unique-ctd_prenet_rtmpose_s.yaml new file mode 100644 index 0000000..cf922ba --- /dev/null +++ b/tests/config/fixtures/pose/generated/multi_no_unique-ctd_prenet_rtmpose_s.yaml @@ -0,0 +1,217 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: CondPreNet + backbone: + type: CSPNeXt + model_name: cspnext_s + freeze_bn_stats: false + freeze_bn_weights: false + deepen_factor: 0.33 + widen_factor: 0.5 + kpt_encoder: + type: StackedKeypointEncoder + num_joints: 2 + kernel_size: + - 15 + - 15 + img_size: + - 256 + - 256 + heads: + bodypart: + type: RTMCCHead + weight_init: RTMPose + target_generator: + type: SimCCGenerator + input_size: + - 256 + - 256 + smoothing_type: gaussian + sigma: + - 5.66 + - 5.66 + simcc_split_ratio: 2.0 + label_smooth_weight: 0.0 + normalize: false + criterion: + x: + type: KLDiscreteLoss + use_target_weight: true + beta: 10.0 + label_softmax: true + y: + type: KLDiscreteLoss + use_target_weight: true + beta: 10.0 + label_softmax: true + predictor: + type: SimCCPredictor + simcc_split_ratio: 2.0 + sigma: + - 5.66 + - 5.66 + decode_beta: 150.0 + input_size: + - 256 + - 256 + in_channels: 512 + out_channels: 2 + in_featuremap_size: + - 8 + - 8 + simcc_split_ratio: 2.0 + final_layer_kernel_size: 7 + gau_cfg: + hidden_dims: 256 + s: 128 + expansion_factor: 2 + dropout_rate: 0 + drop_path: 0.0 + act_fn: SiLU + use_rel_bias: false + pos_enc: false + backbone_output_channels: 512 + neck: + pose_model: +net_type: ctd_prenet_rtmpose_s +method: ctd +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - nose + - tail + unique_bodyparts: [] + individuals: + - mouse1 + - mouse2 + with_identity: false +data: + bbox_margin: 25 + colormode: RGB + gen_sampling: + keypoint_sigmas: 0.1 + keypoints_symmetry: + jitter_prob: 0.16 + swap_prob: 0.08 + inv_prob: 0.03 + miss_prob: 0.1 + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 256 + height: 256 + crop_with_context: false + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 0 + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 256 + height: 256 + crop_with_context: false + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 1e-05 + scheduler: + type: LRListScheduler + params: + lr_list: + - - 0.001 + - - 0.0001 + - - 1e-05 + milestones: + - 5 + - 300 + - 360 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 32 + dataloader_workers: 4 + dataloader_pin_memory: false + display_iters: 500 + epochs: 400 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + source: shuffle + shuffle: 1 + config: + trainset_index: 0 + modelprefix: '' + snapshot: + snapshot_index: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: +resume_training_from: diff --git a/tests/config/fixtures/pose/generated/multi_no_unique-top_down_hrnet_w32.yaml b/tests/config/fixtures/pose/generated/multi_no_unique-top_down_hrnet_w32.yaml new file mode 100644 index 0000000..0b135c6 --- /dev/null +++ b/tests/config/fixtures/pose/generated/multi_no_unique-top_down_hrnet_w32.yaml @@ -0,0 +1,293 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: HRNet + model_name: hrnet_w32 + freeze_bn_stats: true + freeze_bn_weights: false + interpolate_branches: false + increased_channel_count: false + heads: + bodypart: + type: HeatmapHead + weight_init: normal + predictor: + type: HeatmapPredictor + apply_sigmoid: false + clip_scores: true + location_refinement: true + locref_std: 7.2801 + target_generator: + type: HeatmapGaussianGenerator + num_heatmaps: 2 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + gradient_masking: true + background_weight: 0.0 + generate_locref: true + locref_std: 7.2801 + criterion: + heatmap: + type: WeightedMSECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + heatmap_config: + channels: + - 32 + kernel_size: [] + strides: [] + final_conv: + out_channels: 2 + kernel_size: 1 + locref_config: + channels: + - 32 + kernel_size: [] + strides: [] + final_conv: + out_channels: 4 + kernel_size: 1 + backbone_output_channels: 32 + neck: + pose_model: +net_type: hrnet_w32 +method: td +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - nose + - tail + unique_bodyparts: [] + individuals: + - mouse1 + - mouse2 + with_identity: false +data: + bbox_margin: 20 + colormode: RGB + gen_sampling: + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + pad_width_divisor: 32 + pad_height_divisor: 32 + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 256 + height: 256 + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 0 + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + pad_width_divisor: 32 + pad_height_divisor: 32 + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 256 + height: 256 + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0001 + scheduler: + type: LRListScheduler + params: + lr_list: + - - 1e-05 + - - 1e-06 + milestones: + - 160 + - 190 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 8 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 200 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: + model: + type: SSDLite + freeze_bn_stats: true + freeze_bn_weights: false + variant: + box_score_thresh: 0.01 + device: auto + data: + colormode: RGB + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + train: + resize: + longest_max_size: + hflip: true + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 40 + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + type: ResizeFromDataSizeCollate + min_scale: 0.4 + max_scale: 1.0 + min_short_side: 128 + max_short_side: 1152 + multiple_of: 32 + to_square: false + runner: + type: DetectorTrainingRunner + gpus: + device: auto + key_metric: test.mAP@50:95 + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0001 + scheduler: + type: LRListScheduler + params: + milestones: + - 160 + lr_list: + - - 1e-05 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: + train_settings: + batch_size: 16 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 250 + seed: 42 + weight_init: + inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: + resume_training_from: +resume_training_from: diff --git a/tests/config/fixtures/pose/generated/single-ctd_coam_w48_human.yaml b/tests/config/fixtures/pose/generated/single-ctd_coam_w48_human.yaml new file mode 100644 index 0000000..fc1a922 --- /dev/null +++ b/tests/config/fixtures/pose/generated/single-ctd_coam_w48_human.yaml @@ -0,0 +1,230 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: HRNetCoAM + base_model_name: hrnet_w48 + pretrained: true + freeze_bn_stats: false + freeze_bn_weights: false + coam_modules: + - 2 + channel_att_only: false + att_heads: 1 + kpt_encoder: + type: StackedKeypointEncoder + num_joints: 4 + kernel_size: + - 15 + - 15 + img_size: + - 384 + - 288 + heads: + bodypart: + type: HeatmapHead + weight_init: normal + predictor: + type: HeatmapPredictor + apply_sigmoid: false + clip_scores: true + location_refinement: true + locref_std: 7.2801 + target_generator: + type: HeatmapGaussianGenerator + num_heatmaps: 4 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + generate_locref: true + locref_std: 7.2801 + criterion: + heatmap: + type: WeightedMSECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + heatmap_config: + channels: + - 48 + kernel_size: [] + strides: [] + final_conv: + out_channels: 4 + kernel_size: 1 + locref_config: + channels: + - 48 + kernel_size: [] + strides: [] + final_conv: + out_channels: 8 + kernel_size: 1 + backbone_output_channels: 48 + neck: + pose_model: +net_type: ctd_coam_w48_human +method: ctd +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - snout + - leftear + - rightear + - tailbase + unique_bodyparts: [] + individuals: + - individual_1 + with_identity: false +data: + bbox_margin: 5 + colormode: RGB + gen_sampling: + keypoint_sigmas: + - 0.079 + - 0.079 + - 0.072 + - 0.072 + - 0.062 + - 0.062 + - 0.107 + - 0.107 + - 0.087 + - 0.087 + - 0.089 + - 0.089 + - 0.025 + - 0.025 + keypoints_symmetry: + - - 0 + - 1 + - - 2 + - 3 + - - 4 + - 5 + - - 6 + - 7 + - - 8 + - 9 + - - 10 + - 11 + jitter_prob: 0.16 + swap_prob: 0.08 + inv_prob: 0.03 + miss_prob: 0.1 + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 288 + height: 384 + crop_with_context: true + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 0 + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 288 + height: 384 + crop_with_context: true + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0001 + scheduler: + type: LRListScheduler + params: + lr_list: + - - 1e-05 + - - 1e-06 + milestones: + - 160 + - 190 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 8 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 200 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + source: shuffle + shuffle: 1 + config: + trainset_index: 0 + modelprefix: '' + snapshot: + snapshot_index: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: +resume_training_from: diff --git a/tests/config/fixtures/pose/generated/single-resnet_50.yaml b/tests/config/fixtures/pose/generated/single-resnet_50.yaml new file mode 100644 index 0000000..cbf773d --- /dev/null +++ b/tests/config/fixtures/pose/generated/single-resnet_50.yaml @@ -0,0 +1,177 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: ResNet + model_name: resnet50_gn + output_stride: 16 + freeze_bn_stats: false + freeze_bn_weights: false + heads: + bodypart: + type: HeatmapHead + weight_init: normal + predictor: + type: HeatmapPredictor + apply_sigmoid: false + clip_scores: true + location_refinement: true + locref_std: 7.2801 + target_generator: + type: HeatmapGaussianGenerator + num_heatmaps: 4 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + gradient_masking: false + generate_locref: true + locref_std: 7.2801 + criterion: + heatmap: + type: WeightedMSECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + heatmap_config: + channels: + - 2048 + - 4 + kernel_size: + - 3 + strides: + - 2 + locref_config: + channels: + - 2048 + - 8 + kernel_size: + - 3 + strides: + - 2 + backbone_output_channels: 2048 + neck: + pose_model: +net_type: resnet_50 +method: bu +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - snout + - leftear + - rightear + - tailbase + unique_bodyparts: [] + individuals: + - individual_1 + with_identity: false +data: + bbox_margin: 20 + colormode: RGB + gen_sampling: + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 0.5 + - 1.25 + translation: 0 + random_bbox_transform: + crop_sampling: + width: 448 + height: 448 + max_shift: 0.1 + method: hybrid + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0005 + scheduler: + type: LRListScheduler + params: + lr_list: + - - 0.0001 + - - 1e-05 + milestones: + - 90 + - 120 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 8 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 200 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: +resume_training_from: diff --git a/tests/config/fixtures/pose/generated/single-rtmpose_s.yaml b/tests/config/fixtures/pose/generated/single-rtmpose_s.yaml new file mode 100644 index 0000000..ebf6f51 --- /dev/null +++ b/tests/config/fixtures/pose/generated/single-rtmpose_s.yaml @@ -0,0 +1,323 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: CSPNeXt + model_name: cspnext_s + freeze_bn_stats: false + freeze_bn_weights: false + deepen_factor: 0.33 + widen_factor: 0.5 + heads: + bodypart: + type: RTMCCHead + weight_init: RTMPose + target_generator: + type: SimCCGenerator + input_size: + - 256 + - 256 + smoothing_type: gaussian + sigma: + - 5.66 + - 5.66 + simcc_split_ratio: 2.0 + label_smooth_weight: 0.0 + normalize: false + criterion: + x: + type: KLDiscreteLoss + use_target_weight: true + beta: 10.0 + label_softmax: true + y: + type: KLDiscreteLoss + use_target_weight: true + beta: 10.0 + label_softmax: true + predictor: + type: SimCCPredictor + simcc_split_ratio: 2.0 + sigma: + - 5.66 + - 5.66 + decode_beta: 150.0 + apply_softmax: true + normalize_outputs: false + input_size: + - 256 + - 256 + in_channels: 512 + out_channels: 4 + in_featuremap_size: + - 8 + - 8 + simcc_split_ratio: 2.0 + final_layer_kernel_size: 7 + gau_cfg: + hidden_dims: 256 + s: 128 + expansion_factor: 2 + dropout_rate: 0 + drop_path: 0.0 + act_fn: SiLU + use_rel_bias: false + pos_enc: false + backbone_output_channels: 512 + neck: + pose_model: +net_type: rtmpose_s +method: td +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - snout + - leftear + - rightear + - tailbase + unique_bodyparts: [] + individuals: + - individual_1 + with_identity: false +data: + bbox_margin: 20 + colormode: RGB + gen_sampling: + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 256 + height: 256 + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 0 + random_bbox_transform: + shift_factor: 0.16 + shift_prob: 0.3 + scale_factor: + - 0.75 + - 1.25 + scale_prob: 1.0 + p: 1.0 + crop_sampling: + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 256 + height: 256 + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.001 + scheduler: + type: SequentialLR + params: + schedulers: + - type: LinearLR + params: + start_factor: 0.001 + end_factor: 1.0 + total_iters: 5 + - type: CosineAnnealingLR + params: + T_max: 200 + eta_min: 5e-05 + - type: LRListScheduler + params: + milestones: + - 0 + lr_list: + - - 5e-05 + milestones: + - 200 + - 400 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 32 + dataloader_workers: 4 + dataloader_pin_memory: false + display_iters: 500 + epochs: 400 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: + model: + type: SSDLite + freeze_bn_stats: true + freeze_bn_weights: false + variant: + box_score_thresh: 0.01 + device: auto + data: + colormode: RGB + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + train: + resize: + longest_max_size: + hflip: true + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 40 + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + type: ResizeFromDataSizeCollate + min_scale: 0.4 + max_scale: 1.0 + min_short_side: 128 + max_short_side: 1152 + multiple_of: 32 + to_square: false + runner: + type: DetectorTrainingRunner + gpus: + device: auto + key_metric: test.mAP@50:95 + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0001 + scheduler: + type: LRListScheduler + params: + milestones: + - 160 + lr_list: + - - 1e-05 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: + train_settings: + batch_size: 16 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 250 + seed: 42 + weight_init: + inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: + resume_training_from: +resume_training_from: diff --git a/tests/config/fixtures/pose/generated/single-rtmpose_x.yaml b/tests/config/fixtures/pose/generated/single-rtmpose_x.yaml new file mode 100644 index 0000000..95e58f4 --- /dev/null +++ b/tests/config/fixtures/pose/generated/single-rtmpose_x.yaml @@ -0,0 +1,323 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: CSPNeXt + model_name: cspnext_x + freeze_bn_stats: false + freeze_bn_weights: false + deepen_factor: 1.33 + widen_factor: 1.25 + heads: + bodypart: + type: RTMCCHead + weight_init: RTMPose + target_generator: + type: SimCCGenerator + input_size: + - 384 + - 384 + smoothing_type: gaussian + sigma: + - 6.93 + - 6.93 + simcc_split_ratio: 2.0 + label_smooth_weight: 0.0 + normalize: false + criterion: + x: + type: KLDiscreteLoss + use_target_weight: true + beta: 10.0 + label_softmax: true + y: + type: KLDiscreteLoss + use_target_weight: true + beta: 10.0 + label_softmax: true + predictor: + type: SimCCPredictor + simcc_split_ratio: 2.0 + sigma: + - 6.93 + - 6.93 + decode_beta: 150.0 + apply_softmax: true + normalize_outputs: false + input_size: + - 384 + - 384 + in_channels: 1280 + out_channels: 4 + in_featuremap_size: + - 12 + - 12 + simcc_split_ratio: 2.0 + final_layer_kernel_size: 7 + gau_cfg: + hidden_dims: 256 + s: 128 + expansion_factor: 2 + dropout_rate: 0 + drop_path: 0.0 + act_fn: SiLU + use_rel_bias: false + pos_enc: false + backbone_output_channels: 1280 + neck: + pose_model: +net_type: rtmpose_x +method: td +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - snout + - leftear + - rightear + - tailbase + unique_bodyparts: [] + individuals: + - individual_1 + with_identity: false +data: + bbox_margin: 20 + colormode: RGB + gen_sampling: + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 384 + height: 384 + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 0 + random_bbox_transform: + shift_factor: 0.16 + shift_prob: 0.3 + scale_factor: + - 0.75 + - 1.25 + scale_prob: 1.0 + p: 1.0 + crop_sampling: + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 384 + height: 384 + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.001 + scheduler: + type: SequentialLR + params: + schedulers: + - type: LinearLR + params: + start_factor: 0.001 + end_factor: 1.0 + total_iters: 5 + - type: CosineAnnealingLR + params: + T_max: 200 + eta_min: 5e-05 + - type: LRListScheduler + params: + milestones: + - 0 + lr_list: + - - 5e-05 + milestones: + - 200 + - 400 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 32 + dataloader_workers: 4 + dataloader_pin_memory: false + display_iters: 500 + epochs: 400 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: + model: + type: SSDLite + freeze_bn_stats: true + freeze_bn_weights: false + variant: + box_score_thresh: 0.01 + device: auto + data: + colormode: RGB + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + train: + resize: + longest_max_size: + hflip: true + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 40 + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + type: ResizeFromDataSizeCollate + min_scale: 0.4 + max_scale: 1.0 + min_short_side: 128 + max_short_side: 1152 + multiple_of: 32 + to_square: false + runner: + type: DetectorTrainingRunner + gpus: + device: auto + key_metric: test.mAP@50:95 + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0001 + scheduler: + type: LRListScheduler + params: + milestones: + - 160 + lr_list: + - - 1e-05 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: + train_settings: + batch_size: 16 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 250 + seed: 42 + weight_init: + inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: + resume_training_from: +resume_training_from: diff --git a/tests/config/fixtures/pose/generated/single-top_down_resnet_50.yaml b/tests/config/fixtures/pose/generated/single-top_down_resnet_50.yaml new file mode 100644 index 0000000..21c9775 --- /dev/null +++ b/tests/config/fixtures/pose/generated/single-top_down_resnet_50.yaml @@ -0,0 +1,289 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: ResNet + model_name: resnet50_gn + output_stride: 16 + freeze_bn_stats: false + freeze_bn_weights: false + heads: + bodypart: + type: HeatmapHead + weight_init: normal + predictor: + type: HeatmapPredictor + apply_sigmoid: false + clip_scores: true + location_refinement: true + locref_std: 7.2801 + target_generator: + type: HeatmapGaussianGenerator + num_heatmaps: 4 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + gradient_masking: true + background_weight: 0.0 + generate_locref: true + locref_std: 7.2801 + criterion: + heatmap: + type: WeightedMSECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + heatmap_config: + channels: + - 2048 + kernel_size: [] + strides: [] + final_conv: + out_channels: 4 + kernel_size: 1 + locref_config: + channels: + - 2048 + kernel_size: [] + strides: [] + final_conv: + out_channels: 8 + kernel_size: 1 + backbone_output_channels: 2048 + neck: + pose_model: +net_type: resnet_50 +method: td +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - snout + - leftear + - rightear + - tailbase + unique_bodyparts: [] + individuals: + - individual_1 + with_identity: false +data: + bbox_margin: 20 + colormode: RGB + gen_sampling: + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 256 + height: 256 + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 0 + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 256 + height: 256 + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0005 + scheduler: + type: LRListScheduler + params: + lr_list: + - - 0.0001 + - - 1e-05 + milestones: + - 90 + - 120 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 8 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 200 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: + model: + type: SSDLite + freeze_bn_stats: true + freeze_bn_weights: false + variant: + box_score_thresh: 0.01 + device: auto + data: + colormode: RGB + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + train: + resize: + longest_max_size: + hflip: true + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 40 + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + type: ResizeFromDataSizeCollate + min_scale: 0.4 + max_scale: 1.0 + min_short_side: 128 + max_short_side: 1152 + multiple_of: 32 + to_square: false + runner: + type: DetectorTrainingRunner + gpus: + device: auto + key_metric: test.mAP@50:95 + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0001 + scheduler: + type: LRListScheduler + params: + milestones: + - 160 + lr_list: + - - 1e-05 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: + train_settings: + batch_size: 16 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 250 + seed: 42 + weight_init: + inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: + resume_training_from: +resume_training_from: diff --git a/tests/config/fixtures/pose/legacy/dlcrnet_ms5_alias.yaml b/tests/config/fixtures/pose/legacy/dlcrnet_ms5_alias.yaml new file mode 100644 index 0000000..274f628 --- /dev/null +++ b/tests/config/fixtures/pose/legacy/dlcrnet_ms5_alias.yaml @@ -0,0 +1,244 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: DLCRNet + model_name: resnet50 + pretrained: true + output_stride: 16 + heads: + bodypart: + type: DLCRNetHead + predictor: + type: PartAffinityFieldPredictor + num_animals: 2 + num_multibodyparts: 2 + num_uniquebodyparts: 0 + nms_radius: 5 + sigma: 1.0 + locref_stdev: 7.2801 + min_affinity: 0.05 + graph: + - - 0 + - 1 + edges_to_keep: + - 0 + target_generator: + type: SequentialGenerator + generators: + - type: HeatmapPlateauGenerator + num_heatmaps: 2 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + generate_locref: true + locref_std: 7.2801 + - type: PartAffinityFieldGenerator + graph: + - - 0 + - 1 + width: 20 + criterion: + heatmap: + type: WeightedBCECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + paf: + type: WeightedHuberCriterion + weight: 0.1 + heatmap_config: + channels: + - 2304 + - 2 + kernel_size: + - 3 + strides: + - 2 + locref_config: + channels: + - 2304 + - 4 + kernel_size: + - 3 + strides: + - 2 + paf_config: + channels: + - 2304 + - 2 + kernel_size: + - 3 + strides: + - 2 + num_stages: 5 + unique_bodypart: + type: HeatmapHead + weight_init: normal + predictor: + type: HeatmapPredictor + apply_sigmoid: false + clip_scores: true + location_refinement: true + locref_std: 7.2801 + target_generator: + type: HeatmapGaussianGenerator + num_heatmaps: 2 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + gradient_masking: false + generate_locref: true + locref_std: 7.2801 + label_keypoint_key: keypoints_unique + criterion: + heatmap: + type: WeightedMSECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + heatmap_config: + channels: + - 2304 + - 2 + kernel_size: + - 3 + strides: + - 2 + locref_config: + channels: + - 2304 + - 4 + kernel_size: + - 3 + strides: + - 2 + backbone_output_channels: 2304 + neck: + pose_model: + stride: 8 +net_type: dlcrnet_ms5 +method: bu +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - nose + - tail + unique_bodyparts: + - corner1 + - corner2 + individuals: + - mouse1 + - mouse2 + with_identity: false +data: + bbox_margin: 20 + colormode: RGB + gen_sampling: + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 0.5 + - 1.25 + translation: 0 + random_bbox_transform: + crop_sampling: + width: 448 + height: 448 + max_shift: 0.1 + method: hybrid + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 25 + optimizer: + type: AdamW + params: + lr: 0.0001 + scheduler: + type: LRListScheduler + params: + lr_list: + - - 1e-05 + - - 1e-06 + milestones: + - 160 + - 190 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 8 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 200 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: +resume_training_from: diff --git a/tests/config/fixtures/pose/legacy/top_down_crop_mismatch.yaml b/tests/config/fixtures/pose/legacy/top_down_crop_mismatch.yaml new file mode 100644 index 0000000..0c98445 --- /dev/null +++ b/tests/config/fixtures/pose/legacy/top_down_crop_mismatch.yaml @@ -0,0 +1,323 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: CSPNeXt + model_name: cspnext_s + freeze_bn_stats: false + freeze_bn_weights: false + deepen_factor: 0.33 + widen_factor: 0.5 + heads: + bodypart: + type: RTMCCHead + weight_init: RTMPose + target_generator: + type: SimCCGenerator + input_size: + - 256 + - 256 + smoothing_type: gaussian + sigma: + - 5.66 + - 5.66 + simcc_split_ratio: 2.0 + label_smooth_weight: 0.0 + normalize: false + criterion: + x: + type: KLDiscreteLoss + use_target_weight: true + beta: 10.0 + label_softmax: true + y: + type: KLDiscreteLoss + use_target_weight: true + beta: 10.0 + label_softmax: true + predictor: + type: SimCCPredictor + simcc_split_ratio: 2.0 + sigma: + - 5.66 + - 5.66 + decode_beta: 150.0 + apply_softmax: true + normalize_outputs: false + input_size: + - 256 + - 256 + in_channels: 512 + out_channels: 4 + in_featuremap_size: + - 8 + - 8 + simcc_split_ratio: 2.0 + final_layer_kernel_size: 7 + gau_cfg: + hidden_dims: 256 + s: 128 + expansion_factor: 2 + dropout_rate: 0 + drop_path: 0.0 + act_fn: SiLU + use_rel_bias: false + pos_enc: false + backbone_output_channels: 512 + neck: + pose_model: +net_type: rtmpose_s +method: td +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - snout + - leftear + - rightear + - tailbase + unique_bodyparts: [] + individuals: + - individual_1 + with_identity: false +data: + bbox_margin: 20 + colormode: RGB + gen_sampling: + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 192 + height: 256 + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 0 + random_bbox_transform: + shift_factor: 0.16 + shift_prob: 0.3 + scale_factor: + - 0.75 + - 1.25 + scale_prob: 1.0 + p: 1.0 + crop_sampling: + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 192 + height: 256 + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.001 + scheduler: + type: SequentialLR + params: + schedulers: + - type: LinearLR + params: + start_factor: 0.001 + end_factor: 1.0 + total_iters: 5 + - type: CosineAnnealingLR + params: + T_max: 200 + eta_min: 5e-05 + - type: LRListScheduler + params: + milestones: + - 0 + lr_list: + - - 5e-05 + milestones: + - 200 + - 400 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 32 + dataloader_workers: 4 + dataloader_pin_memory: false + display_iters: 500 + epochs: 400 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: + model: + type: SSDLite + freeze_bn_stats: true + freeze_bn_weights: false + variant: + box_score_thresh: 0.01 + device: auto + data: + colormode: RGB + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + train: + resize: + longest_max_size: + hflip: true + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 40 + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + type: ResizeFromDataSizeCollate + min_scale: 0.4 + max_scale: 1.0 + min_short_side: 128 + max_short_side: 1152 + multiple_of: 32 + to_square: false + runner: + type: DetectorTrainingRunner + gpus: + device: auto + key_metric: test.mAP@50:95 + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0001 + scheduler: + type: LRListScheduler + params: + milestones: + - 160 + lr_list: + - - 1e-05 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: + train_settings: + batch_size: 16 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 250 + seed: 42 + weight_init: + inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: + resume_training_from: +resume_training_from: diff --git a/tests/config/fixtures/pose/legacy/top_down_prefix.yaml b/tests/config/fixtures/pose/legacy/top_down_prefix.yaml new file mode 100644 index 0000000..4e8625b --- /dev/null +++ b/tests/config/fixtures/pose/legacy/top_down_prefix.yaml @@ -0,0 +1,289 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: ResNet + model_name: resnet50_gn + output_stride: 16 + freeze_bn_stats: false + freeze_bn_weights: false + heads: + bodypart: + type: HeatmapHead + weight_init: normal + predictor: + type: HeatmapPredictor + apply_sigmoid: false + clip_scores: true + location_refinement: true + locref_std: 7.2801 + target_generator: + type: HeatmapGaussianGenerator + num_heatmaps: 4 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + gradient_masking: true + background_weight: 0.0 + generate_locref: true + locref_std: 7.2801 + criterion: + heatmap: + type: WeightedMSECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + heatmap_config: + channels: + - 2048 + kernel_size: [] + strides: [] + final_conv: + out_channels: 4 + kernel_size: 1 + locref_config: + channels: + - 2048 + kernel_size: [] + strides: [] + final_conv: + out_channels: 8 + kernel_size: 1 + backbone_output_channels: 2048 + neck: + pose_model: +net_type: top_down_resnet_50 +method: td +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - snout + - leftear + - rightear + - tailbase + unique_bodyparts: [] + individuals: + - individual_1 + with_identity: false +data: + bbox_margin: 20 + colormode: RGB + gen_sampling: + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 256 + height: 256 + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 0 + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + width: 256 + height: 256 + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0005 + scheduler: + type: LRListScheduler + params: + lr_list: + - - 0.0001 + - - 1e-05 + milestones: + - 90 + - 120 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 8 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 200 + seed: 42 + weight_init: +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: + model: + type: SSDLite + freeze_bn_stats: true + freeze_bn_weights: false + variant: + box_score_thresh: 0.01 + device: auto + data: + colormode: RGB + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + train: + resize: + longest_max_size: + hflip: true + affine: + p: 0.5 + rotation: 30 + scaling: + - 1.0 + - 1.0 + translation: 40 + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + type: ResizeFromDataSizeCollate + min_scale: 0.4 + max_scale: 1.0 + min_short_side: 128 + max_short_side: 1152 + multiple_of: 32 + to_square: false + runner: + type: DetectorTrainingRunner + gpus: + device: auto + key_metric: test.mAP@50:95 + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0001 + scheduler: + type: LRListScheduler + params: + milestones: + - 160 + lr_list: + - - 1e-05 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: + train_settings: + batch_size: 16 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 250 + seed: 42 + weight_init: + inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: + resume_training_from: +resume_training_from: diff --git a/tests/config/fixtures/pose/legacy/weight_init_before_3.0.0rc5.yaml b/tests/config/fixtures/pose/legacy/weight_init_before_3.0.0rc5.yaml new file mode 100644 index 0000000..6ff1c49 --- /dev/null +++ b/tests/config/fixtures/pose/legacy/weight_init_before_3.0.0rc5.yaml @@ -0,0 +1,180 @@ +# Config schema version. Do not edit manually. +config_version: 0 +model: + backbone: + type: ResNet + model_name: resnet50_gn + output_stride: 16 + freeze_bn_stats: false + freeze_bn_weights: false + heads: + bodypart: + type: HeatmapHead + weight_init: normal + predictor: + type: HeatmapPredictor + apply_sigmoid: false + clip_scores: true + location_refinement: true + locref_std: 7.2801 + target_generator: + type: HeatmapGaussianGenerator + num_heatmaps: 4 + pos_dist_thresh: 17 + heatmap_mode: KEYPOINT + gradient_masking: false + generate_locref: true + locref_std: 7.2801 + criterion: + heatmap: + type: WeightedMSECriterion + weight: 1.0 + locref: + type: WeightedHuberCriterion + weight: 0.05 + heatmap_config: + channels: + - 2048 + - 4 + kernel_size: + - 3 + strides: + - 2 + locref_config: + channels: + - 2048 + - 8 + kernel_size: + - 3 + strides: + - 2 + backbone_output_channels: 2048 + neck: + pose_model: +net_type: resnet_50 +method: bu +device: auto +metadata: + project_path: project + pose_config_path: pytorch_config.yaml + bodyparts: + - snout + - leftear + - rightear + - tailbase + unique_bodyparts: [] + individuals: + - individual_1 + with_identity: false +data: + bbox_margin: 20 + colormode: RGB + gen_sampling: + inference: + resize: + longest_max_size: + hflip: + affine: + random_bbox_transform: + crop_sampling: + hist_eq: false + motion_blur: false + covering: + elastic_transform: + grayscale: + gaussian_noise: + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + train: + resize: + longest_max_size: + hflip: + affine: + p: 0.5 + rotation: 30 + scaling: + - 0.5 + - 1.25 + translation: 0 + random_bbox_transform: + crop_sampling: + width: 448 + height: 448 + max_shift: 0.1 + method: hybrid + hist_eq: false + motion_blur: true + covering: + elastic_transform: + grayscale: + gaussian_noise: 12.75 + auto_padding: + normalize_images: true + scale_to_unit_range: false + top_down_crop: + collate: + loader: +runner: + type: PoseTrainingRunner + gpus: + device: auto + key_metric: test.mAP + key_metric_asc: true + eval_interval: 10 + optimizer: + type: AdamW + params: + lr: 0.0005 + scheduler: + type: LRListScheduler + params: + lr_list: + - - 0.0001 + - - 1e-05 + milestones: + - 90 + - 120 + snapshots: + max_snapshots: 5 + save_epochs: 25 + save_optimizer_state: false + snapshot_prefix: + load_scheduler_state_dict: true + load_weights_only: +train_settings: + batch_size: 8 + dataloader_workers: 0 + dataloader_pin_memory: false + display_iters: 500 + epochs: 200 + seed: 42 + weight_init: + dataset: superanimal_quadruped + with_decoder: false + memory_replay: false +inference: + multithreading: + enabled: true + queue_length: 4 + timeout: 30.0 + compile: + enabled: false + backend: inductor + autocast: + enabled: false + conditions: + snapshot: + eval: + mode: all + pcutoff: 0.6 + comparison_bodyparts: all + per_keypoint_evaluation: false + force_multi_animal: false + output_dir: +logger: +with_center_keypoints: false +detector: +resume_training_from: diff --git a/tests/config/pose/test_pose_config.py b/tests/config/pose/test_pose_config.py new file mode 100644 index 0000000..827a393 --- /dev/null +++ b/tests/config/pose/test_pose_config.py @@ -0,0 +1,167 @@ +# +# DeepLabCut Toolbox (deeplabcut.org) +# © A. & M.W. Mathis Labs +# https://github.com/DeepLabCut/dlccore +# +# Contributors: +# https://github.com/DeepLabCut/dlccore/graphs/contributors +# +# Licensed under GNU Lesser General Public License v3.0 +# + +"""``pytorch_config.yaml`` reads back exactly as DeepLabCut wrote it, without DeepLabCut.""" + +import json +import subprocess +import sys +from pathlib import Path + +import pytest + +from dlccore.config import read_config_as_dict, versioning +from dlccore.config.pose import NetType, PoseConfig +from dlccore.config.pose import pose as pose_module +from dlccore.config.versioning import register_migration + +FIXTURES = Path(__file__).resolve().parents[1] / "fixtures" / "pose" +GENERATED = sorted((FIXTURES / "generated").glob("*.yaml")) +LEGACY = FIXTURES / "legacy" + +LEGACY_READS_AS = { + "dlcrnet_ms5_alias.yaml": "multi-dlcrnet_stride16_ms5.yaml", + "top_down_prefix.yaml": "single-top_down_resnet_50.yaml", + "top_down_crop_mismatch.yaml": "single-rtmpose_s.yaml", +} + + +def _ids(paths: list[Path]) -> list[str]: + return [path.stem for path in paths] + + +@pytest.mark.parametrize("path", GENERATED, ids=_ids(GENERATED)) +def test_a_config_is_written_back_byte_for_byte(path: Path, tmp_path: Path) -> None: + written = tmp_path / path.name + + PoseConfig.from_yaml(path).to_yaml(written) + + assert written.read_bytes() == path.read_bytes() + + +@pytest.mark.parametrize("path", GENERATED, ids=_ids(GENERATED)) +def test_a_stored_dict_reads_back_to_itself(path: Path) -> None: + """The read DeepLabCut-live makes: the dict an exported model stores, not the YAML.""" + stored = PoseConfig.from_yaml(path).to_dict(normalize=True) + + assert PoseConfig.from_dict(stored).to_dict(normalize=True) == stored + + +@pytest.mark.parametrize( + "name", ["single-top_down_resnet_50.yaml", "multi_no_unique-ctd_prenet_rtmpose_s.yaml", "multi-dekr_w32.yaml"] +) +def test_an_exported_config_reads(name: str) -> None: + """DeepLabCut's export wipes these paths (``export.wipe_paths_from_model_config``) before storing the dict.""" + exported = read_config_as_dict(FIXTURES / "generated" / name) + exported["metadata"]["project_path"] = None + exported["metadata"]["pose_config_path"] = None + exported["train_settings"]["weight_init"] = None + exported["resume_training_from"] = None + if exported.get("detector") is not None: + exported["detector"]["resume_training_from"] = None + + config = PoseConfig.from_dict(exported) + + assert config.metadata.project_path is None + assert config.to_dict(normalize=True)["metadata"]["bodyparts"] == exported["metadata"]["bodyparts"] + + +@pytest.mark.parametrize("legacy, current", LEGACY_READS_AS.items(), ids=list(LEGACY_READS_AS)) +def test_a_legacy_config_reads_as_its_current_form(legacy: str, current: str) -> None: + read = PoseConfig.from_yaml(LEGACY / legacy).to_dict(normalize=True) + + assert read == PoseConfig.from_yaml(FIXTURES / "generated" / current).to_dict(normalize=True) + + +def test_a_weight_init_from_before_3_0_0rc5_reads_without_a_snapshot() -> None: + """Pins DeepLabCut's typed read: the legacy path that resolved a SuperAnimal snapshot is never taken.""" + weight_init = PoseConfig.from_yaml(LEGACY / "weight_init_before_3.0.0rc5.yaml").train_settings.weight_init + + assert weight_init.dataset == "superanimal_quadruped" + assert weight_init.snapshot_path is None + + +@pytest.mark.parametrize( + "alias, expected", + [ + ("dlcrnet_ms5", (NetType.DLCRNET_STRIDE16_MS5, False)), + ("top_down_resnet_50", (NetType.RESNET_50, True)), + *[(net_type.value, (net_type, False)) for net_type in NetType], + ], +) +def test_a_stored_net_type_resolves(alias: str, expected: tuple[NetType, bool]) -> None: + assert NetType.from_alias(alias) == expected + + +def test_an_unknown_net_type_is_refused() -> None: + with pytest.raises(ValueError, match="not_a_model"): + NetType.from_alias("not_a_model") + + +def test_pose_config_registers_its_migrations() -> None: + assert versioning._MIGRATIONS[("PoseConfig", 0, 1)] is pose_module.migrate_pose_v0_to_v1 + assert versioning._MIGRATIONS[("PoseConfig", 1, 0)] is pose_module.migrate_pose_v1_to_v0 + + +def test_reading_a_dict_runs_pose_config_migrations(monkeypatch: pytest.MonkeyPatch) -> None: + stored = PoseConfig.from_yaml(GENERATED[0]).to_dict(normalize=True) + stored["dropped_by_migration"] = True + monkeypatch.setitem(versioning.CURRENT_CONFIG_VERSIONS, "PoseConfig", 1) + monkeypatch.delitem(versioning._MIGRATIONS, ("PoseConfig", 0, 1)) + + @register_migration(0, 1, config_type="PoseConfig") + def drop(config: dict) -> dict: + del config["dropped_by_migration"] + return {**config, "config_version": 1} + + assert PoseConfig.from_dict(stored).config_version == 1 + + +@pytest.mark.parametrize("stage", ["train", "inference"]) +def test_pose_config_repairs_top_down_crop_not_matching_head(stage: str, caplog: pytest.LogCaptureFixture) -> None: + """DeepLabCut's test of the same name: configs written by 3.0.1 to 3.0.3 for rtmpose_x (256 crop, 384 head).""" + stored = read_config_as_dict(FIXTURES / "generated" / "single-rtmpose_x.yaml") + stored["data"][stage]["top_down_crop"].update(width=256, height=256) + + repaired = PoseConfig.from_dict(stored) + + crop = getattr(repaired.data, stage).top_down_crop + assert (crop["width"], crop["height"]) == (384, 384) + assert f"data.{stage}.top_down_crop" in caplog.text + assert "loaded config only" in caplog.text + assert "pytorch_config.yaml" in caplog.text + + +@pytest.mark.xfail( + strict=True, + raises=AssertionError, + reason="Owed upstream first: the crop repair reports only to the log; a core repair reports its changes as data", +) +def test_the_crop_repair_is_reported_as_data() -> None: + config = PoseConfig.from_yaml(LEGACY / "top_down_crop_mismatch.yaml") + + assert any("data.train.top_down_crop" in note for note in config.change_notes) + + +def test_reading_needs_neither_deeplabcut_nor_its_training_stack() -> None: + """In a fresh interpreter, since this suite may run beside DeepLabCut.""" + script = f""" +import json, sys +from pathlib import Path +from dlccore.config.pose import PoseConfig +for path in sorted(Path({str(FIXTURES)!r}).glob("*/*.yaml")): + PoseConfig.from_yaml(path) +heavy = {{"deeplabcut", "torch", "albumentations", "cv2"}} +print(json.dumps(sorted(name for name in sys.modules if name.split(".")[0] in heavy))) +""" + result = subprocess.run([sys.executable, "-c", script], capture_output=True, text=True, check=True) + + assert json.loads(result.stdout.splitlines()[-1]) == []