-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[Clojure] examples with opencv4/origami #13813
Conversation
@mxnet-label-bot add [pr-awaiting-review] |
f726ecf
to
8b790f2
Compare
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.
Great work!
_ (Core/flip img result (int 0))] | ||
result) | ||
img)))) | ||
(cv/>> (new-mat height width CV_8UC1) (byte-array raw-data)))] |
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.
neat threading :)
(println "The nd image size is:" {:height h :width w}) | ||
(-> simg | ||
(cv/convert-to! cv/CV_8SC3 0.5) | ||
(cv/add! (cv/new-scalar -103.939 -116.779 -123.68) ) |
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.
Cool - this is a nice way to do this
(let [h (.height simg) w (.width simg)] | ||
(println "The nd image size is:" {:height h :width w}) | ||
(-> simg | ||
(cv/convert-to! cv/CV_8SC3 0.5) |
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.
what does the 0.5
in convert-to!
do?
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.
its scaling the bytes to match the new format. (-128 > 128 instead of 0 > 255)
[(conj rs r) (conj gs g) (conj bs b)])) | ||
[[] [] []] | ||
pixels)] | ||
(when show? (img/show image)) |
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.
Is there a way to show the image to the user if the show?
flag is true? imshow
?
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.
just added !
[opencv4.core :refer [FONT_HERSHEY_PLAIN imread imwrite new-point put-text! rectangle]])) | ||
|
||
(defn black-boxes! [img results] | ||
(doseq [ |
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.
I feel like the formatting is a bit off in this function - I know if varies from editor to editor. There is a tool to keep the style consistent between contributors, (I should run this more often I know :) )
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.
indeed. updated the formatting.
@@ -18,8 +18,8 @@ | |||
(defproject neural-style "0.1.0-SNAPSHOT" |
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.
Ran the example - works great!
:plugins [[lein-cljfmt "0.5.7"]] | ||
:aliases {"sample-detector" ["run" "--" "-m" "models/resnet50_ssd/resnet50_ssd_model" "-i" "images/dog.jpg" "-d" "images/"]} |
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.
nice alias - can you please add to the README too?
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.
added!
@@ -106,10 +127,9 @@ | |||
factory | |||
{:contexts [(context/default-context)]})] | |||
(println "Object detection on a single image") | |||
(print-predictions (detect-single-image detector input-image) width height) |
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.
Could we also leave the printing of the predictions to the console in as well?
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.
re-added.
|
||
(defn detect-images-in-dir | ||
"Detect objects in all jpg images in the directory" | ||
[detector input-dir] | ||
[detector input-dir output-dir] |
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.
Could we make the default output-dir for the example results
or image-results
?
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.
"results" it is.
@@ -20,6 +20,7 @@ | |||
[org.apache.clojure-mxnet.infer :as infer] | |||
[org.apache.clojure-mxnet.layout :as layout] | |||
[clojure.java.io :as io] | |||
[infer.draw :as draw] |
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.
I ran the example and the drawing of the bounding boxes is fantastic!
Can you please merge this PR with master because the output of the predictions has now changed shape a bit
#13864
Object detection now returns a map
{:class car, :prob 0.99847263, :x-min 0.6097917, :y-min 0.1406818, :x-max 0.8906532, :y-max 0.29426125}
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.
Thanks for pointing out ! Re-Merged with master and fixed.
8b790f2
to
4cb7d8b
Compare
4cb7d8b
to
e027290
Compare
Thanks for addressing the feedback so quickly @hellonico 😄 |
e027290
to
d2035dd
Compare
Thanks for all your hard work on making this possible @hellonico - It works great - tested on OSX and Linux 🎆 |
This reverts commit 754ff76.
Description
This PR uses OpenCV/Origami as the image manipulation library.
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Basically using library: [origami "4.0.0-2"] with imports:
Whenever possible.
Comments