Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GuanglinDu opened this issue Mar 20, 2021 · 1 comment

Comments

@GuanglinDu
Copy link

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
Copy link
Author

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) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant