Google Colab can't access drive content












0















Even though I defined my Google Drive(and my dataset in it) to google colab but when I run my code I give this error:FileNotFoundError: [Errno 2] No such file or directory: 'content/drive/My Drive/....



I already defined google drive in google colab and I can access to it through google colab but when I run my code I give this error



from keras.models import Sequential
from keras.layers import Convolution2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from keras.layers import Dense
model=Sequential()
model.add(Convolution2D(32,3,3,input_shape=(64,64,3),activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Convolution2D(32,3,3,activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Flatten())
model.add(Dense(output_dim=128,activation='relu'))
model.add(Dense(output_dim=1,activation='sigmoid'))
model.compile(optimizer='adam',loss='binary_crossentropy',metrics=['accuracy'])

from keras.preprocessing.image import ImageDataGenerator
train_datagen=ImageDataGenerator(
rescale=1./255,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True)
test_datagen=ImageDataGenerator(rescale=1./255)

training_set=train_datagen.flow_from_directory(
directory='content/drive/My Drive/Convolutional_Neural_Networks/dataset/training_set',
target_size=(64,64),
batch_size=32,
class_mode='binary')
test_set=test_datagen.flow_from_directory(
directory='content/drive/My Drive/Convolutional_Neural_Networks/dataset/test_set',
target_size=(64,64),
batch_size=32,
class_mode='binary')

#train
model.fit_generator(
training_set,
samples_per_epoch=8000,
nb_epoch=2,
validation_data=test_set,
nb_val_samples=1000)

import numpy as np
from keras.preprocessing import image
test_image=image.load_img('sunn.jpg',target_size=(64,64))
test_image=image.img_to_array(test_image)
test_image=np.expand_dims(test_image,axis=0)
result=model.predict(test_image)
training_set.class_indices
if result[0][0] >= 0.5:
prediction='dog'
else:
prediction='cat'
print(prediction)









share|improve this question



























    0















    Even though I defined my Google Drive(and my dataset in it) to google colab but when I run my code I give this error:FileNotFoundError: [Errno 2] No such file or directory: 'content/drive/My Drive/....



    I already defined google drive in google colab and I can access to it through google colab but when I run my code I give this error



    from keras.models import Sequential
    from keras.layers import Convolution2D
    from keras.layers import MaxPooling2D
    from keras.layers import Flatten
    from keras.layers import Dense
    model=Sequential()
    model.add(Convolution2D(32,3,3,input_shape=(64,64,3),activation='relu'))
    model.add(MaxPooling2D(pool_size=(2,2)))
    model.add(Convolution2D(32,3,3,activation='relu'))
    model.add(MaxPooling2D(pool_size=(2,2)))
    model.add(Flatten())
    model.add(Dense(output_dim=128,activation='relu'))
    model.add(Dense(output_dim=1,activation='sigmoid'))
    model.compile(optimizer='adam',loss='binary_crossentropy',metrics=['accuracy'])

    from keras.preprocessing.image import ImageDataGenerator
    train_datagen=ImageDataGenerator(
    rescale=1./255,
    shear_range=0.2,
    zoom_range=0.2,
    horizontal_flip=True)
    test_datagen=ImageDataGenerator(rescale=1./255)

    training_set=train_datagen.flow_from_directory(
    directory='content/drive/My Drive/Convolutional_Neural_Networks/dataset/training_set',
    target_size=(64,64),
    batch_size=32,
    class_mode='binary')
    test_set=test_datagen.flow_from_directory(
    directory='content/drive/My Drive/Convolutional_Neural_Networks/dataset/test_set',
    target_size=(64,64),
    batch_size=32,
    class_mode='binary')

    #train
    model.fit_generator(
    training_set,
    samples_per_epoch=8000,
    nb_epoch=2,
    validation_data=test_set,
    nb_val_samples=1000)

    import numpy as np
    from keras.preprocessing import image
    test_image=image.load_img('sunn.jpg',target_size=(64,64))
    test_image=image.img_to_array(test_image)
    test_image=np.expand_dims(test_image,axis=0)
    result=model.predict(test_image)
    training_set.class_indices
    if result[0][0] >= 0.5:
    prediction='dog'
    else:
    prediction='cat'
    print(prediction)









    share|improve this question

























      0












      0








      0








      Even though I defined my Google Drive(and my dataset in it) to google colab but when I run my code I give this error:FileNotFoundError: [Errno 2] No such file or directory: 'content/drive/My Drive/....



      I already defined google drive in google colab and I can access to it through google colab but when I run my code I give this error



      from keras.models import Sequential
      from keras.layers import Convolution2D
      from keras.layers import MaxPooling2D
      from keras.layers import Flatten
      from keras.layers import Dense
      model=Sequential()
      model.add(Convolution2D(32,3,3,input_shape=(64,64,3),activation='relu'))
      model.add(MaxPooling2D(pool_size=(2,2)))
      model.add(Convolution2D(32,3,3,activation='relu'))
      model.add(MaxPooling2D(pool_size=(2,2)))
      model.add(Flatten())
      model.add(Dense(output_dim=128,activation='relu'))
      model.add(Dense(output_dim=1,activation='sigmoid'))
      model.compile(optimizer='adam',loss='binary_crossentropy',metrics=['accuracy'])

      from keras.preprocessing.image import ImageDataGenerator
      train_datagen=ImageDataGenerator(
      rescale=1./255,
      shear_range=0.2,
      zoom_range=0.2,
      horizontal_flip=True)
      test_datagen=ImageDataGenerator(rescale=1./255)

      training_set=train_datagen.flow_from_directory(
      directory='content/drive/My Drive/Convolutional_Neural_Networks/dataset/training_set',
      target_size=(64,64),
      batch_size=32,
      class_mode='binary')
      test_set=test_datagen.flow_from_directory(
      directory='content/drive/My Drive/Convolutional_Neural_Networks/dataset/test_set',
      target_size=(64,64),
      batch_size=32,
      class_mode='binary')

      #train
      model.fit_generator(
      training_set,
      samples_per_epoch=8000,
      nb_epoch=2,
      validation_data=test_set,
      nb_val_samples=1000)

      import numpy as np
      from keras.preprocessing import image
      test_image=image.load_img('sunn.jpg',target_size=(64,64))
      test_image=image.img_to_array(test_image)
      test_image=np.expand_dims(test_image,axis=0)
      result=model.predict(test_image)
      training_set.class_indices
      if result[0][0] >= 0.5:
      prediction='dog'
      else:
      prediction='cat'
      print(prediction)









      share|improve this question














      Even though I defined my Google Drive(and my dataset in it) to google colab but when I run my code I give this error:FileNotFoundError: [Errno 2] No such file or directory: 'content/drive/My Drive/....



      I already defined google drive in google colab and I can access to it through google colab but when I run my code I give this error



      from keras.models import Sequential
      from keras.layers import Convolution2D
      from keras.layers import MaxPooling2D
      from keras.layers import Flatten
      from keras.layers import Dense
      model=Sequential()
      model.add(Convolution2D(32,3,3,input_shape=(64,64,3),activation='relu'))
      model.add(MaxPooling2D(pool_size=(2,2)))
      model.add(Convolution2D(32,3,3,activation='relu'))
      model.add(MaxPooling2D(pool_size=(2,2)))
      model.add(Flatten())
      model.add(Dense(output_dim=128,activation='relu'))
      model.add(Dense(output_dim=1,activation='sigmoid'))
      model.compile(optimizer='adam',loss='binary_crossentropy',metrics=['accuracy'])

      from keras.preprocessing.image import ImageDataGenerator
      train_datagen=ImageDataGenerator(
      rescale=1./255,
      shear_range=0.2,
      zoom_range=0.2,
      horizontal_flip=True)
      test_datagen=ImageDataGenerator(rescale=1./255)

      training_set=train_datagen.flow_from_directory(
      directory='content/drive/My Drive/Convolutional_Neural_Networks/dataset/training_set',
      target_size=(64,64),
      batch_size=32,
      class_mode='binary')
      test_set=test_datagen.flow_from_directory(
      directory='content/drive/My Drive/Convolutional_Neural_Networks/dataset/test_set',
      target_size=(64,64),
      batch_size=32,
      class_mode='binary')

      #train
      model.fit_generator(
      training_set,
      samples_per_epoch=8000,
      nb_epoch=2,
      validation_data=test_set,
      nb_val_samples=1000)

      import numpy as np
      from keras.preprocessing import image
      test_image=image.load_img('sunn.jpg',target_size=(64,64))
      test_image=image.img_to_array(test_image)
      test_image=np.expand_dims(test_image,axis=0)
      result=model.predict(test_image)
      training_set.class_indices
      if result[0][0] >= 0.5:
      prediction='dog'
      else:
      prediction='cat'
      print(prediction)






      keras deep-learning conv-neural-network google-colaboratory






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 19 at 16:24









      armin arianaarmin ariana

      83




      83
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I think you are missing a leading / in your /content/drive... path.



          It's typical to mount you Drive files via



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


          https://colab.research.google.com/notebooks/io.ipynb#scrollTo=u22w3BFiOveA






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54269091%2fgoogle-colab-cant-access-drive-content%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I think you are missing a leading / in your /content/drive... path.



            It's typical to mount you Drive files via



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


            https://colab.research.google.com/notebooks/io.ipynb#scrollTo=u22w3BFiOveA






            share|improve this answer




























              0














              I think you are missing a leading / in your /content/drive... path.



              It's typical to mount you Drive files via



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


              https://colab.research.google.com/notebooks/io.ipynb#scrollTo=u22w3BFiOveA






              share|improve this answer


























                0












                0








                0







                I think you are missing a leading / in your /content/drive... path.



                It's typical to mount you Drive files via



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


                https://colab.research.google.com/notebooks/io.ipynb#scrollTo=u22w3BFiOveA






                share|improve this answer













                I think you are missing a leading / in your /content/drive... path.



                It's typical to mount you Drive files via



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


                https://colab.research.google.com/notebooks/io.ipynb#scrollTo=u22w3BFiOveA







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 19 at 16:55









                Bob SmithBob Smith

                6,96732130




                6,96732130






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54269091%2fgoogle-colab-cant-access-drive-content%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Liquibase includeAll doesn't find base path

                    How to use setInterval in EJS file?

                    Petrus Granier-Deferre