Preparing images to feed into tensorflow as datasets











up vote
0
down vote

favorite












AskTensorFlow



I have used the tensorflow packaged datasets like MNIST, IMDB to study the working of tensorflow. However, in practical applications we have to preprocess and prepare the dataset on our own. Suppose I am working with image dataset, so I want to preprocess them to a format that can be fed into a tensorflow model. How can I preprocess image dataset to a tensorflow format?










share|improve this question


























    up vote
    0
    down vote

    favorite












    AskTensorFlow



    I have used the tensorflow packaged datasets like MNIST, IMDB to study the working of tensorflow. However, in practical applications we have to preprocess and prepare the dataset on our own. Suppose I am working with image dataset, so I want to preprocess them to a format that can be fed into a tensorflow model. How can I preprocess image dataset to a tensorflow format?










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      AskTensorFlow



      I have used the tensorflow packaged datasets like MNIST, IMDB to study the working of tensorflow. However, in practical applications we have to preprocess and prepare the dataset on our own. Suppose I am working with image dataset, so I want to preprocess them to a format that can be fed into a tensorflow model. How can I preprocess image dataset to a tensorflow format?










      share|improve this question













      AskTensorFlow



      I have used the tensorflow packaged datasets like MNIST, IMDB to study the working of tensorflow. However, in practical applications we have to preprocess and prepare the dataset on our own. Suppose I am working with image dataset, so I want to preprocess them to a format that can be fed into a tensorflow model. How can I preprocess image dataset to a tensorflow format?







      tensorflow keras conv-neural-network tensorflow-datasets






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked yesterday









      Anand Nautiyal

      306




      306
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          When working with images, you will usually use a generator.

          Generator is a function which output (u,v), where u are the samples, and v are the labels.



          Example on how to do this can be found here How to train TensorFlow network using a generator to produce inputs?.



          When building the generator function to deal with image, remember that every image is just an array, of either (x,y) for greyscale, or (x,y,channels) for color image.

          Thus your generator function will need to read a batch of images from the disk, and turn them into arrays. there are plenty of tools to handle this: opencv , scipy, PIL.

          After loading the images you can do any manipulations you like on them (using these tools, or others), usualy you will need to reshape the image to fit your model.

          In the end you will need to output a pair ([batch_size,x,y,channels], [batch_size,labels]).






          share|improve this answer





















          • I will try this out and let you know how it turned out. Thanks
            – Anand Nautiyal
            yesterday











          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',
          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%2f53349245%2fpreparing-images-to-feed-into-tensorflow-as-datasets%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








          up vote
          0
          down vote













          When working with images, you will usually use a generator.

          Generator is a function which output (u,v), where u are the samples, and v are the labels.



          Example on how to do this can be found here How to train TensorFlow network using a generator to produce inputs?.



          When building the generator function to deal with image, remember that every image is just an array, of either (x,y) for greyscale, or (x,y,channels) for color image.

          Thus your generator function will need to read a batch of images from the disk, and turn them into arrays. there are plenty of tools to handle this: opencv , scipy, PIL.

          After loading the images you can do any manipulations you like on them (using these tools, or others), usualy you will need to reshape the image to fit your model.

          In the end you will need to output a pair ([batch_size,x,y,channels], [batch_size,labels]).






          share|improve this answer





















          • I will try this out and let you know how it turned out. Thanks
            – Anand Nautiyal
            yesterday















          up vote
          0
          down vote













          When working with images, you will usually use a generator.

          Generator is a function which output (u,v), where u are the samples, and v are the labels.



          Example on how to do this can be found here How to train TensorFlow network using a generator to produce inputs?.



          When building the generator function to deal with image, remember that every image is just an array, of either (x,y) for greyscale, or (x,y,channels) for color image.

          Thus your generator function will need to read a batch of images from the disk, and turn them into arrays. there are plenty of tools to handle this: opencv , scipy, PIL.

          After loading the images you can do any manipulations you like on them (using these tools, or others), usualy you will need to reshape the image to fit your model.

          In the end you will need to output a pair ([batch_size,x,y,channels], [batch_size,labels]).






          share|improve this answer





















          • I will try this out and let you know how it turned out. Thanks
            – Anand Nautiyal
            yesterday













          up vote
          0
          down vote










          up vote
          0
          down vote









          When working with images, you will usually use a generator.

          Generator is a function which output (u,v), where u are the samples, and v are the labels.



          Example on how to do this can be found here How to train TensorFlow network using a generator to produce inputs?.



          When building the generator function to deal with image, remember that every image is just an array, of either (x,y) for greyscale, or (x,y,channels) for color image.

          Thus your generator function will need to read a batch of images from the disk, and turn them into arrays. there are plenty of tools to handle this: opencv , scipy, PIL.

          After loading the images you can do any manipulations you like on them (using these tools, or others), usualy you will need to reshape the image to fit your model.

          In the end you will need to output a pair ([batch_size,x,y,channels], [batch_size,labels]).






          share|improve this answer












          When working with images, you will usually use a generator.

          Generator is a function which output (u,v), where u are the samples, and v are the labels.



          Example on how to do this can be found here How to train TensorFlow network using a generator to produce inputs?.



          When building the generator function to deal with image, remember that every image is just an array, of either (x,y) for greyscale, or (x,y,channels) for color image.

          Thus your generator function will need to read a batch of images from the disk, and turn them into arrays. there are plenty of tools to handle this: opencv , scipy, PIL.

          After loading the images you can do any manipulations you like on them (using these tools, or others), usualy you will need to reshape the image to fit your model.

          In the end you will need to output a pair ([batch_size,x,y,channels], [batch_size,labels]).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          Or Dinari

          500218




          500218












          • I will try this out and let you know how it turned out. Thanks
            – Anand Nautiyal
            yesterday


















          • I will try this out and let you know how it turned out. Thanks
            – Anand Nautiyal
            yesterday
















          I will try this out and let you know how it turned out. Thanks
          – Anand Nautiyal
          yesterday




          I will try this out and let you know how it turned out. Thanks
          – Anand Nautiyal
          yesterday


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53349245%2fpreparing-images-to-feed-into-tensorflow-as-datasets%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

          Create new schema in PostgreSQL using DBeaver

          Deepest pit of an array with Javascript: test on Codility

          Costa Masnaga