hellonico commented on a change in pull request #13813: [WIP] examples with
opencv4/origami
URL: https://github.com/apache/incubator-mxnet/pull/13813#discussion_r247355210
##########
File path:
contrib/clojure-package/examples/neural-style/src/neural_style/core.clj
##########
@@ -41,63 +40,63 @@
(def model-path "model/vgg19.params")
(def max-long-edge 600) ;; resize the content image
(def style-weight 1) ;; the weight for the style image
-(def content-weight 5) ;; the weight for the content image
-(def blur-radius 1) ;; the blur filter radius
+(def content-weight 3) ;; the weight for the content image
+(def blur-radius 5) ;; the blur filter radius
(def output-dir "output")
(def lr 10.0) ;; the learning rate
(def tv-weight 0.01) ;; the magnitude on the tv loss
(def num-epochs 1000)
-(def num-channels 3)
-(defn image->ndarray [simg]
- (let [h (img/height simg)
- w (img/width simg)
- pixels (img/get-pixels simg)
- ;; normalize the pixels for vgg19
- rgb-pixels (reduce (fn [result pixel]
- (let [[rs gs bs] result
- [r g b _] (pixel/unpack-pixel pixel)]
- [(conj rs (- r 123.68))
- (conj gs (- g 116.779))
- (conj bs (- b 103.939))]))
- [[] [] []]
- pixels)]
- (println "The resized image is size " {:height h :width w})
- (-> rgb-pixels
- (flatten)
- (ndarray/array [1 num-channels h w]))))
+;;;;
+; IMAGE MANIPULATION
+;;;;
+
+(defn image->ndarray
+ "normalize the pixels for vgg19"
+ [simg]
+ (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)
Review comment:
its scaling the bytes to match the new format. (-128 > 128 instead of 0 >
255)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services