io19 icon indicating copy to clipboard operation
io19 copied to clipboard

Package google-colab 1.0.0 is incompatible with the current Jupyter Lab

Open GuanglinDu opened this issue 4 years ago • 1 comments

Dear Laurence, thanks for your fantastic io19 talk & code on ML with the Rock-Paper-Scissors demo. It seems that package google-colab 1.0.0 can only run on Google Colab (an old version of Jupyter notebook?). It's incompatible with the current Jupyter Lab and cannot be installed with pip:

jupyter core : 4.7.1 jupyter-notebook : 6.2.0 qtconsole : not installed ipython : 7.21.0 ipykernel : 5.5.0 jupyter client : 6.1.12 jupyter lab : 3.0.12 nbconvert : 6.0.7 ipywidgets : not installed nbformat : 5.1.2 traitlets : 5.0.5

Is there any alternative package or workaround? Thanks.

GuanglinDu avatar Mar 20 '21 14:03 GuanglinDu

Here's is my solution to a standalone Jupyter Lab server (create dir "/tmp/rps-prediction"):

Predict new RPS images downloaded from the Internet

import numpy as np

from google.colab import files # 1.0.0 incompatible with Jupyter Lab

from keras.preprocessing import image

#uploaded = files.upload()

#for fn in uploaded.keys(): rps_prediction_dir = "/tmp/rps-prediction" #files = os.listdir(rps_prediction_files_dir)

for root, dirs, files in os.walk(os.path.abspath(rps_prediction_dir)): for file in files: fn = os.path.join(root, file) # abs file name

    # predicting images
    path = fn
    img = image.load_img(path, target_size=(150, 150))
    x = image.img_to_array(img)
    x = np.expand_dims(x, axis=0)

    images = np.vstack([x])
    classes = model.predict(images, batch_size=10)
    print(fn)
    print(classes) 

GuanglinDu avatar Mar 21 '21 14:03 GuanglinDu