How can I find a solution for the "FileNotFoundError" : <p>I'm currently working on an image classifier project. During the testing of the predict function, I receive the error: FileNotFoundError: [Errno 2] No such file or directory: 'flowers/test/1/image_06760'</p>

<p>the path of the file is correct.
You can find the whole notebook here: 
<a href="https://github.com/MartinTschendel/image-classifier-1/blob/master/190829-0510-Image%20Classifier%20Project.ipynb" rel="nofollow noreferrer">https://github.com/MartinTschendel/image-classifier-1/blob/master/190829-0510-Image%20Classifier%20Project.ipynb</a></p>

<p>Here is the respective predict function and the test of this function:</p>

<pre><code>def predict(image_path, model, topk=5):
    ''' Predict the class (or classes) of an image using a trained deep learning model.
    '''

    #loading model
    loaded_model = load_checkpoint(model)

    # implement the code to predict the class from an image file
    img = Image.open(image_name)
    img = process_image(img)

    # convert 2D image to 1D vector
    img = np.expand_dims(img, 0)

    img = torch.from_numpy(img)

    #set model to evaluation mode and turn off gradients
    loaded_model.eval()
    with torch.no_grad():
        #run image through network
        output = loaded_model.forward(img)

    #calculate probabilities
    probs = torch.exp(output)
    probs_top = probs.topk(topk)[0]
    index_top = probs.topk(topk)[1]

    # Convert probabilities and outputs to lists
    probs_top_list = np.array(probs_top)[0]
    index_top_list = np.array(index_top[0])

    #load index and class mapping
    loaded_model.class_to_idx = train_data.class_to_idx
    #invert index-class dictionary
    idx_to_class = {x: y for y, x in class_to_idx.items()}

    #convert index list to class list
    classes_top_list = []
    for index in index_top_list:
        classes_top_list += [idx_to_class[index]]

    return probs_top_list, classes_top_list
</code></pre>

<pre><code># test predict function

# inputs equal paths to saved model and test image
model_path = '190824_checkpoint.pth'
image_name = data_dir + '/test' + '/1/' + 'image_06760'

probs, classes = predict(image_name, model_path, topk=5)

print(probs)
print(classes)
</code></pre>

<p>This is the error I receive: </p>

<pre><code>FileNotFoundError: [Errno 2] No such file or directory: 'flowers/test/1/image_06760'
</code></pre>
