C3W2A_autograder_can't compile code

I get an autograder error: Cell #5. Can’t compile the student’s code. Error: TypeError(“‘builtin_function_or_method’ object is not iterable”,) but my code runs correctly and all unit tests are successful. I’m not even sure what cell the error refers to

1 Like

Hi Mat!
Welcome to the community :wave:

Did you add any additional cells and didn’t delete them before submitting them, or didn’t you modify anything that is not supposed to be modified by the users? I’m asking this because you are saying that all your unit test cases pass, so TypeError would have been identified there itself if there was some problem with your editable portion. If not share your notebook with me through a private message, I will check and will let you know.

Regards,
Nithin

1 Like

I am getting the same error but all the tests pass. I also had all my cells deleted

July 11, 2023 10:02 AM PDTSubmitted at: Jul 11, 10:02 AM PDT

0/100

Score: 0 of 100

NoAssignment not passed

Exercise 2A

Filename: Exercise 2A

0/100Score: 0 of 100

Hide grader output

Grader output

Cell #5. Can’t compile the student’s code. Error: TypeError(“img should be PIL Image. Got <class ‘torch.Tensor’>”,)

1 Like

There is definitely some issue going on outside of what is being seen on the notebook side; I am hitting the error in the same cell as Roman, but all of my unit tests pass as well. I am sharing the notebook in a PM.

I guess I got the same problem, but finally I noticed that if I changed my C2 (“crop”) function, it works. First I directly use the transforms.CenterCrop function and everything works well on my side, just can noy pass the grader… Then I implement this part myself (calculate the w, h), and this time it works…
I am not sure why, as the notbook import transforms and the beginning, so I was thinking this should work…

1 Like

Yes, then that’s the problem. This is due to a version mismatch with the grader, in the case of Greg, he is using transform.functional.crop() and the thing with this and the CenterCrop function is that in the earlier versions the return type is “PIL Image” but in the higher versions the return type is “PIL Image or Tensors”. Our notebooks use a higher version of Torchvision and hence we don’t see any errors there but the grader might be using an earlier version of Torchvision, which leads to this issue.
This is being persistent now (in the recent past) as many are facing this issue and I have also informed the team. So mostly it will get rectified soon.

Till then it is recommended to do the cropping by array slicing rather than using different functions.

Regards,
Nithin

1 Like

@ [Nithin_Skantha_M],
Thank you.
I had the same issue. Array slicing solved it.

2 Likes

Glad that it helped you.

1 Like

I got the same compilation error. Array indexing would require finding the centre of the height and width for the old image, I guess, and restricting this to half the height/width of the resize shape in indices. Then you’d have to slice for these dimensions. Can anyone advise on a parsimonious way to write this that outputs in the correct format?

I have tried to use array slicing with limited luck. I passed cell 5, but cell 7 failed due to a rounding error.

RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 99 but got size 98 for tensor number 1 in the list.

This cell passed before, when using CentreCrop.

Mark

1 Like

I have got it working now. The slicing differs slightly dependent on whether the slicing dimensions are of odd or even magnitude.

1 Like

FYI, this issue is still not solved!

@Community-Team, is there someone assigned as technical lead for this course (GANS) who can look into this?

I wasn’t able to find the GANS course in the list of LTs.

I’m not a mentor for this course, so I can’t submit an issue for it.

There is an issue submitted by @Nithin_Skantha_M back in May of 2023. I’ll ping the developer it’s assigned to. I suspect it fell of their radar.

1 Like

Thanks @tmosh. I will find an LT to help.

1 Like

Looping @lucas.coutinho who is the assigned LT for GANs.

Hi all!

I could reproduce the error locally. The suggested solution is actually manually cropping as @Nithin_Skantha_M mentioned. However, I do agree that using another function that provides the same result should not be a problem.

Since this assignment wasn’t done by me, the grader it uses is quite old and the actual developer who did the job is unavailable right now, it will take some time for me to properly fix it.

In the meantime I will add a note in the assignment asking learners to not use the CenterCrop function for now.

I will update here as soon as the update is finished.

Thanks,
Lucas

2 Likes