Skip to content

Commit

Permalink
Fix a bug in resizing in Kubric point tracking data augmentation. (#325)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 636189132
  • Loading branch information
cdoersch authored May 22, 2024
1 parent 7a5a2b9 commit 7fa640a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions challenges/point_tracking/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,15 +921,14 @@ def add_tracks(data,

# Crop the video to the sampled window, in a way which matches the coordinate
# frame produced the track_points functions.
crop_window = crop_window / (
np.array(shp[1:3] + shp[1:3]).astype(np.float32) - 1)
crop_window = tf.tile(crop_window[tf.newaxis, :], [num_frames, 1])
video = tf.image.crop_and_resize(
video,
tf.cast(crop_window, tf.float32),
tf.range(num_frames),
train_size,
start = tf.tensor_scatter_nd_update(
[0, 0, 0, 0], [[1], [2]], crop_window[0:2]
)
size = tf.tensor_scatter_nd_update(
tf.shape(video), [[1], [2]], crop_window[2:4] - crop_window[0:2]
)
video = tf.slice(video, start, size)
video = tf.image.resize(tf.cast(video, tf.float32), train_size)
if vflip:
video = video[:, ::-1, :, :]
target_points = target_points * np.array([1, -1])
Expand Down

0 comments on commit 7fa640a

Please sign in to comment.