MCPcopy Create free account
hub / github.com/dcharatan/flowmap / crop_and_resize_batch_for_flow

Function crop_and_resize_batch_for_flow

flowmap/misc/cropping.py:111–122  ·  view source on GitHub ↗
(batch: Batch, cfg: CroppingCfg)

Source from the content-addressed store, hash-verified

109
110
111def 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
125def resize_to_cover(

Callers 2

overfitFunction · 0.85
preprocess_batchMethod · 0.85

Calls 3

get_image_shapeFunction · 0.85
resize_batchFunction · 0.85
patch_crop_batchFunction · 0.85

Tested by

no test coverage detected