Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Clojure] enhance draw bounding box #14567

Merged
merged 4 commits into from
Apr 11, 2019

Conversation

gigasquid
Copy link
Member

Description

Related issue #14506

This builds on #14533
In particular - it uses the core MXNet draw bounding box functionality in the infer objection detection example to unify the use of it in Scala and Clojure.

It also tweaks some of the specs and input names to make the clojure draw bounding box functionality easier to use from the infer object detection.

New output from object detection example:

Output results to: results/ :
Object detection on a single image
looking at image images/dog.jpg
result:  [{:class car, :prob 0.99847263, :x-min 0.60979164, :y-min 0.14068182, :x-max 0.89065313, :y-max 0.29426128} {:class bicycle, :prob 0.904738, :x-min 0.30460572, :y-min 0.29289767, :x-max 0.7496816, :y-max 0.8182521} {:class dog, :prob 0.822682, :x-min 0.16371787, :y-min 0.34988278, :x-max 0.40358955, :y-max 0.9312255} {:class bicycle, :prob 0.21815702, :x-min 0.18173869, :y-min 0.26932585, :x-max 0.46060133, :y-max 0.8074727} {:class person, :prob 0.12772371, :x-min 0.17368972, :y-min 0.2365945, :x-max 0.31111816, :y-max 0.37116468}]

dog

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

… detection example.

Adjust the specs and names to make it easier to run with object detection and clojure draw bounding box example
@gigasquid
Copy link
Member Author

@hellonico and @Chouffe Would you mind taking a look and reviewing?

@abhinavs95
Copy link
Contributor

Thank you for your contribution @gigasquid
@mxnet-label-bot add [Clojure, pr-awaiting-review]

@marcoabreu marcoabreu added Clojure pr-awaiting-review PR is waiting for code review labels Mar 29, 2019
(s/def ::ymin integer?)
(s/def ::ymax integer?)
(s/def ::coordinate (s/keys :req-un [::xmin ::xmax ::ymin ::ymax]))
(s/def ::x-min number?)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for improving this!

(is (= true (ImageIO/write new-img "png" (io/file tmp-dir "out.png"))))))
(is (true? (ImageIO/write new-img "png" (io/file tmp-dir "out.png"))))))

(deftest test-draw-bounding-box!
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you so much for adding this test!

@@ -22,7 +22,6 @@
:aliases {"run-detector" ["run" "--" "-m" "models/resnet50_ssd/resnet50_ssd_model" "-i" "images/dog.jpg" "-d" "images/"]}
:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/tools.cli "0.4.1"]
[origami "4.0.0-3"]
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

@@ -109,7 +114,7 @@
(apply concat
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need a concat here? Cant we use a doseq instead of for to force the lazy computation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, but it's also used in the example test to verify the results.

@Chouffe
Copy link
Contributor

Chouffe commented Mar 31, 2019

Thank you for enhancing the example @gigasquid. I left some comments. Overall LGTM!

@gigasquid
Copy link
Member Author

Thanks @Chouffe for your review and feedback :)

@gigasquid gigasquid merged commit 0284236 into apache:master Apr 11, 2019
@gigasquid gigasquid deleted the clojure-enhance-bounding-box branch April 11, 2019 23:02
larroy pushed a commit to larroy/mxnet that referenced this pull request Apr 15, 2019
* add test for drawing bounding box

* Uses the core image drawing bounding box functionality for the object detection example.

Adjust the specs and names to make it easier to run with object detection and clojure draw bounding box example

* feedback from @Chouffe

* refactor to be 3 top predictions instead of 5 to make the images less crowded
haohuanw pushed a commit to haohuanw/incubator-mxnet that referenced this pull request Jun 23, 2019
* add test for drawing bounding box

* Uses the core image drawing bounding box functionality for the object detection example.

Adjust the specs and names to make it easier to run with object detection and clojure draw bounding box example

* feedback from @Chouffe

* refactor to be 3 top predictions instead of 5 to make the images less crowded
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Clojure pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants