This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-30
Channels
- # announcements (4)
- # babashka (3)
- # beginners (5)
- # calva (20)
- # cider (12)
- # clj-kondo (7)
- # cljs-dev (2)
- # clojure (76)
- # clojure-uk (4)
- # clojuredesign-podcast (8)
- # clojurescript (18)
- # clojutre (1)
- # cursive (9)
- # data-science (27)
- # datomic (2)
- # fulcro (32)
- # graalvm (4)
- # jackdaw (5)
- # jobs (2)
- # joker (5)
- # lumo (20)
- # off-topic (18)
- # pathom (3)
- # shadow-cljs (18)
- # sql (5)
- # tools-deps (1)
- # vim (11)
It looks like this might be the official announcement: https://towardsdatascience.com/introducing-deep-java-library-djl-9de98de8c6ca
;; deps.edn
{:deps {org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.12.1"}
ai.djl.mxnet/mxnet-model-zoo {:mvn/version "0.2.0"}
ai.djl.mxnet/mxnet-native-mkl$osx-x86_64 {:mvn/version "1.6.0-a"}}}
;; example
(ns clj-djl.core
(:require [ :as io])
(:import (ai.djl.modality.cv.util BufferedImageUtils)
(ai.djl.mxnet.zoo MxModelZoo)
(ai.djl.training.util ProgressBar)
(ai.djl.modality.cv ImageVisualization)
(javax.imageio ImageIO)))
(defn example []
(let [img (BufferedImageUtils/fromUrl "")]
(with-open [model (.loadModel (MxModelZoo/SSD) (ProgressBar.))]
(let [predict-result (-> model
(.newPredictor)
(.predict img))]
(ImageVisualization/drawBoundingBoxes img predict-result)
(ImageIO/write img "png" (io/file "ssd.png"))))))
not meaning to start a wrapper, but put the above example into a repo: https://github.com/viesti/clj-djl/blob/master/src/clj_djl/core.clj
Great! Thanks for blazing the way in trying it out :) I plan to check it out too in the near future
It seems great. (Wished it was more functional though) xD
More tinkering (was looking at MXNet tutorials: https://mxnet.apache.org/api/python/docs/tutorials/getting-started/crash-course/1-ndarray.html):
clj-djl.core> (do (import (ai.djl.ndarray NDManager))
(import (ai.djl.ndarray.types Shape))
(with-open [nd-manager (NDManager/newBaseManager)]
(println (.randomUniform nd-manager 1 -1 (Shape. [2 2])))))
#object[ai.djl.mxnet.engine.MxNDArray 0x7b62d17b ND: (2, 2) cpu(0) float32
[[ 0.1527, -0.2471],
[-0.2918, 0.2312],
]
]
which is quite interesting, they have a tool to generate JNA mappings from the MXNet C header file: https://github.com/awslabs/djl/tree/master/mxnet/jnarator
I wonder how this compares to the hand-written JNI in the Scala/Java bindgins of MXNet: https://github.com/apache/incubator-mxnet/blob/master/scala-package/native/src/main/native/org_apache_mxnet_native_c_api.cc
this generator tool reminds me of SWIG (http://www.swig.org/), although that generates straight JNI from C headers
interesting - @chris441 brought up JNA for TVM / MXNet a bit ago https://discuss.tvm.ai/t/clojure-bindings-for-tvm/1127
This 😄 > We would also like to see more java integrations to DMLC projects that allow easier access to multiple languages; ones that force unnecessary dependencies on the scala compiler also force dependencies on the root jvm runtime (mxnet, we are looking at you).