C2W1 Assignment | Grader Error in split_data & create_model function

Hello Everyone,
I am getting the following error,

Details of failed tests for split_data

Failed test case: There was an error grading this function. Details shown in ‘got’ value below:.
Expected:
no exceptions,
but got:
[Errno 2] No such file or directory: ‘./data/images-zero/cats/’.

Failed test case: There was an error grading this function. Details shown in ‘got’ value below:.
Expected:
no exceptions,
but got:
[Errno 2] No such file or directory: ‘./data/images/’.

My code is working perfectly fine in the notebook and I have even trained the model with 98% training accuracy and 82% validation accuracy but still I am getting no directory error with the grader.
Please Help!

In split_data, are you using function parameters and not global variables or hardcoding paths?

Yes, this is my code:

[code removed - moderator]

Please click my name and message your notebook as an attachment.

The problem is due to os.chdir.

The sideeffect of using the above function call is that the interpreter current working directory is changed from the directory where the notebook execution began. As a result, when the grader invokes split_data function with a relative path like ./data/images/, the context is borrowed from /tmp/cats-v-dogs/validation to get the absolute path to directory.

Please create directories without using os.chdir.