Comments (7)
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.
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.
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.
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.
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]
2.)
scales = None
aspect_ratios = [1.0]
Also, aspect_ratios of [1.0, 1.0] throws an error (something with tensor shapes).
So, what's wrong?
from ssd_keras.
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.
You're welcome, I'm glad it's working now!
from ssd_keras.
Related Issues (20)
- InvalidArgumentError when compiling model with ssd_loss HOT 1
- WARNING:tensorflow:Gradients do not exist for variables ['conv4_3/bias:0',...] when minimizing the loss. HOT 1
- "Invalid argument: Index out of range using input dim 0; input has only 0 dims" during ssd300 model training
- load weight
- ValueError: Error when checking input: expected input_3 to have 4 dimensions, but got array with shape
- While training I got training terminate error . Epoch 00001: LearningRateScheduler setting learning rate to 0.001. 1/10 [==>...........................] - ETA: 4:08 - loss: nanBatch 0: Invalid loss, terminating training Epoch 00001: saving model to ssd512_URPC2018_epoch-01.h5 Process finished with exit code 0
- ValueError: An operation has `None` for gradient. Please make sure that all of your ops have a gradient defined (i.e. are differentiable). Common ops without gradient: K.argmax, K.round, K.eval.
- ValueError: Layer model expects 1 input(s), but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, None, None, None) dtype=uint8>, <tf.Tensor 'IteratorGetNext:1' shape=(None, None, None) dtype=float32>] HOT 23
- Parameters of the model HOT 1
- Bouding boxes predictions are concentrated in left top corner HOT 1
- Ambiguous dimension while trying to load weights.
- Urgent!! Invalid Loss HOT 4
- What are the requirements to run this code?. HOT 1
- Pascal VOC Training Person Detection
- The device being used is CPU while capturing image from webcam. How do I use my GPU for processing instead?
- Label error during Coco Training HOT 1
- TypeError: Expected any non-tensor type, got a tensor instead.
- Changes make the code work in 2023 HOT 2
- custom SSD300 model
- error while training with custom dataset in COCO format
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ssd_keras.