]> git.ameliathe1st.gay Git - canal-guix.git/commitdiff
Ajout d'Openseeface. À faire: réellement packager onnxruntime
authorAmélia P. H. Coutard <amy@ameliathe1st.gay>
Wed, 6 Mar 2024 12:22:24 +0000 (13:22 +0100)
committerAmélia P. H. Coutard <amy@ameliathe1st.gay>
Wed, 6 Mar 2024 12:22:24 +0000 (13:22 +0100)
README
amy/packages/openseeface.scm [new file with mode: 0644]

diff --git a/README b/README
index 5ec3078d1aea854602ccfba1ea6129a612ecf706..1f65268fb85b5bd6e50c5652c0ab6483a06b91d2 100644 (file)
--- a/README
+++ b/README
@@ -4,6 +4,10 @@ Il est disponible sur le site https://www.ameliathe1st.gay.
 Projets:
        - Voyage Au Centre Des Fichiers: Un projet de μ-noyau, pour un système d'exploitation inspiré de Plan 9 et de l'ITS.
 
+Projets non-personels:
+       - Onnxruntime
+       - OpenSeeFace
+
 Ajoutez le à votre liste de canaux ainsi:
 ```
 (channel
diff --git a/amy/packages/openseeface.scm b/amy/packages/openseeface.scm
new file mode 100644 (file)
index 0000000..5ec8609
--- /dev/null
@@ -0,0 +1,165 @@
+; Copyright 2023 Amélia COUTARD.
+;
+; This file from the guix channel amy is free software: you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the Free Software Foundation,
+; either version 3 of the License, or (at your option) any later version.
+;
+; This channel is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+; PURPOSE. See the GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License along with this channel. If
+; not, see <https://www.gnu.org/licenses/>.
+
+(define-module (amy packages openseeface)
+  #:use-module (gnu packages cmake)
+  #:use-module (gnu packages commencement)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages elf)
+  #:use-module (gnu packages gcc)
+  #:use-module (gnu packages image-processing)
+  #:use-module (gnu packages protobuf)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages serialization)
+  #:use-module (gnu packages version-control)
+  #:use-module (guix)
+  #:use-module (guix build-system copy)
+  #:use-module (guix git-download)
+  #:use-module ((guix licenses)
+                #:select (bsd-2 expat))
+  #:export (openseeface))
+
+;; (define onnxruntime
+;;   (package
+;;     (name "onnxruntime")
+;;     (version "1.17.1")
+;;     (source
+;;      (origin
+;;        (method git-fetch)
+;;        (uri (git-reference
+;;              (url "https://github.com/microsoft/onnxruntime")
+;;              (commit (string-append "v" version))
+;;              (recursive? #t)))
+;;        (file-name (git-file-name name version))
+;;        (sha256
+;;         (base32 "02fwm3m4kgd8a6v4f7v2al25nbnlphzqlxrx44gcxx3k1kcb96n6"))))
+;;     (build-system pyproject-build-system)
+;;     (inputs (list cmake git))
+;;     (propagated-inputs (list python-coloredlogs
+;;                              python-flatbuffers
+;;                              python-numpy
+;;                              python-packaging
+;;                              python-protobuf
+;;                              python-sympy))
+;;     (arguments
+;;      (list
+;;       #:phases #~(modify-phases %standard-phases
+;;                    (add-after 'unpack 'cmake-version
+;;                      (lambda* (#:key #:allow-other-keys)
+;;                        (substitute* "cmake/CMakeLists.txt"
+;;                          (("3.26")
+;;                           "3.25"))))
+;;                    (replace 'build
+;;                      (lambda* (#:key #:allow-other-keys)
+;;                        (invoke "./build.sh" "--skip_submodule_sync"))))))
+;;     (synopsis "ML inferencing and training accelerator")
+;;     (description
+;;      "ONNX Runtime is a cross-platform inference and training machine-learning accelerator")
+;;     (home-page "https://onnxruntime.ai")
+;;     (license expat)))
+
+;; Downloading builds because it's a ***pain*** to build.
+(define onnxruntime
+  (package
+    (name "onnxruntime")
+    (version "1.17.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+              "https://files.pythonhosted.org/packages/3d/85/db9e2ccef45f1670013495084bf74db7b24e2edfd3d7be92211eb968e369/onnxruntime-" version
+              "-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl"))
+       (sha256
+        (base32 "1mxhqnppipav5v90cip55gs9wc2dxc45giqqdx7gav067ayd5g7b"))
+       (file-name (string-append "onnxruntime-built-v" version ".zip"))))
+    (inputs (list `(,gcc "lib")
+                  gcc-toolchain
+                  patchelf
+                  python
+                  unzip
+                  zlib))
+    (build-system copy-build-system)
+    (arguments
+     (list
+      #:phases #~(modify-phases %standard-phases
+                   (add-after 'unpack 'python-to-python3
+                     (lambda* (#:key #:allow-other-keys)
+                       (substitute* "quantization/calibrate.py"
+                         (("#!/usr/bin/env python")
+                          "#!/usr/bin/env python3"))))
+                   (add-before 'install 'patch-runpath
+                     (lambda* (#:key #:allow-other-keys)
+                       (invoke "patchelf" "--set-rpath"
+                        (string-join (list (string-append #$gcc:lib "/lib")
+                                           (string-append #$gcc-toolchain
+                                                          "/lib")) ":")
+                        "capi/libonnxruntime_providers_shared.so"
+                        "capi/onnxruntime_pybind11_state.cpython-310-x86_64-linux-gnu.so"))))
+      #:install-plan ''(("../onnxruntime" "lib/"))))
+    (synopsis "ML inferencing and training accelerator")
+    (description
+     "ONNX Runtime is a cross-platform inference and training machine-learning accelerator")
+    (home-page "https://onnxruntime.ai")
+    (license expat)))
+
+(define openseeface
+  (package
+    (name "openseeface")
+    (version "1.20.4")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://github.com/emilianavt/OpenSeeFace/archive/refs/tags/v"
+             version ".tar.gz"))
+       (sha256
+        (base32 "0jblygfzk36k1328ymglir4947ba1pmcg77ckwvixvjiji82lj2h"))))
+    (build-system copy-build-system)
+    (inputs (list onnxruntime
+                  opencv
+                  python
+                  python-flatbuffers
+                  python-numpy
+                  python-pillow))
+    (arguments
+     (list
+      #:phases #~(modify-phases %standard-phases
+                   (add-after 'unpack 'fix-py-shebang
+                     (lambda* (#:key #:allow-other-keys)
+                       (substitute* "facetracker.py"
+                         (("import copy")
+                          "#!/usr/bin/python3\nimport copy"))))
+                   (add-after 'install 'wrap
+                     (lambda* (#:key #:allow-other-keys)
+                       (invoke "chmod" "+x"
+                               (string-append #$output "/bin/facetracker.py"))
+                       (wrap-program (string-append #$output
+                                                    "/bin/facetracker.py")
+                         `("PYTHONPATH" =
+                           (,(getenv "GUIX_PYTHONPATH") ,(string-append #$output
+                                                          "/lib/openseeface") ,(string-append #$onnxruntime "/lib")))))))
+      #:install-plan ''(("facetracker.py" "bin/")
+                        ("models" "lib/openseeface/")
+                        ("input_reader.py" "lib/openseeface/")
+                        ("escapi.py" "lib/openseeface/")
+                        ("dshowcapture.py" "lib/openseeface/")
+                        ("remedian.py" "lib/openseeface/")
+                        ("retinaface.py" "lib/openseeface/")
+                        ("similaritytransform.py" "lib/openseeface/")
+                        ("tracker.py" "lib/openseeface/"))))
+    (synopsis "Realtime face tracking")
+    (description
+     "OpenSeeFace is a program for realtime face and facial landmark tracking on the CPU")
+    (home-page "https://github.com/emilianavt/OpenSeeFace")
+    (license bsd-2)))