C3W2A_Assignment Center Cropping

The error is coming from passing directly from this function:

def crop(image, new_shape):

the image input:

you should slice image before feeding it into transform.

A hint to to this: consider using slicing with negative indices to handle both even and odd dimensions more consistently. This can help simplify the calculations for starting and final indices, making the code more concise and less prone to errors related to even/odd dimensions.

1 Like

@Vasili_Reikh, the underlying problem with using CenterCrop() is due to a version mismatch, as mentioned in the first posts on this thread - although back then, the problem was happening in the assignment. Now the assignment works with CenterCrop(), but the grader is still using an older version of python or pytorch. I’ll ping the developers to remind them the grader needs to be updated for this.

In the meantime, instead of using CenterCrop(), you will need to do your own array-slicing to crop the image yourself.

There’s also some discussion of this issue on this thread, if you’re interested:

1 Like