Git Product home page Git Product logo

Comments (4)

roatienza avatar roatienza commented on May 30, 2024 2

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.

roatienza avatar roatienza commented on May 30, 2024

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.

pedrogalher avatar pedrogalher commented on May 30, 2024

Thank you for the explanation and clarification. However i still dont get two things in data_generator.py:

  1. In the method get_n_boxes from class 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).

  1. In line 160 in data_generation, we generate the anchors for each feature layer and feed it to the function get_gt_data to retrieve class ground truth tensor gt_cls for each layer. We append all the gt_cls across all the fature layers and get a tensor cls that has a shape of (self.n_boxes *4, n_classes).

  2. Finally, we store this cls in the corresponding image at gt_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.

pedrogalher avatar pedrogalher commented on May 30, 2024

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)

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.