Git Product home page Git Product logo

Comments (7)

pierluigiferrari avatar pierluigiferrari commented on May 25, 2024 1

Blind trial and error won't help for setting the scales, you have to compute meaningful values based on your dataset. If your images are 224 by 224 pixels and your ground truth boxes are all 43 (h) by 23 (w) pixels, then your only aspect ratio should be around 0.5 (≈ 23/43) and your only scaling factor should be h_box / h_image * sqrt(aspect_ratio) = 43 / 224 * sqrt(0.5) ≈ 0.14. You could set all scaling factors to 0.14. Once again, just as a side note, since all objects are of the same size, it's not immediately clear whether it even makes sense to have multiple predictor layers. But the important point here is that the scaling factors need to represent what fraction of the total image size the detectable objects are. Your ground truth boxes around the digits are only 20% by 10% of the image size, so scaling factors of 0.7 and larger are still way too large. Choosing the scaling factors and (somewhat less importantly, but still importantly) the aspect ratios carefully has strong implications on the matching process.

About the error when passing scales = None: I've (hopefully) just fixed this.

from ssd_keras.

pierluigiferrari avatar pierluigiferrari commented on May 25, 2024 1

I will only get a chance to try to reproduce your ValueError on Monday, but I think I know where it comes from.

In the arguments of val_dataset.generate() in your Jupyter notebooks, you set train=False. It must be train=True though, which is also how the argument is set in the Jupyter notebooks provided in this repository. So you produced that bug yourself :). Please set train=True in the arguments list for val_dataset.generate() and let me know if this fixes the ValueError.

Also, another thing: Note that scales and min_scale/max_scale are meant to be used either/or. Whenever you set scales = None, then min_scale and max_scale will be used to compute the list of scaling factors (by linear interpolation). So if you set scales = None like in your first two examples, but at the same time you leave min_scale = 1.0 and max_scale = 1.0, then all scaling factors will be 1.0 and you will get the same useless results as in your initial trials. So if you want to set scales = None, then you have to set min_scale and max_scale to some values around 0.14 in order for the model to work as you intend.

from ssd_keras.

orlov-alexander avatar orlov-alexander commented on May 25, 2024 1

Thank you so much!
It is finally working! ;-)
After some trials & erros I figured that I used "centroids" instead of "minmax" when plotting boxes on a picture in the last cell of the jupyter notebook. That's why it was SO messed up ;-)

from ssd_keras.

pierluigiferrari avatar pierluigiferrari commented on May 25, 2024

Hey Alexander, the problem is likely in the scaling factors you chose. You set all scaling factors to 1.0, which leads to non-sensical anchor box sizes for the size of the objects you are trying to detect. All anchor boxes will be as large as the training images themselves. This results in a bad matching process between anchor boxes and ground truth boxes: For any given ground truth box, no anchor box will meet the required IoU similarity with that ground truth box since all anchor boxes are way too large, which leads to the anchor box with the highest IoU similarity to be matched to that ground truth box. Since those IoU similarities with the huge anchor boxes don't have much meaning, the matching process becomes meaningless and a bad target tensor will be created.

Try the following:

Set all scaling factors to a value that leads to anchor boxes whose sizes correspond to the sizes of the objects you are trying to detect. Set the aspect ratios accordingly, too. The sizes and shapes of the anchor boxes should be similar to the sizes and shapes of the objects you are trying to detect. In your case, since all objects you're trying to detect have the same shape and size, try setting all scaling factors to the same value and use only one aspect ratio value. Also, it is not immediately clear whether there are any advantages or disadvantages to using multiple predictor layers versus using only one predictor layers if all detectable objects are the same size.

Let me know if this solves the problem.

from ssd_keras.

orlov-alexander avatar orlov-alexander commented on May 25, 2024

Thank you for the reply!
I chose these scaling factors because I thought it would be easier to learn. I've used only 1 font and 1 font size, so I basically wanted it to overfit very easy (but I've never seen loss of 0).

I tried these:

1.)
scales = [0.7, 0.8, 0.9, 1.0, 1.2]
aspect_ratios = [0.5, 1.0, 2.0]

nothing changed

2.)
scales = None
aspect_ratios = [1.0]

threw an error

Also, aspect_ratios of [1.0, 1.0] throws an error (something with tensor shapes).

So, what's wrong?

from ssd_keras.

orlov-alexander avatar orlov-alexander commented on May 25, 2024

Thanks for clarifying!

I fetched updates for your .py files and now it throws a "numpy" error.

ValueError: Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 128 arrays.
128 is batch_size.

So, another batch of blind trials and errors:
1.
scales = None
aspect_ratios = [0.5]
batch_size = 128
here
2.
scales = None
aspect_ratios = [0.5]
batch_size = 1
here
3.
scales = [0.14, 0.14, 0.14, 0.14, 0.14]
aspect_ratios = [0.5]
batch_size = 128
here
4.
scales = [0.12, 0.13, 0.14, 0.15, 0.16]
aspect_ratios = [0.45, 0.5, 0.55]
batch_size = 128
here

I haven't figured yet why where should be different predictor level, it would take some time.

from ssd_keras.

pierluigiferrari avatar pierluigiferrari commented on May 25, 2024

You're welcome, I'm glad it's working now!

from ssd_keras.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.