Skip to content

Commit

Permalink
Set the shape correctly for center crop.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 662844694
  • Loading branch information
The kauldron Authors committed Aug 14, 2024
1 parent 2a984fc commit cf84bbc
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions kauldron/data/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,7 @@ def map_element(self, element: TfArray["..."]) -> TfArray["..."]:
)
# resolve dynamic portions (-1) of self.shape
shape = tf.shape(element)
target_shape = tf.constant( # convert None to -1
[-1 if s is None else s for s in self.shape], dtype=tf.int32
)
target_shape = tf.where(target_shape >= 0, target_shape, shape)
target_shape = _get_target_shape(element, self.shape)
# compute the offset for the tf.slice
offset = (shape - target_shape) // 2
crop = tf.slice(element, offset, target_shape)
Expand Down

0 comments on commit cf84bbc

Please sign in to comment.