This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns gigasquid.seaborn | |
(:require [libpython-clj.require :refer [require-python]] | |
[libpython-clj.python :as py :refer [py. py.. py.-]] | |
[gigasquid.plot :as plot] | |
[clojure.data.csv :as csv])) | |
(require-python '[seaborn :as sns]) | |
(require-python '[matplotlib.pyplot :as pyplot]) | |
(require-python '[pandas :as pandas]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns gigasquid.gpt2 | |
(:require [libpython-clj.require :refer [require-python]] | |
[libpython-clj.python :as py])) | |
;https://huggingface.co/transformers/quickstart.html - OpenAI GPT-2 | |
(require-python '(transformers)) | |
(require-python '(torch)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns gigasquid.mxnet | |
(:require [libpython-clj.require :refer [require-python]] | |
[libpython-clj.python :as py] | |
[clojure.string :as string])) | |
(require-python '(mxnet mxnet.ndarray mxnet.module mxnet.io)) | |
(require-python '(mxnet.test_utils)) | |
(require-python '(mxnet.initializer)) | |
(require-python '(mxnet.metric)) | |
(require-python '(mxnet.symbol)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
sudo apt-get update || true | |
sudo apt-get install -y build-essential | |
sudo apt-get install -y software-properties-common | |
sudo apt-get install -y libatlas-base-dev | |
sudo apt-get install -y libopenblas-dev | |
sudo apt-get install -y libcurl3 | |
sudo add-apt-repository ppa:timsc/opencv-3.4 | |
sudo apt-get update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[INFO] Scanning for projects... | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Reactor Build Order: | |
[INFO] | |
[INFO] MXNet Scala Package - Parent | |
[INFO] MXNet Scala Package - Initializer | |
[INFO] MXNet Scala Package - Initializer Native | |
[INFO] MXNet Scala Package - Macros | |
[INFO] MXNet Scala Package - Native | |
[INFO] MXNet Scala Package - Core |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns dev.generator | |
(:require [clojure.reflect :as r]) | |
(:import (org.apache.mxnet NDArray Symbol)) | |
(:gen-class)) | |
(->> (:members (r/reflect (Symbol/api))) | |
(filter #(clojure.string/includes? (:name %) "FullyConnected"))) | |
;;=> output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(as-> (sym/variable "data") data | |
(sym/fully-connected "fc1" {:data data :num-hidden 128}) | |
(sym/activation "relu1" {:data data :act-type "relu"}) | |
(sym/fully-connected "fc2" {:data data :num-hidden 64}) | |
(sym/activation "relu2" {:data data :act-type "relu"}) | |
(sym/fully-connected "fc3" {:data data :num-hidden 10}) | |
(sym/softmax-output "softmax" {:data data})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(predict "https://upload.wikimedia.org/wikipedia/commons/0/0c/American_Shorthair.jpg" true) | |
;; ({:prob 0.294283, :label "n02123045 tabby, tabby cat"} | |
;; {:prob 0.25543088, :label "n02122878 tabby, queen"} | |
;; {:prob 0.18031825, :label "n02123159 tiger cat"} | |
;; {:prob 0.06245274, :label "n01318894 pet"} | |
;; {:prob 0.04261507, :label "n02120997 feline, felid"}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn predict [img-url show?] | |
(let [mod (m/load-checkpoint {:prefix (str model-dir "/resnet-152") :epoch 0}) | |
labels (-> (slurp (str model-dir "/synset.txt")) | |
(string/split #"\n")) | |
nd-img (get-image img-url show?) | |
prob (-> mod | |
(m/bind {:for-training false | |
:data-shapes [{:name "data" :shape [1 num-channels h w]}]}) | |
(m/forward {:data [nd-img]}) | |
(m/outputs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns graal-test.core | |
(:import (org.graalvm.polyglot Context))) | |
(def py-context (Context/create (into-array ["python"]))) | |
(.eval py-context "python" "print('Hello polyglot world Python!');") | |
(.eval py-context "python" " | |
import time; | |
time.clock() | |
") ;=> #object[org.graalvm.polyglot.Value 0x4a6b3b70 "1.508202803249E9"] |
NewerOlder