(batch: Batch, cfg: CroppingCfg)
| 109 | |
| 110 | |
| 111 | def crop_and_resize_batch_for_flow(batch: Batch, cfg: CroppingCfg) -> Batch: |
| 112 | # Figure out the image size that's used for flow. |
| 113 | image_shape = get_image_shape(tuple(batch.videos.shape[-2:]), cfg) |
| 114 | flow_shape = tuple(dim * cfg.flow_scale_multiplier for dim in image_shape) |
| 115 | |
| 116 | # Resize the batch to match the desired flow shape. |
| 117 | batch = resize_batch(batch, flow_shape) |
| 118 | |
| 119 | # Center-crop the batch so it's cleanly divisible by the patch size times the flow |
| 120 | # multiplier. This ensures that the aspect ratio matches the model input's aspect |
| 121 | # ratio. |
| 122 | return patch_crop_batch(batch, cfg.patch_size * cfg.flow_scale_multiplier) |
| 123 | |
| 124 | |
| 125 | def resize_to_cover( |
no test coverage detected