Keras ImageDataGenerator.flow_from_dataframe keeps on loading












0















I'm working on the MURA dataset by Stanford. I'm trying to load the dataset using Keras's ImageDataGenerator. The data is in the following hierarchy:



The directory hierarchy



The study1_positive folder contains the images.



ImageDataGenerator.flow_from_directory cannot be used with this folder structure, therefore I tried using the flow_from_dataframe method.



However, when run, the code keeps on executing and doesn't stop.



Following is the format of the Pandas DataFrame that I'm passing to the flow_from_directory method:



The DataFrame passed to flow_from_dataframe



I've also tried changing the labels to 'abnormal' and 'normal' in place of 1 and 0, respectively.



EDIT:



I've pasted the code below:



train_imggen = ImageDataGenerator(rescale=1./255, rotation_range=30,
horizontal_flip=True)

train_loader = train_imggen.flow_from_dataframe(traindf, '.', shuffle=True,
x_col='path', y_col='label',
color_mode='grayscale',
target_size=(320,320),
class_mode='binary',
batch_size=8)









share|improve this question

























  • Without code there is no way to help you. Please add it.

    – Matias Valdenegro
    Nov 20 '18 at 9:57











  • @MatiasValdenegro apologies! I've now added the generator code.

    – UserAnon
    Nov 20 '18 at 12:26
















0















I'm working on the MURA dataset by Stanford. I'm trying to load the dataset using Keras's ImageDataGenerator. The data is in the following hierarchy:



The directory hierarchy



The study1_positive folder contains the images.



ImageDataGenerator.flow_from_directory cannot be used with this folder structure, therefore I tried using the flow_from_dataframe method.



However, when run, the code keeps on executing and doesn't stop.



Following is the format of the Pandas DataFrame that I'm passing to the flow_from_directory method:



The DataFrame passed to flow_from_dataframe



I've also tried changing the labels to 'abnormal' and 'normal' in place of 1 and 0, respectively.



EDIT:



I've pasted the code below:



train_imggen = ImageDataGenerator(rescale=1./255, rotation_range=30,
horizontal_flip=True)

train_loader = train_imggen.flow_from_dataframe(traindf, '.', shuffle=True,
x_col='path', y_col='label',
color_mode='grayscale',
target_size=(320,320),
class_mode='binary',
batch_size=8)









share|improve this question

























  • Without code there is no way to help you. Please add it.

    – Matias Valdenegro
    Nov 20 '18 at 9:57











  • @MatiasValdenegro apologies! I've now added the generator code.

    – UserAnon
    Nov 20 '18 at 12:26














0












0








0








I'm working on the MURA dataset by Stanford. I'm trying to load the dataset using Keras's ImageDataGenerator. The data is in the following hierarchy:



The directory hierarchy



The study1_positive folder contains the images.



ImageDataGenerator.flow_from_directory cannot be used with this folder structure, therefore I tried using the flow_from_dataframe method.



However, when run, the code keeps on executing and doesn't stop.



Following is the format of the Pandas DataFrame that I'm passing to the flow_from_directory method:



The DataFrame passed to flow_from_dataframe



I've also tried changing the labels to 'abnormal' and 'normal' in place of 1 and 0, respectively.



EDIT:



I've pasted the code below:



train_imggen = ImageDataGenerator(rescale=1./255, rotation_range=30,
horizontal_flip=True)

train_loader = train_imggen.flow_from_dataframe(traindf, '.', shuffle=True,
x_col='path', y_col='label',
color_mode='grayscale',
target_size=(320,320),
class_mode='binary',
batch_size=8)









share|improve this question
















I'm working on the MURA dataset by Stanford. I'm trying to load the dataset using Keras's ImageDataGenerator. The data is in the following hierarchy:



The directory hierarchy



The study1_positive folder contains the images.



ImageDataGenerator.flow_from_directory cannot be used with this folder structure, therefore I tried using the flow_from_dataframe method.



However, when run, the code keeps on executing and doesn't stop.



Following is the format of the Pandas DataFrame that I'm passing to the flow_from_directory method:



The DataFrame passed to flow_from_dataframe



I've also tried changing the labels to 'abnormal' and 'normal' in place of 1 and 0, respectively.



EDIT:



I've pasted the code below:



train_imggen = ImageDataGenerator(rescale=1./255, rotation_range=30,
horizontal_flip=True)

train_loader = train_imggen.flow_from_dataframe(traindf, '.', shuffle=True,
x_col='path', y_col='label',
color_mode='grayscale',
target_size=(320,320),
class_mode='binary',
batch_size=8)






python python-3.x keras dataset






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 12:23







UserAnon

















asked Nov 20 '18 at 8:59









UserAnonUserAnon

114




114













  • Without code there is no way to help you. Please add it.

    – Matias Valdenegro
    Nov 20 '18 at 9:57











  • @MatiasValdenegro apologies! I've now added the generator code.

    – UserAnon
    Nov 20 '18 at 12:26



















  • Without code there is no way to help you. Please add it.

    – Matias Valdenegro
    Nov 20 '18 at 9:57











  • @MatiasValdenegro apologies! I've now added the generator code.

    – UserAnon
    Nov 20 '18 at 12:26

















Without code there is no way to help you. Please add it.

– Matias Valdenegro
Nov 20 '18 at 9:57





Without code there is no way to help you. Please add it.

– Matias Valdenegro
Nov 20 '18 at 9:57













@MatiasValdenegro apologies! I've now added the generator code.

– UserAnon
Nov 20 '18 at 12:26





@MatiasValdenegro apologies! I've now added the generator code.

– UserAnon
Nov 20 '18 at 12:26












2 Answers
2






active

oldest

votes


















0














Found the solution here. Apparently, the current flow_from_dataframe doesn't handle relative paths.





  1. Clone my "fix_found_0_images" branch. git clone -b fix_found_0_images_bug
    https://github.com/smurak/keras-preprocessing.git


  2. Move the "keras_preprocessing" subdirectory to your working directory.

  3. Import it.




import keras
from keras_preprocessing import image
...
train_imggen = image.ImageDataGenerator(...)





share|improve this answer































    0














    I am actually working on exact same dataset and having huge troubles... I'm now getting it to run, but it claims that "Found 0 images belonging to 2 classes."



    Did you face the same problem?






    share|improve this answer
























    • Please refer to the accepted answer I posted. I was able to fix it with the mentioned steps.

      – UserAnon
      Nov 23 '18 at 5:32











    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%2f53389416%2fkeras-imagedatagenerator-flow-from-dataframe-keeps-on-loading%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Found the solution here. Apparently, the current flow_from_dataframe doesn't handle relative paths.





    1. Clone my "fix_found_0_images" branch. git clone -b fix_found_0_images_bug
      https://github.com/smurak/keras-preprocessing.git


    2. Move the "keras_preprocessing" subdirectory to your working directory.

    3. Import it.




    import keras
    from keras_preprocessing import image
    ...
    train_imggen = image.ImageDataGenerator(...)





    share|improve this answer




























      0














      Found the solution here. Apparently, the current flow_from_dataframe doesn't handle relative paths.





      1. Clone my "fix_found_0_images" branch. git clone -b fix_found_0_images_bug
        https://github.com/smurak/keras-preprocessing.git


      2. Move the "keras_preprocessing" subdirectory to your working directory.

      3. Import it.




      import keras
      from keras_preprocessing import image
      ...
      train_imggen = image.ImageDataGenerator(...)





      share|improve this answer


























        0












        0








        0







        Found the solution here. Apparently, the current flow_from_dataframe doesn't handle relative paths.





        1. Clone my "fix_found_0_images" branch. git clone -b fix_found_0_images_bug
          https://github.com/smurak/keras-preprocessing.git


        2. Move the "keras_preprocessing" subdirectory to your working directory.

        3. Import it.




        import keras
        from keras_preprocessing import image
        ...
        train_imggen = image.ImageDataGenerator(...)





        share|improve this answer













        Found the solution here. Apparently, the current flow_from_dataframe doesn't handle relative paths.





        1. Clone my "fix_found_0_images" branch. git clone -b fix_found_0_images_bug
          https://github.com/smurak/keras-preprocessing.git


        2. Move the "keras_preprocessing" subdirectory to your working directory.

        3. Import it.




        import keras
        from keras_preprocessing import image
        ...
        train_imggen = image.ImageDataGenerator(...)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 7:26









        UserAnonUserAnon

        114




        114

























            0














            I am actually working on exact same dataset and having huge troubles... I'm now getting it to run, but it claims that "Found 0 images belonging to 2 classes."



            Did you face the same problem?






            share|improve this answer
























            • Please refer to the accepted answer I posted. I was able to fix it with the mentioned steps.

              – UserAnon
              Nov 23 '18 at 5:32
















            0














            I am actually working on exact same dataset and having huge troubles... I'm now getting it to run, but it claims that "Found 0 images belonging to 2 classes."



            Did you face the same problem?






            share|improve this answer
























            • Please refer to the accepted answer I posted. I was able to fix it with the mentioned steps.

              – UserAnon
              Nov 23 '18 at 5:32














            0












            0








            0







            I am actually working on exact same dataset and having huge troubles... I'm now getting it to run, but it claims that "Found 0 images belonging to 2 classes."



            Did you face the same problem?






            share|improve this answer













            I am actually working on exact same dataset and having huge troubles... I'm now getting it to run, but it claims that "Found 0 images belonging to 2 classes."



            Did you face the same problem?







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 23 '18 at 0:00









            AvocadoAvocado

            104




            104













            • Please refer to the accepted answer I posted. I was able to fix it with the mentioned steps.

              – UserAnon
              Nov 23 '18 at 5:32



















            • Please refer to the accepted answer I posted. I was able to fix it with the mentioned steps.

              – UserAnon
              Nov 23 '18 at 5:32

















            Please refer to the accepted answer I posted. I was able to fix it with the mentioned steps.

            – UserAnon
            Nov 23 '18 at 5:32





            Please refer to the accepted answer I posted. I was able to fix it with the mentioned steps.

            – UserAnon
            Nov 23 '18 at 5:32


















            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%2f53389416%2fkeras-imagedatagenerator-flow-from-dataframe-keeps-on-loading%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

            MongoDB - Not Authorized To Execute Command

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

            Npm cannot find a required file even through it is in the searched directory