diff --git a/contrib/clojure-package/.gitignore b/contrib/clojure-package/.gitignore index 884834e3843e..c304e7926588 100644 --- a/contrib/clojure-package/.gitignore +++ b/contrib/clojure-package/.gitignore @@ -46,5 +46,6 @@ test/test-symbol.clj test/test-symbol-random.clj test/test-symbol-random-api.clj test/test-symbol-api.clj +test/test-images/* src/org/apache/clojure_mxnet/gen/* diff --git a/contrib/clojure-package/examples/infer/objectdetector/images/marcel.jpg b/contrib/clojure-package/examples/infer/objectdetector/images/marcel.jpg deleted file mode 100644 index 1bf7387e097d..000000000000 Binary files a/contrib/clojure-package/examples/infer/objectdetector/images/marcel.jpg and /dev/null differ diff --git a/contrib/clojure-package/scripts/get_test_images.sh b/contrib/clojure-package/scripts/get_test_images.sh new file mode 100755 index 000000000000..e85094848684 --- /dev/null +++ b/contrib/clojure-package/scripts/get_test_images.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -evx + +MXNET_ROOT=$(cd "$(dirname $0)/.."; pwd) + +image_path=$MXNET_ROOT/test/test-images + +if [ ! -d "$image_path" ]; then + mkdir -p "$image_path" +fi + +if [ ! -f "$image_path/kitten.jpg" ]; then + wget https://s3.us-east-2.amazonaws.com/mxnet-scala/scala-example-ci/resnet152/kitten.jpg -P $image_path + wget https://s3.amazonaws.com/model-server/inputs/Pug-Cookie.jpg -P $image_path +fi diff --git a/contrib/clojure-package/test/org/apache/clojure_mxnet/image_test.clj b/contrib/clojure-package/test/org/apache/clojure_mxnet/image_test.clj index fd200f18a78f..a5b68033678d 100644 --- a/contrib/clojure-package/test/org/apache/clojure_mxnet/image_test.clj +++ b/contrib/clojure-package/test/org/apache/clojure_mxnet/image_test.clj @@ -19,10 +19,14 @@ (:require [org.apache.clojure-mxnet.image :as image] [org.apache.clojure-mxnet.ndarray :as ndarray] [clojure.java.io :as io] - [clojure.test :refer [deftest is use-fixtures]]) + [clojure.test :refer [deftest is use-fixtures run-tests]] + [test-helper]) (:import (javax.imageio ImageIO) (java.io File))) + +(test-helper/load-test-images) + (def tmp-dir (System/getProperty "java.io.tmpdir")) (def image-path (.getAbsolutePath (io/file tmp-dir "Pug-Cookie.jpg"))) (def image-src-path "test/test-images/Pug-Cookie.jpg") diff --git a/contrib/clojure-package/test/org/apache/clojure_mxnet/infer/imageclassifier_test.clj b/contrib/clojure-package/test/org/apache/clojure_mxnet/infer/imageclassifier_test.clj index b7f468f341cd..5890f754033f 100644 --- a/contrib/clojure-package/test/org/apache/clojure_mxnet/infer/imageclassifier_test.clj +++ b/contrib/clojure-package/test/org/apache/clojure_mxnet/infer/imageclassifier_test.clj @@ -22,7 +22,10 @@ [org.apache.clojure-mxnet.ndarray :as ndarray] [clojure.java.io :as io] [clojure.java.shell :refer [sh]] - [clojure.test :refer :all])) + [clojure.test :refer :all] + [test-helper])) + +(test-helper/load-test-images) (def model-dir "data/") (def model-path-prefix (str model-dir "resnet-18/resnet-18")) diff --git a/contrib/clojure-package/test/test-images/Pug-Cookie.jpg b/contrib/clojure-package/test/test-images/Pug-Cookie.jpg deleted file mode 100644 index 56f5dc16ed7a..000000000000 Binary files a/contrib/clojure-package/test/test-images/Pug-Cookie.jpg and /dev/null differ diff --git a/contrib/clojure-package/test/test-images/kitten.jpg b/contrib/clojure-package/test/test-images/kitten.jpg deleted file mode 100644 index ffcd2be2c674..000000000000 Binary files a/contrib/clojure-package/test/test-images/kitten.jpg and /dev/null differ diff --git a/contrib/clojure-package/test/test_helper.clj b/contrib/clojure-package/test/test_helper.clj new file mode 100644 index 000000000000..1dda7871ad69 --- /dev/null +++ b/contrib/clojure-package/test/test_helper.clj @@ -0,0 +1,26 @@ +;; Licensed to the Apache Software Foundation (ASF) under one or more +;; contributor license agreements. See the NOTICE file distributed with +;; this work for additional information regarding copyright ownership. +;; The ASF licenses this file to You under the Apache License, Version 2.0 +;; (the "License"); you may not use this file except in compliance with +;; the License. You may obtain a copy of the License at +;; +;; http://www.apache.org/licenses/LICENSE-2.0 +;; +;; Unless required by applicable law or agreed to in writing, software +;; distributed under the License is distributed on an "AS IS" BASIS, +;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +;; See the License for the specific language governing permissions and +;; limitations under the License. +;; + + +(ns test-helper + (:require [clojure.java.io :as io] + [clojure.java.shell :refer [sh]])) + +(def data-dir "test/test-images/") + +(defn load-test-images [] + (when-not (.exists (io/file (str data-dir "Pug-Cookie.jpg"))) + (sh "./scripts/get_test_images.sh")))