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

PtndArrayEx.multiboxDetection() implementation #2769

Merged

Conversation

juliangamble
Copy link
Contributor

Description

The big goal here is to implement PtNDArrayEx.multiBoxDetection() (currently throws NotImplementException) so that you can run PikachuTraining with Pytorch and so you can run SSD Training on M1 Macs.

The implementation for this is derived from:
https://github.com/apache/mxnet/blob/master/src/operator/contrib/multibox_detection.cc
and
https://github.com/apache/mxnet/blob/master/src/operator/contrib/multibox_detection-inl.h

This implementation is based on implementing the unit test on the C++ side and comparing the steps internally.

outputs[i][0] = id - 1;
outputs[i][1] = score;
int offset = i * 4;
float[] pAnchorRow4 = new float[4];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that possible to achieve below code under matrix calculation through using existing NDArray functions?

@juliangamble
Copy link
Contributor Author

juliangamble commented Sep 6, 2023 via email

@zachgk zachgk force-pushed the ptndarrayex_multiboxdetection branch from b3a92fd to 61597e5 Compare September 28, 2023 04:58
@zachgk
Copy link
Contributor

zachgk commented Sep 28, 2023

I made a few updates to merge this in for our next release. This includes some cleanup and a few bug fixes (including with freezing parameters in PtModel loading outside the scope of this PR).

One thing to note is I got the tests running in SingleShotDetectionTest. Right now, it passes the SingleShotDetectionTest.testLoadPredict using the new code. However, it does not fully support SSD. It won't pass SingleShotDetectionTest.testLoadTrain or other SSD training without also implementing PtNDArrayEx.multiBoxTarget

@codecov-commenter
Copy link

Codecov Report

Attention: 1375 lines in your changes are missing coverage. Please review.

Comparison is base (bb5073f) 72.08% compared to head (61597e5) 72.21%.
Report is 885 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2769      +/-   ##
============================================
+ Coverage     72.08%   72.21%   +0.12%     
- Complexity     5126     7111    +1985     
============================================
  Files           473      702     +229     
  Lines         21970    31680    +9710     
  Branches       2351     3284     +933     
============================================
+ Hits          15838    22879    +7041     
- Misses         4925     7237    +2312     
- Partials       1207     1564     +357     
Files Coverage Δ
...ava/ai/djl/inference/streaming/StreamingBlock.java 100.00% <100.00%> (ø)
api/src/main/java/ai/djl/metric/Dimension.java 100.00% <100.00%> (ø)
api/src/main/java/ai/djl/metric/Unit.java 100.00% <100.00%> (ø)
api/src/main/java/ai/djl/modality/audio/Audio.java 100.00% <100.00%> (ø)
api/src/main/java/ai/djl/modality/cv/Image.java 69.23% <ø> (-4.11%) ⬇️
...rc/main/java/ai/djl/modality/cv/MultiBoxPrior.java 76.00% <ø> (ø)
...ava/ai/djl/modality/cv/output/DetectedObjects.java 96.29% <100.00%> (+1.29%) ⬆️
...rc/main/java/ai/djl/modality/cv/output/Joints.java 71.42% <100.00%> (ø)
.../main/java/ai/djl/modality/cv/output/Landmark.java 100.00% <ø> (ø)
...i/djl/modality/cv/transform/RandomResizedCrop.java 94.11% <100.00%> (+5.22%) ⬆️
... and 226 more

... and 372 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@juliangamble
Copy link
Contributor Author

juliangamble commented Sep 28, 2023 via email

@zachgk zachgk merged commit 963332d into deepjavalibrary:master Sep 28, 2023
5 checks passed
frankfliu pushed a commit that referenced this pull request Apr 26, 2024
* Implement PtNDArraryEx.multiboxDetection

* MultiboxDetection - code cleanup

* MultiboxDetection - code cleanup

* MultiboxDetection - code cleanup

* MultiboxDetection - code cleanup

* format code

* Fix, add tests, and pass CI

---------

Co-authored-by: Zach Kimberg <kimbergz@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants