Comments (4)
tracing back my code, I believe I may have to correct myself. self.n_boxes
is the total number of anchor boxes for all feature layers. The code for get_n_boxes()
may be misleading which got me confused since each feature_shape is in fact feature_height x feature_width x n_anchors x 4 . 4 came from the number of offsets (there are 4 corners of a rectangle). The total number of anchor boxes per feature layer is (feature_height x feature_width x n_anchors x 4)/4. Since the number of anchors per feature pt is also 4, the computation was correct by accident.
in the data_generation
, the inner for loop, generates the ground truth class, offset and mask per feature layer anchors. so, when you get the total, it is equal to self.n_boxes
.
from advanced-deep-learning-with-keras.
Pls note that self.n_boxes
refers to the number of bounding boxes per feature layer. In other words, if a feature layer is divided into 3x2 region, there are 6 bounding boxes. An anchor box is assigned to a bounding box as ground truth if: 1) it has max iou with that bounding box or 2) it has iou with that bounding box that is greater than a threshold (eg 0.6). Majority of these self.n_boxes
bounding boxes are never assigned an anchor box (ie it is a background).
from advanced-deep-learning-with-keras.
Thank you for the explanation and clarification. However i still dont get two things in data_generator.py
:
- In the method
get_n_boxes
fromclass DataGenerator
, as you mention,self.n_boxes
is the sum of the number of bounding boxes (without taking into account the anchor boxes) for each feature layer:
self.n_boxes += np.prod(shape) // self.n_anchors
Let's say that the total number of bounding boxes accross all the feature layers is 500 for example.
2 )Later on, in function data_generation
, we create a tensor for storing class ground truth (line 130) which has dimensions gt_class.shape = (self.args.batch_size, self.n_boxes, self.n_classes)
, i.e, gt_class.shape = ( batch_size, 500, n_classes)
, if we consider 500 bounding boxes and 4 layers (1 for the background).
-
In line 160 in
data_generation
, we generate the anchors for each feature layer and feed it to the functionget_gt_data
to retrieve class ground truth tensorgt_cls
for each layer. We append all thegt_cls
across all the fature layers and get a tensorcls
that has a shape of(self.n_boxes *4, n_classes)
. -
Finally, we store this
cls
in the corresponding image atgt_class
in line 182:
gt_class[i] = cls
This is the question: How can we assign cls
to gt_class
if they have different shape? Whereas gt_class
has 500 rows, cls
has 2000 rows (since it takes into account the anchors per feature map point.
I have not run the code yet since I want to understand it before running it, and this difference in shape between gt_class and gt_cls is preventing me from advancing since I'm afraid I'm missing something important.
Thank you very much for your patience and help. I'm loving your book!
Pedro
from advanced-deep-learning-with-keras.
Thank you very much for your answer and for solving the question. I'll close the issue now.
from advanced-deep-learning-with-keras.
Related Issues (19)
- issue with tf version
- from lib import gan HOT 2
- The average precision and the average recall have the same result values HOT 1
- possibly unnecessary multiplication at the mask_offset function? HOT 1
- possible error at calculating the number of boxes HOT 2
- Invalid Argument Error HOT 2
- Error for dcgan-mnist-4.2.1.py HOT 2
- Error occurred when finalizing GeneratorDataset iterator | Trying to run image segmentation on custom dataset HOT 6
- z_mean does not change in CVAE CNN HOT 4
- ssd evaluate
- Warning for dcgan-mnist-4.2.1.py HOT 1
- SSD train HOT 4
- Project dependencies may have API risk issues HOT 1
- autoencoder-2dim-mnist-3.2.2.py: expected decoder_input to have shape (16,) but got array with shape (2,)
- In dqn-cartpole-9.6.1.py, line 115, where does "reward" variable come from? HOT 1
- WGAN fails. No lib/gan exists. HOT 2
- Why the last dimension of the tensor is size=4 HOT 1
- Unable to locate 'dataset' mentioned in Chapter 11 or it is not there. HOT 1
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 advanced-deep-learning-with-keras.