Classifying Car Data By Year












3












$begingroup$


I have huge car photos.



I want to predict car's "brand-model-body type and production year"



data



First, I splitted data into train and validation, and I categorized them like this.



categorized_cars



Every category has about 1000 train and 900 validation images.



My plan was: I train my keras model with these categories after training, model can predict labels like below:



audi a3 sedan 2008 => %25



audi a3 sedan 2009 => %25



audi a3 sedan 2010 => %25



audi a3 sedan 2011 => %25



And I can tell user that: "This car is Audi A3 Sedan 2008-2011"



My problem is, some of these categories have very similar photos. For example: audi a3 2009 and audi a3 2010 have same body type and there is not much difference between photos (No difference in reality).
Because of that, train accuracy has improved to about 0.9 but validation accuracy hasn't improved above 0.55



When I try some predictions, it usually gives same label, "Ford Focus sedan 2009" :)



Here is my output:



epoch,          acc,              loss,              val_acc,       val_loss
27, 0.7965514530544776, 0.56618134500483, 0.5192149643316993, 1.729015349846447

28, 0.8058803490480816, 0.5408204138258657, 0.5176764522193236, 1.778763979018732

29, 0.8167710489770164, 0.5116128672937693, 0.523258489762041, 1.7806432932022545

30, 0.8256544639818643, 0.4872381848016096, 0.5207534764479939, 1.8059904007678271

31, 0.8355546238309248, 0.4629556378035959, 0.5237253032663666, 1.8191414148756815

32, 0.8424464767701014, 0.4444190686917562, 0.5242512903147193, 1.8496954914466912

33, 0.8508739288802705, 0.422022156655134, 0.5303593149032422, 1.8565427863780883

34, 0.8576819265745635, 0.40545297008116027, 0.5262894901236571, 1.909881308499735


My train code is here:



Image_width, Image_height = 224, 224
num_epoch = 5000
batch_size = 16
learning_rate = 0.0001
model = ResNet50(weights='imagenet', include_top=False, input_shape=(Image_width, Image_height, 3))
fc_neuron_count = 1024
output = model.output
output = GlobalAveragePooling2D()(output)
output = Dense(fc_neuron_count, activation='relu')(output)
predictions = Dense(num_classes, activation='softmax')(output)
model = Model(inputs=model.input, outputs=predictions)

model.compile(optimizer=opt.Adam(lr=learning_rate), loss=losses.categorical_crossentropy,
metrics=['accuracy'])

history_transfer_learning = model.fit_generator(
train_generator,
epochs=num_epoch,
steps_per_epoch=num_train_samples // batch_size,
validation_data=validation_generator,
validation_steps=num_validate_samples // batch_size,
class_weight='auto',
callbacks=callbacks_list)



  • Am I doing something wrong? How can I achieve this result?


  • Should I change validation accuracy calculation, or should I give more photos per category?











share|improve this question











$endgroup$




bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    3












    $begingroup$


    I have huge car photos.



    I want to predict car's "brand-model-body type and production year"



    data



    First, I splitted data into train and validation, and I categorized them like this.



    categorized_cars



    Every category has about 1000 train and 900 validation images.



    My plan was: I train my keras model with these categories after training, model can predict labels like below:



    audi a3 sedan 2008 => %25



    audi a3 sedan 2009 => %25



    audi a3 sedan 2010 => %25



    audi a3 sedan 2011 => %25



    And I can tell user that: "This car is Audi A3 Sedan 2008-2011"



    My problem is, some of these categories have very similar photos. For example: audi a3 2009 and audi a3 2010 have same body type and there is not much difference between photos (No difference in reality).
    Because of that, train accuracy has improved to about 0.9 but validation accuracy hasn't improved above 0.55



    When I try some predictions, it usually gives same label, "Ford Focus sedan 2009" :)



    Here is my output:



    epoch,          acc,              loss,              val_acc,       val_loss
    27, 0.7965514530544776, 0.56618134500483, 0.5192149643316993, 1.729015349846447

    28, 0.8058803490480816, 0.5408204138258657, 0.5176764522193236, 1.778763979018732

    29, 0.8167710489770164, 0.5116128672937693, 0.523258489762041, 1.7806432932022545

    30, 0.8256544639818643, 0.4872381848016096, 0.5207534764479939, 1.8059904007678271

    31, 0.8355546238309248, 0.4629556378035959, 0.5237253032663666, 1.8191414148756815

    32, 0.8424464767701014, 0.4444190686917562, 0.5242512903147193, 1.8496954914466912

    33, 0.8508739288802705, 0.422022156655134, 0.5303593149032422, 1.8565427863780883

    34, 0.8576819265745635, 0.40545297008116027, 0.5262894901236571, 1.909881308499735


    My train code is here:



    Image_width, Image_height = 224, 224
    num_epoch = 5000
    batch_size = 16
    learning_rate = 0.0001
    model = ResNet50(weights='imagenet', include_top=False, input_shape=(Image_width, Image_height, 3))
    fc_neuron_count = 1024
    output = model.output
    output = GlobalAveragePooling2D()(output)
    output = Dense(fc_neuron_count, activation='relu')(output)
    predictions = Dense(num_classes, activation='softmax')(output)
    model = Model(inputs=model.input, outputs=predictions)

    model.compile(optimizer=opt.Adam(lr=learning_rate), loss=losses.categorical_crossentropy,
    metrics=['accuracy'])

    history_transfer_learning = model.fit_generator(
    train_generator,
    epochs=num_epoch,
    steps_per_epoch=num_train_samples // batch_size,
    validation_data=validation_generator,
    validation_steps=num_validate_samples // batch_size,
    class_weight='auto',
    callbacks=callbacks_list)



    • Am I doing something wrong? How can I achieve this result?


    • Should I change validation accuracy calculation, or should I give more photos per category?











    share|improve this question











    $endgroup$




    bumped to the homepage by Community yesterday


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      3












      3








      3





      $begingroup$


      I have huge car photos.



      I want to predict car's "brand-model-body type and production year"



      data



      First, I splitted data into train and validation, and I categorized them like this.



      categorized_cars



      Every category has about 1000 train and 900 validation images.



      My plan was: I train my keras model with these categories after training, model can predict labels like below:



      audi a3 sedan 2008 => %25



      audi a3 sedan 2009 => %25



      audi a3 sedan 2010 => %25



      audi a3 sedan 2011 => %25



      And I can tell user that: "This car is Audi A3 Sedan 2008-2011"



      My problem is, some of these categories have very similar photos. For example: audi a3 2009 and audi a3 2010 have same body type and there is not much difference between photos (No difference in reality).
      Because of that, train accuracy has improved to about 0.9 but validation accuracy hasn't improved above 0.55



      When I try some predictions, it usually gives same label, "Ford Focus sedan 2009" :)



      Here is my output:



      epoch,          acc,              loss,              val_acc,       val_loss
      27, 0.7965514530544776, 0.56618134500483, 0.5192149643316993, 1.729015349846447

      28, 0.8058803490480816, 0.5408204138258657, 0.5176764522193236, 1.778763979018732

      29, 0.8167710489770164, 0.5116128672937693, 0.523258489762041, 1.7806432932022545

      30, 0.8256544639818643, 0.4872381848016096, 0.5207534764479939, 1.8059904007678271

      31, 0.8355546238309248, 0.4629556378035959, 0.5237253032663666, 1.8191414148756815

      32, 0.8424464767701014, 0.4444190686917562, 0.5242512903147193, 1.8496954914466912

      33, 0.8508739288802705, 0.422022156655134, 0.5303593149032422, 1.8565427863780883

      34, 0.8576819265745635, 0.40545297008116027, 0.5262894901236571, 1.909881308499735


      My train code is here:



      Image_width, Image_height = 224, 224
      num_epoch = 5000
      batch_size = 16
      learning_rate = 0.0001
      model = ResNet50(weights='imagenet', include_top=False, input_shape=(Image_width, Image_height, 3))
      fc_neuron_count = 1024
      output = model.output
      output = GlobalAveragePooling2D()(output)
      output = Dense(fc_neuron_count, activation='relu')(output)
      predictions = Dense(num_classes, activation='softmax')(output)
      model = Model(inputs=model.input, outputs=predictions)

      model.compile(optimizer=opt.Adam(lr=learning_rate), loss=losses.categorical_crossentropy,
      metrics=['accuracy'])

      history_transfer_learning = model.fit_generator(
      train_generator,
      epochs=num_epoch,
      steps_per_epoch=num_train_samples // batch_size,
      validation_data=validation_generator,
      validation_steps=num_validate_samples // batch_size,
      class_weight='auto',
      callbacks=callbacks_list)



      • Am I doing something wrong? How can I achieve this result?


      • Should I change validation accuracy calculation, or should I give more photos per category?











      share|improve this question











      $endgroup$




      I have huge car photos.



      I want to predict car's "brand-model-body type and production year"



      data



      First, I splitted data into train and validation, and I categorized them like this.



      categorized_cars



      Every category has about 1000 train and 900 validation images.



      My plan was: I train my keras model with these categories after training, model can predict labels like below:



      audi a3 sedan 2008 => %25



      audi a3 sedan 2009 => %25



      audi a3 sedan 2010 => %25



      audi a3 sedan 2011 => %25



      And I can tell user that: "This car is Audi A3 Sedan 2008-2011"



      My problem is, some of these categories have very similar photos. For example: audi a3 2009 and audi a3 2010 have same body type and there is not much difference between photos (No difference in reality).
      Because of that, train accuracy has improved to about 0.9 but validation accuracy hasn't improved above 0.55



      When I try some predictions, it usually gives same label, "Ford Focus sedan 2009" :)



      Here is my output:



      epoch,          acc,              loss,              val_acc,       val_loss
      27, 0.7965514530544776, 0.56618134500483, 0.5192149643316993, 1.729015349846447

      28, 0.8058803490480816, 0.5408204138258657, 0.5176764522193236, 1.778763979018732

      29, 0.8167710489770164, 0.5116128672937693, 0.523258489762041, 1.7806432932022545

      30, 0.8256544639818643, 0.4872381848016096, 0.5207534764479939, 1.8059904007678271

      31, 0.8355546238309248, 0.4629556378035959, 0.5237253032663666, 1.8191414148756815

      32, 0.8424464767701014, 0.4444190686917562, 0.5242512903147193, 1.8496954914466912

      33, 0.8508739288802705, 0.422022156655134, 0.5303593149032422, 1.8565427863780883

      34, 0.8576819265745635, 0.40545297008116027, 0.5262894901236571, 1.909881308499735


      My train code is here:



      Image_width, Image_height = 224, 224
      num_epoch = 5000
      batch_size = 16
      learning_rate = 0.0001
      model = ResNet50(weights='imagenet', include_top=False, input_shape=(Image_width, Image_height, 3))
      fc_neuron_count = 1024
      output = model.output
      output = GlobalAveragePooling2D()(output)
      output = Dense(fc_neuron_count, activation='relu')(output)
      predictions = Dense(num_classes, activation='softmax')(output)
      model = Model(inputs=model.input, outputs=predictions)

      model.compile(optimizer=opt.Adam(lr=learning_rate), loss=losses.categorical_crossentropy,
      metrics=['accuracy'])

      history_transfer_learning = model.fit_generator(
      train_generator,
      epochs=num_epoch,
      steps_per_epoch=num_train_samples // batch_size,
      validation_data=validation_generator,
      validation_steps=num_validate_samples // batch_size,
      class_weight='auto',
      callbacks=callbacks_list)



      • Am I doing something wrong? How can I achieve this result?


      • Should I change validation accuracy calculation, or should I give more photos per category?








      machine-learning keras computer-vision






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 10 '18 at 11:56









      ebrahimi

      75521022




      75521022










      asked Sep 10 '18 at 11:28









      ibrahimozgonibrahimozgon

      1212




      1212





      bumped to the homepage by Community yesterday


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community yesterday


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0












          $begingroup$

          I want to say how I solved my problem for anyone who is looking for a similar question.



          My categorization was a mistake. I realized later that, I gave the same photos to my model and waited for the different results. For example, I had nearly same photos in Audi A3 Hatchback/5 2009 and Audi A3 Hatchback/5 2010. When the model starts training, first it learns data. Then it predicts and validates output itself. If the output is wrong, it tries a different way to success. But wait a minute, there was no mistake. I gave you the same photos and waited for different results! My categorization failed here.



          I categorized my cars by body changes like Audi A3 Hatchback 2008-2013. Except for categories that have the wrong photos, my results are great for now.



          Now, we will work on better photos and better year categorization.






          share|improve this answer









          $endgroup$














            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "557"
            };
            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: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2fdatascience.stackexchange.com%2fquestions%2f38042%2fclassifying-car-data-by-year%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












            $begingroup$

            I want to say how I solved my problem for anyone who is looking for a similar question.



            My categorization was a mistake. I realized later that, I gave the same photos to my model and waited for the different results. For example, I had nearly same photos in Audi A3 Hatchback/5 2009 and Audi A3 Hatchback/5 2010. When the model starts training, first it learns data. Then it predicts and validates output itself. If the output is wrong, it tries a different way to success. But wait a minute, there was no mistake. I gave you the same photos and waited for different results! My categorization failed here.



            I categorized my cars by body changes like Audi A3 Hatchback 2008-2013. Except for categories that have the wrong photos, my results are great for now.



            Now, we will work on better photos and better year categorization.






            share|improve this answer









            $endgroup$


















              0












              $begingroup$

              I want to say how I solved my problem for anyone who is looking for a similar question.



              My categorization was a mistake. I realized later that, I gave the same photos to my model and waited for the different results. For example, I had nearly same photos in Audi A3 Hatchback/5 2009 and Audi A3 Hatchback/5 2010. When the model starts training, first it learns data. Then it predicts and validates output itself. If the output is wrong, it tries a different way to success. But wait a minute, there was no mistake. I gave you the same photos and waited for different results! My categorization failed here.



              I categorized my cars by body changes like Audi A3 Hatchback 2008-2013. Except for categories that have the wrong photos, my results are great for now.



              Now, we will work on better photos and better year categorization.






              share|improve this answer









              $endgroup$
















                0












                0








                0





                $begingroup$

                I want to say how I solved my problem for anyone who is looking for a similar question.



                My categorization was a mistake. I realized later that, I gave the same photos to my model and waited for the different results. For example, I had nearly same photos in Audi A3 Hatchback/5 2009 and Audi A3 Hatchback/5 2010. When the model starts training, first it learns data. Then it predicts and validates output itself. If the output is wrong, it tries a different way to success. But wait a minute, there was no mistake. I gave you the same photos and waited for different results! My categorization failed here.



                I categorized my cars by body changes like Audi A3 Hatchback 2008-2013. Except for categories that have the wrong photos, my results are great for now.



                Now, we will work on better photos and better year categorization.






                share|improve this answer









                $endgroup$



                I want to say how I solved my problem for anyone who is looking for a similar question.



                My categorization was a mistake. I realized later that, I gave the same photos to my model and waited for the different results. For example, I had nearly same photos in Audi A3 Hatchback/5 2009 and Audi A3 Hatchback/5 2010. When the model starts training, first it learns data. Then it predicts and validates output itself. If the output is wrong, it tries a different way to success. But wait a minute, there was no mistake. I gave you the same photos and waited for different results! My categorization failed here.



                I categorized my cars by body changes like Audi A3 Hatchback 2008-2013. Except for categories that have the wrong photos, my results are great for now.



                Now, we will work on better photos and better year categorization.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 14 '18 at 17:25









                ibrahimozgonibrahimozgon

                1212




                1212






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Data Science Stack Exchange!


                    • 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.


                    Use MathJax to format equations. MathJax reference.


                    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%2fdatascience.stackexchange.com%2fquestions%2f38042%2fclassifying-car-data-by-year%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

                    How to label and detect the document text images

                    Vallis Paradisi

                    Tabula Rosettana