Search code examples
pythonjupyter-notebookconv-neural-networkkaggle

How can I upload a file from my local machine to a Jupyter notebook on Kaggle and run it there?


I am trying to install a library on Kaggle runtime, but I get an error that says "metadata-generation-failed". What does this error mean and how can I fix it?

Here is the code that I used to install the library on google colab (Worked fine):

!pip install google-colab 

from google.colab import files

    
uploaded = files.upload()
 
for fn in uploaded.keys():
    new_path = fn
    img = image.load_img(new_path, target_size=(250, 250))

    img_plot = plt.imshow(img)
    x = image.img_to_array(img)
    x = np.expand_dims(x, axis=0)
    images = np.vstack([x])
    predict_class = model.predict(images, batch_size=4)
    predict_class = np.argmax(predict_class)
    print(classes[predict_class])

Solution

  • #This should work
    
    !pip install kaggle
    
    from google.colab import files
    files.upload() #run this and upload your key
    
    !mkdir -p ~/.kaggle
    !cp kaggle.json ~/.kaggle/
    !chmod 600 ~/.kaggle/kaggle.json
    
    !kaggle datasets download -d [author_name]/[dataset_name]
    !unzip [dataset_name].zip
    
    path = "/content/[file_name]"