-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Object_Detection] Add MultiScaleAnchorGenerator and docstring for An… #2
Conversation
Wow +611 -124 😄 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import tensorflow as tf | ||
|
||
|
||
class AnchorGenerator(tf.keras.layers.Layer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this base class designed over the experience of https://github.com/tensorflow/models/blob/master/research/object_detection/core/anchor_generator.py? Or is this a from scratch design?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question!
This is mostly a scratch design for proof of concept at this moment. Francois and I will send out RFC for public comments and feedbacks later :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok cause there are a few derived classes at https://github.com/tensorflow/models/tree/master/research/object_detection/anchor_generators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep and we intend to make them layers. Though the arguments are slightly different than this directory
from .anchor_generator import AnchorGenerator | ||
|
||
|
||
class MultiScaleAnchorGenerator(tf.keras.layers.Layer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same above
Just moving files and adding comprehensive tests :-) |
feature map cell when `anchor_stride=None`, or center of anchor stride otherwise. | ||
clip_boxes: Boolean to represents whether the anchor coordinates should be clipped to the image size. | ||
Defaults to `True`. | ||
norm_coords: Boolean to represents whether the anchor coordinates should be normalized to [0., 1.] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, prefer fully-spelled out argument names, e.g. normalize_coordinates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
from .anchor_generator import AnchorGenerator | ||
|
||
|
||
class MultiScaleAnchorGenerator(tf.keras.layers.Layer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the similarity with AnchorGenerator why not subclass it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the class that accepts a list of things and then apply to each one of the anchor generator?
**Must** have the same length as `scales`. For example, if `image_size=(300, 200)`, `scales=[.1]`, | ||
and `aspect_ratios=[.64]`, the base anchor size is 20, then anchor height is 25 and anchor width is 16. | ||
The anchor aspect ratio is independent to the original aspect ratio of image size. | ||
anchor_stride: A list/tuple of 2 ints or floats representing the distance between anchor points. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: why anchor_stride
and anchor_offset
rather than just stride
and offset
? It's an anchor generator, after all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Done.
LGTM! |
* add fmix init commit * fix issues try #1 * fix issues try #2 * change random generator to normal from uniform to support negative values * add support for variable channels attempt 1 * update fftfreq description * add changes * add support for variable label shapes * add changes * fix errors * remove newline * change name to FourierMix attempt 1 * fixed lint issue * remove edge softening * Final pass Co-authored-by: Luke Wood <lukewoodcs@gmail.com>
* add fmix init commit * fix issues try #1 * fix issues try #2 * change random generator to normal from uniform to support negative values * add support for variable channels attempt 1 * update fftfreq description * add changes * add support for variable label shapes * add changes * fix errors * remove newline * change name to FourierMix attempt 1 * fixed lint issue * remove edge softening * Final pass Co-authored-by: Luke Wood <lukewoodcs@gmail.com>
* add fmix init commit * fix issues try keras-team#1 * fix issues try keras-team#2 * change random generator to normal from uniform to support negative values * add support for variable channels attempt 1 * update fftfreq description * add changes * add support for variable label shapes * add changes * fix errors * remove newline * change name to FourierMix attempt 1 * fixed lint issue * remove edge softening * Final pass Co-authored-by: Luke Wood <lukewoodcs@gmail.com>
…d update iou losses (#1296) * first attempt at introducing YoloX * formatted and fixed bugs * cast fix #1 * cast fix #2 * cast fix #3 * cast fix #4 * adding ensure shape for support * reverting and removing ensure_shape * fixed another bug * updated train.py * updated docs, tests and added support for loss strings * first attempt at introducing YoloX * formatted and fixed bugs * adding ensure shape for support * reverting and removing ensure_shape * reformatted by black * fixed a linting issue * finally rebased atop the recent changes * finally rebased atop the new changes * fixed linting issues * reverted rebasing issues with iou loss * fixing rebased errors part 2 * fixed more linting issues * TPU testing changes * linting fixes * updated with implementation details from paper * updated based on review comments and api changes * first attempt at introducing YoloX * updated docs, tests and added support for loss strings * fixed linting issues * reverted rebasing issues with iou loss * review comments * removed examples * linting fix * fixed rebasing error * updated no_reduction warning * review comments * revert version and linting fixes
…sifier Port `ResNetV2Backbone`, `EfficientNetV2Backbone`, and `ImageClassifier` to Keras Core
Add RandomNormal and RandomUniform Initializers
…d update iou losses (keras-team#1296) * first attempt at introducing YoloX * formatted and fixed bugs * cast fix keras-team#1 * cast fix keras-team#2 * cast fix keras-team#3 * cast fix keras-team#4 * adding ensure shape for support * reverting and removing ensure_shape * fixed another bug * updated train.py * updated docs, tests and added support for loss strings * first attempt at introducing YoloX * formatted and fixed bugs * adding ensure shape for support * reverting and removing ensure_shape * reformatted by black * fixed a linting issue * finally rebased atop the recent changes * finally rebased atop the new changes * fixed linting issues * reverted rebasing issues with iou loss * fixing rebased errors part 2 * fixed more linting issues * TPU testing changes * linting fixes * updated with implementation details from paper * updated based on review comments and api changes * first attempt at introducing YoloX * updated docs, tests and added support for loss strings * fixed linting issues * reverted rebasing issues with iou loss * review comments * removed examples * linting fix * fixed rebasing error * updated no_reduction warning * review comments * revert version and linting fixes
[Object_Detection] Add MultiScaleAnchorGenerator