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

03_Conv_NN_in_TF Exercise 3 How read and save images into notebook #533

Open
PatrickRooney opened this issue Mar 31, 2023 · 1 comment
Open

Comments

@PatrickRooney
Copy link

I'm working on Exercise 3 from 03_Conv_NN_in_TF: Take 10 photos of two different things and build your own CNN image classifier using the techniques we've built here.

I have 20 images saved in my Google drive folders (train/mugs, train/books, test/mugs, test/books) with which to build a Conv_NN classifier (see the screenshot below for the train/mugs files).

How do I read these files into my colab notebook?

I tried

!wget https://drive.google.com/drive/u/0/folders/1QLadgsowxtVp0UUWrpL3Z3cSwRsoxe8K

and it appears to read something in but

!ls 1QLadgsowxtVp0UUWrpL3Z3cSwRsoxe8K

didn't produce the expect 8 filenames but only displayed

1QLadgsowxtVp0UUWrpL3Z3cSwRsoxe8K

I don't like not seeing the folder names as I assigned them in Google drive (train/mugs). Is there any way around that?

Here's what Google drive shows for my train/mugs folder:

Screenshot from 2023-03-31 10-48-02

Thank you in advance for any code or help you can give me on how to read in these image files!

@PatrickRooney
Copy link
Author

PatrickRooney commented Mar 31, 2023

This method seems to work:

from google.colab import drive
drive.mount('/content/gdrive')

Specify a path variable (project path)

train_mugs = '/content/gdrive/MyDrive/images_CNN_jpg/train/mugs/'
train_books = '/content/gdrive/MyDrive/images_CNN_jpg/train/books/'

test_mugs = '/content/gdrive/MyDrive/images_CNN_jpg/test/mugs/'
test_books = '/content/gdrive/MyDrive/images_CNN_jpg/test/books/'

import os
os.listdir(test_mugs)

['IMG_1914.HEIC.jpg', 'IMG_1918.HEIC.jpg']

Thanks to Adam Nelson's post https://levelup.gitconnected.com/how-to-get-data-from-gdrive-into-google-colab-b0a807c01300

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