googlecodelabs / tensorflow-for-poets-2

Apache License 2.0
508 stars 463 forks source link

Detecting other objects similar to trained model #134

Open navneet-applify opened 4 years ago

navneet-applify commented 4 years ago

Hello. Thanks for this awesome lib.

I'm facing a problem that it is detecting the other objects which similar to the trained object in terms of colors.

How can i stop TensorFlow to not give a result based on some color matching thing?

Please let me know if there's anything I can do.

Ashwin-Ramesh2607 commented 4 years ago

There is no easy fix to this, however, I can suggest some alternatives. You want your model to learn features and not just colors (maybe to some extent yes) of each object you want to detect. You can probably achieve this by augmenting your images and increasing the size of the dataset. For choosing which augmentation to apply, choose anything which might change colors of an object to a little extent but retain the overall structure and shapes of the objects you want to classify. I could think of changing brightness, saturation, contrast, hue, etc. Although this will increase your model's learning capability, it will still give a class label from the classes you have provided. 2 possible fixes:

  1. Find a suitable threshold in the softmax probability of the last layer, something to the effect of, if no class has a confidence of greater than 50 %, then don't display any class. (Ad-Hoc approach)
  2. Create a new class in your image dataset of random things, that have a similar color to your previous objects and label the class as 'background'. This way, the model will actually learn what constitutes as background, and not one of the original class labels.
navneet-applify commented 4 years ago

Hi Ashwin

Thanks for suggestion

I think your second point can be helpful. I will try and let you know about this. And one more thing do I have to add landscape and verticle image of the same model? because in some cases the failure to scan in portrait or landscape.

Ashwin-Ramesh2607 commented 4 years ago

I think there may be some image size issues, because having both portrait and landscape may result in inconsistent image sizes.