Skip to content
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

Port Faster R-CNN to Keras3 #2458

Merged
merged 46 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c37ae23
Base structure for faster rcnn till rpn head
sineeli Jun 10, 2024
973dd6a
Add export for Faster RNN
sineeli Jun 10, 2024
70c7f24
add init file
sineeli Jun 10, 2024
de67b89
initalize faster rcnn at model level
sineeli Jun 10, 2024
aaebe30
code fix fo roi align
sineeli Jun 12, 2024
0707858
Forward Pass code for Faster R-CNN
sineeli Jun 12, 2024
cff3b8e
Faster RCNN Base code for Keras3(Draft-1)
sineeli Jun 25, 2024
4f511e9
Add local batch size
sineeli Jun 25, 2024
0eef933
Add parameters to RPN Head
sineeli Jul 2, 2024
75c64ca
Make FPN more customizable with parameters and remove redudant code
sineeli Jul 2, 2024
6267a4b
Compute output shape for ROI Generator
sineeli Jul 2, 2024
1931f02
Faster RCNN functional model with required import corrections
sineeli Jul 2, 2024
58dc7f9
add clip boxes to forward pass
sineeli Jul 8, 2024
7c65348
add prediction decoder and use "yxyx" as default internal bounding bo…
sineeli Jul 11, 2024
676fcf1
feature pryamid correction
sineeli Jul 16, 2024
dcea19f
change ops.divide to ops.divide_no_nan
sineeli Jul 29, 2024
2179157
use from logits=True for Non Max supression
sineeli Jul 29, 2024
a002c49
include box convertions for both rois and ground truth boxes
sineeli Jul 29, 2024
5953f0a
Change number of detections in decoder
sineeli Jul 29, 2024
91f21fa
Use categoricalcrossentropy to avoid -1 class error + added get_confi…
sineeli Jul 30, 2024
abf0b44
add basic test cases + linting
sineeli Jul 30, 2024
d2b78e0
Add seed generator for sampling in RPN label encoding and ROI samplin…
sineeli Jul 30, 2024
a397a6c
Use only spatial dimension for ops.nn.avg_pool + use ops.convert_to_t…
sineeli Jul 30, 2024
e336d69
Convert list to tensor using keras ops
sineeli Jul 30, 2024
ecd0dad
Remove seed number from seed generator
sineeli Jul 31, 2024
c91ac27
Remove print and add proper comments
sineeli Aug 5, 2024
ba86502
- Use stddev(0.01) as per paper across RPN and R-CNN Heads
sineeli Aug 8, 2024
4979a99
- Fixes slice for multi backend
sineeli Aug 8, 2024
357a14a
- Add compute metrics method
sineeli Aug 9, 2024
ef27533
Correct test cases and add missing args
sineeli Aug 12, 2024
f37d799
Fix lint issues
sineeli Aug 13, 2024
36d4e10
- Fix lint and remove hard coded params to make it user friendly.
sineeli Aug 13, 2024
5060382
- Generate ROI's while decoding for predictions
sineeli Aug 14, 2024
02d24b0
- Add faster rcnn to build method
sineeli Aug 14, 2024
c0556d8
- Test only for Keras3
sineeli Aug 14, 2024
879028f
- Correct test case
sineeli Aug 15, 2024
c77d03c
- Correct the test cases decorator to skip for Keras2
sineeli Aug 16, 2024
10b9e76
- Skip Legacy test cases
sineeli Aug 16, 2024
e1d89e7
- Remove unecessary import in legacy code to fix lint
sineeli Aug 16, 2024
58178c6
- Correct pytest complexity
sineeli Aug 16, 2024
1c6125b
- FIx Image Shape to 512, 512 default which will not break other test…
sineeli Aug 16, 2024
df56fa6
- Lower image sizes for test cases
sineeli Aug 19, 2024
6b03271
- fix keras to 3.3.3 version
sineeli Aug 20, 2024
8608516
- Generate api
sineeli Aug 20, 2024
d1f05af
- Lint fix
sineeli Aug 20, 2024
8360e5b
- Increase the atol, rtol for YOLOv8 Detector forward pass
sineeli Aug 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions keras_cv/api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,7 @@
from keras_cv.src.models.stable_diffusion.stable_diffusion import (
StableDiffusionV2,
)
from keras_cv.src.models.object_detection.faster_rcnn.faster_rcnn import (
FasterRCNN
)
from keras_cv.src.models.task import Task
2 changes: 1 addition & 1 deletion keras_cv/src/bounding_box/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _clip_boxes(boxes, box_format, image_shape):

if isinstance(image_shape, list) or isinstance(image_shape, tuple):
height, width, _ = image_shape
max_length = [height, width, height, width]
max_length = ops.stack([height, width, height, width], axis=-1)
else:
image_shape = ops.cast(image_shape, dtype=boxes.dtype)
height = image_shape[0]
Expand Down
2 changes: 1 addition & 1 deletion keras_cv/src/layers/object_detection/roi_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def multilevel_crop_and_resize(
# TODO(tanzhenyu): replace tf.gather with tf.gather_nd and try to get
# similar performance.
features_per_box = ops.reshape(
ops.take(features_r2, indices),
ops.take(features_r2, indices, axis=0),
[
batch_size,
num_boxes,
Expand Down
3 changes: 3 additions & 0 deletions keras_cv/src/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,6 @@
)
from keras_cv.src.models.stable_diffusion import StableDiffusion
from keras_cv.src.models.stable_diffusion import StableDiffusionV2
from keras_cv.src.models.object_detection.faster_rcnn.faster_rcnn import (
FasterRCNN
)
6 changes: 6 additions & 0 deletions keras_cv/src/models/object_detection/faster_rcnn/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from keras_cv.src.models.object_detection.faster_rcnn.feature_pyramid import (
FeaturePyramid
)

from keras_cv.src.models.object_detection.faster_rcnn.rpn_head import RPNHead
from keras_cv.src.models.object_detection.faster_rcnn.rcnn_head import RCNNHead
Loading