How to retrain an Image Classifier with new classes and keep old classes











up vote
0
down vote

favorite












I'm trying to make an image classifier that can identify how likely it is that an image is an image of a watermelon. To do this I followed the flower classifier example here: https://www.tensorflow.org/hub/tutorials/image_retrainin and trained the model using this command



python retrain.py --image_dir ~/flower_photos


The problem I found when trying this classifier out is that it only classifies among the new classes, that is the flower classes in this case. So when I tried to classify an image of a dog (which I know is present in the Inception module) it classified it as a rose



python label_image.py 
--graph=/tmp/output_graph.pb --labels=/tmp/output_labels.txt
--input_layer=Placeholder
--output_layer=final_result
--image=/images/dog.jpg


Result



roses 0.7626607
tulips 0.12247563
dandelion 0.071335025
sunflowers 0.028395686
daisy 0.0151329385


How could I use TensorFlow to extend the model with an additional class instead of creating a new model with only the new classes?










share|improve this question


























    up vote
    0
    down vote

    favorite












    I'm trying to make an image classifier that can identify how likely it is that an image is an image of a watermelon. To do this I followed the flower classifier example here: https://www.tensorflow.org/hub/tutorials/image_retrainin and trained the model using this command



    python retrain.py --image_dir ~/flower_photos


    The problem I found when trying this classifier out is that it only classifies among the new classes, that is the flower classes in this case. So when I tried to classify an image of a dog (which I know is present in the Inception module) it classified it as a rose



    python label_image.py 
    --graph=/tmp/output_graph.pb --labels=/tmp/output_labels.txt
    --input_layer=Placeholder
    --output_layer=final_result
    --image=/images/dog.jpg


    Result



    roses 0.7626607
    tulips 0.12247563
    dandelion 0.071335025
    sunflowers 0.028395686
    daisy 0.0151329385


    How could I use TensorFlow to extend the model with an additional class instead of creating a new model with only the new classes?










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm trying to make an image classifier that can identify how likely it is that an image is an image of a watermelon. To do this I followed the flower classifier example here: https://www.tensorflow.org/hub/tutorials/image_retrainin and trained the model using this command



      python retrain.py --image_dir ~/flower_photos


      The problem I found when trying this classifier out is that it only classifies among the new classes, that is the flower classes in this case. So when I tried to classify an image of a dog (which I know is present in the Inception module) it classified it as a rose



      python label_image.py 
      --graph=/tmp/output_graph.pb --labels=/tmp/output_labels.txt
      --input_layer=Placeholder
      --output_layer=final_result
      --image=/images/dog.jpg


      Result



      roses 0.7626607
      tulips 0.12247563
      dandelion 0.071335025
      sunflowers 0.028395686
      daisy 0.0151329385


      How could I use TensorFlow to extend the model with an additional class instead of creating a new model with only the new classes?










      share|improve this question













      I'm trying to make an image classifier that can identify how likely it is that an image is an image of a watermelon. To do this I followed the flower classifier example here: https://www.tensorflow.org/hub/tutorials/image_retrainin and trained the model using this command



      python retrain.py --image_dir ~/flower_photos


      The problem I found when trying this classifier out is that it only classifies among the new classes, that is the flower classes in this case. So when I tried to classify an image of a dog (which I know is present in the Inception module) it classified it as a rose



      python label_image.py 
      --graph=/tmp/output_graph.pb --labels=/tmp/output_labels.txt
      --input_layer=Placeholder
      --output_layer=final_result
      --image=/images/dog.jpg


      Result



      roses 0.7626607
      tulips 0.12247563
      dandelion 0.071335025
      sunflowers 0.028395686
      daisy 0.0151329385


      How could I use TensorFlow to extend the model with an additional class instead of creating a new model with only the new classes?







      image tensorflow machine-learning






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 7 at 12:15









      OriginalUtter

      1511922




      1511922
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          What you can do is join the two datasets and train them together or just leave the classes of model you are retraining in the possible classes and add a few images of those classes to the dataset just for the model to not forget what it already learned.






          share|improve this answer





















          • I don't understand exactly how to do this. How do I join the datasets? Or how do I leave the classes of the inception model I'm retraining in the possible classes? :)
            – OriginalUtter
            Nov 9 at 12:47











          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%2f53189299%2fhow-to-retrain-an-image-classifier-with-new-classes-and-keep-old-classes%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













          What you can do is join the two datasets and train them together or just leave the classes of model you are retraining in the possible classes and add a few images of those classes to the dataset just for the model to not forget what it already learned.






          share|improve this answer





















          • I don't understand exactly how to do this. How do I join the datasets? Or how do I leave the classes of the inception model I'm retraining in the possible classes? :)
            – OriginalUtter
            Nov 9 at 12:47















          up vote
          0
          down vote













          What you can do is join the two datasets and train them together or just leave the classes of model you are retraining in the possible classes and add a few images of those classes to the dataset just for the model to not forget what it already learned.






          share|improve this answer





















          • I don't understand exactly how to do this. How do I join the datasets? Or how do I leave the classes of the inception model I'm retraining in the possible classes? :)
            – OriginalUtter
            Nov 9 at 12:47













          up vote
          0
          down vote










          up vote
          0
          down vote









          What you can do is join the two datasets and train them together or just leave the classes of model you are retraining in the possible classes and add a few images of those classes to the dataset just for the model to not forget what it already learned.






          share|improve this answer












          What you can do is join the two datasets and train them together or just leave the classes of model you are retraining in the possible classes and add a few images of those classes to the dataset just for the model to not forget what it already learned.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 7 at 14:56









          Novak

          66848




          66848












          • I don't understand exactly how to do this. How do I join the datasets? Or how do I leave the classes of the inception model I'm retraining in the possible classes? :)
            – OriginalUtter
            Nov 9 at 12:47


















          • I don't understand exactly how to do this. How do I join the datasets? Or how do I leave the classes of the inception model I'm retraining in the possible classes? :)
            – OriginalUtter
            Nov 9 at 12:47
















          I don't understand exactly how to do this. How do I join the datasets? Or how do I leave the classes of the inception model I'm retraining in the possible classes? :)
          – OriginalUtter
          Nov 9 at 12:47




          I don't understand exactly how to do this. How do I join the datasets? Or how do I leave the classes of the inception model I'm retraining in the possible classes? :)
          – OriginalUtter
          Nov 9 at 12:47


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53189299%2fhow-to-retrain-an-image-classifier-with-new-classes-and-keep-old-classes%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







          這個網誌中的熱門文章

          Hercules Kyvelos

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud