How to remove .ipynb checkpoint

(ecdrid) #21

Get into the correct directory i.e the directory where the .ipynb folder is visible via doing ls and then this should work
rm -f . ipynb_checkpoints/
Should work or do a google search or checkout
man rm

(Harry Coppock) #22

Thank you, will give it a try now!

(Harry Coppock) #23

Would this be done in the paper space code or in the Jupyter notebook?

(ecdrid) #24

You can use both…

(Nicole) #25

Harry did you ever figure this out? I am running into the same problem

(Harry Coppock) #26

Unfortunately not, I can’t work out a way of deleting the check points. Or maybe I am successfully deleting them but they are being automatically generated before I can run the Image classifier code?

I would also like to know why these check points are being created in my image folders. My .ipynb notebook is not in the data path and I can’t find any other reason with a google. I do not get the same problem when running the image classified code for the dogs and cats set though. Maybe this has something to do with the way the folder is set up?

(ecdrid) #27

To remove a directory that contains other files or directories, use the following command. For example, if the directory was named "files", you would type rm -r files at the prompt.

(Harry Coppock) #28

Thank you Aditya that worked!! I have to delete the checkpoints every time I want to re run it but that doesn’t matter.

(Harry Coppock) #29

Have you sorted out the problem now?

(Nicole) #30

I haven’t yet. So you went into the folder that was giving the error, created a notebook and ran rm -r /.ipynb_checkpoints? i was starting to think it has something to do with the file names of my pictures cuz there is a space. im was going to try removing it.

(Nicole) #31

actually i tried this and it worked for me too! but i also can’t re-run without deleting checkpoints each time

(ecdrid) #32

So I had searched a bit and found this works…

Just run this line but at your own risk as your work isn’t saved automatically,you won’t want this anyways

%autosave 0
(Check whether it has a single or double %)

(Harry Coppock) #33

Could some one help me delete these checkpoints which are appearing in my results, as I can’t find which cd they’re in.

I would also greatly appreciate it if anyone has an explanation as to why these checkpoints keep cropping up? (my notebook is not in the data folder)

(Suvro Banerjee) #34

Did anyone figure out the solution? I am facing the same problem. I have tried all these options mentioned in the post. The confusing bit is the data folder and the notebook folder is different and also when I check the fastai function it just picks the name from the PATH = “data/cricketbaseball/”

Putting the function here-


Thanks .

@jeremy - need your help if you have figured this out. Thanks.

(ecdrid) #35

(Harry Coppock) #36

While through doing this I can get the image classified to run, I cannot seem to get rid of the .ipynbcheckpoints in the data folder which contains the results. However, I don’t think it’s a huge issue as it doesn’t affect my results, you just need to alter the code that follows it so that cat is 1 and dog is 2 (rather than 0 and 1). But it would obv be great if we could get this sorted out aha

(ecdrid) #37

Disable autosave should work but it’s risky…

(Harry Coppock) #38

Will give that a go, thanks :smiley:

(Suvro Banerjee) #39

What did not work for me
Sorry to say mate, I tried all the options mentioned in the post but ‘.ipynb_checkpoints’ keeps coming. I did not want to turn off the autosave. So, decided to go and fix the code.

Now, here is the solution
If you see the data is being read from the following line of code-
data = ImageClassifierData.from_paths(PATH, tfms = tfms_from_model(arch, sz))

Inturn ImageClassifierData.from_paths calls ~/fastai/courses/dl1/fastai/ (if you do a shift tab on the function you will get it.) This will inturn call the function from_paths and it’s first line goes as
trn,val = [folder_source(path, o) for o in (trn_name, val_name)]
Here the folder_source(path, o) function calls another function called read_dirs which actually read through the data folders and create an array where we are getting the problems.

So, what I have done is added a line of code in that function. Copying the entire edited function here

def read_dirs(path, folder):
labels, filenames, all_labels = [], [], []
full_path = os.path.join(path, folder)
for label in sorted(os.listdir(full_path)):
    if label not in ('.ipynb_checkpoints'):
        for fname in os.listdir(os.path.join(full_path, label)):
            filenames.append(os.path.join(folder, label, fname))
return filenames, labels, all_labels

What I have added here is if label not in (’.ipynb_checkpoints’):. It solves the problem once and for all.

Now you can make it better if you filter out the hidden files instead of only filtering out the checkpoint file which I have done here, but didn’t want to spend a lot of time here and wanted to move on. I have tested the code as well with different iterations and it works well.

Hope it helps everyone.


(ecdrid) #40

Added it as a PR…