Skip to content

Instantly share code, notes, and snippets.

@Krutonium
Last active September 17, 2024 01:56
Show Gist options
  • Save Krutonium/a29cc6631cf021165764f54bd3ba92f7 to your computer and use it in GitHub Desktop.
Save Krutonium/a29cc6631cf021165764f54bd3ba92f7 to your computer and use it in GitHub Desktop.
A shell.nix that runs OpenSeeFace automatically on anything that can run Nix. Great for use with VSeeFace!
let
pkgs = import <nixpkgs> {};
in pkgs.mkShell {
packages = [
(pkgs.python3.withPackages (python-pkgs: [
python-pkgs.onnxruntime
python-pkgs.opencv4
python-pkgs.pillow
python-pkgs.numpy
]))
pkgs.git
];
shellHook = ''
if [ -d "OpenSeeFace" ]; then
echo "Updating OpenSeeFace"
cd OpenSeeFace
git pull
else
echo "Cloning OpenSeeFace"
git clone https://github.com/emilianavt/OpenSeeFace.git
cd OpenSeeFace
fi
python facetracker.py -c 0 -W 1280 -H 720 -F 20 --discard-after 0 --scan-every 0 --no-3d-adapt 1 --max-feature-updates 900 --ip 127.0.0.1 --port 11573
exit
'';
}
{
description = "OpenSeeFace development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
pythonEnv = pkgs.python3.withPackages (python-pkgs: with python-pkgs; [
onnxruntime
opencv4
pillow
numpy
]);
in
{
devShells.default = pkgs.mkShell {
packages = [
pythonEnv
pkgs.git
];
shellHook = ''
if [ -d "OpenSeeFace" ]; then
echo "Updating OpenSeeFace"
cd OpenSeeFace
git pull
else
echo "Cloning OpenSeeFace"
git clone https://github.com/emilianavt/OpenSeeFace.git
cd OpenSeeFace
fi
python facetracker.py -c 0 -W 1280 -H 720 -F 20 --discard-after 0 --scan-every 0 --no-3d-adapt 1 --max-feature-updates 900 --ip 127.0.0.1 --port 11573
exit
'';
};
});
}
let
pkgs = import <nixpkgs> {};
in pkgs.mkShell {
packages = [
(pkgs.python3.withPackages (python-pkgs: [
python-pkgs.onnxruntime
python-pkgs.opencv4
python-pkgs.pillow
python-pkgs.numpy
]))
];
shellHook = ''
python facetracker.py -c 0 -W 1280 -H 720 -F 20 --discard-after 0 --scan-every 0 --no-3d-adapt 1 --max-feature-updates 900 --ip 127.0.0.1 --port 11573
exit
'';
}
@Krutonium
Copy link
Author

alsoshell.nix will also download and keep up to date OpenSeeFace. shell.nix will simply run it from the current directory.

Both are run by simply typing nix-shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment