commit 818e1abf6d1602bc932ad9a1dfc7cf5856fe6e03 Author: henryruhs Date: Mon Nov 27 00:09:36 2023 +0100 Initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b88a39d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +indent_size = 4 +indent_style = tab +trim_trailing_whitespace = true diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..a2127bc --- /dev/null +++ b/.eslintrc @@ -0,0 +1,10 @@ +{ + "extends": + [ + "@isnotdefined/eslint-config/common" + ], + "parserOptions": + { + "ecmaVersion": 2020 + } +} diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..718d8a6 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: henryruhs +custom: https://paypal.me/henryruhs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..84decb6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,16 @@ +name: ci + +on: [ push, pull_request ] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Node 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + - run: npm install + - run: npm run lint diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84fae54 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea +.vscode +node_modules diff --git a/README.md b/README.md new file mode 100644 index 0000000..7e42d54 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +FaceFusion Pinokio +================== + +> Next generation face swapper and enhancer. + +[![Build Status](https://img.shields.io/github/actions/workflow/status/facefusion/facefusion-pinokio/ci.yml.svg?branch=master)](https://github.com/facefusion/facefusion-pinokio/actions?query=workflow:ci) diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..9ff7eb1 Binary files /dev/null and b/icon.png differ diff --git a/install.js b/install.js new file mode 100644 index 0000000..4a05b18 --- /dev/null +++ b/install.js @@ -0,0 +1,81 @@ +function install(kernel) +{ + const { platform, arch, gpu } = kernel; + + if (platform === 'darwin') + { + if (arch === 'arm64') + { + return 'python install.py --onnxruntime coreml-silicon --torch default'; + } + return 'python install.py --onnxruntime default --torch default'; + } + if (gpu === 'nvidia') + { + return 'python install.py --onnxruntime cuda --torch cuda'; + } + if (gpu === 'amd') + { + return 'python install.py --onnxruntime default --torch cpu'; + } + return 'python install.py --onnxruntime default --torch cpu'; +} + +module.exports = async kernel => +{ + const config = + { + requires: + [ + { + type: 'conda', + name: + [ + 'cmake', + 'ffmpeg' + ], + args: '-c conda-forge' + }, + { + gpu: 'nvidia', + name: 'cuda' + } + ], + run: + [ + { + method: 'shell.run', + params: + { + message: 'git clone https://github.com/facefusion/facefusion --branch next --single-branch' + } + }, + { + method: 'shell.run', + params: + { + message: install(kernel), + path: 'facefusion', + venv: 'env' + } + }, + { + method: 'input', + params: + { + title: 'Install complete', + description: 'Go back to the dashboard and launch the application.' + } + }, + { + method: 'browser.open', + params: + { + uri: '/?selected=facefusion' + } + } + ] + }; + + return config; +}; diff --git a/menu.js b/menu.js new file mode 100644 index 0000000..00d41e1 --- /dev/null +++ b/menu.js @@ -0,0 +1,106 @@ +module.exports = async kernel => +{ + const hasEnv = await kernel.exists(__dirname, 'facefusion', 'env'); + const hasRepo = await kernel.exists(__dirname, 'facefusion'); + + let menu = []; + + if (hasEnv && hasRepo) + { + if (kernel.running(__dirname, 'start.js')) + { + const session = await kernel.require(__dirname, 'session.json'); + + menu = + [ + { + icon: 'fa-solid fa-spin fa-circle-notch', + text: 'Running ' + session.mode + }, + { + icon: 'fa-solid fa-desktop', + text: 'Server', + href: 'start.js', + params: + { + fullscreen: true + } + } + ]; + if (session && session.url) + { + menu.push( + { + icon: 'fa-solid fa-rocket', + text: 'Open session', + href: session.url, + target: '_blank' + }); + } + return menu; + } + menu = + [ + { + icon: 'fa-solid fa-photo-film', + text: 'Launch default', + href: 'start.js', + params: + { + run: true, + fullscreen: true, + mode: 'Default' + } + }, + { + icon: 'fa-solid fa-gauge', + text: 'Launch benchmark', + href: 'start.js', + params: + { + run: true, + fullscreen: true, + mode: 'Benchmark' + } + }, + { + icon: 'fa-solid fa-webcam', + text: 'Launch webcam', + href: 'start.js', + params: + { + run: true, + fullscreen: true, + mode: 'Webcam' + } + }, + { + icon: 'fa-solid fa-rotate', + text: 'Update', + href: 'update.js', + params: + { + run: true, + fullscreen: true + } + } + ]; + } + else + { + menu = + [ + { + icon: 'fa-solid fa-plug', + text: 'Install', + href: 'install.js', + params: + { + run: true, + fullscreen: true + } + } + ]; + } + return menu; +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..3f59407 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "facefusion-pinokio", + "description": "Next generation face swapper and enhancer", + "version": "2.0.0", + "license": "MIT", + "devDependencies": + { + "@isnotdefined/eslint-config": "9.8.0", + "eslint": "8.54.0" + }, + "scripts": + { + "lint": "eslint . --ext=.js", + "fix": "npm run lint -- --fix" + } +} diff --git a/pinokio.js b/pinokio.js new file mode 100644 index 0000000..9324be2 --- /dev/null +++ b/pinokio.js @@ -0,0 +1,7 @@ +module.exports = +{ + title: 'FaceFusion Next', + description: 'Next generation face swapper and enhancer', + icon: 'icon.png', + menu: require(__dirname + '/menu.js') +}; diff --git a/start.js b/start.js new file mode 100644 index 0000000..b24b688 --- /dev/null +++ b/start.js @@ -0,0 +1,60 @@ +module.exports = () => +{ + const config = + { + daemon: true, + cmd: + { + Default: 'python run.py', + Benchmark: 'python run.py --ui-layouts benchmark', + Webcam: 'python run.py --ui-layouts webcam' + }, + run: + [ + { + method: 'local.set', + params: + { + mode: '{{input.mode}}' + } + }, + { + method: 'shell.run', + params: + { + message: '{{self.cmd[local.mode]}}', + path: 'facefusion', + venv: 'env', + on: + [ + { + event: '/(http:\/\/[0-9.:]+)/', + done: true + } + ] + } + }, + { + method: 'self.set', + params: + { + 'session.json': + { + mode: '{{local.mode}}', + url: '{{input.stdout.match(/(http:\\S+)/gi)[0]}}' + } + } + }, + { + method: 'browser.open', + params: + { + uri: '{{self.session.url}}', + target: '_blank' + } + } + ] + }; + + return config; +}; diff --git a/update.js b/update.js new file mode 100644 index 0000000..a414339 --- /dev/null +++ b/update.js @@ -0,0 +1,27 @@ +module.exports = () => +{ + const config = + { + run: + [ + { + method: 'shell.run', + params: + { + 'message': 'git pull' + } + }, + { + method: 'shell.run', + params: + { + message: 'git pull', + path: 'facefusion' + } + } + ] + }; + + return config; +}; +