Skip to content

Commit

Permalink
Add tests for centered instance with scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
gitttt-1234 committed Dec 20, 2024
1 parent e4a5260 commit 53d84f7
Show file tree
Hide file tree
Showing 13 changed files with 461 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sleap/nn/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1832,12 +1832,12 @@ def call(self, inputs):
# See: https://github.com/tensorflow/tensorflow/issues/6720
centroid_points = (centroid_points / self.input_scale) + 0.5

# resize full images
if self.precrop_resize != 1.0:
full_imgs = sleap.nn.data.resizing.resize_image(
full_imgs, self.precrop_resize
)
centroid_points *= self.precrop_resize
# resize full images
if self.precrop_resize != 1.0:
full_imgs = sleap.nn.data.resizing.resize_image(
full_imgs, self.precrop_resize
)
centroid_points *= self.precrop_resize

# Store crop offsets.
crop_offsets = centroid_points - (self.crop_size / 2)
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
{
"data": {
"labels": {
"training_labels": null,
"validation_labels": null,
"validation_fraction": 0.1,
"test_labels": null,
"split_by_inds": false,
"training_inds": null,
"validation_inds": null,
"test_inds": null,
"search_path_hints": [],
"skeletons": []
},
"preprocessing": {
"ensure_rgb": false,
"ensure_grayscale": false,
"imagenet_mode": null,
"input_scaling": 0.5,
"pad_to_stride": null,
"resize_and_pad_to_target": true,
"target_height": null,
"target_width": null
},
"instance_cropping": {
"center_on_part": null,
"crop_size": null,
"crop_size_detection_padding": 16
}
},
"model": {
"backbone": {
"leap": null,
"unet": {
"stem_stride": null,
"max_stride": 8,
"output_stride": 2,
"filters": 16,
"filters_rate": 1.5,
"middle_block": true,
"up_interpolate": false,
"stacks": 1
},
"hourglass": null,
"resnet": null,
"pretrained_encoder": null
},
"heads": {
"single_instance": null,
"centroid": null,
"centered_instance": {
"anchor_part": null,
"part_names": null,
"sigma": 1.5,
"output_stride": 2,
"loss_weight": 1.0,
"offset_refinement": true
},
"multi_instance": null,
"multi_class_bottomup": null,
"multi_class_topdown": null
},
"base_checkpoint": null
},
"optimization": {
"preload_data": false,
"augmentation_config": {
"rotate": false,
"rotation_min_angle": -180.0,
"rotation_max_angle": 180.0,
"translate": false,
"translate_min": -5,
"translate_max": 5,
"scale": false,
"scale_min": 0.9,
"scale_max": 1.1,
"uniform_noise": false,
"uniform_noise_min_val": 0.0,
"uniform_noise_max_val": 10.0,
"gaussian_noise": false,
"gaussian_noise_mean": 5.0,
"gaussian_noise_stddev": 1.0,
"contrast": false,
"contrast_min_gamma": 0.5,
"contrast_max_gamma": 2.0,
"brightness": false,
"brightness_min_val": 0.0,
"brightness_max_val": 10.0,
"random_crop": false,
"random_crop_height": 256,
"random_crop_width": 256,
"random_flip": false,
"flip_horizontal": true
},
"online_shuffling": true,
"shuffle_buffer_size": 128,
"prefetch": true,
"batch_size": 4,
"batches_per_epoch": null,
"min_batches_per_epoch": 100,
"val_batches_per_epoch": null,
"min_val_batches_per_epoch": 1,
"epochs": 10,
"optimizer": "adam",
"initial_learning_rate": 0.0001,
"learning_rate_schedule": {
"reduce_on_plateau": true,
"reduction_factor": 0.5,
"plateau_min_delta": 1e-06,
"plateau_patience": 5,
"plateau_cooldown": 3,
"min_learning_rate": 1e-08
},
"hard_keypoint_mining": {
"online_mining": false,
"hard_to_easy_ratio": 2.0,
"min_hard_keypoints": 2,
"max_hard_keypoints": null,
"loss_scale": 5.0
},
"early_stopping": {
"stop_training_on_plateau": true,
"plateau_min_delta": 1e-06,
"plateau_patience": 10
}
},
"outputs": {
"save_outputs": true,
"run_name": "minimal_instance.UNet.centered_instance_with_scaling",
"run_name_prefix": "",
"run_name_suffix": null,
"runs_folder": "models",
"tags": [],
"save_visualizations": false,
"keep_viz_images": false,
"zip_outputs": false,
"log_to_csv": true,
"checkpointing": {
"initial_model": false,
"best_model": true,
"every_epoch": false,
"latest_model": false,
"final_model": false
},
"tensorboard": {
"write_logs": false,
"loss_frequency": "epoch",
"architecture_graph": false,
"profile_graph": false,
"visualizations": true
},
"zmq": {
"subscribe_to_controller": false,
"controller_address": "tcp://127.0.0.1:9000",
"controller_polling_timeout": 10,
"publish_updates": false,
"publish_address": "tcp://127.0.0.1:9001"
}
},
"name": "",
"description": "",
"sleap_version": "1.4.1",
"filename": "models\\minimal_instance.UNet.centered_instance_with_scaling\\initial_config.json"
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 53d84f7

Please sign in to comment.