Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
625b818d8c | ||
|
|
cbbc2d0705 | ||
|
|
6d74670556 | ||
|
|
61cbf4c624 | ||
|
|
cd39fea580 | ||
|
|
f77ddbd6a3 | ||
|
|
22b9b94679 | ||
|
|
64b2c72cf4 |
@@ -1,2 +0,0 @@
|
||||
[*]
|
||||
end_of_line = lf
|
||||
@@ -1,9 +1,7 @@
|
||||
name: 🐞 Bug Report
|
||||
title: '[bug] '
|
||||
title: "[bug] "
|
||||
description: Report a bug
|
||||
labels: ['type: 🐛 bug', 'status: 🧹 needs triage']
|
||||
assignees:
|
||||
- melMass
|
||||
labels: ["type: 🐛 bug", "status: 🧹 needs triage"]
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
@@ -12,8 +10,6 @@ body:
|
||||
## Before submiting an issue
|
||||
- Make sure to read the README & INSTALL instructions.
|
||||
- Please search for [existing issues](https://github.com/melMass/comfy_mtb/issues?q=is%3Aissue) around your problem before filing a report.
|
||||
- Optionally check the `#mtb-nodes` channel on the Banodoco discord:
|
||||
[](https://discord.gg/IAXhsabmDhn)
|
||||
|
||||
### Try using the debug mode to get more info
|
||||
|
||||
@@ -44,30 +40,16 @@ body:
|
||||
label: Expected behavior
|
||||
description: A clear description of what you expected to happen.
|
||||
|
||||
- type: dropdown
|
||||
id: os
|
||||
- type: textarea
|
||||
id: info
|
||||
attributes:
|
||||
label: Operating System
|
||||
description: What OS are you using?
|
||||
options:
|
||||
- Windows (Default)
|
||||
- Linux
|
||||
- Mac
|
||||
default: 0
|
||||
validations:
|
||||
required: true
|
||||
label: Platform and versions
|
||||
description: "informations about the environment you run Comfy in"
|
||||
render: sh
|
||||
placeholder: |
|
||||
- OS: [e.g. Linux]
|
||||
- Comfy Mode [e.g. custom env, standalone, google colab]
|
||||
|
||||
- type: dropdown
|
||||
id: comfy_mode
|
||||
attributes:
|
||||
label: Comfy Mode
|
||||
description: What flavor of Comfy do you use?
|
||||
options:
|
||||
- Comfy Portable (embed) (Default)
|
||||
- In a custom virtual env (venv, virtualenv, conda...)
|
||||
- Google Colab
|
||||
- Other (online services, containers etc..)
|
||||
default: 0
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
name: 📦 Publish to Comfy registry
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
publish-node:
|
||||
name: Publish Custom Node to registry
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: ♻️ Check out code
|
||||
uses: actions/checkout@v4
|
||||
- name: 📦 Publish Custom Node
|
||||
uses: Comfy-Org/publish-node-action@main
|
||||
with:
|
||||
personal_access_token: ${{ secrets.COMFY_REGISTRY_TOKEN }}
|
||||
+1
-7
@@ -2,10 +2,4 @@ __pycache__
|
||||
*.py[cod]
|
||||
*.onnx
|
||||
wheels/
|
||||
node_modules/
|
||||
compose.yaml
|
||||
comfy_mtb.wsb
|
||||
Dockerfile
|
||||
|
||||
# I store the gh-pages worktrees (src & build) there
|
||||
.worktrees
|
||||
node_modules/
|
||||
@@ -7,6 +7,3 @@
|
||||
[submodule "extern/frame_interpolation"]
|
||||
path = extern/frame_interpolation
|
||||
url = https://github.com/google-research/frame-interpolation
|
||||
[submodule "wiki"]
|
||||
path = wiki
|
||||
url = https://github.com/melMass/comfy_mtb.wiki.git
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
-- HACK: this should theorically not be needed since the lsp should read from the pyproject
|
||||
-- tried: ruff-lsp or basedpyright
|
||||
|
||||
local comfyRoot = vim.fn.expand("%:p:h:h:h")
|
||||
|
||||
if not vim.env.PYTHONPATH or vim.env.PYTHONPATH == "" then
|
||||
vim.env.PYTHONPATH = comfyRoot
|
||||
else
|
||||
vim.env.PYTHONPATH = vim.env.PYTHONPATH .. ";" .. comfyRoot
|
||||
end
|
||||
@@ -1,8 +0,0 @@
|
||||
default_language_version:
|
||||
python: python3.10
|
||||
repos:
|
||||
- repo: https://github.com/melmass/hooks
|
||||
rev: e8c6c18175ed4f6e30f23991de7989411e09c73b
|
||||
hooks:
|
||||
- id: fix-trailing-whitespace
|
||||
- id: bump-version
|
||||
-402
@@ -1,402 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
This is an automated changelog based on the commits in this repository.
|
||||
|
||||
Check the notes in the [releases](https://github.com/melMass/comfy_mtb/releases) for more information.
|
||||
## [main] - 2024-03-07
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- 🐛 font fallback ([9fccdee](https://github.com/melMass/comfy_mtb/commit/9fccdee82d721e88c64d2292c209fec869524dd2))
|
||||
- ✨ optional inputs of colored image ([cd32f26](https://github.com/melMass/comfy_mtb/commit/cd32f26b167088d6b489e43b260c187ea5e4d223)) by [@ScottNealon](https://github.com/ScottNealon) in [#147](https://github.com/melMass/comfy_mtb/pull/147)
|
||||
- 📝 adds a way to not load the imagefeed ([501c330](https://github.com/melMass/comfy_mtb/commit/501c3301056b2851555cccd75ab3ff15b1ab8e0c))
|
||||
- 🐛 colored image mask input ([30c4311](https://github.com/melMass/comfy_mtb/commit/30c4311b69f6481a34f968cb67a9b5ce5d2e9fda))
|
||||
- 🐛 handle font cache errors ([c43a661](https://github.com/melMass/comfy_mtb/commit/c43a661ba31dcd7720b4f32d8e96760e6191fbd9))
|
||||
- 💄 register the COLOR type even for external extensions ([12b134a](https://github.com/melMass/comfy_mtb/commit/12b134ab4c937c192aaf4a3667d9885dd4fe43ca))
|
||||
- ✨ mask crop output ([59a361a](https://github.com/melMass/comfy_mtb/commit/59a361af5870b8ffc984c6680dd3282d3553dcf9))
|
||||
- 🚑️ thread font loading ([e4da832](https://github.com/melMass/comfy_mtb/commit/e4da832b99bd640b72c31b67178a3168e3238fa0))
|
||||
- 📦 changed way of creating bbox from mask ([14ee9e2](https://github.com/melMass/comfy_mtb/commit/14ee9e23c009ab55fa3b2fc6ec60fb683c46d57d)) by [@Yurchikian](https://github.com/Yurchikian) in [#124](https://github.com/melMass/comfy_mtb/pull/124)
|
||||
- ✨ expose invert of bboxfrommask ([53cb503](https://github.com/melMass/comfy_mtb/commit/53cb503866da6d83b47eaeb8073039ace2ae0a95))
|
||||
- ✨ less strict csv parsing ([d5c4c5f](https://github.com/melMass/comfy_mtb/commit/d5c4c5f2649ecdb4bf7b517c5b33bbf8df753047))
|
||||
- 🐛 fit number regression ([c8658df](https://github.com/melMass/comfy_mtb/commit/c8658dfbdd3a0ca8c3e88cd1adfddc55c7444045))
|
||||
- 🐛 remove uneeded installs ([4e07450](https://github.com/melMass/comfy_mtb/commit/4e07450bcabb0105b5610e52f7d4692ea07f9c1d))
|
||||
- 🐛 import issue ([255ac03](https://github.com/melMass/comfy_mtb/commit/255ac036bab1d776301857843d0e7a85e9a9dcb8))
|
||||
- 🐛 wrong output for bbox ([8d12b59](https://github.com/melMass/comfy_mtb/commit/8d12b59844958fbc696d01d51162f97262664ae9))
|
||||
- 🚑️ fallback when symlink detection fails ([278f22c](https://github.com/melMass/comfy_mtb/commit/278f22c2093b6eca63d2d00f7936774918707e4e))
|
||||
- ✨ handle malformed styles.csv ([e6f6502](https://github.com/melMass/comfy_mtb/commit/e6f65026735770df8aced4a3acb75550ff1c84da))
|
||||
- 🐛 encoding ([5af2840](https://github.com/melMass/comfy_mtb/commit/5af284067c65042bcdfff04a5d5a2360bf9e4af7))
|
||||
- ⚡️ add the cli deps ([bb90e04](https://github.com/melMass/comfy_mtb/commit/bb90e0415f6a1ececbf468815dc0f5959d9a34e8))
|
||||
- 🚑️ check for symlink ([25b933c](https://github.com/melMass/comfy_mtb/commit/25b933c698b250a411549d2600fae49bec225b7a))
|
||||
- 🚑️ remove problematic dependencies ([5dfea51](https://github.com/melMass/comfy_mtb/commit/5dfea51dd8db2a4829e559eadeda22374b51c8a4))
|
||||
- 🐛 batch support ([f1ff9fc](https://github.com/melMass/comfy_mtb/commit/f1ff9fc7c4684ad673c3178df3b8142dcf0b16ac))
|
||||
- 🐛 automatically disable tiling if seamless is on ([4605f74](https://github.com/melMass/comfy_mtb/commit/4605f74f370d4d221ab1d50f21b72910fa6909c7))
|
||||
- 🐛 debug node ([dc500b7](https://github.com/melMass/comfy_mtb/commit/dc500b788e885205f017956da6a71a677f822941))
|
||||
- ⚡️ hack to handle prompt validation ([d49b257](https://github.com/melMass/comfy_mtb/commit/d49b2578c247dcba9b09b374d99f5cc45cac172d))
|
||||
- ✨ deepbump update ([87b245c](https://github.com/melMass/comfy_mtb/commit/87b245c6a6895490e3612b235879fa90b62dea2b))
|
||||
- 👷 user folder_paths to retrieve comfy root ([38df58a](https://github.com/melMass/comfy_mtb/commit/38df58a78c363ef2657011893d4d811676b1c664))
|
||||
- 🐛 typo ([90aee83](https://github.com/melMass/comfy_mtb/commit/90aee83797a863cf4797cdbe187f949061cbd176))
|
||||
- 🐛 do not resolve symlink for "here" ([a50b11b](https://github.com/melMass/comfy_mtb/commit/a50b11bdaa66f4e805811b1676c937ade11318c2))
|
||||
- ✏️ use Union to allow support for <3.10 ([88a2779](https://github.com/melMass/comfy_mtb/commit/88a277968745ac990406b14d300a8ada9c575b11)) by [@M1kep](https://github.com/M1kep) in [#91](https://github.com/melMass/comfy_mtb/pull/91)
|
||||
- ⚡️ simplify widgets cleanup ([cdd098e](https://github.com/melMass/comfy_mtb/commit/cdd098e10258401402b8023c9143532cfa4a1745))
|
||||
- ✨ don't assume the install was ran ([cc43654](https://github.com/melMass/comfy_mtb/commit/cc43654af2987bc8860557caa99cde91e8309b21))
|
||||
- 🐛 install ([616b2bf](https://github.com/melMass/comfy_mtb/commit/616b2bfc6c629cef1d30cb0d717bd805c3a086aa))
|
||||
- 🐛 properly escape paths ([22cac9b](https://github.com/melMass/comfy_mtb/commit/22cac9b2d95910197941b73e7548735470bd3b17))
|
||||
- 🐛 use relative paths in JS ([e2773ff](https://github.com/melMass/comfy_mtb/commit/e2773ff22e43e7756ad618344a03d661a576cf35))
|
||||
- 💄 BatchFromHistory when "listening" ([3b07984](https://github.com/melMass/comfy_mtb/commit/3b07984716402fbbf5da41020bf73befd52e7ebf))
|
||||
- ✨ save gif widget removal ([fe8f519](https://github.com/melMass/comfy_mtb/commit/fe8f519f8860b0610d8cafcd9b843b4171c2b3d4))
|
||||
|
||||
### Documentation
|
||||
|
||||
- 📝 add changelog ([0d817bf](https://github.com/melMass/comfy_mtb/commit/0d817bf326b4a22e2221264a414af50c3b7048b9))
|
||||
- 📄 add note+ screenshot ([90d9636](https://github.com/melMass/comfy_mtb/commit/90d96366c8b7637b55d1b4f88cb9aca217c1414b))
|
||||
- 📝 add cover image ([6b993b8](https://github.com/melMass/comfy_mtb/commit/6b993b84071bbb80ba1b8bd63576f31e35d05590))
|
||||
- 📝 fix image size ([3e8c2fe](https://github.com/melMass/comfy_mtb/commit/3e8c2fe789925e7017c2f8c8d9164c139588aba4))
|
||||
- 📝 add image ([3e93ea6](https://github.com/melMass/comfy_mtb/commit/3e93ea6f2c73353891b1a3f6223b5730bc69df37))
|
||||
- 📝 explain optional nodes ([cea0b08](https://github.com/melMass/comfy_mtb/commit/cea0b08eb044756ab1b408f630435095b8969d36))
|
||||
- 📝 add the example previews from the wiki ([8f90986](https://github.com/melMass/comfy_mtb/commit/8f909864bfaa9f2d0fbdcf3942eacb9d78ee8fb8))
|
||||
- 📝 update node list ([4917e31](https://github.com/melMass/comfy_mtb/commit/4917e31c427c74d28c830fd7b2423cab393ba0f8))
|
||||
- 📝 add some deprecation warnings and recommendations ([e11df9d](https://github.com/melMass/comfy_mtb/commit/e11df9d45c81d93f4334841de036b4aa3364375a))
|
||||
- 📝 add a reference to SlickComfy for colab ([bb35098](https://github.com/melMass/comfy_mtb/commit/bb35098c656b0b2d30909b83df0a3b65c5975f78))
|
||||
|
||||
### Features
|
||||
|
||||
- ✨ add "To Device" ([c28181f](https://github.com/melMass/comfy_mtb/commit/c28181f1615d2e183767aa76cc2350934330e546))
|
||||
- ✨ add note+ example ([90f3bc2](https://github.com/melMass/comfy_mtb/commit/90f3bc2d953b299ea34e9e3a925f1a824b488855))
|
||||
- 💄 node+ improvements ([4b29395](https://github.com/melMass/comfy_mtb/commit/4b29395000254382882c0d1be115b2ed80cd7c99))
|
||||
- 📝 add note plus ([605c8db](https://github.com/melMass/comfy_mtb/commit/605c8db320e1531c6347f6888606fa50d8eb268b))
|
||||
- 🚧 add playlist nodes ([cf96572](https://github.com/melMass/comfy_mtb/commit/cf965727e8e7064328704d88cd0410c61f1e686e))
|
||||
- 🚨 add missing node ([16c1a59](https://github.com/melMass/comfy_mtb/commit/16c1a59312b1d9841f5f8a814eff93a1ddf04edb))
|
||||
- ✨ Math Expression node ([142624e](https://github.com/melMass/comfy_mtb/commit/142624eea616a5622387b1b641c02605455ee6f1))
|
||||
- 🚀 add optional inputs to colored image ([049983d](https://github.com/melMass/comfy_mtb/commit/049983dbe2dbce6b772908468c4042d2bfde5eb2))
|
||||
- ✨ Add support for extra_model_paths.yaml ([d7b8ac8](https://github.com/melMass/comfy_mtb/commit/d7b8ac8e0c98b0d7a2e21889d35aad9f6b093560))
|
||||
- ✨ add batch shake ([af94203](https://github.com/melMass/comfy_mtb/commit/af94203d1b461d934ca1c44211ca0f71a5d05d48))
|
||||
- ✨ enhance concat images ([a798eb0](https://github.com/melMass/comfy_mtb/commit/a798eb07d0d891cfbd47013b442ef2fa3d7cc5bc))
|
||||
- 💄 add a few more batch nodes ([c1d42de](https://github.com/melMass/comfy_mtb/commit/c1d42de0fcde86d2a167fb4b5e781ee987814da2))
|
||||
- ✨ Batch node utilities ([cef5023](https://github.com/melMass/comfy_mtb/commit/cef5023efc17366a2e937ef43944de3587707fac))
|
||||
- 🚨 Image Stack node (horizontal and vertical stack) ([bb3277d](https://github.com/melMass/comfy_mtb/commit/bb3277d85f4ca21735cb1f5237cb1430db88c183))
|
||||
- 🚀 add seamless model hack ([21acc87](https://github.com/melMass/comfy_mtb/commit/21acc87ff0a84b7588f4b5aae0aeb5ae94bbbfbe))
|
||||
- 🔧 debug handle a few more types ([638498c](https://github.com/melMass/comfy_mtb/commit/638498c6b47c2b2cab82f76aec1f3d46df67f263))
|
||||
- 🎨 Add an editor for the styles loader ([2faa2f2](https://github.com/melMass/comfy_mtb/commit/2faa2f2a148a4dbf5525e4945f688a239f244546))
|
||||
- ✨ add a static assets path ([6a00d1d](https://github.com/melMass/comfy_mtb/commit/6a00d1da5a8a5fa47af1bf1ab5d3cd206c599841))
|
||||
- ✨ add Interpolate Clip Sequential ([a71c273](https://github.com/melMass/comfy_mtb/commit/a71c273baf450ad7e2a7e032451f015d3be3e9e9))
|
||||
|
||||
### Miscellaneous Tasks
|
||||
|
||||
- 🧹 applied some linting ([fe49312](https://github.com/melMass/comfy_mtb/commit/fe49312cbef03c6540304448fa88aa7a88391efa))
|
||||
- 📝 header links not parsed ([514c0d2](https://github.com/melMass/comfy_mtb/commit/514c0d2eda9990435eb18258d4bbd1aa137feb3d))
|
||||
- 📝 hardcode links in changelog ([915b744](https://github.com/melMass/comfy_mtb/commit/915b7444a9db83f349d83b636304af0d276f529f))
|
||||
- 🔖 local updates ([6c5e5d3](https://github.com/melMass/comfy_mtb/commit/6c5e5d36379bdab223b4503e42b7956b55a82ab0))
|
||||
- 📝 update node list ([dd27f99](https://github.com/melMass/comfy_mtb/commit/dd27f990c72fa94aff205eb314a8ea360f57479e))
|
||||
- ✨ update node_list ([537a0d8](https://github.com/melMass/comfy_mtb/commit/537a0d8108d0caa3ab2daeafd1d25d680214ef26))
|
||||
- ✨ local stuff ([9afad1a](https://github.com/melMass/comfy_mtb/commit/9afad1a1680073006d946be10f8c97b75ddfe253))
|
||||
- 📝 fix update issue template ([da290db](https://github.com/melMass/comfy_mtb/commit/da290dbcf2952a56be9334f7bf9dc4d8fa64a21d))
|
||||
- 📝 update issue template ([b949bb4](https://github.com/melMass/comfy_mtb/commit/b949bb406bc1929634600465ea389eaedefe6e6f))
|
||||
|
||||
### Refactor
|
||||
|
||||
- ⚡️ small local fixes ([bcac665](https://github.com/melMass/comfy_mtb/commit/bcac66508d2e788cc437da289d1ccede19465b8c))
|
||||
- 🗑️ remove unused code in install script ([5b75436](https://github.com/melMass/comfy_mtb/commit/5b75436610c6312adf47c6baa3e9fe9cc7d56dcf))
|
||||
|
||||
### Merge
|
||||
|
||||
- 🔀 pull request #109 from melMass/dev/0.2.0 ([87e301d](https://github.com/melMass/comfy_mtb/commit/87e301d120a542d5aabe544bec10d38dbd19b2f6)) in [#109](https://github.com/melMass/comfy_mtb/pull/109)
|
||||
- 🔀 pull request #86 from melMass/feature/styles-editor ([cbdb816](https://github.com/melMass/comfy_mtb/commit/cbdb816164900061ddaa1671f4287763d0b79ee1)) in [#86](https://github.com/melMass/comfy_mtb/pull/86)
|
||||
|
||||
### Wip
|
||||
|
||||
- 🚧 add text template node ([af2175a](https://github.com/melMass/comfy_mtb/commit/af2175a1fc0c2fb29ef3493f242fe45ec6fcabac))
|
||||
|
||||
## New Contributors
|
||||
* [@ScottNealon](https://github.com/ScottNealon) made their first contribution in [#147](https://github.com/melMass/comfy_mtb/pull/147)
|
||||
* [@Yurchikian](https://github.com/Yurchikian) made their first contribution in [#124](https://github.com/melMass/comfy_mtb/pull/124)
|
||||
* [@M1kep](https://github.com/M1kep) made their first contribution in [#91](https://github.com/melMass/comfy_mtb/pull/91)
|
||||
## [0.1.4] - 2023-08-12
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- 🚀 pending fixes ([ea5d73d](https://github.com/melMass/comfy_mtb/commit/ea5d73d48cfa4046f48a52609cff7f754d8364ed))
|
||||
- 🚑️ image resize infinite loop ([30d6cfe](https://github.com/melMass/comfy_mtb/commit/30d6cfe81292d0f7702544b3c2cbad1820c4a926))
|
||||
- ✨ update example files ([610afe0](https://github.com/melMass/comfy_mtb/commit/610afe031f21d737b2fd5128e4be7100b6666181))
|
||||
- 🐛 simplify install steps ([4fc84d6](https://github.com/melMass/comfy_mtb/commit/4fc84d615dd0f546442c3537f00c52366db4ca9b))
|
||||
- ✨ refactor ([8523392](https://github.com/melMass/comfy_mtb/commit/8523392df74c586dc940841ddbb5069943b16f7d))
|
||||
- 🐛 debug rgba ([40560f8](https://github.com/melMass/comfy_mtb/commit/40560f8154d3ddeabf708be4d111370648d466ac))
|
||||
- 🎨 rename fun to generate ([e7f72f9](https://github.com/melMass/comfy_mtb/commit/e7f72f9825da58254e3084b4ba91f76e6cf2cf5f))
|
||||
- ✨ refactor existing ([1144466](https://github.com/melMass/comfy_mtb/commit/11444662b9198861b62aff06a08b9c9ea01dd8bd))
|
||||
- ⚡️ move getbatchfromhistory to graphutils ([2eccba4](https://github.com/melMass/comfy_mtb/commit/2eccba4e33b21d1d080cb2f415f76a93488120f0))
|
||||
- 🚧 wip dependency installer UI ([630b492](https://github.com/melMass/comfy_mtb/commit/630b492347f75d7308b31a000061b41d7dfa4a10))
|
||||
- 🐛 image feed zorder ([0fb2d4d](https://github.com/melMass/comfy_mtb/commit/0fb2d4da90a7e65f82b3f9c8942a68e360456cf7))
|
||||
- ⬇️ download_antelopev2 ([4dd5321](https://github.com/melMass/comfy_mtb/commit/4dd532185223a1fa5978446e7bb75d32d77ebdb5))
|
||||
- 🚑️ frontend pushed too early ([91f60d4](https://github.com/melMass/comfy_mtb/commit/91f60d4c463c474ac10e868e8e73e13fa019856b))
|
||||
- 🚑️ missing input ([84ac8ac](https://github.com/melMass/comfy_mtb/commit/84ac8ac852aeb962029bfd8369fe5ed59a203977))
|
||||
- 🐛 shell command bug ([3d5075f](https://github.com/melMass/comfy_mtb/commit/3d5075fea2e219a179271c9810017c7e38bff6cc))
|
||||
- 🚑️ remove pipe mode from the install.py ([b854a30](https://github.com/melMass/comfy_mtb/commit/b854a302ce4708d2ad2dac249860308dbdcae5a6))
|
||||
- ⚡️ colab install ([36d8e6b](https://github.com/melMass/comfy_mtb/commit/36d8e6bdb06edab72ccfb686266d2e644a9f028c))
|
||||
- 🚑️ install typo ([ffa1a87](https://github.com/melMass/comfy_mtb/commit/ffa1a87b9184df5a3699a6118714b39d359bde4d))
|
||||
|
||||
### Documentation
|
||||
|
||||
- 📝 link the actual action instead of badge ([098d74a](https://github.com/melMass/comfy_mtb/commit/098d74a3cd8449d836569a074995e20d775c6728))
|
||||
- 📝 add action badge ([e74314b](https://github.com/melMass/comfy_mtb/commit/e74314b04eb218c140482ccf704b61af06db3f4d))
|
||||
|
||||
### Features
|
||||
|
||||
- 💫 export to prores -> export with ffmpeg ([a4d99d9](https://github.com/melMass/comfy_mtb/commit/a4d99d966b1207191243a9749385b998d1a9c6b1))
|
||||
- 🔥 add any to string & refactor ([dbdb872](https://github.com/melMass/comfy_mtb/commit/dbdb872b74e18c16feb44bd037abc3aafbb4700f))
|
||||
- ✨ add UI for interpolate clip sequential ([5ec5511](https://github.com/melMass/comfy_mtb/commit/5ec551143302b2a94ca82e477f684ecee23f1459))
|
||||
- ✨ add portable reqs ([3f14b16](https://github.com/melMass/comfy_mtb/commit/3f14b1676d28f5ffa1f47fda00b9bc244951045c))
|
||||
- ✨ add border extension ([fb64484](https://github.com/melMass/comfy_mtb/commit/fb644847ca434123e8e8e4991d33949fd31e3cbe))
|
||||
- ✨ use PIL for gif saving ([2bc7ae8](https://github.com/melMass/comfy_mtb/commit/2bc7ae88bf4cdfa575d11233c0e6f7b07f9dfd23))
|
||||
- 🎨 update node list ([a54d7d5](https://github.com/melMass/comfy_mtb/commit/a54d7d5346c272898dd4e67c65495de7325ab3a0))
|
||||
- ✨ install fix ([512de60](https://github.com/melMass/comfy_mtb/commit/512de6023e55f2cc47516bf44436efe22157273f)) in [#41](https://github.com/melMass/comfy_mtb/pull/41)
|
||||
|
||||
### Miscellaneous Tasks
|
||||
|
||||
- 💄 encoding ([49c64c7](https://github.com/melMass/comfy_mtb/commit/49c64c74eb3e99f456b563bbd79e3fe47a85c70d))
|
||||
- 🚀 only fetch controlnet_preprocessor deps ([414beb9](https://github.com/melMass/comfy_mtb/commit/414beb99a1f9bf719eca6ac139c9b2ccdfd6d743))
|
||||
- 🚀 add controlnetpreprocessors to tests ([63b3aec](https://github.com/melMass/comfy_mtb/commit/63b3aece2ba05adc2b655afeb41e3d47e7887b33))
|
||||
- ✨ remove unused input ([d4f791d](https://github.com/melMass/comfy_mtb/commit/d4f791d7a14ba9cb8abd7c95ba70b081fee5fb7c))
|
||||
- ✨ use the same cwd as manager ([2ff0467](https://github.com/melMass/comfy_mtb/commit/2ff04672daff773d52e1552dca1bf616bc32daa6))
|
||||
- 🎨 no brace glob ([bbfcb62](https://github.com/melMass/comfy_mtb/commit/bbfcb62c398de39058bcb6e18161425059d53e8e))
|
||||
- 🎨 extract txt ([a22fd01](https://github.com/melMass/comfy_mtb/commit/a22fd01d664276e4cd833ae1326feeece1d1deaf))
|
||||
- 🎨 also push wheels_order to releases ([8e5b776](https://github.com/melMass/comfy_mtb/commit/8e5b7765cc0c6730bd5517ccfd56e817ea39bd3a))
|
||||
- 🚧 more info for bug reports ([3dadc11](https://github.com/melMass/comfy_mtb/commit/3dadc119f44fca1029ec4b349d71ce99fb20a4b6))
|
||||
- ✨ individual wheels ([346ff64](https://github.com/melMass/comfy_mtb/commit/346ff649d50c9f0286ad2243938406fefb62853b))
|
||||
|
||||
### Refactor
|
||||
|
||||
- 🚧 tidy ([4f30829](https://github.com/melMass/comfy_mtb/commit/4f30829e06c41b3685644bfe7bece07e0bcfb70e))
|
||||
- ♻️ get batch from history ([13d255a](https://github.com/melMass/comfy_mtb/commit/13d255a730b08c4903647875350b9b3dcd61b4a6))
|
||||
|
||||
### Revert
|
||||
|
||||
- 💄 use BOOLEAN instead of BOOL ([cfb3b23](https://github.com/melMass/comfy_mtb/commit/cfb3b237cf64b512414a17f71e6d89c3355aa8ef))
|
||||
|
||||
### Testing
|
||||
|
||||
- 🧪 remove sha input ([c5bbe83](https://github.com/melMass/comfy_mtb/commit/c5bbe83008bb194cbd6ad5e3dc70cb3850b18985))
|
||||
- 🧪 ci for comfy embedded ([7b3afca](https://github.com/melMass/comfy_mtb/commit/7b3afca8179760e35e8a6fbf742080dee13e4fc7))
|
||||
|
||||
### Merge
|
||||
|
||||
- 🔀 pull request #50 from melMass/dev/august-refactor ([2ecd470](https://github.com/melMass/comfy_mtb/commit/2ecd4700d77c0727e6b5d2124e0a6ebd48ec96ed)) in [#50](https://github.com/melMass/comfy_mtb/pull/50)
|
||||
|
||||
## [0.1.3] - 2023-07-29
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- 🔥 manage pip from install only, remove requirements.txt ([247fbfb](https://github.com/melMass/comfy_mtb/commit/247fbfbc216b8259d607e0699d5b990b6a06ca71)) in [#38](https://github.com/melMass/comfy_mtb/pull/38)
|
||||
- 🎨 use image ratio for imagefeed ([f5cd56c](https://github.com/melMass/comfy_mtb/commit/f5cd56ce861c8c0a931744ae6cf2b96e9c8bca06))
|
||||
|
||||
### Documentation
|
||||
|
||||
- 📝 update imagefeed preview ([cbcacbe](https://github.com/melMass/comfy_mtb/commit/cbcacbe3c92ebb5f74d046b83504c3723710f130))
|
||||
- 📝 fix typo and add more details ([7c020ba](https://github.com/melMass/comfy_mtb/commit/7c020bab288aa7d17dc937b5f102319d43c3ebb3))
|
||||
|
||||
### Miscellaneous Tasks
|
||||
|
||||
- ✨ use wheel order if present ([9b24edd](https://github.com/melMass/comfy_mtb/commit/9b24eddd9c51004af08d7ac6ff2b6473dd3ee161))
|
||||
- ✨ store order of install for wheels ([5053142](https://github.com/melMass/comfy_mtb/commit/505314294f02e7c19ac95e4d0ed37fd397a54b46))
|
||||
|
||||
## [0.1.2] - 2023-07-28
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- ✨ various small things ([0e311cf](https://github.com/melMass/comfy_mtb/commit/0e311cf2c64cf2b4861d4cc612a3409390e3039a))
|
||||
- 📝 last release ([889f08c](https://github.com/melMass/comfy_mtb/commit/889f08c08b721be8fdb4e4d7eacc47169d5692d6)) in [#36](https://github.com/melMass/comfy_mtb/pull/36)
|
||||
- 📝 narrow requirements ([5d661b2](https://github.com/melMass/comfy_mtb/commit/5d661b2509fecf3940c3c0fab25b16ec0eae7a2d))
|
||||
- ✨ Separate FaceAnalysis model loading ([d143e83](https://github.com/melMass/comfy_mtb/commit/d143e83dba3bffa16e1b98d7ad1e9cf92dc94db2))
|
||||
- ⚡️ update examples to match wiki ([3dfe98c](https://github.com/melMass/comfy_mtb/commit/3dfe98c7957df48723380de85e1242a424ec23de))
|
||||
|
||||
### Documentation
|
||||
|
||||
- 📝 add readme for web extensions features ([be162a2](https://github.com/melMass/comfy_mtb/commit/be162a20477258627fa0d742c97a478bd085ff4f))
|
||||
- 📝 link to the proper lang instructions ([232cf89](https://github.com/melMass/comfy_mtb/commit/232cf8966cc20291b60c68f487dfd37bf6aa4dfa)) in [#33](https://github.com/melMass/comfy_mtb/pull/33)
|
||||
- 📝 update readmes ([96a0618](https://github.com/melMass/comfy_mtb/commit/96a0618c5990a8559a9e2dd17c868d3465b8ca90))
|
||||
|
||||
### Miscellaneous Tasks
|
||||
|
||||
- 🎉 bump version ([9e751a2](https://github.com/melMass/comfy_mtb/commit/9e751a242f4e9afee3dc5c871c414b29b9706ff6))
|
||||
- 👷 remove stale example ([c237737](https://github.com/melMass/comfy_mtb/commit/c2377374201fc34b107c8b7db1cdeb2f483d1e18))
|
||||
- 🐛 fix size ([c0cc557](https://github.com/melMass/comfy_mtb/commit/c0cc5572d8c727568eca8a3d0f116a1f540c31ff))
|
||||
|
||||
## [0.1.1] - 2023-07-24
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- 🎨 improve a bit the HTML response of endpoints ([50d51c7](https://github.com/melMass/comfy_mtb/commit/50d51c70d04e49e9df524975c171288c0fc0b20f))
|
||||
- 🐛 caching issues ([55c9736](https://github.com/melMass/comfy_mtb/commit/55c9736a9b2ca036926be4b06406121bfb9ebad2))
|
||||
- 🔥 remove notice ([abf1e82](https://github.com/melMass/comfy_mtb/commit/abf1e82adb9fac8cd70d5c409baad55309ef6fe1))
|
||||
- 🔥 use BOOL everywhere ([a393793](https://github.com/melMass/comfy_mtb/commit/a393793cfa93721eac46295723076a1dda940dcd))
|
||||
|
||||
### Documentation
|
||||
|
||||
- 📝 added lang links ([bbdac97](https://github.com/melMass/comfy_mtb/commit/bbdac97e49af4e90d22eeec3f63b96ecc126ffcf))
|
||||
- 📝 add comfyforum example ([10d0503](https://github.com/melMass/comfy_mtb/commit/10d05031b1791ab3534cf838be6eb75df638dfb6))
|
||||
|
||||
### Features
|
||||
|
||||
- 🚧 jupyter seems to require an __init__ there ([9a4eda3](https://github.com/melMass/comfy_mtb/commit/9a4eda3ef573bf382c13515f67ae8a415bf61abd))
|
||||
- ⚡️ use notify ([a2ecc11](https://github.com/melMass/comfy_mtb/commit/a2ecc11ebde79c2403959bf09c258f3a2465894a))
|
||||
- ✨ first version of Notify ([7e9c97e](https://github.com/melMass/comfy_mtb/commit/7e9c97ecb48672b25e5ed17b9b35dba9208ac311))
|
||||
- ⚡️ add an "actions" endpoint ([3de160a](https://github.com/melMass/comfy_mtb/commit/3de160af25b516c02aaa8cc32baec16e9ef358fb))
|
||||
- ✨ add Unsplash Image node ([8d3cc39](https://github.com/melMass/comfy_mtb/commit/8d3cc39b72dff1b5eb61bf7e2e395753c138ec8a))
|
||||
- ✨ add back Save Tensors ([7142b28](https://github.com/melMass/comfy_mtb/commit/7142b284adc7fba9a1bdafd1a52621bfc168bde1))
|
||||
- ✨ add TransformImage node ([11128ff](https://github.com/melMass/comfy_mtb/commit/11128ff85a7e0b4a54f405548969c2478da26df6))
|
||||
|
||||
### Miscellaneous Tasks
|
||||
|
||||
- 🚀 bump version ([cf86552](https://github.com/melMass/comfy_mtb/commit/cf865529ab64b350cd7af964b41160e7d130d12d))
|
||||
- 🚀 Remove large files from release ([3b9190a](https://github.com/melMass/comfy_mtb/commit/3b9190a69b002b8933c097fd6655bb4fe07264d2))
|
||||
|
||||
### Refactor
|
||||
|
||||
- ✨ cleaned up frontend code a bit ([3801a44](https://github.com/melMass/comfy_mtb/commit/3801a443bc1e89c70fdb35ce0b1724d86fa22928))
|
||||
- ⚡️ remove empty inits ([21729b2](https://github.com/melMass/comfy_mtb/commit/21729b2784a50fcaf24a63ac283bdae475a53ce7))
|
||||
|
||||
### Merge
|
||||
|
||||
- 🔀 pull request #32 from melMass/dev/next ([8695cd3](https://github.com/melMass/comfy_mtb/commit/8695cd3f1b6d27b5cd6c616ed1215ea2f25c5304)) in [#32](https://github.com/melMass/comfy_mtb/pull/32)
|
||||
|
||||
## [0.1.0] - 2023-07-22
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- 🔥 properly match built wheels ([119b4d6](https://github.com/melMass/comfy_mtb/commit/119b4d6e16c2a90db1664ccaac748507feb73ea0)) in [#30](https://github.com/melMass/comfy_mtb/pull/30)
|
||||
- ✨ also try to copy web if symlink fails ([0df55de](https://github.com/melMass/comfy_mtb/commit/0df55def29fb992751010f6b8a707699f230ff37))
|
||||
- ✨ install process tested in comfy-manager (embed, colab) ([b40730d](https://github.com/melMass/comfy_mtb/commit/b40730ddbc3f8e3e7d5a17e9e9e4526ff37977fd))
|
||||
- 🚀 try to support remote install too ([3c66de2](https://github.com/melMass/comfy_mtb/commit/3c66de2500a89efd2d2e3af88fc58429af725789))
|
||||
- 💄 save gif issues ([7335003](https://github.com/melMass/comfy_mtb/commit/7335003346e83666c5dee631b8e6b15586d871e7))
|
||||
- 🚑️ always use latest for now ([fccf313](https://github.com/melMass/comfy_mtb/commit/fccf31348994ab6e344a1ab00a8f9998309f9319))
|
||||
- 🐛 install logic ([7e301e2](https://github.com/melMass/comfy_mtb/commit/7e301e2a067d41cba9b8ef357496dd1df94e4cdd))
|
||||
- 🎉 remove tests & add missing docs ([4e6b877](https://github.com/melMass/comfy_mtb/commit/4e6b87719989aa144946c5c9a43b9398c20bf11e))
|
||||
- ⚡️ update node_list ([c794d6a](https://github.com/melMass/comfy_mtb/commit/c794d6a071778220d654b526d2edfddcc79752fc))
|
||||
- 🚑️ set debug level from endpoint ([18402e3](https://github.com/melMass/comfy_mtb/commit/18402e3be1ab47e10109cfd2dff18863a1ee56f7))
|
||||
- 🐛 add base64 prefix to outputs ([0950f99](https://github.com/melMass/comfy_mtb/commit/0950f9914c9bbed7c89f3de33a967cb76f9d0bbb))
|
||||
- 🎨 refactor and add Gif preview on node ([c2e8379](https://github.com/melMass/comfy_mtb/commit/c2e83794faeb8da708c98908882e38b2a42827bd))
|
||||
- ✨ Various widgets issues ([27500ca](https://github.com/melMass/comfy_mtb/commit/27500ca432d686774b991045b7cffc58c0b67faf))
|
||||
- 🔥 deprecate some nodes and fix image list ([9aa934f](https://github.com/melMass/comfy_mtb/commit/9aa934f70ff6adf91efb26aa8e5cb21ec575196a))
|
||||
- 🐛 crop nodes ([67d3783](https://github.com/melMass/comfy_mtb/commit/67d3783ac9186da6bba4b7dc7e8dc3d5db5a1b0f))
|
||||
- 🐛 tensor2pil ([8a59508](https://github.com/melMass/comfy_mtb/commit/8a59508ff91d6b2d9ca287ef1c054ec5755337a4))
|
||||
- ⚡️ a few missing __doc__ ([ab09cca](https://github.com/melMass/comfy_mtb/commit/ab09ccadd905bebbf1b7b2d992e96e36fc60d68a))
|
||||
- ⚡️ from tensor2np always returning a list ([6168b3a](https://github.com/melMass/comfy_mtb/commit/6168b3a2ac38b5eebed3daf9e52df5742abf6813))
|
||||
- 🚑️ TF by default fills vram ([c225da5](https://github.com/melMass/comfy_mtb/commit/c225da5f298acb4cb2b39022382543c0c966d428))
|
||||
- ✨ leftovers ([da3e6f4](https://github.com/melMass/comfy_mtb/commit/da3e6f47c6073e73cf9d3a3cd23ba5ccbe1fedce))
|
||||
- ✨ handle non fork gdown in model dll ([95797e8](https://github.com/melMass/comfy_mtb/commit/95797e823e12e62ae8758753f60c34afbe19ec90))
|
||||
- ✨ properly add the submodules ([00510ed](https://github.com/melMass/comfy_mtb/commit/00510ed0b8583dd64518daa67d963582f4f029d3))
|
||||
- 📌 remove sad talker for now ([1622cbc](https://github.com/melMass/comfy_mtb/commit/1622cbcb9d51ddd0e1a8b4d87ba47b99327163eb))
|
||||
- 🎨 narrow requirements ([1a92ef7](https://github.com/melMass/comfy_mtb/commit/1a92ef734dd4271efc875856038f9e3b6b9ded6c))
|
||||
- 🚀 use the comfy util to handle graph interruption ([9752f3e](https://github.com/melMass/comfy_mtb/commit/9752f3e9dec9aa59cfa809aa14f0151594c03858))
|
||||
- 🔥 much faster (using GPU) on windows ([2f455aa](https://github.com/melMass/comfy_mtb/commit/2f455aaca55c0a044735c768b295d077b2f5b8d6))
|
||||
- 🐛 uint8 to uint16 ([be5a655](https://github.com/melMass/comfy_mtb/commit/be5a655cfaba1794f7b09c82d65de42e2b031720))
|
||||
- ✨ add missing requirements ([b779bc3](https://github.com/melMass/comfy_mtb/commit/b779bc39ac19f779aeb73c98b916671d1d16806f))
|
||||
- 📝 don't propagate base logs ([7fd99c2](https://github.com/melMass/comfy_mtb/commit/7fd99c25c4e50566def5c5166a9d9059b1febfa6))
|
||||
- 🐛 bg upscaler in gfpgan ([fee48ad](https://github.com/melMass/comfy_mtb/commit/fee48adff3d66960cb17836f3f4efbfd0c8740c4))
|
||||
- 📝 separate debug / info better ([e24863d](https://github.com/melMass/comfy_mtb/commit/e24863d1f9f63f367a2b392e6228ffa42927b71b))
|
||||
- 🔥 change log level of the base logger ([7538c2c](https://github.com/melMass/comfy_mtb/commit/7538c2c4bad8390a32226dc0a5a6ef978b00d201))
|
||||
- ✨ handle externs dynamicly ([6ef308a](https://github.com/melMass/comfy_mtb/commit/6ef308a87062c91e2d7249c05d96c6fb76e5a6c4))
|
||||
- 🐛 separate faceswap model load ([8e267c0](https://github.com/melMass/comfy_mtb/commit/8e267c0204ce5abe8e113fd401234d49f377646a))
|
||||
|
||||
### Documentation
|
||||
|
||||
- 📝 fold each comfy mode ([3c3c438](https://github.com/melMass/comfy_mtb/commit/3c3c4380bd1a3f0eed5216b835e076c26fce2f88))
|
||||
- 📝 add more description to examples ([46eab5c](https://github.com/melMass/comfy_mtb/commit/46eab5ca2f0e04d872d87c849b11551fd219bdb9))
|
||||
- 📝 add model notice ([cbe67ed](https://github.com/melMass/comfy_mtb/commit/cbe67edd4befb7260be01fa09af8448e5bcf5680))
|
||||
- 📝 add preview for examples ([b5176ca](https://github.com/melMass/comfy_mtb/commit/b5176ca0ee489ada52b6632f68b794b4f709d5ba))
|
||||
- 📝 add jp and cn (using deep translation) ([da559b9](https://github.com/melMass/comfy_mtb/commit/da559b9eaf135a49c0ab9bfa45573baf0c18dfb2))
|
||||
- 📝 update readme ([b0fb522](https://github.com/melMass/comfy_mtb/commit/b0fb5222cb19e4004533d3367863be5c9ce8e72b)) in [#15](https://github.com/melMass/comfy_mtb/pull/15)
|
||||
- 📝 update README.md ([f8dc768](https://github.com/melMass/comfy_mtb/commit/f8dc768635a2d21f6ff81b42c418724c432159bf))
|
||||
- 📝 updated instructions ([c3b9fd4](https://github.com/melMass/comfy_mtb/commit/c3b9fd4afedbb46748aef17b40e167a4cfad65f5))
|
||||
|
||||
### Features
|
||||
|
||||
- ✨ update install instructions ([7be37db](https://github.com/melMass/comfy_mtb/commit/7be37dbbfac45e8038f94ced8a2fa8ec2b06fb34))
|
||||
- 🚀 add install script ([dad3966](https://github.com/melMass/comfy_mtb/commit/dad3966ba219c1998e4fc7f6e641864fb0e7c3e8))
|
||||
- 🚧 add my CLIs ([44eaae5](https://github.com/melMass/comfy_mtb/commit/44eaae5c79f4dbec344053d945e7275be5c3c0a5))
|
||||
- ✨comfy_widget shared utils ([91bb95d](https://github.com/melMass/comfy_mtb/commit/91bb95da914468de533b040324700c7f9707e4fb))
|
||||
- 🚀 debug node ([b27b8ef](https://github.com/melMass/comfy_mtb/commit/b27b8ef91fe7335b1df3766547edaf4b9625ae4d))
|
||||
- ✨ add FitNumber node ([aa551eb](https://github.com/melMass/comfy_mtb/commit/aa551ebe57801c69010815119fe21e19a858780c))
|
||||
- 🔥 add API endpoints ([95afbdb](https://github.com/melMass/comfy_mtb/commit/95afbdbf76e66897e632252d876384ada9acf153))
|
||||
- ✨ categorize ([d2b3962](https://github.com/melMass/comfy_mtb/commit/d2b396236a10fe620ebebabd5a22c36159921913))
|
||||
- 🚀 add a few examples ([b9c1d3d](https://github.com/melMass/comfy_mtb/commit/b9c1d3df7a1460fe9ffa84f6f9ea0cfb5409de1a))
|
||||
- ✨ added a way to export the node list ([5f5297f](https://github.com/melMass/comfy_mtb/commit/5f5297f80debc77f3fda2f0d37b3acff8419140d))
|
||||
- ✨ WIP batch from history ([cde7293](https://github.com/melMass/comfy_mtb/commit/cde72938d5ffd09179f5974676e12d4599a8d6ff))
|
||||
- ✨ extract node names using ast ([38f6147](https://github.com/melMass/comfy_mtb/commit/38f61473bc23b4c5d4efc5048d54c059565a6fa0))
|
||||
- 🔥 add batch support for load image sequence ([3faadc4](https://github.com/melMass/comfy_mtb/commit/3faadc4b8a5049cb8c264b8a3d50565adec405f1))
|
||||
- 🎨 add support for image.size(0) == 0 ([629e2b5](https://github.com/melMass/comfy_mtb/commit/629e2b5f5fbebe4e79e8b7a4cff2de6017e79225))
|
||||
- ✨ image feed ([99eb5ae](https://github.com/melMass/comfy_mtb/commit/99eb5ae0c7413f6ab1f24cfc8337c9b1b2d9824c))
|
||||
- ✨ FILM interpolation nodes ([e04e77e](https://github.com/melMass/comfy_mtb/commit/e04e77eb097735ec1369dec51238cdcc5abe39b7))
|
||||
- ✨ add an headless option for model downloads ([217e8a1](https://github.com/melMass/comfy_mtb/commit/217e8a1546d06b97250d99612ac6bdb5ce89e155))
|
||||
- 🐛 support batch count > 1 for restore face ([8ef48a0](https://github.com/melMass/comfy_mtb/commit/8ef48a013a8d6b832b8c0c7dcabc1b78c27ff207))
|
||||
- 🚧 wrapper for GFPGAN bg upscaler ([88cdcc6](https://github.com/melMass/comfy_mtb/commit/88cdcc6a87dae452924e8915eccdadc69d7d136e))
|
||||
- ✨ add GFPGAN (FaceRestore) ([3a6e545](https://github.com/melMass/comfy_mtb/commit/3a6e5450502f3b1d7c505178fc9ba337cd95c39e))
|
||||
|
||||
### Miscellaneous Tasks
|
||||
|
||||
- ✨ before categorize ([0cc54e5](https://github.com/melMass/comfy_mtb/commit/0cc54e58ec86c28354cae37e14f39e831c13ea02))
|
||||
- ✨ add more issue templates ([710a638](https://github.com/melMass/comfy_mtb/commit/710a638a8187ef08254478f684307dccdebcded2)) in [#25](https://github.com/melMass/comfy_mtb/pull/25)
|
||||
- ✨ add bug report template ([f927bc7](https://github.com/melMass/comfy_mtb/commit/f927bc7c9a82951e6df4763433732f20ea87e9cb))
|
||||
- 🍻 create FUNDING.yml ([f634fe0](https://github.com/melMass/comfy_mtb/commit/f634fe0e6b2db28138e4bd7932fbfc8606a0f033))
|
||||
- 🍻 add bmc to readme ([cd1b603](https://github.com/melMass/comfy_mtb/commit/cd1b603565464fe98a718e1fbaa8c7cd84057576))
|
||||
- 📝 extra files from another branch ([b78be8f](https://github.com/melMass/comfy_mtb/commit/b78be8fd3cd36666fd94a3ab08eca11cce526043))
|
||||
- 🚀 push leftovers ([4c41fe7](https://github.com/melMass/comfy_mtb/commit/4c41fe7af9f8e16d895eb06223349e1294dd4698))
|
||||
|
||||
### Refactor
|
||||
|
||||
- ♻️ removes a few nodes, moved other around ([4d8ddac](https://github.com/melMass/comfy_mtb/commit/4d8ddaca320ce483640d030618e70730b3453df2))
|
||||
- ♻️ remove test ([68c250e](https://github.com/melMass/comfy_mtb/commit/68c250e890dacae9f627b0d266ad6dcab0fa0c8b))
|
||||
- 🚧 remove color_widget ([e480d07](https://github.com/melMass/comfy_mtb/commit/e480d071171cffa789930620f1e7ccc76473bf93))
|
||||
|
||||
### Testing
|
||||
|
||||
- 🔧 pipe detection ([ee17d57](https://github.com/melMass/comfy_mtb/commit/ee17d57c3d6d71fda1a5acc2cf85f936c525bc87))
|
||||
|
||||
### Install
|
||||
|
||||
- 🚧 handle symlink errors ([d982b69](https://github.com/melMass/comfy_mtb/commit/d982b69a58c05ccead9c49370764beaa4549992a))
|
||||
|
||||
### Merge
|
||||
|
||||
- 🔀 pull request #22 from melMass/dev/next-release ([c34de0a](https://github.com/melMass/comfy_mtb/commit/c34de0ab351b2c95d7fa4fab4487155bee6bfa3a)) in [#22](https://github.com/melMass/comfy_mtb/pull/22)
|
||||
- 🎉 pull request #11 from dev/frame_interpolation ([1e28606](https://github.com/melMass/comfy_mtb/commit/1e28606427bcc8d895b87eaa6cd4147ab6d9a11f)) in [#11](https://github.com/melMass/comfy_mtb/pull/11)
|
||||
- 🎉 pull request #8 from dev/small-fixes ([7585624](https://github.com/melMass/comfy_mtb/commit/7585624de5895eb34c6a520d4dab18b47e64b6ca)) in [#8](https://github.com/melMass/comfy_mtb/pull/8)
|
||||
|
||||
## [0.0.1] - 2023-06-28
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- 🤦 add missing file ([e2c4561](https://github.com/melMass/comfy_mtb/commit/e2c456147c260b4e9d583662e3bb9d6d9a019a5e))
|
||||
- ✨ small edits ([bcf55ca](https://github.com/melMass/comfy_mtb/commit/bcf55ca9a3a07067be3319182501f7b635e5d2ba))
|
||||
- ⚡️ add support for batch in roop ([2dae020](https://github.com/melMass/comfy_mtb/commit/2dae02056a11ddfe1f84ee040818028177e404b5))
|
||||
- 🔥 various preparing for the first tag ([793784a](https://github.com/melMass/comfy_mtb/commit/793784a5fd08e8a70d670fc8edbc3bb5b6e13e67))
|
||||
- 🐛 various bugs ([afd0843](https://github.com/melMass/comfy_mtb/commit/afd08431458e3bbb14a25c84a87408113edf5db5))
|
||||
- ⚡️ add missing controls to QRCode ([7e86b0e](https://github.com/melMass/comfy_mtb/commit/7e86b0ed4d300021517f6c5cf28a45012497b5c5))
|
||||
|
||||
### Documentation
|
||||
|
||||
- 📝 add rembg screenshot ([9a2d523](https://github.com/melMass/comfy_mtb/commit/9a2d52325f87ecf6342ef4897da919006755b9db))
|
||||
- 📝 add a few screenshots ([e162336](https://github.com/melMass/comfy_mtb/commit/e162336cd366d39cd4b96f05b3c9c68eecec3dc4))
|
||||
- 📝 update readme ([7f3070d](https://github.com/melMass/comfy_mtb/commit/7f3070debbc3330da50ff845621ce299894cf862))
|
||||
|
||||
### Features
|
||||
|
||||
- 💄 faceswap node using roop ([966a14b](https://github.com/melMass/comfy_mtb/commit/966a14b40d88f4fccfb2eaa5ff9b222f0eedd7cb))
|
||||
- ✨ sync local changes ([647bf9e](https://github.com/melMass/comfy_mtb/commit/647bf9e94195c279a620c74c2253471b9c4b90f7))
|
||||
- ✨ bbox from alpha ([37abf8a](https://github.com/melMass/comfy_mtb/commit/37abf8aad12f4711c6d82c6be4be6fa3578e7af5))
|
||||
- ✨ a111 like style loader ([f59b68e](https://github.com/melMass/comfy_mtb/commit/f59b68e3ad92841a4d189d8dddf7b41e915c9b4e))
|
||||
- ✨ add a color type and widget ([9a2e986](https://github.com/melMass/comfy_mtb/commit/9a2e986327c34227a707beab6d9929b0a05e41e6))
|
||||
- ✨ add a few nodes ([811443b](https://github.com/melMass/comfy_mtb/commit/811443b92161815db1cdff81898e8834dcd6fbfa))
|
||||
- ✨ add SadTalker as a submodule ([3fb8716](https://github.com/melMass/comfy_mtb/commit/3fb871651b12bce62d8e911bd3884f417f80c937))
|
||||
- 🚨 push local changes ([6cac344](https://github.com/melMass/comfy_mtb/commit/6cac344f6fb15ebb902acee70ee71edc585ec4bc))
|
||||
- ⚡️ initial commit ([1ae3bbc](https://github.com/melMass/comfy_mtb/commit/1ae3bbc89ae6e0d2e8c61122485bd0df837e17c2))
|
||||
|
||||
### Miscellaneous Tasks
|
||||
|
||||
- 🚀 add gh action ([572b4d5](https://github.com/melMass/comfy_mtb/commit/572b4d52bce1398660d4d7ca0c5c48c11e0128e3)) in [#4](https://github.com/melMass/comfy_mtb/pull/4)
|
||||
|
||||
[main]: https://github.com/melMass/comfy_mtb/compare/v0.1.4..main
|
||||
[0.1.4]: https://github.com/melMass/comfy_mtb/compare/v0.1.3..v0.1.4
|
||||
[0.1.3]: https://github.com/melMass/comfy_mtb/compare/v0.1.2..v0.1.3
|
||||
[0.1.2]: https://github.com/melMass/comfy_mtb/compare/v0.1.1..v0.1.2
|
||||
[0.1.1]: https://github.com/melMass/comfy_mtb/compare/v0.1.0..v0.1.1
|
||||
[0.1.0]: https://github.com/melMass/comfy_mtb/compare/v0.0.1..v0.1.0
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# 安装
|
||||
- [安装](#安装)
|
||||
- [自动安装(推荐)](#自动安装推荐)
|
||||
- [ComfyUI 管理器](#comfyui-管理器)
|
||||
- [虚拟环境](#虚拟环境)
|
||||
- [模型下载](#模型下载)
|
||||
- [网络扩展](#网络扩展)
|
||||
- [旧的安装方法 (MANUAL)](#旧的安装方法-manual)
|
||||
- [依赖关系](#依赖关系)
|
||||
### 自动安装(推荐)
|
||||
|
||||
### ComfyUI 管理器
|
||||
|
||||
从 0.1.0 版开始,该扩展将使用 [ComfyUI-Manager](https://github.com/ltdrdata/ComfyUI-Manager) 进行安装,这对处理各种环境下的各种安装问题大有帮助。
|
||||
|
||||
### 虚拟环境
|
||||
还有一种试验性的单行安装方法,即在 ComfyUI 根目录下使用以下命令进行安装。它将下载代码、安装依赖项并运行安装脚本:
|
||||
|
||||
|
||||
```bash
|
||||
curl -sSL "https://raw.githubusercontent.com/username/repo/main/install.py" | python3 -
|
||||
```
|
||||
|
||||
## 模型下载
|
||||
某些节点需要下载额外的模型,您可以使用与上述相同的 python 环境以交互方式完成下载:
|
||||
|
||||
```bash
|
||||
python scripts/download_models.py
|
||||
```
|
||||
|
||||
然后根据提示或直接按回车键下载每个模型。
|
||||
|
||||
> **Note**
|
||||
> 您可以使用以下方法下载所有型号,无需提示:
|
||||
```bash
|
||||
python scripts/download_models.py -y
|
||||
```
|
||||
|
||||
#### 网络扩展
|
||||
|
||||
首次运行时,脚本会尝试将 [网络扩展](https://github.com/melMass/comfy_mtb/tree/main/web)链接到你的 "web/extensions "文件夹,[请参阅](https://github.com/melMass/comfy_mtb/blob/d982b69a58c05ccead9c49370764beaa4549992a/__init__.py#L45-L61)。
|
||||
|
||||
<img alt="color widget preview" src="https://github.com/melMass/comfy_mtb/assets/7041726/cff7e66a-4cc4-4866-b35b-10af0bb2d110" width=450>
|
||||
|
||||
### 旧的安装方法 (MANUAL)
|
||||
### 依赖关系
|
||||
<details><summary><h4>Custom Virtualenv(我主要用这个)</h4></summary
|
||||
|
||||
1. 确保您处于用于 ComfyUI 的 Python 环境中。
|
||||
2. 运行以下命令安装所需的依赖项:
|
||||
```bash
|
||||
pip install -r comfy_mtb/reqs.txt
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details><summary><h4>Comfy 便携式/单机版(来自 ComfyUI 版本)</h4></summary>
|
||||
|
||||
如果您使用 ComfyUI 单机版中的 `python-embeded `,那么当二进制文件没有轮子时,您就无法使用 pip 安装二进制文件的依赖项,在这种情况下,请查看最近的 [发布](https://github.com/melMass/comfy_mtb/releases),那里有一个预编译轮子的 linux 和 windows 捆绑包(只有那些需要从源代码编译的轮子),请查看 [此问题 (#1)](https://github.com/melMass/comfy_mtb/issues/1) 以获取更多信息。
|
||||

|
||||
|
||||
|
||||
</details>
|
||||
|
||||
<details><summary><h4>Google Colab</h4></summary>
|
||||
|
||||
在 **Run ComfyUI with localtunnel (Recommended Way)** 标题之后(代码单元格之前)添加一个新的代码单元格
|
||||
|
||||

|
||||
|
||||
|
||||
```python
|
||||
# download the nodes
|
||||
!git clone --recursive https://github.com/melMass/comfy_mtb.git custom_nodes/comfy_mtb
|
||||
|
||||
# download all models
|
||||
!python custom_nodes/comfy_mtb/scripts/download_models.py -y
|
||||
|
||||
# install the dependencies
|
||||
!pip install -r custom_nodes/comfy_mtb/reqs.txt -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.0/index.html
|
||||
```
|
||||
|
||||
如果运行后 colab 抱怨需要重新启动运行时,请重新启动,然后不要重新运行之前的单元格,只运行运行本地隧道的单元格。(可能需要先添加一个包含 `%cd ComfyUI` 的单元格)
|
||||
|
||||
|
||||
> **Note**:
|
||||
> If you don't need all models, remove the `-y` as collab actually supports user input: 
|
||||
|
||||
> **Preview**
|
||||
> 
|
||||
|
||||
</details>
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# インストール
|
||||
|
||||
- [インストール](#インストール)
|
||||
- [自動インストール (推奨)](#自動インストール-推奨)
|
||||
- [ComfyUI マネージャ](#comfyui-マネージャ)
|
||||
- [仮想環境](#仮想環境)
|
||||
- [モデルのダウンロード](#モデルのダウンロード)
|
||||
- [ウェブ拡張機能](#ウェブ拡張機能)
|
||||
- [旧インストール方法 (MANUAL)](#旧インストール方法-manual)
|
||||
- [依存関係](#依存関係)
|
||||
|
||||
|
||||
## 自動インストール (推奨)
|
||||
|
||||
### ComfyUI マネージャ
|
||||
|
||||
バージョン0.1.0では、この拡張機能は[ComfyUI-Manager](https://github.com/ltdrdata/ComfyUI-Manager)と一緒にインストールすることを想定しています。これは、様々な環境で直面する様々なインストール問題を処理するのに非常に役立ちます。
|
||||
|
||||
### 仮想環境
|
||||
また、ComfyUIのルートから以下のコマンドを使用する実験的なワンライナー・インストールもあります。これはコードをダウンロードし、依存関係をインストールし、インストールスクリプトを実行します:
|
||||
|
||||
```bash
|
||||
curl -sSL "https://raw.githubusercontent.com/username/repo/main/install.py" | python3 -
|
||||
```
|
||||
|
||||
## モデルのダウンロード
|
||||
ノードによっては、追加モデルのダウンロードが必要な場合があるので、上記と同じ python 環境を使って対話的に行うことができる:
|
||||
```bash
|
||||
python scripts/download_models.py
|
||||
```
|
||||
|
||||
プロンプトに従うか、Enterを押すだけで全てのモデルをダウンロードできます。
|
||||
|
||||
|
||||
> **Note**
|
||||
> プロンプトを出さずに全てのモデルをダウンロードするには、以下のようにします:
|
||||
```bash
|
||||
python scripts/download_models.py -y
|
||||
```
|
||||
|
||||
### ウェブ拡張機能
|
||||
|
||||
初回実行時にスクリプトは[web extensions](https://github.com/melMass/comfy_mtb/tree/main/web)をあなたの快適な `web/extensions` フォルダに[シンボリックリンク](https://github.com/melMass/comfy_mtb/blob/d982b69a58c05ccead9c49370764beaa4549992a/__init__.py#L45-L61)しようとします。万が一失敗した場合は、mtbフォルダを手動で`ComfyUI/web/extensions`にコピーしてください:
|
||||
|
||||
<img alt="color widget preview" src="https://github.com/melMass/comfy_mtb/assets/7041726/cff7e66a-4cc4-4866-b35b-10af0bb2d110" width=450>
|
||||
|
||||
## 旧インストール方法 (MANUAL)
|
||||
### 依存関係
|
||||
|
||||
<details><summary><h4>カスタム Virtualenv (私は主にこれを使っています)</h4></summary>
|
||||
|
||||
1. ComfyUIで使用しているPython環境であることを確認してください。
|
||||
2. 以下のコマンドを実行して、必要な依存関係をインストールします:
|
||||
```bash
|
||||
pip install -r comfy_mtb/reqs.txt
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details><summary><h4>Comfy-portable / standalone (ComfyUI リリースより)</h4></summary>。
|
||||
|
||||
もしあなたがComfyUIスタンドアロンから`python-embeded`を使用している場合、バイナリがホイールを持っていない場合、依存関係をpipでインストールすることができません。この場合、最後の[リリース](https://github.com/melMass/comfy_mtb/releases)をチェックしてください。(ソースからのビルドが必要なもののみ)あらかじめビルドされたホイールがあるlinuxとwindows用のバンドルがあります。詳細は[この問題(#1)](https://github.com/melMass/comfy_mtb/issues/1)をチェックしてください。
|
||||
|
||||

|
||||
|
||||
</details>
|
||||
|
||||
<details><summary><h4>Google Colab</h4></summary>
|
||||
|
||||
ComfyUI with localtunnel (Recommended Way)**ヘッダーのすぐ後(コードセルの前)に、新しいコードセルを追加してください。
|
||||

|
||||
|
||||
```python
|
||||
# download the nodes
|
||||
!git clone --recursive https://github.com/melMass/comfy_mtb.git custom_nodes/comfy_mtb
|
||||
|
||||
# download all models
|
||||
!python custom_nodes/comfy_mtb/scripts/download_models.py -y
|
||||
|
||||
# install the dependencies
|
||||
!pip install -r custom_nodes/comfy_mtb/reqs.txt -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.0/index.html
|
||||
```
|
||||
これを実行した後、colabがランタイムを再起動する必要があると文句を言ったら、それを実行し、それ以前のセルは再実行せず、localtunnelを実行するセルだけを再実行してください。(最初に`%cd ComfyUI`のセルを追加する必要があるかもしれません...)
|
||||
|
||||
|
||||
> **Note**:
|
||||
> すべてのモデルが必要でない場合は、`-y`を削除してください : 
|
||||
|
||||
> **プレビュー**
|
||||
> 
|
||||
|
||||
</details>
|
||||
|
||||
+7
-1
@@ -4,6 +4,7 @@
|
||||
- [ComfyUI Manager](#comfyui-manager)
|
||||
- [Virtual Env](#virtual-env)
|
||||
- [Models Download](#models-download)
|
||||
- [Web Extensions](#web-extensions)
|
||||
- [Old installation method (MANUAL)](#old-installation-method-manual)
|
||||
- [Dependencies](#dependencies)
|
||||
|
||||
@@ -34,6 +35,11 @@ then follow the prompt or just press enter to download every models.
|
||||
python scripts/download_models.py -y
|
||||
```
|
||||
|
||||
### Web Extensions
|
||||
|
||||
On first run the script [tries to symlink](https://github.com/melMass/comfy_mtb/blob/d982b69a58c05ccead9c49370764beaa4549992a/__init__.py#L45-L61) the [web extensions](https://github.com/melMass/comfy_mtb/tree/main/web) to your comfy `web/extensions` folder. In case it fails you can manually copy the mtb folder to `ComfyUI/web/extensions` it only provides a color widget for now shared by a few nodes:
|
||||
|
||||
<img alt="color widget preview" src="https://github.com/melMass/comfy_mtb/assets/7041726/cff7e66a-4cc4-4866-b35b-10af0bb2d110" width=450>
|
||||
|
||||
## Old installation method (MANUAL)
|
||||
### Dependencies
|
||||
@@ -42,7 +48,7 @@ then follow the prompt or just press enter to download every models.
|
||||
1. Make sure you are in the Python environment you use for ComfyUI.
|
||||
2. Install the required dependencies by running the following command:
|
||||
```bash
|
||||
pip install -r comfy_mtb/requirements.txt
|
||||
pip install -r comfy_mtb/reqs.txt
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# MTB Nodes
|
||||
|
||||
<a href="https://www.buymeacoffee.com/melmass" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 32px !important;width: 140px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
|
||||
|
||||
[** 安装指南**](./INSTALL-CN.md) | [** 示例**](https://github.com/melMass/comfy_mtb/wiki/Examples)
|
||||
|
||||
欢迎使用 MTB Nodes 项目!这个代码库是开放的,您可以自由地探索和利用。它的主要目的是构建用于 [MLOPs](https://github.com/Bismuth-Consultancy-BV/MLOPs) 中的概念验证(POCs)。该项目中的许多节点都是受到现有社区贡献或内置功能的启发而创建的。
|
||||
|
||||
在继续之前,请注意与此项目中使用的某些库相关的许可证。例如,`deepbump` 库采用 [GPLv3](https://github.com/HugoTini/DeepBump/blob/master/LICENSE) 许可证。
|
||||
|
||||
- [节点列表](#节点列表)
|
||||
- [bbox](#bbox)
|
||||
- [colors](#colors)
|
||||
- [人脸检测/交换](#人脸检测交换)
|
||||
- [图像插值(动画)](#图像插值动画)
|
||||
- [图像操作](#图像操作)
|
||||
- [潜在变量工具](#潜在变量工具)
|
||||
- [其他工具](#其他工具)
|
||||
- [纹理](#纹理)
|
||||
- [Comfy 资源](#comfy-资源)
|
||||
|
||||
|
||||
|
||||
|
||||
# 节点列表
|
||||
|
||||
## bbox
|
||||
- `Bounding Box`: BBox 构造函数(自定义类型)
|
||||
- `BBox From Mask`: 从遮罩中提取边界框
|
||||
- `Crop`: 根据边界框裁剪图像
|
||||
- `Uncrop`: 根据边界框还原图像
|
||||
|
||||
## colors
|
||||
- `Colored Image`: 给定尺寸的纯色图像
|
||||
- `RGB to HSV`: -
|
||||
- `HSV to RGB`: -
|
||||
- `Color Correct`: 基本颜色校正工具
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/7c20ac83-31ff-40ea-a1a0-06c2acefb2ef" width=345/>
|
||||
|
||||
## 人脸检测/交换
|
||||
- `Face Swap`: 使用 deepinsight/insightface 模型进行人脸交换(该节点在早期版本中称为 `Roop`,功能相同,`Roop` 只是使用这些模型的应用程序)
|
||||
> **注意**
|
||||
> 人脸索引允许您选择要替换的人脸,如下所示:
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/2e9d6066-c466-4a01-bd6c-315f7f1e8b42" width=320/>
|
||||
- `Load Face Swap Model`: 加载 insightface 模型用于人脸交换
|
||||
- `Restore Face`: 使用 [GFPGan](https://github.com/TencentARC/GFPGAN) 还原人脸,与 `Face Swap` 配合使用效果很好,并支持 `bg_upscaler` 的 Comfy 原生放大器
|
||||
|
||||
## 图像插值(动画)
|
||||
- `Load Film Model`: 加载 [FILM](https://github.com/google-research/frame-interpolation) 模型
|
||||
- `Film Interpolation`: 使用 [FILM](https://github.com/google-research/frame-interpolation) 处理输入帧
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/3afd1647-6634-4b92-a34b-51432e6a9834" width=400/>
|
||||
- `Export to Prores (experimental)`: 将输入帧导出为 ProRes 4444 mov 文件。这使用 ffmpeg stdin 发送原始的 NumPy 数组,与 `Film Interpolation` 一起使用,目前很简单,但可以进一步扩展。
|
||||
|
||||
## 图像操作
|
||||
- `Blur`: 使用高斯滤波器对图像进行模糊处理。
|
||||
- `Deglaze Image`: 从 [FN16](https://github.com/Fannovel16/FN16-ComfyUI-nodes/blob/main/DeglazeImage.py) 中提取
|
||||
- `Denoise`: 对输入图像进行降噪处理
|
||||
- `Image Compare`: 比较两个图像并返回差异图像
|
||||
- `Image Premultiply`: 使用掩码对图像进行预乘处理
|
||||
- `Image Remove Background Rembg`: 使用 [RemBG](https://github.com/danielgatis/rembg) 进行背景去除
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/e69253b4-c03c-45e9-92b5-aa46fb887be8" width=320/>
|
||||
- `Image Resize Factor`: 大部分提取自 [WAS Node Suite](https://github.com/WASasquatch/was-node-suite-comfyui),经过一些编辑(特别是支持多个图像)和较少的功能。
|
||||
- `Mask To Image`: 将遮罩(Alpha)转换为带有颜色和背景的 RGB 图像
|
||||
- `Save Image Grid`: 将输入批次中的所有图像保存为图像网格。
|
||||
|
||||
## 潜在变量工具
|
||||
- `Latent Lerp`: 两个潜在变量之间的线性插值(混合)
|
||||
|
||||
|
||||
## 其他工具
|
||||
- `Concat Images`: 接受两个图像流,并将它们合并为其他 Comfy 管道支持的图像批次。
|
||||
- `Image Resize Factor`: **已弃用**,因为我后来发现了内
|
||||
|
||||
置的图像调整大小功能。
|
||||
- `Text To Image`: 使用字体将文本转换为图像的工具
|
||||
- `Styles Loader`: 加载 csv 文件并从行中填充下拉列表(类似于 A111)
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/02fe3211-18ee-4e54-a029-931388f5fde8" width=320/>
|
||||
- `Smart Step`: 一个非常基本的节点,用于获取在 KSampler 高级中使用的步骤百分比
|
||||
- `Qr Code`: 基本的 QR Code 生成器
|
||||
- `Save Tensors`: 调试节点,将来可能会被删除
|
||||
- `Int to Number`: 用于 WASSuite 数字节点的补充
|
||||
- `Smart Step`: 使用百分比来控制 `KAdvancedSampler` 的步骤(开始/停止)
|
||||
|
||||
## 纹理
|
||||
|
||||
- `DeepBump`: 从单张图片生成法线图和高度图
|
||||
|
||||
# Comfy 资源
|
||||
|
||||
**指南**:
|
||||
- [官方示例(英文)](https://comfyanonymous.github.io/ComfyUI_examples/)
|
||||
- @BlenderNeko 的[ComfyUI 社区手册(英文)](https://blenderneko.github.io/ComfyUI-docs/)
|
||||
|
||||
- @tjhayasaka 的[Tomoaki 个人 Wiki(日文)](https://comfyui.creamlab.net/guides/)
|
||||
|
||||
**扩展和自定义节点**:
|
||||
- @WASasquatch 的[Comfy 列表插件(英文)](https://github.com/WASasquatch/comfyui-plugins)
|
||||
|
||||
- [CivitAI 上的 ComfyUI 标签(英文)](https://civitai.com/tag/comfyui)
|
||||
@@ -0,0 +1,96 @@
|
||||
# MTB Nodes
|
||||
|
||||
<a href="https://www.buymeacoffee.com/melmass" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 32px !important;width: 140px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
|
||||
|
||||
[**インストールガイド**](./INSTALL-JP.md) | [**サンプル**](https://github.com/melMass/comfy_mtb/wiki/Examples)
|
||||
|
||||
MTB Nodesプロジェクトへようこそ!このコードベースは、自由に探索し、利用することができます。主な目的は、[MLOPs](https://github.com/Bismuth-Consultancy-BV/MLOPs)の実装のための概念実証(POC)を構築することです。このプロジェクトの多くのノードは、既存のコミュニティの貢献や組み込みの機能に触発されています。
|
||||
|
||||
続行する前に、このプロジェクトで使用されている特定のライブラリに関連するライセンスに注意してください。たとえば、「deepbump」ライブラリは、[GPLv3](https://github.com/HugoTini/DeepBump/blob/master/LICENSE)の下でライセンスされています。
|
||||
|
||||
- [ノードリスト](#ノードリスト)
|
||||
- [bbox](#bbox)
|
||||
- [colors](#colors)
|
||||
- [顔検出 / スワッピング](#顔検出--スワッピング)
|
||||
- [画像補間(アニメーション)](#画像補間アニメーション)
|
||||
- [画像操作](#画像操作)
|
||||
- [潜在的なユーティリティ](#潜在的なユーティリティ)
|
||||
- [その他のユーティリティ](#その他のユーティリティ)
|
||||
- [テクスチャ](#テクスチャ)
|
||||
- [Comfyリソース](#comfyリソース)
|
||||
|
||||
|
||||
# ノードリスト
|
||||
|
||||
## bbox
|
||||
- `Bounding Box`: BBoxコンストラクタ(カスタムタイプ)
|
||||
- `BBox From Mask`: マスクからバウンディングボックスを抽出
|
||||
- `Crop`: BBoxから画像を切り抜く
|
||||
- `Uncrop`: BBoxから画像を元に戻す
|
||||
|
||||
## colors
|
||||
- `Colored Image`: 指定されたサイズの一定の色の画像
|
||||
- `RGB to HSV`: -
|
||||
- `HSV to RGB`: -
|
||||
- `Color Correct`: 基本的なカラーコレクションツール
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/7c20ac83-31ff-40ea-a1a0-06c2acefb2ef" width=345/>
|
||||
|
||||
## 顔検出 / スワッピング
|
||||
- `Face Swap`: deepinsight/insightfaceモデルを使用した顔の入れ替え(このノードは初期バージョンでは「Roop」と呼ばれていましたが、同じ機能を提供します。Roopは単にこれらのモデルを使用するアプリです)
|
||||
> **注意**
|
||||
> 顔のインデックスを使用して置き換える顔を選択できます。以下を参照してください:
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/2e9d6066-c466-4a01-bd6c-315f7f1e8b42" width=320/>
|
||||
- `Load Face Swap Model`: 顔の交換のためのinsightfaceモデルを読み込む
|
||||
- `Restore Face`: [GFPGan](https://github.com/TencentARC/GFPGAN)を使用して顔を復元し、`Face Swap`と組み合わせて使用すると非常に効果的であり、`bg_upscaler`のComfyネイティブアップスケーラーもサポートしています。
|
||||
|
||||
## 画像補間(アニメーション)
|
||||
- `Load Film Model`: [FILM](https://github.com/google-research/frame-interpolation)モデルを読み込む
|
||||
- `Film Interpolation`: [FILM](https://github.com/google-research/frame-interpolation)を使用して入力フレームを処理する
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/3afd1647-6634-4b92-a34b-51432e6a9834" width=400/>
|
||||
- `Export to Prores (experimental)`: 入力フレームをProRes 4444 movファイルにエクスポートします。これは現在は単純なものですが、`Film Interpolation`と組み合わせて使用するためのffmpegのstdinを使用して生のNumPy配列を送信するもので、拡張することもできます。
|
||||
|
||||
## 画像操作
|
||||
- `Blur`: ガウスフィルタを使用して画像をぼかす
|
||||
- `Deglaze Image`: [FN16](https://github.com/Fannovel16/FN16-ComfyUI-nodes/blob/main/DeglazeImage.py)から取得
|
||||
- `Denoise`: 入力画像のノイズを除去する
|
||||
- `Image Compare`: 2つの画像を比較し、差分画像を返す
|
||||
- `Image Premultiply`: 画像をマスクで乗算
|
||||
- `Image Remove Background Rembg`: [RemBG](https://github.com/danielgatis/rembg)を使用した背景除去
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/704172
|
||||
|
||||
6/e69253b4-c03c-45e9-92b5-aa46fb887be8" width=320/>
|
||||
- `Image Resize Factor`: [WAS Node Suite](https://github.com/WASasquatch/was-node-suite-comfyui)から抽出され、いくつかの編集(特に複数の画像のサポート)と機能の削減が行われました。
|
||||
- `Mask To Image`: マスク(アルファ)をカラーと背景を持つRGBイメージに変換します。
|
||||
- `Save Image Grid`: 入力バッチのすべての画像を画像グリッドとして保存します。
|
||||
|
||||
## 潜在的なユーティリティ
|
||||
- `Latent Lerp`: 2つの潜在的なベクトルの間の線形補間(ブレンド)
|
||||
|
||||
## その他のユーティリティ
|
||||
- `Concat Images`: 2つの画像ストリームを取り、他のComfyパイプラインでサポートされている画像のバッチとしてマージします。
|
||||
- `Image Resize Factor`: **非推奨**。組み込みの画像リサイズ機能を発見したため、削除される予定です。
|
||||
- `Text To Image`: フォントを使用してテキストを画像に変換するためのユーティリティ
|
||||
- `Styles Loader`: csvファイルをロードし、行からドロップダウンを作成します(A111のようなもの)
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/02fe3211-18ee-4e54-a029-931388f5fde8" width=320/>
|
||||
- `Smart Step`: KSamplerの高度な使用に使用するステップパーセントを取得する非常に基本的なノード
|
||||
- `Qr Code`: 基本的なQRコード生成器
|
||||
- `Save Tensors`: 将来的に削除される可能性のあるデバッグノード
|
||||
- `Int to Number`: WASSuiteの数値ノードの補完
|
||||
- `Smart Step`: `KAdvancedSampler`のステップ(開始/停止)を制御するための非常に基本的なツールで、パーセンテージを使用します。
|
||||
|
||||
## テクスチャ
|
||||
|
||||
- `DeepBump`: 1枚の画像から法線マップと高さマップを生成します。
|
||||
|
||||
# Comfyリソース
|
||||
|
||||
**ガイド**:
|
||||
- [公式の例(英語)](https://comfyanonymous.github.io/ComfyUI_examples/)
|
||||
- @BlenderNekoによる[ComfyUIコミュニティマニュアル(英語)](https://blenderneko.github.io/ComfyUI-docs/)
|
||||
|
||||
- @tjhayasakaによる[Tomoakiの個人Wiki(日本語)](https://comfyui.creamlab.net/guides/)
|
||||
|
||||
**拡張機能とカスタムノード**:
|
||||
- @WASasquatchによる[Comfyリスト用のプラグイン(英語)](https://github.com/WASasquatch/comfyui-plugins)
|
||||
|
||||
- [CivitAIのComfyUIタグ(英語)](https://civitai.com/tag/comfyui)
|
||||
@@ -1,11 +1,105 @@
|
||||
# MTB Nodes
|
||||
|
||||
[](https://github.com/melMass/comfy_mtb/actions/workflows/test_embedded.yml)
|
||||
|
||||

|
||||
|
||||
<!-- omit in toc -->
|
||||
|
||||
**Translated Readme (using DeepTranslate, PRs are welcome)**:
|
||||

|
||||
[日本語による説明](./README-JP.md)
|
||||

|
||||
[中文说明](./README-CN.md)
|
||||
|
||||
<a href="https://www.buymeacoffee.com/melmass" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 32px !important;width: 140px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
|
||||
|
||||
[**Wiki**](https://github.com/melMass/comfy_mtb/wiki) | [**Install Guide**](./INSTALL.md) | [**Examples**](https://github.com/melMass/comfy_mtb/wiki/Examples)
|
||||
[**Install Guide**](./INSTALL.md) | [**Examples**](https://github.com/melMass/comfy_mtb/wiki/Examples)
|
||||
|
||||
Welcome to the MTB Nodes project! This codebase is open for you to explore and utilize as you wish. Its primary purpose is to build proof-of-concepts (POCs) for implementation in [MLOPs](https://github.com/Bismuth-Consultancy-BV/MLOPs). Many nodes in this project are inspired by existing community contributions or built-in functionalities.
|
||||
|
||||
Before proceeding, please be aware of the licenses associated with certain libraries used in this project. For example, the `deepbump` library is licensed under [GPLv3](https://github.com/HugoTini/DeepBump/blob/master/LICENSE).
|
||||
|
||||
- [Node List](#node-list)
|
||||
- [bbox](#bbox)
|
||||
- [colors](#colors)
|
||||
- [face detection / swapping](#face-detection--swapping)
|
||||
- [image interpolation (animation)](#image-interpolation-animation)
|
||||
- [image ops](#image-ops)
|
||||
- [latent utils](#latent-utils)
|
||||
- [misc utils](#misc-utils)
|
||||
- [textures](#textures)
|
||||
- [Comfy Resources](#comfy-resources)
|
||||
|
||||
|
||||
# Node List
|
||||
|
||||
## bbox
|
||||
- `Bounding Box`: BBox constructor (custom type),
|
||||
- `BBox From Mask`: From a mask extract the bounding box
|
||||
- `Crop`: Crop image from BBox
|
||||
- `Uncrop`: Uncrop image from BBox
|
||||
|
||||
## colors
|
||||
- `Colored Image`: Constant color image of given size
|
||||
- `RGB to HSV`: -,
|
||||
- `HSV to RGB`: -,
|
||||
- `Color Correct`: Basic color correction tools
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/7c20ac83-31ff-40ea-a1a0-06c2acefb2ef" width=345/>
|
||||
|
||||
## face detection / swapping
|
||||
- `Face Swap`: Face swap using deepinsight/insightface models (this node used to be called `Roop` in early versions, it does the same, roop is *just* an app that uses those model)
|
||||
> **Note**
|
||||
> The face index allow you to choose which face to replace as you can see here:
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/2e9d6066-c466-4a01-bd6c-315f7f1e8b42" width=320/>
|
||||
- `Load Face Swap Model`: Load an insightface model for face swapping
|
||||
- `Restore Face`: Using [GFPGan](https://github.com/TencentARC/GFPGAN) to restore faces, works great in conjunction with `Face Swap` and supports Comfy native upscalers for the `bg_upscaler`
|
||||
|
||||
## image interpolation (animation)
|
||||
- `Load Film Model`: Loads a [FILM](https://github.com/google-research/frame-interpolation) model
|
||||
- `Film Interpolation`: Process input frames using [FILM](https://github.com/google-research/frame-interpolation)
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/3afd1647-6634-4b92-a34b-51432e6a9834" width=400/>
|
||||
- `Export to Prores (experimental)`: Exports the input frames to a ProRes 4444 mov file. This is using ffmpeg stdin to send raw numpy arrays, used with `Film Interpolation` and very simple for now but could be expanded upon.
|
||||
|
||||
## image ops
|
||||
- `Blur`: Blur an image using a Gaussian filter.
|
||||
- `Deglaze Image`: taken from [FN16](https://github.com/Fannovel16/FN16-ComfyUI-nodes/blob/main/DeglazeImage.py),
|
||||
- `Denoise`: Denoise the input image,
|
||||
- `Image Compare`: Compare two images and return a difference image
|
||||
- `Image Premultiply`: Premultiply image with mask
|
||||
- `Image Remove Background Rembg`: [RemBG](https://github.com/danielgatis/rembg) powered background removal.
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/e69253b4-c03c-45e9-92b5-aa46fb887be8" width=320/>
|
||||
- `Image Resize Factor`: Extracted mostly from [WAS Node Suite](https://github.com/WASasquatch/was-node-suite-comfyui), with a few edits (most notably multiple image support) and less features.
|
||||
- `Mask To Image`: Converts a mask (alpha) to an RGB image with a color and background
|
||||
- `Save Image Grid`: Save all the images in the input batch as a grid of images.
|
||||
|
||||
## latent utils
|
||||
- `Latent Lerp`: Linear interpolation (blend) between two latent
|
||||
|
||||
|
||||
## misc utils
|
||||
- `Concat Images`: Takes two image stream and merge them as a batch of images supported by other Comfy pipelines.
|
||||
- `Image Resize Factor`: **Deprecated**, I since discovered the builtin image resize.
|
||||
- `Text To Image`: Utils to convert text to image using a font
|
||||
- `Styles Loader`: Load csv files and populate a dropdown from the rows (à la A111)
|
||||
<img src="https://github.com/melMass/comfy_mtb/assets/7041726/02fe3211-18ee-4e54-a029-931388f5fde8" width=320/>
|
||||
- `Smart Step`: A very basic node to get step percent to use in KSampler advanced,
|
||||
- `Qr Code`: Basic QR Code generator
|
||||
- `Save Tensors`: Debug node that will probably be removed in the future
|
||||
- `Int to Number`: Supplement for WASSuite number nodes
|
||||
- `Smart Step`: A very basic tool to control the steps (start/stop) of the `KAdvancedSampler` using percentage
|
||||
|
||||
## textures
|
||||
|
||||
- `DeepBump`: Normal & height maps generation from single pictures
|
||||
|
||||
# Comfy Resources
|
||||
|
||||
**Guides**:
|
||||
- [Official Examples (eng)](https://comfyanonymous.github.io/ComfyUI_examples/)
|
||||
- [ComfyUI Community Manual (eng)](https://blenderneko.github.io/ComfyUI-docs/) by @BlenderNeko
|
||||
|
||||
- [Tomoaki's personal Wiki (jap)](https://comfyui.creamlab.net/guides/) by @tjhayasaka
|
||||
|
||||
**Extensions and Custom Nodes**:
|
||||
- [Plugins for Comfy List (eng)](https://github.com/WASasquatch/comfyui-plugins) by @WASasquatch
|
||||
|
||||
- [ComfyUI tag on CivitAI (eng)](https://civitai.com/tag/comfyui)
|
||||
|
||||
+108
-348
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*-
|
||||
###
|
||||
# File: __init__.py
|
||||
# Project: comfy_mtb
|
||||
@@ -6,47 +7,35 @@
|
||||
# Copyright (c) 2023 Mel Massadian
|
||||
#
|
||||
###
|
||||
|
||||
__version__ = "0.2.0"
|
||||
|
||||
import os
|
||||
|
||||
from aiohttp.web_request import Request
|
||||
# todo: don't override this if the user has that setup already
|
||||
os.environ["TF_FORCE_GPU_ALLOW_GROWTH"] = "true"
|
||||
os.environ["TF_GPU_ALLOCATOR"] = "cuda_malloc_async"
|
||||
|
||||
# TODO: don't override this if the user has that setup already
|
||||
if not os.environ.get("TF_FORCE_GPU_ALLOW_GROWTH"):
|
||||
os.environ["TF_FORCE_GPU_ALLOW_GROWTH"] = "true"
|
||||
|
||||
if not os.environ.get("TF_GPU_ALLOCATOR"):
|
||||
os.environ["TF_GPU_ALLOCATOR"] = "cuda_malloc_async"
|
||||
|
||||
import ast
|
||||
import contextlib
|
||||
import importlib
|
||||
import json
|
||||
import logging
|
||||
import shutil
|
||||
import traceback
|
||||
from importlib import reload
|
||||
from pathlib import Path
|
||||
from .log import log, blue_text, cyan_text, get_summary, get_label
|
||||
from .utils import here
|
||||
from .utils import comfy_dir
|
||||
import importlib
|
||||
import os
|
||||
import ast
|
||||
import json
|
||||
|
||||
from aiohttp import web
|
||||
from server import PromptServer
|
||||
NODE_CLASS_MAPPINGS = {}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {}
|
||||
NODE_CLASS_MAPPINGS_DEBUG = {}
|
||||
|
||||
from .endpoint import endlog
|
||||
from .log import blue_text, cyan_text, get_label, get_summary, log
|
||||
from .utils import comfy_dir, here
|
||||
|
||||
NODE_CLASS_MAPPINGS: dict[str, type] = {}
|
||||
NODE_DISPLAY_NAME_MAPPINGS: dict[str, str] = {}
|
||||
NODE_CLASS_MAPPINGS_DEBUG: dict[str, str | None] = {}
|
||||
WEB_DIRECTORY = "./web"
|
||||
__version__ = "0.1.4"
|
||||
|
||||
|
||||
def extract_nodes_from_source(filename: Path):
|
||||
def extract_nodes_from_source(filename):
|
||||
source_code = ""
|
||||
source_code = filename.read_text(encoding="utf-8")
|
||||
nodes: list[str] = []
|
||||
|
||||
with open(filename, "r") as file:
|
||||
source_code = file.read()
|
||||
|
||||
nodes = []
|
||||
|
||||
try:
|
||||
parsed = ast.parse(source_code)
|
||||
@@ -55,24 +44,23 @@ def extract_nodes_from_source(filename: Path):
|
||||
target = node.targets[0]
|
||||
if isinstance(target, ast.Name) and target.id == "__nodes__":
|
||||
value = ast.get_source_segment(source_code, node.value)
|
||||
if value:
|
||||
node_value = ast.parse(value).body[0].value
|
||||
if isinstance(node_value, ast.List | ast.Tuple):
|
||||
nodes.extend(
|
||||
str(element.id)
|
||||
for element in node_value.elts
|
||||
if isinstance(element, ast.Name)
|
||||
)
|
||||
break
|
||||
node_value = ast.parse(value).body[0].value
|
||||
if isinstance(node_value, (ast.List, ast.Tuple)):
|
||||
nodes.extend(
|
||||
element.id
|
||||
for element in node_value.elts
|
||||
if isinstance(element, ast.Name)
|
||||
)
|
||||
break
|
||||
except SyntaxError:
|
||||
log.error("Failed to parse")
|
||||
return nodes
|
||||
|
||||
|
||||
def load_nodes():
|
||||
errors: list[str] = []
|
||||
nodes: list[type] = []
|
||||
nodes_failed: list[str] = []
|
||||
errors = []
|
||||
nodes = []
|
||||
nodes_failed = []
|
||||
|
||||
for filename in (here / "nodes").iterdir():
|
||||
if filename.suffix == ".py":
|
||||
@@ -82,16 +70,14 @@ def load_nodes():
|
||||
module = importlib.import_module(
|
||||
f".nodes.{module_name}", package=__package__
|
||||
)
|
||||
_nodes = getattr(module, "__nodes__", [])
|
||||
_nodes = getattr(module, "__nodes__")
|
||||
nodes.extend(_nodes)
|
||||
log.debug(f"Imported {module_name} nodes")
|
||||
|
||||
except AttributeError:
|
||||
log.debug(f"Skipping wip module {module_name}")
|
||||
pass # wip nodes
|
||||
except Exception:
|
||||
error_message = traceback.format_exc().splitlines()[-1]
|
||||
|
||||
errors.append(
|
||||
f"Failed to import module {module_name} because {error_message}"
|
||||
)
|
||||
@@ -99,8 +85,8 @@ def load_nodes():
|
||||
nodes_failed.extend(extract_nodes_from_source(filename))
|
||||
|
||||
if errors:
|
||||
log.debug(
|
||||
"Some nodes failed to load:\n\t"
|
||||
log.info(
|
||||
f"Some nodes failed to load:\n\t"
|
||||
+ "\n\t".join(errors)
|
||||
+ "\n\n"
|
||||
+ "Check that you properly installed the dependencies.\n"
|
||||
@@ -111,94 +97,66 @@ def load_nodes():
|
||||
|
||||
|
||||
# - REGISTER WEB EXTENSIONS
|
||||
def uninstall_old_web_extensions():
|
||||
web_extensions_root = comfy_dir / "web" / "extensions"
|
||||
web_mtb = web_extensions_root / "mtb"
|
||||
web_extensions_root = comfy_dir / "web" / "extensions"
|
||||
web_mtb = web_extensions_root / "mtb"
|
||||
|
||||
if web_mtb.exists() and hasattr(nodes, "EXTENSION_WEB_DIRS"):
|
||||
if web_mtb.exists():
|
||||
log.debug(f"Web extensions folder found at {web_mtb}")
|
||||
if not os.path.islink(web_mtb.as_posix()):
|
||||
log.warn(
|
||||
f"Web extensions folder at {web_mtb} is not a symlink, if updating please delete it before"
|
||||
)
|
||||
|
||||
|
||||
elif web_extensions_root.exists():
|
||||
web_tgt = here / "web"
|
||||
src = web_tgt.as_posix()
|
||||
dst = web_mtb.as_posix()
|
||||
try:
|
||||
if os.name == "nt":
|
||||
import _winapi
|
||||
|
||||
_winapi.CreateJunction(src, dst)
|
||||
else:
|
||||
os.symlink(web_tgt.as_posix(), web_mtb.as_posix())
|
||||
|
||||
except OSError:
|
||||
log.warn(f"Failed to create symlink to {web_mtb}, trying to copy it")
|
||||
try:
|
||||
if web_mtb.is_symlink():
|
||||
web_mtb.unlink()
|
||||
else:
|
||||
shutil.rmtree(web_mtb)
|
||||
import shutil
|
||||
|
||||
shutil.copytree(web_tgt, web_mtb)
|
||||
log.info(f"Successfully copied {web_tgt} to {web_mtb}")
|
||||
except Exception as e:
|
||||
log.warning(
|
||||
f"""Failed to remove web mtb directory: {e}
|
||||
Please manually remove it from disk ({web_mtb}) and restart the server."""
|
||||
log.warn(
|
||||
f"Failed to symlink and copy {web_tgt} to {web_mtb}. Please copy the folder manually."
|
||||
)
|
||||
log.warn(e)
|
||||
|
||||
|
||||
# uninstall_old_web_extensions()
|
||||
|
||||
|
||||
# - GATHER WIKI PAGES
|
||||
def wiki_to_classname(s: str):
|
||||
wiki_name = s.replace("nodes-", "", 1)
|
||||
return "MTB_" + "".join(
|
||||
[part.capitalize() for part in wiki_name.split("-")]
|
||||
except Exception as e:
|
||||
log.warn(
|
||||
f"Failed to create symlink to {web_mtb}. Please copy the folder manually."
|
||||
)
|
||||
log.warn(e)
|
||||
else:
|
||||
log.warn(
|
||||
f"Comfy root probably not found automatically, please copy the folder {web_mtb} manually in the web/extensions folder of ComfyUI"
|
||||
)
|
||||
|
||||
|
||||
def classname_to_wiki(s: str):
|
||||
classname = s.replace("MTB_", "")
|
||||
parts: list[str] = []
|
||||
start = 0
|
||||
for i in range(1, len(classname)):
|
||||
if classname[i].isupper():
|
||||
parts.append(classname[start:i].lower())
|
||||
start = i
|
||||
parts.append(classname[start:].lower())
|
||||
return "nodes-" + "-".join(parts)
|
||||
|
||||
|
||||
wiki = here / "wiki"
|
||||
node_docs = {}
|
||||
if wiki.exists() and wiki.is_dir():
|
||||
node_docs = {
|
||||
wiki_to_classname(x.stem): x.read_text(encoding="utf-8")
|
||||
for x in (wiki / "nodes").glob("*.md")
|
||||
}
|
||||
|
||||
|
||||
# - REGISTER NODES
|
||||
MTB_EXPORT = os.environ.get("MTB_EXPORT")
|
||||
|
||||
nodes, failed = load_nodes()
|
||||
for node_class in nodes:
|
||||
class_name: str = node_class.__name__
|
||||
linked_doc = node_docs.get(class_name)
|
||||
|
||||
if not hasattr(node_class, "DESCRIPTION"):
|
||||
if linked_doc:
|
||||
log.debug(f"Found linked doc for {class_name}, using it")
|
||||
node_class.DESCRIPTION = linked_doc
|
||||
elif node_class.__doc__:
|
||||
log.debug(f"Using __doc__ as description for {class_name}")
|
||||
node_class.DESCRIPTION = node_class.__doc__
|
||||
if MTB_EXPORT:
|
||||
wiki_name = classname_to_wiki(class_name)
|
||||
_ = (wiki / "nodes" / (wiki_name + ".md")).write_text(
|
||||
node_class.__doc__, encoding="utf-8"
|
||||
)
|
||||
|
||||
else:
|
||||
log.debug(
|
||||
f"None of the methods could retrieve documentation for {class_name}"
|
||||
)
|
||||
|
||||
class_name = node_class.__name__
|
||||
node_label = f"{get_label(class_name)} (mtb)"
|
||||
NODE_CLASS_MAPPINGS[node_label] = node_class
|
||||
NODE_DISPLAY_NAME_MAPPINGS[class_name] = node_label
|
||||
NODE_CLASS_MAPPINGS_DEBUG[node_label] = node_class.__doc__
|
||||
|
||||
# TODO: I removed this, I find it more convenient to write without spaces
|
||||
# but it breaks every of my workflows
|
||||
# TODO (cont): and until I find a way to automate the conversion
|
||||
# I'll leave it like this
|
||||
# TODO: I removed this, I find it more convenient to write without spaces, but it breaks every of my workflows
|
||||
# TODO (cont): and until I find a way to automate the conversion, I'll leave it like this
|
||||
|
||||
if os.environ.get("MTB_EXPORT"):
|
||||
with open(here / "node_list.json", "w") as f:
|
||||
_ = f.write(
|
||||
f.write(
|
||||
json.dumps(
|
||||
{
|
||||
k: NODE_CLASS_MAPPINGS_DEBUG[k]
|
||||
@@ -208,81 +166,32 @@ for node_class in nodes:
|
||||
)
|
||||
)
|
||||
|
||||
log.debug(
|
||||
"Loaded the following nodes:\n\t"
|
||||
log.info(
|
||||
f"Loaded the following nodes:\n\t"
|
||||
+ "\n\t".join(
|
||||
f"{cyan_text(k)}: {blue_text(get_summary(doc)) if doc else '-'}"
|
||||
for k, doc in NODE_CLASS_MAPPINGS_DEBUG.items()
|
||||
)
|
||||
)
|
||||
|
||||
log.info(f"loaded {cyan_text(str(len(nodes)))} nodes successfuly")
|
||||
|
||||
if failed:
|
||||
with contextlib.suppress(Exception):
|
||||
base_url, port = utils.get_server_info()
|
||||
log.info(
|
||||
f"Some nodes ({len(failed)}) could not be loaded. This can be ignored, but go to http://{base_url}:{port}/mtb if you want more information."
|
||||
)
|
||||
log.debug(failed)
|
||||
|
||||
|
||||
# - ENDPOINT
|
||||
|
||||
from server import PromptServer
|
||||
from .log import log
|
||||
from aiohttp import web
|
||||
from importlib import reload
|
||||
import logging
|
||||
from .endpoint import endlog
|
||||
|
||||
if hasattr(PromptServer, "instance"):
|
||||
img_cache = None
|
||||
prompt_cache = None
|
||||
|
||||
with contextlib.suppress(ImportError):
|
||||
from cachetools import TTLCache
|
||||
|
||||
img_cache = TTLCache(maxsize=100, ttl=5) # 1 min TTL
|
||||
prompt_cache = TTLCache(maxsize=100, ttl=5) # 1 min TTL
|
||||
|
||||
restore_deps = ["basicsr"]
|
||||
onnx_deps = ["onnxruntime"]
|
||||
swap_deps = ["insightface"] + onnx_deps
|
||||
swap_deps = ["insightface", "onnxruntime"]
|
||||
|
||||
node_dependency_mapping = {
|
||||
"QrCode": ["qrcode"],
|
||||
"DeepBump": onnx_deps,
|
||||
"FaceSwap": swap_deps,
|
||||
"LoadFaceSwapModel": swap_deps,
|
||||
"LoadFaceAnalysisModel": restore_deps,
|
||||
}
|
||||
|
||||
PromptServer.instance.app.router.add_static(
|
||||
"/mtb-assets/", path=(here / "html").as_posix()
|
||||
)
|
||||
|
||||
# NOTE: we add an extra static path to avoid comfy mechanism
|
||||
# that loads every script in web.
|
||||
PromptServer.instance.app.add_routes(
|
||||
[web.static("/mtb_async", (here / "web_async").as_posix())]
|
||||
)
|
||||
|
||||
@PromptServer.instance.routes.get("/mtb/manage")
|
||||
async def manage(request):
|
||||
from . import endpoint
|
||||
|
||||
reload(endpoint)
|
||||
|
||||
endlog.debug("Initializing Manager")
|
||||
if "text/html" in request.headers.get("Accept", ""):
|
||||
csv_editor = endpoint.csv_editor()
|
||||
|
||||
tabview = endpoint.render_tab_view(Styles=csv_editor)
|
||||
return web.Response(
|
||||
text=endpoint.render_base_template("MTB", tabview),
|
||||
content_type="text/html",
|
||||
)
|
||||
|
||||
return web.json_response(
|
||||
{
|
||||
"message": "manage only has a POST api for now",
|
||||
}
|
||||
)
|
||||
|
||||
@PromptServer.instance.routes.get("/mtb/status")
|
||||
async def get_full_library(request):
|
||||
from . import endpoint
|
||||
@@ -318,10 +227,10 @@ if hasattr(PromptServer, "instance"):
|
||||
}
|
||||
)
|
||||
|
||||
@PromptServer.instance.routes.post("/mtb/server-info")
|
||||
async def set_server_info(request: Request):
|
||||
json_data: dict[str, bool] = await request.json()
|
||||
enabled = json_data.get("debug")
|
||||
@PromptServer.instance.routes.post("/mtb/debug")
|
||||
async def set_debug(request):
|
||||
json_data = await request.json()
|
||||
enabled = json_data.get("enabled")
|
||||
if enabled:
|
||||
os.environ["MTB_DEBUG"] = "true"
|
||||
log.setLevel(logging.DEBUG)
|
||||
@@ -329,7 +238,7 @@ if hasattr(PromptServer, "instance"):
|
||||
|
||||
elif "MTB_DEBUG" in os.environ:
|
||||
# del os.environ["MTB_DEBUG"]
|
||||
_ = os.environ.pop("MTB_DEBUG")
|
||||
os.environ.pop("MTB_DEBUG")
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
return web.json_response(
|
||||
@@ -337,19 +246,18 @@ if hasattr(PromptServer, "instance"):
|
||||
)
|
||||
|
||||
@PromptServer.instance.routes.get("/mtb")
|
||||
async def get_home(request: Request):
|
||||
async def get_home(request):
|
||||
from . import endpoint
|
||||
|
||||
_ = reload(endpoint)
|
||||
reload(endpoint)
|
||||
# Check if the request prefers HTML content
|
||||
if "text/html" in request.headers.get("Accept", ""):
|
||||
# # Return an HTML page
|
||||
html_response = """
|
||||
<div class="flex-container menu">
|
||||
<a href="/mtb/manage">manage</a>
|
||||
<a href="/mtb/server-info">Server Info</a>
|
||||
<a href="/mtb/debug">debug</a>
|
||||
<a href="/mtb/status">status</a>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
return web.Response(
|
||||
text=endpoint.render_base_template("MTB", html_response),
|
||||
@@ -359,176 +267,28 @@ if hasattr(PromptServer, "instance"):
|
||||
# Return JSON for other requests
|
||||
return web.json_response({"message": "Welcome to MTB!"})
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from io import BytesIO
|
||||
|
||||
from aiohttp import web
|
||||
from PIL import Image
|
||||
|
||||
def get_cached_image(file_path: str, preview_params=None, channel=None):
|
||||
cache_key = (file_path, preview_params, channel)
|
||||
if img_cache and (cache_key in img_cache):
|
||||
return img_cache[cache_key]
|
||||
|
||||
with Image.open(file_path) as img:
|
||||
info = img.info
|
||||
if preview_params:
|
||||
img = process_preview(img, preview_params)
|
||||
if channel:
|
||||
img = process_channel(img, channel)
|
||||
if prompt_cache:
|
||||
prompt_cache[cache_key] = info
|
||||
if img_cache:
|
||||
img_cache[cache_key] = img.getvalue()
|
||||
return img_cache[cache_key]
|
||||
|
||||
return img.getvalue()
|
||||
|
||||
def process_preview(img: Image.Image, preview_params):
|
||||
image_format, quality, width = preview_params
|
||||
quality = int(quality)
|
||||
|
||||
if width:
|
||||
width = int(width)
|
||||
img.thumbnail((width, int(width * img.height / img.width)))
|
||||
|
||||
buffer = BytesIO()
|
||||
img.save(
|
||||
buffer, format=image_format, quality=quality, metadata=img.info
|
||||
)
|
||||
buffer.seek(0)
|
||||
return buffer
|
||||
|
||||
def process_channel(img: Image.Image, channel: str):
|
||||
if channel == "rgb":
|
||||
if img.mode == "RGBA":
|
||||
r, g, b, _ = img.split()
|
||||
img = Image.merge("RGB", (r, g, b))
|
||||
else:
|
||||
img = img.convert("RGB")
|
||||
elif channel == "a":
|
||||
if img.mode == "RGBA":
|
||||
_, _, _, a = img.split()
|
||||
else:
|
||||
a = Image.new("L", img.size, 255)
|
||||
img = Image.new("RGBA", img.size)
|
||||
img.putalpha(a)
|
||||
|
||||
buffer = BytesIO()
|
||||
img.save(buffer, format="PNG")
|
||||
_ = buffer.seek(0)
|
||||
return buffer
|
||||
|
||||
async def get_image_response(
|
||||
file, filename: str, preview_info=None, channel=None
|
||||
):
|
||||
img = await asyncio.to_thread(
|
||||
get_cached_image, file, preview_info, channel
|
||||
)
|
||||
return web.Response(
|
||||
body=img,
|
||||
content_type="image/webp" if preview_info else "image/png",
|
||||
headers={"Content-Disposition": f'filename="{filename}"'},
|
||||
)
|
||||
|
||||
# TODO: Embed the metadatas somehow so we can drag and drop
|
||||
# to load workflows in the sidebar
|
||||
@PromptServer.instance.routes.get("/mtb/view")
|
||||
async def view_image(request: Request):
|
||||
import folder_paths
|
||||
|
||||
filename = request.rel_url.query.get("filename")
|
||||
if not filename:
|
||||
return web.Response(status=404)
|
||||
|
||||
filename, output_dir = folder_paths.annotated_filepath(filename)
|
||||
if filename[0] == "/" or ".." in filename:
|
||||
return web.Response(status=400)
|
||||
|
||||
if output_dir is None:
|
||||
rtype = request.rel_url.query.get("type", "output")
|
||||
output_dir = folder_paths.get_directory_by_type(rtype)
|
||||
|
||||
if output_dir is None:
|
||||
return web.Response(status=400)
|
||||
|
||||
if "subfolder" in request.rel_url.query:
|
||||
full_output_dir = os.path.join(
|
||||
output_dir, request.rel_url.query["subfolder"]
|
||||
)
|
||||
if (
|
||||
os.path.commonpath(
|
||||
(os.path.abspath(full_output_dir), output_dir)
|
||||
)
|
||||
!= output_dir
|
||||
):
|
||||
return web.Response(status=403)
|
||||
output_dir = full_output_dir
|
||||
|
||||
filename = os.path.basename(filename)
|
||||
file = os.path.join(output_dir, filename)
|
||||
|
||||
if not os.path.isfile(file):
|
||||
return web.Response(status=404)
|
||||
|
||||
preview_info = None
|
||||
if "preview" in request.rel_url.query:
|
||||
preview_params = request.rel_url.query["preview"].split(";")
|
||||
image_format = (
|
||||
preview_params[0]
|
||||
if preview_params[0] in ["webp", "jpeg"]
|
||||
else "webp"
|
||||
)
|
||||
quality = (
|
||||
int(preview_params[1])
|
||||
if len(preview_params) > 1 and preview_params[1].isdigit()
|
||||
else 90
|
||||
)
|
||||
width = request.rel_url.query.get("width")
|
||||
preview_info = (image_format, quality, width)
|
||||
|
||||
channel = request.rel_url.query.get("channel")
|
||||
|
||||
return await get_image_response(file, filename, preview_info, channel)
|
||||
|
||||
@PromptServer.instance.routes.get("/mtb/server-info")
|
||||
async def get_debug(request: Request):
|
||||
@PromptServer.instance.routes.get("/mtb/debug")
|
||||
async def get_debug(request):
|
||||
from . import endpoint
|
||||
|
||||
_ = reload(endpoint)
|
||||
isdebug = "MTB_DEBUG" in os.environ
|
||||
exposed = "MTB_EXPOSE" in os.environ
|
||||
|
||||
def render_property(name: str, val: str):
|
||||
return f"""<strong>{name}:</strong>
|
||||
<p>
|
||||
{val}
|
||||
</p>"""
|
||||
|
||||
reload(endpoint)
|
||||
enabled = "MTB_DEBUG" in os.environ
|
||||
# Check if the request prefers HTML content
|
||||
if "text/html" in request.headers.get("Accept", ""):
|
||||
# # Return an HTML page
|
||||
html_response = ""
|
||||
|
||||
html_response += render_property(
|
||||
"Debug", "Enabled" if isdebug else "Disabled"
|
||||
)
|
||||
|
||||
html_response += render_property("Exposed", str(exposed))
|
||||
|
||||
html_response = f"""
|
||||
<h1>MTB Debug Status: {'Enabled' if enabled else 'Disabled'}</h1>
|
||||
"""
|
||||
return web.Response(
|
||||
text=endpoint.render_base_template(
|
||||
"Server Info", html_response
|
||||
),
|
||||
text=endpoint.render_base_template("Debug", html_response),
|
||||
content_type="text/html",
|
||||
)
|
||||
|
||||
# Return JSON for other requests
|
||||
return web.json_response({"exposed": exposed, "debug": isdebug})
|
||||
return web.json_response({"enabled": enabled})
|
||||
|
||||
@PromptServer.instance.routes.get("/mtb/actions")
|
||||
async def no_route(request: Request):
|
||||
async def no_route(request):
|
||||
from . import endpoint
|
||||
|
||||
if "text/html" in request.headers.get("Accept", ""):
|
||||
@@ -542,7 +302,7 @@ if hasattr(PromptServer, "instance"):
|
||||
return web.json_response({"message": "actions has no get for now"})
|
||||
|
||||
@PromptServer.instance.routes.post("/mtb/actions")
|
||||
async def do_action(request: Request):
|
||||
async def do_action(request):
|
||||
from . import endpoint
|
||||
|
||||
reload(endpoint)
|
||||
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.6.1/schema.json",
|
||||
"organizeImports": {
|
||||
"enabled": true
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true,
|
||||
"suspicious": {
|
||||
"noConsoleLog": "warn"
|
||||
},
|
||||
"style": {
|
||||
"noParameterAssign": "off",
|
||||
"noShoutyConstants": "warn",
|
||||
"useNamingConvention": "off"
|
||||
}
|
||||
}
|
||||
},
|
||||
"formatter": {
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2,
|
||||
"lineEnding": "lf"
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"quoteStyle": "single",
|
||||
"semicolons": "asNeeded"
|
||||
}
|
||||
}
|
||||
}
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
[changelog]
|
||||
header = """
|
||||
# Changelog\n
|
||||
This is an automated changelog based on the commits in this repository.
|
||||
|
||||
Check the notes in the [releases](https://github.com/melMass/comfy_mtb/releases) for more information.
|
||||
"""
|
||||
# https://keats.github.io/tera/docs/#introduction
|
||||
body = """
|
||||
{% if version -%}\
|
||||
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
|
||||
{% else %}\
|
||||
## [Unreleased]
|
||||
{% endif -%}\
|
||||
|
||||
{% for group, commits in commits | group_by(attribute="group") %}
|
||||
### {{ group | upper_first }}
|
||||
{% for commit in commits %}
|
||||
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first | trim }} ([{{ commit.id | truncate(length=7, end="") }}](<REPO>/commit/{{ commit.id }}))\
|
||||
{% if commit.github.username and commit.github.username != remote.github.owner %} by [@{{ commit.github.username }}](https://github.com/{{ commit.github.username }}){%- endif -%}
|
||||
{% if commit.github.pr_number %} in [#{{ commit.github.pr_number }}](<REPO>/pull/{{ commit.github.pr_number }}){%- endif -%}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
{%- if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
|
||||
## New Contributors
|
||||
{%- endif -%}
|
||||
|
||||
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
|
||||
* [@{{ contributor.username }}](https://github.com/{{ contributor.username }}) made their first contribution in [#{{ contributor.pr_number }}](<REPO>/pull/{{ contributor.pr_number }})\
|
||||
{%- endfor %}\n
|
||||
"""
|
||||
footer = """
|
||||
{% for release in releases -%}
|
||||
{% if release.version -%}
|
||||
{% if release.previous.version -%}
|
||||
[{{ release.version | trim_start_matches(pat="v") }}]: \
|
||||
<REPO>/compare/{{ release.previous.version }}..{{ release.version }}
|
||||
{% endif -%}
|
||||
{% else -%}
|
||||
[unreleased]: <REPO>/compare/{{ release.previous.version }}..HEAD
|
||||
{% endif -%}
|
||||
{% endfor %}
|
||||
"""
|
||||
trim = true
|
||||
postprocessors = [
|
||||
{ pattern = '<REPO>', replace = "https://github.com/melMass/comfy_mtb" }, # replace repository URL
|
||||
]
|
||||
|
||||
[git]
|
||||
# https://www.conventionalcommits.org
|
||||
conventional_commits = true
|
||||
filter_unconventional = true
|
||||
split_commits = false
|
||||
commit_preprocessors = [
|
||||
# { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))" }, # replace issue numbers
|
||||
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
|
||||
]
|
||||
commit_parsers = [
|
||||
{ message = "^feat", group = "Features" },
|
||||
{ message = "^fix", group = "Bug Fixes" },
|
||||
{ message = "^doc", group = "Documentation" },
|
||||
{ message = "^perf", group = "Performance" },
|
||||
{ message = "^refactor", group = "Refactor" },
|
||||
{ message = "^style", group = "Styling" },
|
||||
{ message = "^test", group = "Testing" },
|
||||
{ message = "^chore\\(release\\): prepare for", skip = true },
|
||||
{ message = "^chore\\(deps\\)", skip = true },
|
||||
{ message = "^chore\\(pr\\)", skip = true },
|
||||
{ message = "^chore\\(pull\\)", skip = true },
|
||||
{ message = "^chore|ci", group = "Miscellaneous Tasks" },
|
||||
{ body = ".*security", group = "Security" },
|
||||
{ message = "^revert", group = "Revert" },
|
||||
]
|
||||
protect_breaking_commits = false
|
||||
filter_commits = false
|
||||
tag_pattern = "v[0-9].*"
|
||||
topo_order = false
|
||||
sort_commits = "newest"
|
||||
|
||||
[remote.github]
|
||||
owner = "melMass"
|
||||
repo = "comfy_mtb"
|
||||
+45
-374
@@ -1,198 +1,40 @@
|
||||
import csv
|
||||
import secrets
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Literal
|
||||
|
||||
from .utils import here, run_command, comfy_mode
|
||||
from aiohttp import web
|
||||
|
||||
from .log import mklog
|
||||
from .utils import (
|
||||
SortMode,
|
||||
backup_file,
|
||||
build_glob_patterns,
|
||||
glob_multiple,
|
||||
here,
|
||||
import_install,
|
||||
input_dir,
|
||||
output_dir,
|
||||
reqs_map,
|
||||
run_command,
|
||||
styles_dir,
|
||||
)
|
||||
import sys
|
||||
|
||||
endlog = mklog("mtb endpoint")
|
||||
|
||||
# - ACTIONS
|
||||
import asyncio
|
||||
import platform
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import requirements
|
||||
|
||||
try:
|
||||
import websockets.server
|
||||
except ModuleNotFoundError:
|
||||
endlog.warning(
|
||||
"You do not have websockets installed, the video server won't work"
|
||||
)
|
||||
websockets = False
|
||||
|
||||
import_install("requirements")
|
||||
import io
|
||||
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
|
||||
|
||||
def generate_random_frame():
|
||||
# Generate a random image frame
|
||||
width, height = 640, 480
|
||||
image = np.random.randint(0, 256, (height, width, 3), dtype=np.uint8)
|
||||
pil_image = Image.fromarray(image)
|
||||
byte_buffer = io.BytesIO()
|
||||
pil_image.save(byte_buffer, format="JPEG")
|
||||
frame_data = byte_buffer.getvalue()
|
||||
return frame_data
|
||||
|
||||
|
||||
class VideoStreamingManager:
|
||||
def __init__(self):
|
||||
self.video_servers = {}
|
||||
self.next_port = (
|
||||
8767 # Start with a default port and increment for each server
|
||||
)
|
||||
|
||||
async def start_video_streaming_server(self, video_id):
|
||||
if video_id not in self.video_servers:
|
||||
# Create and start a new video streaming server for the specified video
|
||||
video_server = await self.create_video_streaming_server(video_id)
|
||||
self.video_servers[video_id] = video_server
|
||||
|
||||
return video_server
|
||||
|
||||
async def video_stream(self, websocket, path):
|
||||
# Implement the logic to continuously capture and send video frames here
|
||||
while True:
|
||||
# frame_data = capture_and_encode_frame() # Implement this function
|
||||
frame_data = generate_random_frame()
|
||||
await websocket.send(frame_data)
|
||||
await asyncio.sleep(0.033) # Adjust the frame rate as needed
|
||||
|
||||
async def create_video_streaming_server(self, video_id):
|
||||
# Create and start a new WebSocket server for the specified video
|
||||
port = self.next_port
|
||||
self.next_port += 1 # Increment port number for the next server
|
||||
|
||||
server = await websockets.server.serve(
|
||||
self.video_stream, "localhost", port
|
||||
)
|
||||
|
||||
return server
|
||||
|
||||
async def stop_video_streaming_server(self, video_id):
|
||||
if video_id in self.video_servers:
|
||||
# Terminate and remove the video streaming server for the specified video
|
||||
video_server = self.video_servers[video_id]
|
||||
video_server.close()
|
||||
await video_server.wait_closed()
|
||||
del self.video_servers[video_id]
|
||||
|
||||
|
||||
async def start_video_streaming_server():
|
||||
async def video_stream(websocket, path):
|
||||
# Continuously capture and send video frames here
|
||||
while True:
|
||||
frame_data = capture_and_encode_frame() # Implement this function
|
||||
await websocket.send(frame_data)
|
||||
await asyncio.sleep(0.033) # Adjust the frame rate as needed
|
||||
|
||||
start_server = websockets.server.serve(
|
||||
video_stream, "localhost", 8766
|
||||
) # Use a different port (e.g., 8766)
|
||||
|
||||
return await start_server
|
||||
|
||||
|
||||
def ACTIONS_installDependency(dependency_names=None):
|
||||
if dependency_names is None:
|
||||
# return web.Response(text="No dependency name provided", status=400)
|
||||
return {"error": "No dependency name provided"}
|
||||
|
||||
endlog.debug(f"Received Install Dependency request for {dependency_names}")
|
||||
# reqs = []
|
||||
resolved_names = [reqs_map.get(name, name) for name in dependency_names]
|
||||
try:
|
||||
run_command(
|
||||
[Path(sys.executable), "-m", "pip", "install"] + resolved_names
|
||||
)
|
||||
return {"success": True}
|
||||
|
||||
except Exception as e:
|
||||
return {"error": f"Failed to install dependencies: {e}"}
|
||||
|
||||
# if platform.system() == "Windows":
|
||||
# reqs = list(requirements.parse((here / "reqs_windows.txt").read_text()))
|
||||
# else:
|
||||
# reqs = list(requirements.parse((here / "reqs.txt").read_text()))
|
||||
# print([x.specs for x in reqs])
|
||||
# print(
|
||||
# "\n".join([f"{x.line} {''.join(x.specs[0] if x.specs else '')}" for x in reqs])
|
||||
# )
|
||||
# for dependency_name in dependency_names:
|
||||
# for req in reqs:
|
||||
# if req.name == dependency_name:
|
||||
# endlog.debug(f"Dependency {dependency_name} installed")
|
||||
# break
|
||||
|
||||
|
||||
def ACTIONS_getUserImages(
|
||||
mode: Literal["input", "output"],
|
||||
count=200,
|
||||
offset=0,
|
||||
sort: str | None = None,
|
||||
include_subfolders: bool = False,
|
||||
):
|
||||
# enabled = "MTB_EXPOSE" in os.environ
|
||||
# if not enabled:
|
||||
# return {"error": "Session not authorized to getInputs"}
|
||||
|
||||
imgs = {}
|
||||
entry_dir = input_dir if mode == "input" else output_dir
|
||||
supported = ["png", "jpg", "jpeg", "webp", "gif"]
|
||||
|
||||
entries = {}
|
||||
patterns = build_glob_patterns(supported, recursive=include_subfolders)
|
||||
entries = glob_multiple(entry_dir, patterns)
|
||||
|
||||
sort_mode = SortMode.from_str(sort)
|
||||
|
||||
if sort_mode:
|
||||
sort_key = {
|
||||
SortMode.MODIFIED: lambda x: x.stat().st_mtime,
|
||||
SortMode.MODIFIED_REVERSE: lambda x: x.stat().st_mtime,
|
||||
SortMode.NAME: lambda x: x.name,
|
||||
SortMode.NAME_REVERSE: lambda x: x.name,
|
||||
}.get(sort_mode)
|
||||
if sort_key:
|
||||
reverse = sort_mode in (SortMode.MODIFIED, SortMode.NAME_REVERSE)
|
||||
entries = sorted(entries, key=sort_key, reverse=reverse)
|
||||
|
||||
imgs = {
|
||||
img.name: (
|
||||
f"/mtb/view?filename={img.name}&width=512&type={mode}&subfolder="
|
||||
f"{img.parent.relative_to(entry_dir) if include_subfolders else ''}"
|
||||
f"&preview=&rand={secrets.randbelow(424242)}"
|
||||
)
|
||||
for i, img in enumerate(entries)
|
||||
if offset <= i < offset + count
|
||||
}
|
||||
return imgs
|
||||
reqs = []
|
||||
if comfy_mode == "embeded":
|
||||
reqs = list(requirements.parse((here / "reqs_portable.txt").read_text()))
|
||||
else:
|
||||
reqs = list(requirements.parse((here / "reqs.txt").read_text()))
|
||||
print([x.specs for x in reqs])
|
||||
print(
|
||||
"\n".join([f"{x.line} {''.join(x.specs[0] if x.specs else '')}" for x in reqs])
|
||||
)
|
||||
for dependency_name in dependency_names:
|
||||
for req in reqs:
|
||||
if req.name == dependency_name:
|
||||
endlog.debug(f"Dependency {dependency_name} installed")
|
||||
break
|
||||
return {"success": True}
|
||||
|
||||
|
||||
def ACTIONS_getStyles(style_name=None):
|
||||
from .nodes.conditions import MTB_StylesLoader
|
||||
from .nodes.conditions import StylesLoader
|
||||
|
||||
styles = MTB_StylesLoader.options
|
||||
styles = StylesLoader.options
|
||||
match_list = ["name"]
|
||||
if styles:
|
||||
filtered_styles = {
|
||||
@@ -201,42 +43,12 @@ def ACTIONS_getStyles(style_name=None):
|
||||
if not key.startswith("__") and key not in match_list
|
||||
}
|
||||
if style_name:
|
||||
return filtered_styles.get(
|
||||
style_name, {"error": "Style not found"}
|
||||
)
|
||||
return filtered_styles.get(style_name, {"error": "Style not found"})
|
||||
return filtered_styles
|
||||
return {"error": "No styles found"}
|
||||
|
||||
|
||||
def ACTIONS_saveStyle(data):
|
||||
# endlog.debug(f"Received Save Styles for {data.keys()}")
|
||||
# endlog.debug(data)
|
||||
|
||||
styles = [f.name for f in styles_dir.iterdir() if f.suffix == ".csv"]
|
||||
target = None
|
||||
rows = []
|
||||
for fp, content in data.items():
|
||||
if fp in styles:
|
||||
endlog.debug(f"Overwriting {fp}")
|
||||
target = styles_dir / fp
|
||||
rows = content
|
||||
break
|
||||
|
||||
if not target:
|
||||
endlog.warning(
|
||||
f"Could not determine the target file for {data.keys()}"
|
||||
)
|
||||
return {"error": "Could not determine the target file for the style"}
|
||||
|
||||
backup_file(target)
|
||||
|
||||
with target.open("w", newline="", encoding="utf-8") as file:
|
||||
csv_writer = csv.writer(file, quoting=csv.QUOTE_ALL)
|
||||
for row in rows:
|
||||
csv_writer.writerow(row)
|
||||
|
||||
|
||||
async def do_action(request: web.Request) -> web.Response:
|
||||
async def do_action(request) -> web.Response:
|
||||
endlog.debug("Init action request")
|
||||
request_data = await request.json()
|
||||
name = request_data.get("name")
|
||||
@@ -248,191 +60,44 @@ async def do_action(request: web.Request) -> web.Response:
|
||||
method = globals().get(method_name)
|
||||
|
||||
if callable(method):
|
||||
result = None
|
||||
if args:
|
||||
result = method(*args) if isinstance(args, list) else method(args)
|
||||
else:
|
||||
result = method()
|
||||
|
||||
result = method(args) if args else method()
|
||||
endlog.debug(f"Action result: {result}")
|
||||
return web.json_response({"result": result})
|
||||
|
||||
available_methods = [
|
||||
attr[len("ACTIONS_") :]
|
||||
for attr in globals()
|
||||
if attr.startswith("ACTIONS_")
|
||||
attr[len("ACTIONS_") :] for attr in globals() if attr.startswith("ACTIONS_")
|
||||
]
|
||||
|
||||
return web.json_response(
|
||||
{
|
||||
"error": "Invalid method name.",
|
||||
"available_methods": available_methods,
|
||||
}
|
||||
{"error": "Invalid method name.", "available_methods": available_methods}
|
||||
)
|
||||
|
||||
|
||||
# - HTML UTILS
|
||||
|
||||
|
||||
def dependencies_button(name: str, dependencies: list[str]) -> str:
|
||||
def dependencies_button(name, dependencies):
|
||||
deps = ",".join([f"'{x}'" for x in dependencies])
|
||||
return f"""
|
||||
<button
|
||||
class="dependency-button"
|
||||
onclick="window.mtb_action('installDependency',[{deps}])"
|
||||
>Install {name} deps</button>
|
||||
<button class="dependency-button" onclick="window.mtb_action('installDependency',[{deps}])">Install {name} deps</button>
|
||||
"""
|
||||
|
||||
|
||||
def csv_editor():
|
||||
inputs = [f for f in styles_dir.iterdir() if f.suffix == ".csv"]
|
||||
# rows = {f.stem: list(csv.reader(f.read_text("utf8"))) for f in styles}
|
||||
|
||||
style_files = {}
|
||||
for file in inputs:
|
||||
with open(file, encoding="utf8") as f:
|
||||
parsed = csv.reader(f)
|
||||
style_files[file.name] = []
|
||||
for row in parsed:
|
||||
endlog.debug(f"Adding style {row[0]}")
|
||||
style_files[file.name].append((row[0], row[1], row[2]))
|
||||
|
||||
html_out = """
|
||||
<div id="style-editor">
|
||||
<h1>Style Editor</h1>
|
||||
|
||||
"""
|
||||
for current, styles in style_files.items():
|
||||
current_out = f"<h3>{current}</h3>"
|
||||
table_rows = []
|
||||
for index, style in enumerate(styles):
|
||||
table_rows += (
|
||||
(["<tr>"] + [f"<th>{cell}</th>" for cell in style] + ["</tr>"])
|
||||
if index == 0
|
||||
else (
|
||||
["<tr>"]
|
||||
+ [
|
||||
f"<td><input type='text' value='{cell}'></td>"
|
||||
if i == 0
|
||||
else f"<td><textarea name='Text1' cols='40' rows='5'>{cell}</textarea></td>"
|
||||
for i, cell in enumerate(style)
|
||||
]
|
||||
+ ["</tr>"]
|
||||
)
|
||||
)
|
||||
current_out += (
|
||||
f"<table data-id='{current}' data-filename='{current}'>"
|
||||
+ "".join(table_rows)
|
||||
+ "</table>"
|
||||
)
|
||||
current_out += f"<button data-id='{current}' onclick='saveTableData(this.getAttribute(\"data-id\"))'>Save {current}</button>"
|
||||
|
||||
html_out += add_foldable_region(current, current_out)
|
||||
|
||||
html_out += "</div>"
|
||||
html_out += """<script src='/mtb-assets/js/saveTableData.js'></script>"""
|
||||
|
||||
return html_out
|
||||
|
||||
|
||||
def render_tab_view(**kwargs):
|
||||
tab_headers = []
|
||||
tab_contents = []
|
||||
|
||||
for idx, (tab_name, content) in enumerate(kwargs.items()):
|
||||
active_class = "active" if idx == 0 else ""
|
||||
tab_headers.append(
|
||||
f"<button class='tablinks {active_class}' onclick=\"openTab(event, '{tab_name}')\">{tab_name}</button>"
|
||||
)
|
||||
tab_contents.append(
|
||||
f"<div id='{tab_name}' class='tabcontent {active_class}'>{content}</div>"
|
||||
)
|
||||
|
||||
headers_str = "\n".join(tab_headers)
|
||||
contents_str = "\n".join(tab_contents)
|
||||
|
||||
return f"""
|
||||
<div class='tab-container'>
|
||||
<div class='tab'>
|
||||
{headers_str}
|
||||
</div>
|
||||
{contents_str}
|
||||
</div>
|
||||
<script src='/mtb-assets/js/tabSwitch.js'></script>
|
||||
"""
|
||||
|
||||
|
||||
def add_foldable_region(title: str, content: str):
|
||||
symbol_id = f"{title}-symbol"
|
||||
return f"""
|
||||
<div class='foldable'>
|
||||
<div
|
||||
class='foldable-title'
|
||||
onclick="toggleFoldable('{title}', '{symbol_id}')"
|
||||
>
|
||||
<span id='{symbol_id}' class='foldable-symbol'>▷</span>
|
||||
{title}
|
||||
</div>
|
||||
<div id='{title}' class='foldable-content'>
|
||||
{content}
|
||||
</div>
|
||||
</div>
|
||||
<script src='/mtb-assets/js/foldable.js'></script>
|
||||
"""
|
||||
|
||||
|
||||
def add_split_pane(
|
||||
left_content: str, right_content: str, *, vertical: bool = True
|
||||
):
|
||||
orientation = "vertical" if vertical else "horizontal"
|
||||
return f"""
|
||||
<div class="split-pane {orientation}">
|
||||
<div id="leftPane">
|
||||
{left_content}
|
||||
</div>
|
||||
<div id="resizer"></div>
|
||||
<div id="rightPane">
|
||||
{right_content}
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
initSplitPane({str(vertical).lower()});
|
||||
</script>
|
||||
<script src='/mtb-assets/js/splitPane.js'></script>
|
||||
"""
|
||||
|
||||
|
||||
def add_dropdown(title, options):
|
||||
option_str = "\n".join(
|
||||
[f"<option value='{opt}'>{opt}</option>" for opt in options]
|
||||
)
|
||||
return f"""
|
||||
<select>
|
||||
<option disabled selected>{title}</option>
|
||||
{option_str}
|
||||
</select>
|
||||
"""
|
||||
|
||||
|
||||
def render_table(table_dict: dict[str, Any], sort=True, title=None):
|
||||
table_list = sorted(
|
||||
def render_table(table_dict, sort=True, title=None):
|
||||
table_dict = sorted(
|
||||
table_dict.items(), key=lambda item: item[0]
|
||||
) # Sort the dictionary by keys
|
||||
|
||||
table_rows = ""
|
||||
for name, item in table_list:
|
||||
for name, item in table_dict:
|
||||
if isinstance(item, dict):
|
||||
if "dependencies" in item:
|
||||
table_rows += f"<tr><td>{name}</td><td>"
|
||||
table_rows += (
|
||||
f"{dependencies_button(name,item['dependencies'])}"
|
||||
)
|
||||
table_rows += f"{dependencies_button(name,item['dependencies'])}"
|
||||
|
||||
table_rows += "</td></tr>"
|
||||
else:
|
||||
table_rows += (
|
||||
f"<tr><td>{name}</td><td>{render_table(item)}</td></tr>"
|
||||
)
|
||||
table_rows += f"<tr><td>{name}</td><td>{render_table(item)}</td></tr>"
|
||||
# elif isinstance(item, str):
|
||||
# table_rows += f"<tr><td>{name}</td><td>{item}</td></tr>"
|
||||
else:
|
||||
@@ -451,19 +116,27 @@ def render_table(table_dict: dict[str, Any], sort=True, title=None):
|
||||
<tbody>
|
||||
{table_rows}
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
</div>
|
||||
"""
|
||||
|
||||
|
||||
def render_base_template(title: str, content: str):
|
||||
def render_base_template(title, content):
|
||||
css_content = ""
|
||||
css_path = here / "html" / "style.css"
|
||||
if css_path:
|
||||
with open(css_path, "r") as css_file:
|
||||
css_content = css_file.read()
|
||||
|
||||
github_icon_svg = """<svg xmlns="http://www.w3.org/2000/svg" fill="whitesmoke" height="3em" viewBox="0 0 496 512"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>"""
|
||||
return f"""
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{title}</title>
|
||||
<link rel="stylesheet" href="/mtb-assets/style.css"/>
|
||||
<style>
|
||||
{css_content}
|
||||
</style>
|
||||
</head>
|
||||
<script type="module">
|
||||
import {{ api }} from '/scripts/api.js'
|
||||
@@ -492,9 +165,7 @@ def render_base_template(title: str, content: str):
|
||||
<header>
|
||||
<a href="/">Back to Comfy</a>
|
||||
<div class="mtb_logo">
|
||||
<img
|
||||
src="https://repository-images.githubusercontent.com/649047066/a3eef9a7-20dd-4ef9-b839-884502d4e873"
|
||||
alt="Comfy MTB Logo" height="70" width="128">
|
||||
<img src="https://repository-images.githubusercontent.com/649047066/a3eef9a7-20dd-4ef9-b839-884502d4e873" alt="Comfy MTB Logo" height="70" width="128">
|
||||
<span class="title">Comfy MTB</span></div>
|
||||
<a style="width:128px;text-align:center" href="https://www.github.com/melmass/comfy_mtb">
|
||||
{github_icon_svg}
|
||||
@@ -509,6 +180,6 @@ def render_base_template(title: str, content: str):
|
||||
<!-- Shared footer content here -->
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
"""
|
||||
|
||||
@@ -1,247 +0,0 @@
|
||||
# NOTE: This file is only use for development you can ignore it
|
||||
|
||||
|
||||
# NOTE: for CI it's easier to extract parts of my cli for now
|
||||
|
||||
const THREE_VERSION = "0.171.0"
|
||||
# Update the external web extensions
|
||||
export def "comfy mtb update-web" [] {
|
||||
|
||||
let async_dir = $"($env.COMFY_MTB)/web_async"
|
||||
let three_base = $"https://cdn.jsdelivr.net/npm/three@($THREE_VERSION)"
|
||||
let three = {
|
||||
"." : [
|
||||
"build/three.module.js",
|
||||
"build/three.core.js",
|
||||
],
|
||||
three_addons/capabilities: [
|
||||
"examples/jsm/capabilities/WebGPU.js",
|
||||
"examples/jsm/controls/ArcballControls.js",
|
||||
"examples/jsm/controls/DragControls.js",
|
||||
"examples/jsm/controls/FirstPersonControls.js",
|
||||
"examples/jsm/controls/FlyControls.js",
|
||||
"examples/jsm/controls/MapControls.js",
|
||||
"examples/jsm/controls/OrbitControls.js",
|
||||
"examples/jsm/controls/PointerLockControls.js",
|
||||
"examples/jsm/controls/TrackballControls.js",
|
||||
"examples/jsm/controls/TransformControls.js",
|
||||
],
|
||||
three_addons/offscreen: [
|
||||
"jank.js",
|
||||
"offscreen.js",
|
||||
"scene.js",
|
||||
],
|
||||
thee_addons/exporters : [
|
||||
"examples/jsm/exporters/DRACOExporter.js",
|
||||
"examples/jsm/exporters/EXRExporter.js",
|
||||
"examples/jsm/exporters/GLTFExporter.js",
|
||||
"examples/jsm/exporters/KTX2Exporter.js",
|
||||
"examples/jsm/exporters/MMDExporter.js",
|
||||
"examples/jsm/exporters/OBJExporter.js",
|
||||
"examples/jsm/exporters/PLYExporter.js",
|
||||
"examples/jsm/exporters/STLExporter.js",
|
||||
"examples/jsm/exporters/USDZExporter.js"
|
||||
],
|
||||
|
||||
three_addons/loaders : [
|
||||
"examples/jsm/loaders/3DMLoader.js",
|
||||
"examples/jsm/loaders/BVHLoader.js",
|
||||
"examples/jsm/loaders/ColladaLoader.js",
|
||||
"examples/jsm/loaders/DRACOLoader.js",
|
||||
"examples/jsm/loaders/EXRLoader.js",
|
||||
"examples/jsm/loaders/FBXLoader.js",
|
||||
"examples/jsm/loaders/FontLoader.js",
|
||||
"examples/jsm/loaders/GLTFLoader.js",
|
||||
"examples/jsm/loaders/HDRCubeTextureLoader.js",
|
||||
"examples/jsm/loaders/MaterialXLoader.js",
|
||||
"examples/jsm/loaders/MTLLoader.js",
|
||||
"examples/jsm/loaders/OBJLoader.js",
|
||||
"examples/jsm/loaders/PCDLoader.js",
|
||||
"examples/jsm/loaders/PDBLoader.js",
|
||||
"examples/jsm/loaders/PLYLoader.js",
|
||||
"examples/jsm/loaders/STLLoader.js",
|
||||
"examples/jsm/loaders/UltraHDRLoader.js",
|
||||
"examples/jsm/loaders/USDZLoader.js",
|
||||
"examples/jsm/loaders/VOXLoader.js"
|
||||
]
|
||||
}
|
||||
$three | items {|root,urls|
|
||||
let dest = $async_dir | path join $root
|
||||
mkdir $dest
|
||||
|
||||
$urls | par-each {|url|
|
||||
let url = $"($three_base)/($url)"
|
||||
let local = ($dest | path join ($url | path basename))
|
||||
wget -c $url -O ($local)
|
||||
}
|
||||
}
|
||||
|
||||
# $three
|
||||
}
|
||||
|
||||
|
||||
def get_root [--clean] {
|
||||
if $clean {
|
||||
$env.COMFY_CLEAN_ROOT
|
||||
} else {
|
||||
$env.COMFY_ROOT
|
||||
}
|
||||
}
|
||||
|
||||
export def "comfy build-web" [] {
|
||||
cd $env.COMFY_MTB
|
||||
cd web_source
|
||||
npm run build
|
||||
cp dist/*.js ../web/dist
|
||||
}
|
||||
|
||||
export def "comfy dev-web" [] {
|
||||
cd $env.COMFY_MTB
|
||||
cd web_source
|
||||
npm run dev
|
||||
}
|
||||
|
||||
|
||||
# start the comfy server
|
||||
export def "comfy start" [--clean,--old-ui, --listen] {
|
||||
|
||||
let root = get_root --clean=($clean)
|
||||
cd $root
|
||||
MTB_DEBUG=true python main.py --port 3000 ...(if $old_ui { ["--front-end-version", "Comfy-Org/ComfyUI_legacy_frontend@latest"]} else {[ --front-end-version Comfy-Org/ComfyUI_frontend@latest]}) --preview-method auto ...(if $listen {["--listen"]} else {[]})
|
||||
}
|
||||
|
||||
# update comfy itself and merge master in current branch
|
||||
export def "comfy update" [
|
||||
--clean # ??
|
||||
--rebase # Rebase instead of merge
|
||||
] {
|
||||
let root = get_root --clean=($clean)
|
||||
let models = $"($root)/models"
|
||||
let inputs = $"($root)/input"
|
||||
cd $root
|
||||
let branch_name = (git rev-parse --abbrev-ref HEAD | str trim)
|
||||
print $"(ansi yellow_italic)Backing up and removing models symlinks(ansi reset)"
|
||||
|
||||
if not $clean {
|
||||
cd $models
|
||||
# find all symlinks
|
||||
let links = (ls -la |
|
||||
where not ($it.target | is-empty) |
|
||||
select name target |
|
||||
sort-by name)
|
||||
|
||||
|
||||
if not ($links | is-empty) {
|
||||
$links | save -f links.nuon
|
||||
# remove them
|
||||
open links.nuon | each {|p| rm $p.name }
|
||||
}
|
||||
} else {
|
||||
rm $models
|
||||
rm $inputs
|
||||
}
|
||||
|
||||
cd $root
|
||||
|
||||
print $"(ansi yellow_italic)Checking out to master(ansi reset)"
|
||||
git checkout master
|
||||
|
||||
print $"(ansi yellow_italic)Fetching and pulling remote updates(ansi reset)"
|
||||
if ($clean) {
|
||||
git fetch local master
|
||||
git pull local master
|
||||
} else {
|
||||
git fetch
|
||||
git pull
|
||||
}
|
||||
|
||||
|
||||
print $"(ansi yellow_italic)Back to our branch \(($branch_name)\)(ansi reset)"
|
||||
git checkout -
|
||||
|
||||
if $rebase {
|
||||
print $"(ansi yellow_italic)Rebasing changes(ansi reset)"
|
||||
git rebase master
|
||||
|
||||
} else {
|
||||
print $"(ansi yellow_italic)Merging changes(ansi reset)"
|
||||
git merge master
|
||||
}
|
||||
|
||||
print $"(ansi yellow_italic)Linking back the models(ansi reset)"
|
||||
|
||||
if not $clean {
|
||||
cd $models
|
||||
# resymlink them
|
||||
open links.nuon | each {|p| link -a $p.target $p.name }
|
||||
} else {
|
||||
let master = (get_root)
|
||||
link ($master | path join models) $models
|
||||
link ($master | path join input) $inputs
|
||||
}
|
||||
|
||||
let commit_count = (git rev-list --count $branch_name $"^origin/($branch_name)")
|
||||
|
||||
|
||||
print $"(ansi green_bold)Update successful \(($commit_count) new commits\)(ansi reset)"
|
||||
|
||||
|
||||
}
|
||||
|
||||
export def "comfy toggle_extensions" [--clean] {
|
||||
let root = get_root --clean=($clean)
|
||||
cd $root
|
||||
cd custom_nodes
|
||||
let exts = (ls | where type in ["dir","symlink"] | get name)
|
||||
let choices = ($exts | input list -m "choose extension to toggle")
|
||||
if ($choices | is-empty) {
|
||||
return
|
||||
}
|
||||
|
||||
print $choices
|
||||
|
||||
let filtered = $choices | wrap name | upsert enabled {|p| not ($p.name | str ends-with ".disabled")}
|
||||
|
||||
print $filtered
|
||||
$filtered | each {|f|
|
||||
let new_name = ($f.name | str replace ".disabled" "")
|
||||
|
||||
let new_name = if $f.enabled {
|
||||
$"($new_name).disabled"
|
||||
} else {
|
||||
$new_name
|
||||
}
|
||||
print $"Moving ($f.name) to ($new_name)"
|
||||
mv $f.name $new_name
|
||||
}
|
||||
}
|
||||
|
||||
# git pull all extensions
|
||||
export def "comfy update_extensions" [--clean] {
|
||||
let root = get_root --clean=($clean)
|
||||
cd $root
|
||||
cd custom_nodes
|
||||
git multipull . -s -q
|
||||
}
|
||||
|
||||
def --env path-add [pth] {
|
||||
$env.PATH = ($env.PATH | append ($pth | path expand))
|
||||
|
||||
}
|
||||
|
||||
|
||||
export-env {
|
||||
$env.COMFY_MTB = ("." | path expand | str replace -a '\' '/')
|
||||
# $env.CUDA_ROOT = 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\'
|
||||
|
||||
$env.CUDA_HOME = $env.CUDA_ROOT
|
||||
|
||||
$env.COMFY_ROOT = ("../.." | path expand)
|
||||
$env.COMFY_CLEAN_ROOT = ($env.COMFY_ROOT | path dirname | path join ComfyClean)
|
||||
|
||||
path-add 'C:/Portable/TensorRT-8.6.0.12/lib'
|
||||
path-add ($env.CUDA_ROOT | path join bin)
|
||||
overlay use ../../.venv/Scripts/activate.nu
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
class ModelNotFound(Exception):
|
||||
def __init__(self, model_name, *args, **kwargs):
|
||||
super().__init__(
|
||||
f"The model {model_name} could not be found, make sure to download it using ComfyManager first.\nrepository: https://github.com/ltdrdata/ComfyUI-Manager",
|
||||
*args,
|
||||
**kwargs,
|
||||
)
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,905 +0,0 @@
|
||||
{
|
||||
"last_node_id": 97,
|
||||
"last_link_id": 179,
|
||||
"nodes": [
|
||||
{
|
||||
"id": 6,
|
||||
"type": "CLIPTextEncode",
|
||||
"pos": [
|
||||
-1165.8749246009997,
|
||||
30
|
||||
],
|
||||
"size": [
|
||||
422.84503173828125,
|
||||
164.31304931640625
|
||||
],
|
||||
"flags": {},
|
||||
"order": 4,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "clip",
|
||||
"type": "CLIP",
|
||||
"link": 3
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "CONDITIONING",
|
||||
"type": "CONDITIONING",
|
||||
"links": [
|
||||
4,
|
||||
158
|
||||
],
|
||||
"slot_index": 0
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "CLIPTextEncode"
|
||||
},
|
||||
"widgets_values": [
|
||||
"Closeup texture of rocks"
|
||||
],
|
||||
"color": "#432",
|
||||
"bgcolor": "#653",
|
||||
"shape": 1
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"type": "CLIPTextEncode",
|
||||
"pos": [
|
||||
-1175.8749246009997,
|
||||
250
|
||||
],
|
||||
"size": [
|
||||
425.27801513671875,
|
||||
180.6060791015625
|
||||
],
|
||||
"flags": {},
|
||||
"order": 5,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "clip",
|
||||
"type": "CLIP",
|
||||
"link": 5
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "CONDITIONING",
|
||||
"type": "CONDITIONING",
|
||||
"links": [
|
||||
6
|
||||
],
|
||||
"slot_index": 0
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "CLIPTextEncode"
|
||||
},
|
||||
"widgets_values": [
|
||||
"((drawing, cartoon, painting, sketch, blur, depth of field, dof))"
|
||||
],
|
||||
"color": "#432",
|
||||
"bgcolor": "#653",
|
||||
"shape": 1
|
||||
},
|
||||
{
|
||||
"id": 89,
|
||||
"type": "Reroute",
|
||||
"pos": [
|
||||
350,
|
||||
803
|
||||
],
|
||||
"size": [
|
||||
75,
|
||||
26
|
||||
],
|
||||
"flags": {},
|
||||
"order": 9,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "*",
|
||||
"link": 176
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "IMAGE",
|
||||
"links": [
|
||||
167
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"showOutputText": false,
|
||||
"horizontal": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"type": "CheckpointLoaderSimple",
|
||||
"pos": [
|
||||
-1740,
|
||||
236
|
||||
],
|
||||
"size": [
|
||||
315,
|
||||
98
|
||||
],
|
||||
"flags": {},
|
||||
"order": 0,
|
||||
"mode": 0,
|
||||
"outputs": [
|
||||
{
|
||||
"name": "MODEL",
|
||||
"type": "MODEL",
|
||||
"links": [
|
||||
170
|
||||
],
|
||||
"slot_index": 0
|
||||
},
|
||||
{
|
||||
"name": "CLIP",
|
||||
"type": "CLIP",
|
||||
"links": [
|
||||
3,
|
||||
5
|
||||
],
|
||||
"slot_index": 1
|
||||
},
|
||||
{
|
||||
"name": "VAE",
|
||||
"type": "VAE",
|
||||
"links": [],
|
||||
"slot_index": 2
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "CheckpointLoaderSimple"
|
||||
},
|
||||
"widgets_values": [
|
||||
"revAnimated_v122.safetensors"
|
||||
],
|
||||
"shape": 1
|
||||
},
|
||||
{
|
||||
"id": 63,
|
||||
"type": "SaveImage",
|
||||
"pos": [
|
||||
1315,
|
||||
18
|
||||
],
|
||||
"size": [
|
||||
539.2050170898438,
|
||||
617.2159423828125
|
||||
],
|
||||
"flags": {},
|
||||
"order": 13,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "images",
|
||||
"type": "IMAGE",
|
||||
"link": 115
|
||||
}
|
||||
],
|
||||
"title": "Normal",
|
||||
"properties": {},
|
||||
"widgets_values": [
|
||||
"Normal"
|
||||
],
|
||||
"shape": 1
|
||||
},
|
||||
{
|
||||
"id": 67,
|
||||
"type": "SaveImage",
|
||||
"pos": [
|
||||
2095,
|
||||
22
|
||||
],
|
||||
"size": [
|
||||
539.2050170898438,
|
||||
617.2159423828125
|
||||
],
|
||||
"flags": {},
|
||||
"order": 16,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "images",
|
||||
"type": "IMAGE",
|
||||
"link": 119
|
||||
}
|
||||
],
|
||||
"title": "Curvature",
|
||||
"properties": {},
|
||||
"widgets_values": [
|
||||
"Curvature"
|
||||
],
|
||||
"shape": 1
|
||||
},
|
||||
{
|
||||
"id": 69,
|
||||
"type": "SaveImage",
|
||||
"pos": [
|
||||
1560,
|
||||
1290
|
||||
],
|
||||
"size": [
|
||||
539.2050170898438,
|
||||
617.2159423828125
|
||||
],
|
||||
"flags": {},
|
||||
"order": 17,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "images",
|
||||
"type": "IMAGE",
|
||||
"link": 121
|
||||
}
|
||||
],
|
||||
"title": "Depth",
|
||||
"properties": {},
|
||||
"widgets_values": [
|
||||
"Height"
|
||||
],
|
||||
"shape": 1
|
||||
},
|
||||
{
|
||||
"id": 91,
|
||||
"type": "Model Patch Seamless (mtb)",
|
||||
"pos": [
|
||||
-1150,
|
||||
-146
|
||||
],
|
||||
"size": [
|
||||
430.8000183105469,
|
||||
78
|
||||
],
|
||||
"flags": {},
|
||||
"order": 3,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "model",
|
||||
"type": "MODEL",
|
||||
"link": 170
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "Original Model (passthrough)",
|
||||
"type": "MODEL",
|
||||
"links": null,
|
||||
"shape": 3
|
||||
},
|
||||
{
|
||||
"name": "Patched Model",
|
||||
"type": "MODEL",
|
||||
"links": [
|
||||
169
|
||||
],
|
||||
"shape": 3,
|
||||
"slot_index": 1
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "Model Patch Seamless (mtb)"
|
||||
},
|
||||
"widgets_values": [
|
||||
true
|
||||
],
|
||||
"color": "#232",
|
||||
"bgcolor": "#353"
|
||||
},
|
||||
{
|
||||
"id": 93,
|
||||
"type": "PreviewImage",
|
||||
"pos": [
|
||||
1115,
|
||||
-597
|
||||
],
|
||||
"size": [
|
||||
451.3526306152344,
|
||||
478.3444519042969
|
||||
],
|
||||
"flags": {},
|
||||
"order": 12,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "images",
|
||||
"type": "IMAGE",
|
||||
"link": 179
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "PreviewImage"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 43,
|
||||
"type": "VAELoader",
|
||||
"pos": [
|
||||
-598.2757622278747,
|
||||
577.3595309932109
|
||||
],
|
||||
"size": [
|
||||
387.48089599609375,
|
||||
70.60645294189453
|
||||
],
|
||||
"flags": {},
|
||||
"order": 1,
|
||||
"mode": 0,
|
||||
"outputs": [
|
||||
{
|
||||
"name": "VAE",
|
||||
"type": "VAE",
|
||||
"links": [
|
||||
174
|
||||
],
|
||||
"slot_index": 0
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "VAELoader"
|
||||
},
|
||||
"widgets_values": [
|
||||
"vae-ft-mse-840000-ema-pruned.safetensors"
|
||||
],
|
||||
"shape": 1
|
||||
},
|
||||
{
|
||||
"id": 97,
|
||||
"type": "Image Tile Offset (mtb)",
|
||||
"pos": [
|
||||
617,
|
||||
-598
|
||||
],
|
||||
"size": [
|
||||
315,
|
||||
58
|
||||
],
|
||||
"flags": {},
|
||||
"order": 10,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "image",
|
||||
"type": "IMAGE",
|
||||
"link": 178
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "IMAGE",
|
||||
"type": "IMAGE",
|
||||
"links": [
|
||||
179
|
||||
],
|
||||
"shape": 3,
|
||||
"slot_index": 0
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "Image Tile Offset (mtb)"
|
||||
},
|
||||
"widgets_values": [
|
||||
2
|
||||
],
|
||||
"color": "#232",
|
||||
"bgcolor": "#353"
|
||||
},
|
||||
{
|
||||
"id": 96,
|
||||
"type": "Vae Decode (mtb)",
|
||||
"pos": [
|
||||
-52,
|
||||
40
|
||||
],
|
||||
"size": [
|
||||
315,
|
||||
126
|
||||
],
|
||||
"flags": {},
|
||||
"order": 7,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "samples",
|
||||
"type": "LATENT",
|
||||
"link": 173
|
||||
},
|
||||
{
|
||||
"name": "vae",
|
||||
"type": "VAE",
|
||||
"link": 174
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "IMAGE",
|
||||
"type": "IMAGE",
|
||||
"links": [
|
||||
175,
|
||||
176,
|
||||
178
|
||||
],
|
||||
"shape": 3,
|
||||
"slot_index": 0
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "Vae Decode (mtb)"
|
||||
},
|
||||
"widgets_values": [
|
||||
true,
|
||||
false,
|
||||
512
|
||||
],
|
||||
"color": "#232",
|
||||
"bgcolor": "#353"
|
||||
},
|
||||
{
|
||||
"id": 46,
|
||||
"type": "SaveImage",
|
||||
"pos": [
|
||||
533,
|
||||
25
|
||||
],
|
||||
"size": [
|
||||
539.2050170898438,
|
||||
617.2159423828125
|
||||
],
|
||||
"flags": {},
|
||||
"order": 8,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "images",
|
||||
"type": "IMAGE",
|
||||
"link": 175
|
||||
}
|
||||
],
|
||||
"title": "Albedo",
|
||||
"properties": {},
|
||||
"widgets_values": [
|
||||
"Albedo"
|
||||
],
|
||||
"shape": 1
|
||||
},
|
||||
{
|
||||
"id": 74,
|
||||
"type": "EmptyLatentImage",
|
||||
"pos": [
|
||||
-1075.8749246009997,
|
||||
480
|
||||
],
|
||||
"size": [
|
||||
315,
|
||||
106
|
||||
],
|
||||
"flags": {},
|
||||
"order": 2,
|
||||
"mode": 0,
|
||||
"outputs": [
|
||||
{
|
||||
"name": "LATENT",
|
||||
"type": "LATENT",
|
||||
"links": [
|
||||
132
|
||||
],
|
||||
"shape": 3,
|
||||
"slot_index": 0
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "EmptyLatentImage"
|
||||
},
|
||||
"widgets_values": [
|
||||
768,
|
||||
768,
|
||||
1
|
||||
],
|
||||
"color": "#323",
|
||||
"bgcolor": "#535",
|
||||
"shape": 1
|
||||
},
|
||||
{
|
||||
"id": 62,
|
||||
"type": "Deep Bump (mtb)",
|
||||
"pos": [
|
||||
727,
|
||||
801
|
||||
],
|
||||
"size": [
|
||||
315,
|
||||
130
|
||||
],
|
||||
"flags": {},
|
||||
"order": 11,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "image",
|
||||
"type": "IMAGE",
|
||||
"link": 167
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "IMAGE",
|
||||
"type": "IMAGE",
|
||||
"links": [
|
||||
115,
|
||||
118,
|
||||
122
|
||||
],
|
||||
"shape": 3,
|
||||
"slot_index": 0
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "Deep Bump (mtb)"
|
||||
},
|
||||
"widgets_values": [
|
||||
"Color to Normals",
|
||||
"SMALL",
|
||||
"SMALLEST",
|
||||
true
|
||||
],
|
||||
"color": "#232",
|
||||
"bgcolor": "#353",
|
||||
"shape": 1
|
||||
},
|
||||
{
|
||||
"id": 66,
|
||||
"type": "Deep Bump (mtb)",
|
||||
"pos": [
|
||||
1626,
|
||||
808
|
||||
],
|
||||
"size": [
|
||||
315,
|
||||
130
|
||||
],
|
||||
"flags": {},
|
||||
"order": 14,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "image",
|
||||
"type": "IMAGE",
|
||||
"link": 118
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "IMAGE",
|
||||
"type": "IMAGE",
|
||||
"links": [
|
||||
119
|
||||
],
|
||||
"shape": 3,
|
||||
"slot_index": 0
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "Deep Bump (mtb)"
|
||||
},
|
||||
"widgets_values": [
|
||||
"Normals to Curvature",
|
||||
"SMALL",
|
||||
"SMALLEST",
|
||||
true
|
||||
],
|
||||
"color": "#232",
|
||||
"bgcolor": "#353",
|
||||
"shape": 1
|
||||
},
|
||||
{
|
||||
"id": 68,
|
||||
"type": "Deep Bump (mtb)",
|
||||
"pos": [
|
||||
1185,
|
||||
1288
|
||||
],
|
||||
"size": [
|
||||
315,
|
||||
130
|
||||
],
|
||||
"flags": {},
|
||||
"order": 15,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "image",
|
||||
"type": "IMAGE",
|
||||
"link": 122
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "IMAGE",
|
||||
"type": "IMAGE",
|
||||
"links": [
|
||||
121
|
||||
],
|
||||
"shape": 3,
|
||||
"slot_index": 0
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "Deep Bump (mtb)"
|
||||
},
|
||||
"widgets_values": [
|
||||
"Normals to Height",
|
||||
"SMALL",
|
||||
"SMALLEST",
|
||||
true
|
||||
],
|
||||
"color": "#232",
|
||||
"bgcolor": "#353",
|
||||
"shape": 1
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": "KSampler",
|
||||
"pos": [
|
||||
-518.2757622278748,
|
||||
47.359530993211024
|
||||
],
|
||||
"size": [
|
||||
315,
|
||||
474
|
||||
],
|
||||
"flags": {},
|
||||
"order": 6,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "model",
|
||||
"type": "MODEL",
|
||||
"link": 169
|
||||
},
|
||||
{
|
||||
"name": "positive",
|
||||
"type": "CONDITIONING",
|
||||
"link": 4
|
||||
},
|
||||
{
|
||||
"name": "negative",
|
||||
"type": "CONDITIONING",
|
||||
"link": 6
|
||||
},
|
||||
{
|
||||
"name": "latent_image",
|
||||
"type": "LATENT",
|
||||
"link": 132
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "LATENT",
|
||||
"type": "LATENT",
|
||||
"links": [
|
||||
173
|
||||
],
|
||||
"slot_index": 0
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "KSampler"
|
||||
},
|
||||
"widgets_values": [
|
||||
1001,
|
||||
"fixed",
|
||||
28,
|
||||
8,
|
||||
"dpmpp_2m",
|
||||
"normal",
|
||||
1
|
||||
],
|
||||
"color": "#222",
|
||||
"bgcolor": "#000",
|
||||
"shape": 1
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
[
|
||||
3,
|
||||
4,
|
||||
1,
|
||||
6,
|
||||
0,
|
||||
"CLIP"
|
||||
],
|
||||
[
|
||||
4,
|
||||
6,
|
||||
0,
|
||||
3,
|
||||
1,
|
||||
"CONDITIONING"
|
||||
],
|
||||
[
|
||||
5,
|
||||
4,
|
||||
1,
|
||||
7,
|
||||
0,
|
||||
"CLIP"
|
||||
],
|
||||
[
|
||||
6,
|
||||
7,
|
||||
0,
|
||||
3,
|
||||
2,
|
||||
"CONDITIONING"
|
||||
],
|
||||
[
|
||||
115,
|
||||
62,
|
||||
0,
|
||||
63,
|
||||
0,
|
||||
"IMAGE"
|
||||
],
|
||||
[
|
||||
118,
|
||||
62,
|
||||
0,
|
||||
66,
|
||||
0,
|
||||
"IMAGE"
|
||||
],
|
||||
[
|
||||
119,
|
||||
66,
|
||||
0,
|
||||
67,
|
||||
0,
|
||||
"IMAGE"
|
||||
],
|
||||
[
|
||||
121,
|
||||
68,
|
||||
0,
|
||||
69,
|
||||
0,
|
||||
"IMAGE"
|
||||
],
|
||||
[
|
||||
122,
|
||||
62,
|
||||
0,
|
||||
68,
|
||||
0,
|
||||
"IMAGE"
|
||||
],
|
||||
[
|
||||
132,
|
||||
74,
|
||||
0,
|
||||
3,
|
||||
3,
|
||||
"LATENT"
|
||||
],
|
||||
[
|
||||
158,
|
||||
6,
|
||||
0,
|
||||
86,
|
||||
0,
|
||||
"*"
|
||||
],
|
||||
[
|
||||
167,
|
||||
89,
|
||||
0,
|
||||
62,
|
||||
0,
|
||||
"IMAGE"
|
||||
],
|
||||
[
|
||||
169,
|
||||
91,
|
||||
1,
|
||||
3,
|
||||
0,
|
||||
"MODEL"
|
||||
],
|
||||
[
|
||||
170,
|
||||
4,
|
||||
0,
|
||||
91,
|
||||
0,
|
||||
"MODEL"
|
||||
],
|
||||
[
|
||||
173,
|
||||
3,
|
||||
0,
|
||||
96,
|
||||
0,
|
||||
"LATENT"
|
||||
],
|
||||
[
|
||||
174,
|
||||
43,
|
||||
0,
|
||||
96,
|
||||
1,
|
||||
"VAE"
|
||||
],
|
||||
[
|
||||
175,
|
||||
96,
|
||||
0,
|
||||
46,
|
||||
0,
|
||||
"IMAGE"
|
||||
],
|
||||
[
|
||||
176,
|
||||
96,
|
||||
0,
|
||||
89,
|
||||
0,
|
||||
"*"
|
||||
],
|
||||
[
|
||||
178,
|
||||
96,
|
||||
0,
|
||||
97,
|
||||
0,
|
||||
"IMAGE"
|
||||
],
|
||||
[
|
||||
179,
|
||||
97,
|
||||
0,
|
||||
93,
|
||||
0,
|
||||
"IMAGE"
|
||||
]
|
||||
],
|
||||
"groups": [
|
||||
{
|
||||
"title": "Seamless Diffusion",
|
||||
"bounding": [
|
||||
-1752,
|
||||
-392,
|
||||
1658,
|
||||
1102
|
||||
],
|
||||
"color": "#3f789e",
|
||||
"font_size": 76,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"title": "Seamless Check",
|
||||
"bounding": [
|
||||
421,
|
||||
-795,
|
||||
1374,
|
||||
763
|
||||
],
|
||||
"color": "#3f789e",
|
||||
"font_size": 76,
|
||||
"locked": false
|
||||
}
|
||||
],
|
||||
"config": {},
|
||||
"extra": {},
|
||||
"version": 0.4
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
{"last_node_id":9,"last_link_id":0,"nodes":[{"id":9,"type":"Note Plus (mtb)","pos":[332, 139, 0, 0, 0, 0, 0, 0, 0, 0],"size":[573.4446126650389, 1292.5298919072263],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[],"title":"Note+ (mtb)","properties":{},"widgets_values":["# Note+ Demo\n\n# Images \nyou can resize them (see showdown syntax)\n\n\n\n# iFrame (embeds)\n<iframe src=\"https://www.youtube.com/embed/tgbNymZ7vqY\">\n</iframe>\n\n# Headings\n\n# h1 Heading:smile:\n\n## h2 Heading\n\n### h3 Heading\n\n#### h4 Heading\n\n##### h5 Heading\n\n###### h6 Heading\n\n# Tables\n\nColons can be used to align columns.\n\n| Tables|Are|Cool |\n| ------------- |:-----------:| ----:|\n| col 3 is| right-aligned | $1600 |\n| col 2 is| centered| $12 |\n| zebra stripes | are neat|$1 |\n\nEmphasis, aka italics, with _asterisks_ or _underscores_.\n\nStrong emphasis, aka bold, with **asterisks** or **underscores**.\n\nCombined emphasis with **asterisks and _underscores_**.\n\nStrikethrough uses two tildes. ~~Scratch this.~~\n\n**This is bold text**\n\n**This is bold text**\n\n_This is italic text_\n\n_This is italic text_\n\n~~Strikethrough~~\n\n1. First ordered list item\n2. Another item\n\n- Unordered sub-list.\n\n1. Actual numbers don't matter, just that it's a number\n1. Ordered sub-list\n1. And another item.\n1.\n\n- [x] Finish my changes\n- [] Push my commits to GitHub\n- [] Open a pull request\n- [x] mentions:@melmass, #refs, [links](), **formatting**, and <del>tags</del> supported\n- [x] list syntax required (any unordered or ordered list supported)\n- [x] this is a complete item\n- [] this is an incomplete item\n","markdown","*{\ncolor:whitesmoke;\n}\n\nh1{\ncolor:cyan;\n}\nh2{\ncolor:yellow;\n}\nh3{\ncolor:pink;\n}\n\nstrong{\ncolor:red;\n}"],"color":"#223","bgcolor":"#335","shape":1}],"links":[],"groups":[],"config":{},"extra":{},"version":0.4}
|
||||
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* File: foldable.js
|
||||
* Project: comfy_mtb
|
||||
* Author: Mel Massadian
|
||||
*
|
||||
* Copyright (c) 2023 Mel Massadian
|
||||
*
|
||||
*/
|
||||
|
||||
function toggleFoldable(elementId, symbolId) {
|
||||
const content = document.getElementById(elementId)
|
||||
const symbol = document.getElementById(symbolId)
|
||||
if (content.style.display === 'none' || content.style.display === '') {
|
||||
content.style.display = 'flex'
|
||||
symbol.innerHTML = '▽' // Down arrow
|
||||
} else {
|
||||
content.style.display = 'none'
|
||||
symbol.innerHTML = '▷' // Right arrow
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* File: saveTableData.js
|
||||
* Project: comfy_mtb
|
||||
* Author: Mel Massadian
|
||||
*
|
||||
* Copyright (c) 2023 Mel Massadian
|
||||
*
|
||||
*/
|
||||
|
||||
function saveTableData(identifier) {
|
||||
const table = document.querySelector(
|
||||
`#style-editor table[data-id='${identifier}']`
|
||||
)
|
||||
|
||||
let currentData = []
|
||||
const rows = table.querySelectorAll('tr')
|
||||
const filename = table.getAttribute('data-id')
|
||||
|
||||
rows.forEach((row, rowIndex) => {
|
||||
const rowData = []
|
||||
const cells =
|
||||
rowIndex === 0
|
||||
? row.querySelectorAll('th')
|
||||
: row.querySelectorAll('td input, td textarea')
|
||||
|
||||
cells.forEach((cell) => {
|
||||
rowData.push(rowIndex === 0 ? cell.textContent : cell.value)
|
||||
})
|
||||
|
||||
currentData.push(rowData)
|
||||
})
|
||||
|
||||
let tablesData = {}
|
||||
tablesData[filename] = currentData
|
||||
|
||||
console.debug('Sending styles to manage endpoint:', tablesData)
|
||||
fetch('/mtb/actions', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name: 'saveStyle',
|
||||
args: tablesData,
|
||||
}),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
console.debug('Success:', data)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error)
|
||||
})
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/**
|
||||
* File: splitPane.js
|
||||
* Project: comfy_mtb
|
||||
* Author: Mel Massadian
|
||||
*
|
||||
* Copyright (c) 2023 Mel Massadian
|
||||
*
|
||||
*/
|
||||
|
||||
function initSplitPane(vertical) {
|
||||
let resizer = document.getElementById('resizer')
|
||||
let left = document.getElementById('leftPane')
|
||||
let right = document.getElementById('rightPane')
|
||||
resizer.addEventListener('mousedown', function (e) {
|
||||
document.addEventListener('mousemove', onMouseMove)
|
||||
document.addEventListener('mouseup', function () {
|
||||
document.removeEventListener('mousemove', onMouseMove)
|
||||
})
|
||||
})
|
||||
|
||||
const onMouseMove = (e) => {
|
||||
if (vertical) {
|
||||
let leftWidth = e.clientX
|
||||
let rightWidth = window.innerWidth - e.clientX
|
||||
left.style.width = leftWidth + 'px'
|
||||
right.style.width = rightWidth + 'px'
|
||||
} else {
|
||||
let topHeight = e.clientY
|
||||
let bottomHeight = window.innerHeight - e.clientY
|
||||
left.style.height = topHeight + 'px'
|
||||
right.style.height = bottomHeight + 'px'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* File: tabSwitch.js
|
||||
* Project: comfy_mtb
|
||||
* Author: Mel Massadian
|
||||
*
|
||||
* Copyright (c) 2023 Mel Massadian
|
||||
*
|
||||
*/
|
||||
|
||||
function openTab(evt, tabName) {
|
||||
var i, tabcontent, tablinks
|
||||
tabcontent = document.getElementsByClassName('tabcontent')
|
||||
for (i = 0; i < tabcontent.length; i++) {
|
||||
tabcontent[i].style.display = 'none'
|
||||
}
|
||||
tablinks = document.getElementsByClassName('tablinks')
|
||||
for (i = 0; i < tablinks.length; i++) {
|
||||
tablinks[i].className = tablinks[i].className.replace(' active', '')
|
||||
}
|
||||
document.getElementById(tabName).style.display = 'block'
|
||||
evt.currentTarget.className += ' active'
|
||||
}
|
||||
+3
-98
@@ -18,7 +18,7 @@ a {
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ main {
|
||||
justify-content: center;
|
||||
padding: 1em;
|
||||
margin: 0;
|
||||
/* height: 80%; */
|
||||
height: 80%;
|
||||
}
|
||||
|
||||
.flex-container {
|
||||
@@ -130,99 +130,4 @@ main {
|
||||
.menu {
|
||||
font-size: 3em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
input, button, textarea {
|
||||
background-color: rgba(0,0,0,0.5);
|
||||
color: white;
|
||||
border: none;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: rgba(0,0,0,0.3);
|
||||
|
||||
}
|
||||
button {
|
||||
padding: 14px 16px;
|
||||
|
||||
}
|
||||
/* -STYLES EDITOR */
|
||||
|
||||
#style-editor {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width:100%;
|
||||
|
||||
}
|
||||
|
||||
#style-editor > table {
|
||||
/* background-color: red; */
|
||||
width:100%;
|
||||
}
|
||||
#style-editor input, #style-editor textarea {
|
||||
/* background-color: blue; */
|
||||
width:100%;
|
||||
}
|
||||
|
||||
#style-editor td{
|
||||
width: 33.33%;
|
||||
}
|
||||
|
||||
/* -TABS */
|
||||
|
||||
.tab {
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
}
|
||||
|
||||
.tab-container{
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.tab button {
|
||||
background-color: transparent;
|
||||
color:white;
|
||||
float: left;
|
||||
border: none;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
padding: 14px 16px;
|
||||
transition: 0.3s;
|
||||
width:100%;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.tab button.active {
|
||||
background-color: #2e2e2e;
|
||||
}
|
||||
|
||||
.tabcontent {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tabcontent.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.foldable-title {
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.foldable-symbol {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.foldable-content {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
margin-left: 20px;
|
||||
}
|
||||
}
|
||||
+293
-82
@@ -1,34 +1,37 @@
|
||||
import argparse
|
||||
import ast
|
||||
import os
|
||||
import platform
|
||||
import shlex
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
from contextlib import contextmanager
|
||||
from importlib import import_module
|
||||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
import os
|
||||
import ast
|
||||
import argparse
|
||||
import sys
|
||||
import subprocess
|
||||
from importlib import import_module
|
||||
import platform
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import stat
|
||||
import threading
|
||||
import signal
|
||||
from contextlib import suppress
|
||||
from queue import Queue, Empty
|
||||
from contextlib import contextmanager
|
||||
|
||||
# region constants
|
||||
here = Path(__file__).parent
|
||||
executable = Path(sys.executable)
|
||||
executable = sys.executable
|
||||
|
||||
# - detect mode
|
||||
mode = None
|
||||
if os.environ.get("COLAB_GPU"):
|
||||
mode = "colab"
|
||||
elif "python_embeded" in str(executable):
|
||||
elif "python_embeded" in executable:
|
||||
mode = "embeded"
|
||||
elif ".venv" in str(executable):
|
||||
elif ".venv" in executable:
|
||||
mode = "venv"
|
||||
|
||||
|
||||
if mode is None:
|
||||
mode = "unknown"
|
||||
|
||||
# - Constants
|
||||
repo_url = "https://github.com/melmass/comfy_mtb.git"
|
||||
repo_owner = "melmass"
|
||||
repo_name = "comfy_mtb"
|
||||
@@ -37,17 +40,6 @@ short_platform = {
|
||||
"linux": "linux_x86_64",
|
||||
}
|
||||
current_platform = platform.system().lower()
|
||||
pip_map = {
|
||||
"onnxruntime-gpu": "onnxruntime",
|
||||
"opencv-contrib": "cv2",
|
||||
"tb-nightly": "tensorboard",
|
||||
"protobuf": "google.protobuf",
|
||||
"qrcode[pil]": "qrcode",
|
||||
"requirements-parser": "requirements"
|
||||
# Add more mappings as needed
|
||||
}
|
||||
|
||||
# endregion
|
||||
|
||||
# region ansi
|
||||
# ANSI escape sequences for text styling
|
||||
@@ -144,6 +136,12 @@ def print_formatted(text, *formats, color=None, background=None, **kwargs):
|
||||
|
||||
|
||||
# region utils
|
||||
def enqueue_output(out, queue):
|
||||
for char in iter(lambda: out.read(1), b""):
|
||||
queue.put(char)
|
||||
out.close()
|
||||
|
||||
|
||||
def run_command(cmd, ignored_lines_start=None):
|
||||
if ignored_lines_start is None:
|
||||
ignored_lines_start = []
|
||||
@@ -151,49 +149,113 @@ def run_command(cmd, ignored_lines_start=None):
|
||||
if isinstance(cmd, str):
|
||||
shell_cmd = cmd
|
||||
elif isinstance(cmd, list):
|
||||
shell_cmd = " ".join(
|
||||
arg.as_posix() if isinstance(arg, Path) else shlex.quote(str(arg))
|
||||
for arg in cmd
|
||||
)
|
||||
shell_cmd = ""
|
||||
for arg in cmd:
|
||||
if isinstance(arg, Path):
|
||||
arg = arg.as_posix()
|
||||
shell_cmd += f"{arg} "
|
||||
else:
|
||||
raise ValueError(
|
||||
"Invalid 'cmd' argument. It must be a string or a list of arguments."
|
||||
)
|
||||
|
||||
try:
|
||||
_run_command(shell_cmd, ignored_lines_start)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Command failed with return code: {e.returncode}", file=sys.stderr)
|
||||
print(e.stderr.strip(), file=sys.stderr)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("Command execution interrupted.")
|
||||
|
||||
|
||||
def _run_command(shell_cmd, ignored_lines_start):
|
||||
print_formatted(f"Running {shell_cmd}", "bold")
|
||||
result = subprocess.run(
|
||||
process = subprocess.Popen(
|
||||
shell_cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
universal_newlines=True,
|
||||
shell=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
stdout_lines = result.stdout.strip().split("\n")
|
||||
stderr_lines = result.stderr.strip().split("\n")
|
||||
# Create separate threads to read standard output and standard error streams
|
||||
stdout_queue = Queue()
|
||||
stderr_queue = Queue()
|
||||
stdout_thread = threading.Thread(
|
||||
target=enqueue_output, args=(process.stdout, stdout_queue)
|
||||
)
|
||||
stderr_thread = threading.Thread(
|
||||
target=enqueue_output, args=(process.stderr, stderr_queue)
|
||||
)
|
||||
stdout_thread.daemon = True
|
||||
stderr_thread.daemon = True
|
||||
stdout_thread.start()
|
||||
stderr_thread.start()
|
||||
|
||||
# Print stdout, skipping ignored lines
|
||||
for line in stdout_lines:
|
||||
if not any(line.startswith(ign) for ign in ignored_lines_start):
|
||||
print(line)
|
||||
interrupted = False
|
||||
|
||||
# Print stderr
|
||||
for line in stderr_lines:
|
||||
print(line, file=sys.stderr)
|
||||
def signal_handler(signum, frame):
|
||||
nonlocal interrupted
|
||||
interrupted = True
|
||||
print("Command execution interrupted.")
|
||||
|
||||
print("Command executed successfully!")
|
||||
# Register the signal handler for keyboard interrupts (SIGINT)
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
||||
stdout_buffer = ""
|
||||
stderr_buffer = ""
|
||||
|
||||
# Process output from both streams until the process completes or interrupted
|
||||
while not interrupted and (
|
||||
process.poll() is None or not stdout_queue.empty() or not stderr_queue.empty()
|
||||
):
|
||||
with suppress(Empty):
|
||||
stdout_char = stdout_queue.get_nowait()
|
||||
stdout_buffer += stdout_char
|
||||
if stdout_char == "\n":
|
||||
if not any(
|
||||
stdout_buffer.startswith(ign) for ign in ignored_lines_start
|
||||
):
|
||||
print(stdout_buffer.strip())
|
||||
stdout_buffer = ""
|
||||
with suppress(Empty):
|
||||
stderr_char = stderr_queue.get_nowait()
|
||||
stderr_buffer += stderr_char
|
||||
if stderr_char == "\n":
|
||||
print(stderr_buffer.strip())
|
||||
stderr_buffer = ""
|
||||
|
||||
# Print any remaining content in buffers
|
||||
if stdout_buffer and not any(
|
||||
stdout_buffer.startswith(ign) for ign in ignored_lines_start
|
||||
):
|
||||
print(stdout_buffer.strip())
|
||||
if stderr_buffer:
|
||||
print(stderr_buffer.strip())
|
||||
|
||||
return_code = process.returncode
|
||||
|
||||
if return_code == 0 and not interrupted:
|
||||
print("Command executed successfully!")
|
||||
else:
|
||||
if not interrupted:
|
||||
print(f"Command failed with return code: {return_code}")
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
try:
|
||||
import requirements
|
||||
except ImportError:
|
||||
print_formatted("Installing requirements-parser...", "italic", color="yellow")
|
||||
run_command([sys.executable, "-m", "pip", "install", "requirements-parser"])
|
||||
import requirements
|
||||
|
||||
print_formatted("Done.", "italic", color="green")
|
||||
|
||||
try:
|
||||
from tqdm import tqdm
|
||||
except ImportError:
|
||||
print_formatted("Installing tqdm...", "italic", color="yellow")
|
||||
run_command([sys.executable, "-m", "pip", "install", "--upgrade", "tqdm"])
|
||||
from tqdm import tqdm
|
||||
|
||||
pip_map = {
|
||||
"onnxruntime-gpu": "onnxruntime",
|
||||
"opencv-contrib": "cv2",
|
||||
"tb-nightly": "tensorboard",
|
||||
"protobuf": "google.protobuf",
|
||||
# Add more mappings as needed
|
||||
}
|
||||
|
||||
|
||||
def is_pipe():
|
||||
@@ -268,6 +330,24 @@ def download_file(url, file_name):
|
||||
progress_bar.update(len(chunk))
|
||||
|
||||
|
||||
def get_requirements(path: Path):
|
||||
with open(path.resolve(), "r") as requirements_file:
|
||||
requirements_txt = requirements_file.read()
|
||||
|
||||
try:
|
||||
parsed_requirements = requirements.parse(requirements_txt)
|
||||
except AttributeError:
|
||||
print_formatted(
|
||||
f"Failed to parse {path}. Please make sure the file is correctly formatted.",
|
||||
"bold",
|
||||
color="red",
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
return parsed_requirements
|
||||
|
||||
|
||||
def try_import(requirement):
|
||||
dependency = requirement.name.strip()
|
||||
import_name = pip_map.get(dependency, dependency)
|
||||
@@ -310,7 +390,7 @@ def import_or_install(requirement, dry=False):
|
||||
)
|
||||
else:
|
||||
try:
|
||||
run_command([executable, "-m", "pip", "install", pip_install_name])
|
||||
run_command([sys.executable, "-m", "pip", "install", pip_install_name])
|
||||
print_formatted(
|
||||
f"Package {pip_install_name} installed successfully using pip package name (import name: '{import_name}')",
|
||||
"bold",
|
||||
@@ -347,29 +427,29 @@ def get_github_assets(tag=None):
|
||||
return tag_data, tag_name
|
||||
|
||||
|
||||
# endregion
|
||||
# Install dependencies from requirements.txt
|
||||
def install_dependencies(dry=False):
|
||||
parsed_requirements = get_requirements(here / "reqs.txt")
|
||||
if not parsed_requirements:
|
||||
return
|
||||
print_formatted(
|
||||
"Installing dependencies from reqs.txt...", "italic", color="yellow"
|
||||
)
|
||||
|
||||
for requirement in parsed_requirements:
|
||||
import_or_install(requirement, dry=dry)
|
||||
|
||||
|
||||
try:
|
||||
from tqdm import tqdm
|
||||
except ImportError:
|
||||
print_formatted("Installing tqdm...", "italic", color="yellow")
|
||||
run_command([executable, "-m", "pip", "install", "--upgrade", "tqdm"])
|
||||
from tqdm import tqdm
|
||||
|
||||
|
||||
def main():
|
||||
if __name__ == "__main__":
|
||||
full = False
|
||||
if len(sys.argv) == 1:
|
||||
print_formatted(
|
||||
"mtb doesn't need an install script anymore.", "italic", color="yellow"
|
||||
"No arguments provided, doing a full install/update...",
|
||||
"italic",
|
||||
color="yellow",
|
||||
)
|
||||
return
|
||||
if all(arg not in ("-p", "--path") for arg in sys.argv):
|
||||
print(
|
||||
"This script is only used for and edge case of remote installs on some cloud providers, unrecognized arguments:",
|
||||
sys.argv[1:],
|
||||
)
|
||||
return
|
||||
|
||||
full = True
|
||||
|
||||
# Parse command-line arguments
|
||||
parser = argparse.ArgumentParser(description="Comfy_mtb install script")
|
||||
@@ -379,11 +459,29 @@ def main():
|
||||
type=str,
|
||||
help="Path to clone the repository to (i.e the absolute path to ComfyUI/custom_nodes)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--wheels", "-w", action="store_true", help="Install wheel dependencies"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--requirements", "-r", action="store_true", help="Install requirements.txt"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--dry",
|
||||
action="store_true",
|
||||
help="Print what will happen without doing it (still making requests to the GH Api)",
|
||||
)
|
||||
|
||||
# - keep
|
||||
# parser.add_argument(
|
||||
# "--version",
|
||||
# default=get_local_version(),
|
||||
# help="Version to check against the GitHub API",
|
||||
# )
|
||||
print_formatted("mtb install", "bold", color="yellow")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# wheels_directory = here / "wheels"
|
||||
print_formatted(f"Detected environment: {apply_color(mode,'cyan')}")
|
||||
|
||||
if args.path:
|
||||
@@ -404,18 +502,131 @@ def main():
|
||||
f"Directory {repo_dir} already exists, we will update it..."
|
||||
)
|
||||
run_command(["git", "pull", "-C", repo_dir])
|
||||
# os.chdir(clone_dir)
|
||||
here = clone_dir
|
||||
full = True
|
||||
|
||||
# Install dependencies from requirements.txt
|
||||
# if args.requirements or mode == "venv":
|
||||
|
||||
# if (not args.wheels and mode not in ["colab", "embeded"]) and not full:
|
||||
# print_formatted(
|
||||
# "Skipping wheel installation. Use --wheels to install wheel dependencies. (only needed for Comfy embed)",
|
||||
# "italic",
|
||||
# color="yellow",
|
||||
# )
|
||||
|
||||
# install_dependencies(dry=args.dry)
|
||||
# sys.exit()
|
||||
|
||||
# if mode in ["colab", "embeded"]:
|
||||
# print_formatted(
|
||||
# f"Downloading and installing release wheels since we are in a Comfy {apply_color(mode,'cyan')} environment",
|
||||
# "italic",
|
||||
# color="yellow",
|
||||
# )
|
||||
# if full:
|
||||
# print_formatted(
|
||||
# f"Downloading and installing release wheels since no arguments where provided",
|
||||
# "italic",
|
||||
# color="yellow",
|
||||
# )
|
||||
|
||||
print_formatted("Checking environment...", "italic", color="yellow")
|
||||
missing_deps = []
|
||||
install_cmd = [executable, "-m", "pip", "install", "-r", "requirements.txt"]
|
||||
run_command(install_cmd)
|
||||
if parsed_requirements := get_requirements(here / "reqs.txt"):
|
||||
for requirement in parsed_requirements:
|
||||
installed, pip_name, pip_spec, import_name = try_import(requirement)
|
||||
if not installed:
|
||||
missing_deps.append(pip_name.split("-")[0])
|
||||
|
||||
print_formatted(
|
||||
"✅ Successfully installed all dependencies.", "italic", color="green"
|
||||
)
|
||||
if not missing_deps:
|
||||
print_formatted(
|
||||
"All requirements are already installed. Enjoy 🚀",
|
||||
"italic",
|
||||
color="green",
|
||||
)
|
||||
sys.exit()
|
||||
|
||||
# # - Get the tag version from the GitHub API
|
||||
# tag_data, tag_name = get_github_assets(tag=None)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
# # - keep
|
||||
# version = args.version
|
||||
# # Compare the local and tag versions
|
||||
# if version and tag_name:
|
||||
# if re.match(r"v?(\d+(\.\d+)+)", version) and re.match(
|
||||
# r"v?(\d+(\.\d+)+)", tag_name
|
||||
# ):
|
||||
# version_parts = [int(part) for part in version.lstrip("v").split(".")]
|
||||
# tag_version_parts = [int(part) for part in tag_name.lstrip("v").split(".")]
|
||||
|
||||
# if version_parts > tag_version_parts:
|
||||
# print_formatted(
|
||||
# f"Local version ({version}) is greater than the release version ({tag_name}).",
|
||||
# "bold",
|
||||
# "yellow",
|
||||
# )
|
||||
# sys.exit()
|
||||
|
||||
# matching_assets = [
|
||||
# asset
|
||||
# for asset in tag_data["assets"]
|
||||
# if asset["name"].endswith(".whl")
|
||||
# and (
|
||||
# "any" in asset["name"] or short_platform[current_platform] in asset["name"]
|
||||
# )
|
||||
# ]
|
||||
# if not matching_assets:
|
||||
# print_formatted(
|
||||
# f"Unsupported operating system: {current_platform}", color="yellow"
|
||||
# )
|
||||
# wheel_order_asset = next(
|
||||
# (asset for asset in tag_data["assets"] if asset["name"] == "wheel_order.txt"),
|
||||
# None,
|
||||
# )
|
||||
# if wheel_order_asset is not None:
|
||||
# print_formatted(
|
||||
# "⚙️ Sorting the release wheels using wheels order", "italic", color="yellow"
|
||||
# )
|
||||
# response = requests.get(wheel_order_asset["browser_download_url"])
|
||||
# if response.status_code == 200:
|
||||
# wheel_order = [line.strip() for line in response.text.splitlines()]
|
||||
|
||||
# def get_order_index(val):
|
||||
# try:
|
||||
# return wheel_order.index(val)
|
||||
# except ValueError:
|
||||
# return len(wheel_order)
|
||||
|
||||
# matching_assets = sorted(
|
||||
# matching_assets,
|
||||
# key=lambda x: get_order_index(x["name"].split("-")[0]),
|
||||
# )
|
||||
# else:
|
||||
# print("Failed to fetch wheel_order.txt. Status code:", response.status_code)
|
||||
|
||||
# missing_deps_urls = []
|
||||
# for whl_file in matching_assets:
|
||||
# # check if installed
|
||||
# missing_deps_urls.append(whl_file["browser_download_url"])
|
||||
|
||||
install_cmd = [sys.executable, "-m", "pip", "install"]
|
||||
|
||||
# - Install all deps
|
||||
if not args.dry:
|
||||
if platform.system() == "Windows":
|
||||
wheel_cmd = install_cmd + ["-r", (here / "reqs_windows.txt")]
|
||||
else:
|
||||
wheel_cmd = install_cmd + ["-r", (here / "reqs.txt")]
|
||||
|
||||
run_command(wheel_cmd)
|
||||
print_formatted(
|
||||
"✅ Successfully installed all dependencies.", "italic", color="green"
|
||||
)
|
||||
else:
|
||||
print_formatted(
|
||||
f"Would have run the following command:\n\t{apply_color(' '.join(install_cmd),'cyan')}",
|
||||
"italic",
|
||||
color="yellow",
|
||||
)
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import os
|
||||
|
||||
base_log_level = logging.DEBUG if os.environ.get("MTB_DEBUG") else logging.INFO
|
||||
|
||||
|
||||
# Custom object that discards the output
|
||||
class NullWriter:
|
||||
"""Custom object that discards the output."""
|
||||
|
||||
def write(self, text):
|
||||
pass
|
||||
|
||||
|
||||
class ConsoleFormatter(logging.Formatter):
|
||||
"""Formatter for console based log, using base ansi colors."""
|
||||
|
||||
class Formatter(logging.Formatter):
|
||||
grey = "\x1b[38;20m"
|
||||
cyan = "\x1b[36;20m"
|
||||
purple = "\x1b[35;20m"
|
||||
@@ -23,39 +19,24 @@ class ConsoleFormatter(logging.Formatter):
|
||||
red = "\x1b[31;20m"
|
||||
bold_red = "\x1b[31;1m"
|
||||
reset = "\x1b[0m"
|
||||
# format = ("%(asctime)s - [%(name)s] - %(levelname)s "
|
||||
# "- %(message)s (%(filename)s:%(lineno)d)")
|
||||
fmt = "[%(name)s] | %(levelname)s -> %(message)s"
|
||||
# format = "%(asctime)s - [%(name)s] - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
|
||||
format = "[%(name)s] | %(levelname)s -> %(message)s"
|
||||
|
||||
FORMATS = {
|
||||
logging.DEBUG: f"{purple}{fmt}{reset}",
|
||||
logging.INFO: f"{cyan}{fmt}{reset}",
|
||||
logging.WARNING: f"{yellow}{fmt}{reset}",
|
||||
logging.ERROR: f"{red}{fmt}{reset}",
|
||||
logging.CRITICAL: f"{bold_red}{fmt}{reset}",
|
||||
logging.DEBUG: purple + format + reset,
|
||||
logging.INFO: cyan + format + reset,
|
||||
logging.WARNING: yellow + format + reset,
|
||||
logging.ERROR: red + format + reset,
|
||||
logging.CRITICAL: bold_red + format + reset,
|
||||
}
|
||||
|
||||
def format(self, record):
|
||||
log_fmt = self.FORMATS.get(record.levelno)
|
||||
|
||||
formatter = logging.Formatter(log_fmt)
|
||||
return formatter.format(record)
|
||||
|
||||
|
||||
class FileFormatter(logging.Formatter):
|
||||
"""Formatter for file base logs."""
|
||||
|
||||
# File specific formatting
|
||||
fmt = (
|
||||
"%(asctime)s - [%(name)s] - "
|
||||
"%(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
|
||||
)
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(self.fmt, "%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
def mklog(name: str, level: int = base_log_level, log_file: str | None = None):
|
||||
def mklog(name, level=base_log_level):
|
||||
logger = logging.getLogger(name)
|
||||
logger.setLevel(level)
|
||||
|
||||
@@ -64,16 +45,9 @@ def mklog(name: str, level: int = base_log_level, log_file: str | None = None):
|
||||
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(level)
|
||||
ch.setFormatter(ConsoleFormatter())
|
||||
ch.setFormatter(Formatter())
|
||||
logger.addHandler(ch)
|
||||
|
||||
if log_file:
|
||||
# file handler
|
||||
fh = logging.FileHandler(log_file)
|
||||
fh.setLevel(level)
|
||||
fh.setFormatter(FileFormatter())
|
||||
logger.addHandler(fh)
|
||||
|
||||
# Disable log propagation
|
||||
logger.propagate = False
|
||||
|
||||
@@ -84,30 +58,22 @@ def mklog(name: str, level: int = base_log_level, log_file: str | None = None):
|
||||
log = mklog(__package__, base_log_level)
|
||||
|
||||
|
||||
def log_user(arg: str):
|
||||
print(f"\033[34mComfy MTB Utils:\033[0m {arg}")
|
||||
def log_user(arg):
|
||||
print("\033[34mComfy MTB Utils:\033[0m {arg}")
|
||||
|
||||
|
||||
def get_summary(docstring: str):
|
||||
def get_summary(docstring):
|
||||
return docstring.strip().split("\n\n", 1)[0]
|
||||
|
||||
|
||||
def blue_text(text: str):
|
||||
def blue_text(text):
|
||||
return f"\033[94m{text}\033[0m"
|
||||
|
||||
|
||||
def cyan_text(text: str):
|
||||
def cyan_text(text):
|
||||
return f"\033[96m{text}\033[0m"
|
||||
|
||||
|
||||
def get_label(label: str):
|
||||
if label.startswith("MTB_"):
|
||||
label = label[4:]
|
||||
|
||||
words = re.findall(
|
||||
r"(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z]))",
|
||||
label,
|
||||
)
|
||||
reformatted_label = re.sub(r"([A-Z]+)", r" \1", label).strip()
|
||||
words = reformatted_label.split()
|
||||
def get_label(label):
|
||||
words = re.findall(r"(?:^|[A-Z])[a-z]*", label)
|
||||
return " ".join(words).strip()
|
||||
|
||||
+46
-79
@@ -1,79 +1,46 @@
|
||||
{
|
||||
"Animation Builder (mtb)": "Convenient way to manage basic animation maths at the core of many of my workflows",
|
||||
"Any To String (mtb)": "Tries to take any input and convert it to a string",
|
||||
"Batch Float (mtb)": "Generates a batch of float values with interpolation",
|
||||
"Batch Float Assemble (mtb)": "Assembles mutiple batches of floats into a single stream (batch)",
|
||||
"Batch Float Fill (mtb)": "Fills a batch float with a single value until it reaches the target length",
|
||||
"Batch Make (mtb)": "Simply duplicates the input frame as a batch",
|
||||
"Batch Merge (mtb)": "Merges multiple image batches with different frame counts",
|
||||
"Batch Shake (mtb)": "Applies a shaking effect to batches of images.",
|
||||
"Batch Shape (mtb)": "Generates a batch of 2D shapes with optional shading (experimental)",
|
||||
"Batch Transform (mtb)": "Transform a batch of images using a batch of keyframes",
|
||||
"Bbox (mtb)": "The bounding box (BBOX) custom type used by other nodes",
|
||||
"Bbox From Mask (mtb)": "From a mask extract the bounding box",
|
||||
"Blur (mtb)": "Blur an image using a Gaussian filter.",
|
||||
"Color Correct (mtb)": "Various color correction methods",
|
||||
"Colored Image (mtb)": "Constant color image of given size",
|
||||
"Concat Images (mtb)": "Add images to batch",
|
||||
"Crop (mtb)": "Crops an image and an optional mask to a given bounding box\n\n The bounding box can be given as a tuple of (x, y, width, height) or as a BBOX type\n The BBOX input takes precedence over the tuple input\n ",
|
||||
"Debug (mtb)": "Experimental node to debug any Comfy values, support for more types and widgets is planned",
|
||||
"Deep Bump (mtb)": "Normal & height maps generation from single pictures",
|
||||
"Export With Ffmpeg (mtb)": "Export with FFmpeg (Experimental)",
|
||||
"Face Swap (mtb)": "Face swap using deepinsight/insightface models",
|
||||
"Film Interpolation (mtb)": "Google Research FILM frame interpolation for large motion",
|
||||
"Fit Number (mtb)": "Fit the input float using a source and target range",
|
||||
"Float To Number (mtb)": "Node addon for the WAS Suite. Converts a \"comfy\" FLOAT to a NUMBER.",
|
||||
"Geometry Box (mtb)": "Makes a Box 3D geometry",
|
||||
"Geometry Decimater (mtb)": "Optimized the geometry to match the target number of triangles",
|
||||
"Geometry Info (mtb)": "Retrieve information about a 3D geometry",
|
||||
"Geometry Sphere (mtb)": "Makes a Sphere 3D geometry",
|
||||
"Geometry Test (mtb)": "Fetches an Open3D data geometry",
|
||||
"Get Batch From History (mtb)": "Very experimental node to load images from the history of the server.\n\n Queue items without output are ignored in the count.",
|
||||
"Image Compare (mtb)": "Compare two images and return a difference image",
|
||||
"Image Distort With Uv (mtb)": "Distorts an image based on a UV map.",
|
||||
"Image Premultiply (mtb)": "Premultiply image with mask",
|
||||
"Image Remove Background Rembg (mtb)": "Removes the background from the input using Rembg.",
|
||||
"Image Resize Factor (mtb)": "Extracted mostly from WAS Node Suite, with a few edits (most notably multiple image support) and less features.",
|
||||
"Image Tile Offset (mtb)": "Mimics an old photoshop technique to check for seamless textures",
|
||||
"Image To Uv (mtb)": "Turn an image back into a UV map. (Shallow converter)",
|
||||
"Image Tile Offset (mtb)": "Mimics an old photoshop technique to check for seamless textures",
|
||||
"Int To Bool (mtb)": "Basic int to bool conversion",
|
||||
"Int To Number (mtb)": "Node addon for the WAS Suite. Converts a \"comfy\" INT to a NUMBER.",
|
||||
"Interpolate Clip Sequential (mtb)": null,
|
||||
"Latent Lerp (mtb)": "Linear interpolation (blend) between two latent vectors",
|
||||
"Load Face Analysis Model (mtb)": "Loads a face analysis model",
|
||||
"Load Face Enhance Model (mtb)": "Loads a GFPGan or RestoreFormer model for face enhancement.",
|
||||
"Load Face Swap Model (mtb)": "Loads a faceswap model",
|
||||
"Load Film Model (mtb)": "Loads a FILM model",
|
||||
"Load Geometry (mtb)": "Load a 3D geometry",
|
||||
"Load Image From Url (mtb)": "Load an image from the given URL",
|
||||
"Load Image Sequence (mtb)": "Load an image sequence from a folder. The current frame is used to determine which image to load.\n\n Usually used in conjunction with the `Primitive` node set to increment to load a sequence of images from a folder.\n Use -1 to load all matching frames as a batch.\n ",
|
||||
"Mask To Image (mtb)": "Converts a mask (alpha) to an RGB image with a color and background",
|
||||
"Model Patch Seamless (mtb)": "Experimental patcher to enable the circular padding mode of the sd model layers, requires a custom VAE",
|
||||
"Math Expression (mtb)": "Node to evaluate a simple math expression string",
|
||||
"Model Patch Seamless (mtb)": "Uses the stable diffusion 'hack' to infer seamless images by setting the model layers padding mode to circular (experimental)",
|
||||
"Pick From Batch (mtb)": "Pick a specific number of images from a batch, either from the start or end.",
|
||||
"Qr Code (mtb)": "Basic QR Code generator",
|
||||
"Restore Face (mtb)": "Uses GFPGan to restore faces",
|
||||
"Save Gif (mtb)": "Save the images from the batch as a GIF",
|
||||
"Save Image Grid (mtb)": "Save all the images in the input batch as a grid of images.",
|
||||
"Save Image Sequence (mtb)": "Save an image sequence to a folder. The current frame is used to determine which image to save.\n\n This is merely a wrapper around the `save_images` function with formatting for the output folder and filename.\n ",
|
||||
"Save Tensors (mtb)": "Save torch tensors (image, mask or latent) to disk, useful to debug things outside comfy",
|
||||
"Sharpen (mtb)": "Sharpens an image using a Gaussian kernel.",
|
||||
"Smart Step (mtb)": "Utils to control the steps start/stop of the KAdvancedSampler in percentage",
|
||||
"Stack Images (mtb)": "Stack the input images horizontally or vertically",
|
||||
"String Replace (mtb)": "Basic string replacement",
|
||||
"Styles Loader (mtb)": "Load csv files and populate a dropdown from the rows (\u00e0 la A111)",
|
||||
"Text To Image (mtb)": "Utils to convert text to image using a font\n\n\n The tool looks for any .ttf file in the Comfy folder hierarchy.\n ",
|
||||
"Transform Geometry (mtb)": "Transforms the input geometry",
|
||||
"Transform Image (mtb)": "Save torch tensors (image, mask or latent) to disk, useful to debug things outside comfy\n\n\n it return a tensor representing the transformed images with the same shape as the input tensor\n ",
|
||||
"Uncrop (mtb)": "Uncrops an image to a given bounding box\n\n The bounding box can be given as a tuple of (x, y, width, height) or as a BBOX type\n The BBOX input takes precedence over the tuple input",
|
||||
"Unsplash Image (mtb)": "Unsplash Image given a keyword and a size",
|
||||
"Uv Distort (mtb)": "Applies a polar coordinates or wave distortion to the UV map",
|
||||
"Uv Map (mtb)": "Generates a UV Map tensor given a widht and height",
|
||||
"Uv Remove Seams (mtb)": "Blends values near the UV borders to mitigate visible seams.",
|
||||
"Uv Tile (mtb)": "Tiles the UV map based on the specified number of tiles.",
|
||||
"Uv To Image (mtb)": "Converts the UV map to an image. (Shallow converter)",
|
||||
"Vae Decode (mtb)": "Wrapper for the 2 core decoders (nomarl and tiled) but also adding the sd seamless hack, taken from: FlyingFireCo/tiled_ksampler"
|
||||
}
|
||||
|
||||
{
|
||||
"Animation Builder (mtb)": "Convenient way to manage basic animation maths at the core of many of my workflows",
|
||||
"Any To String (mtb)": "Tries to take any input and convert it to a string",
|
||||
"Bbox (mtb)": "The bounding box (BBOX) custom type used by other nodes",
|
||||
"Bbox From Mask (mtb)": "From a mask extract the bounding box",
|
||||
"Blur (mtb)": "Blur an image using a Gaussian filter.",
|
||||
"Color Correct (mtb)": "Various color correction methods",
|
||||
"Colored Image (mtb)": "Constant color image of given size",
|
||||
"Concat Images (mtb)": "Add images to batch",
|
||||
"Crop (mtb)": "Crops an image and an optional mask to a given bounding box\n\n The bounding box can be given as a tuple of (x, y, width, height) or as a BBOX type\n The BBOX input takes precedence over the tuple input\n ",
|
||||
"Debug (mtb)": "Experimental node to debug any Comfy values, support for more types and widgets is planned",
|
||||
"Deep Bump (mtb)": "Normal & height maps generation from single pictures",
|
||||
"Export With Ffmpeg (mtb)": "Export with FFmpeg (Experimental)",
|
||||
"Face Swap (mtb)": "Face swap using deepinsight/insightface models",
|
||||
"Film Interpolation (mtb)": "Google Research FILM frame interpolation for large motion",
|
||||
"Fit Number (mtb)": "Fit the input float using a source and target range",
|
||||
"Float To Number (mtb)": "Node addon for the WAS Suite. Converts a \"comfy\" FLOAT to a NUMBER.",
|
||||
"Get Batch From History (mtb)": "Very experimental node to load images from the history of the server.\n\n Queue items without output are ignored in the count.",
|
||||
"Image Compare (mtb)": "Compare two images and return a difference image",
|
||||
"Image Premultiply (mtb)": "Premultiply image with mask",
|
||||
"Image Remove Background Rembg (mtb)": "Removes the background from the input using Rembg.",
|
||||
"Image Resize Factor (mtb)": "Extracted mostly from WAS Node Suite, with a few edits (most notably multiple image support) and less features.",
|
||||
"Int To Bool (mtb)": "Basic int to bool conversion",
|
||||
"Int To Number (mtb)": "Node addon for the WAS Suite. Converts a \"comfy\" INT to a NUMBER.",
|
||||
"Latent Lerp (mtb)": "Linear interpolation (blend) between two latent vectors",
|
||||
"Load Face Analysis Model (mtb)": "Loads a face analysis model",
|
||||
"Load Face Enhance Model (mtb)": "Loads a GFPGan or RestoreFormer model for face enhancement.",
|
||||
"Load Face Swap Model (mtb)": "Loads a faceswap model",
|
||||
"Load Film Model (mtb)": "Loads a FILM model",
|
||||
"Load Image From Url (mtb)": "Load an image from the given URL",
|
||||
"Load Image Sequence (mtb)": "Load an image sequence from a folder. The current frame is used to determine which image to load.\n\n Usually used in conjunction with the `Primitive` node set to increment to load a sequence of images from a folder.\n Use -1 to load all matching frames as a batch.\n ",
|
||||
"Mask To Image (mtb)": "Converts a mask (alpha) to an RGB image with a color and background",
|
||||
"Qr Code (mtb)": "Basic QR Code generator",
|
||||
"Restore Face (mtb)": "Uses GFPGan to restore faces",
|
||||
"Save Gif (mtb)": "Save the images from the batch as a GIF",
|
||||
"Save Image Grid (mtb)": "Save all the images in the input batch as a grid of images.",
|
||||
"Save Image Sequence (mtb)": "Save an image sequence to a folder. The current frame is used to determine which image to save.\n\n This is merely a wrapper around the `save_images` function with formatting for the output folder and filename.\n ",
|
||||
"Save Tensors (mtb)": "Save torch tensors (image, mask or latent) to disk, useful to debug things outside comfy",
|
||||
"Smart Step (mtb)": "Utils to control the steps start/stop of the KAdvancedSampler in percentage",
|
||||
"String Replace (mtb)": "Basic string replacement",
|
||||
"Styles Loader (mtb)": "Load csv files and populate a dropdown from the rows (\u00e0 la A111)",
|
||||
"Text To Image (mtb)": "Utils to convert text to image using a font\n\n\n The tool looks for any .ttf file in the Comfy folder hierarchy.\n ",
|
||||
"Transform Image (mtb)": "Save torch tensors (image, mask or latent) to disk, useful to debug things outside comfy\n\n\n it return a tensor representing the transformed images with the same shape as the input tensor\n ",
|
||||
"Uncrop (mtb)": "Uncrops an image to a given bounding box\n\n The bounding box can be given as a tuple of (x, y, width, height) or as a BBOX type\n The BBOX input takes precedence over the tuple input",
|
||||
"Unsplash Image (mtb)": "Unsplash Image given a keyword and a size"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
"""MTB Nodes module."""
|
||||
|
||||
+3
-33
@@ -1,8 +1,8 @@
|
||||
from ..log import log
|
||||
|
||||
|
||||
class MTB_AnimationBuilder:
|
||||
"""Simple maths for animation."""
|
||||
class AnimationBuilder:
|
||||
"""Convenient way to manage basic animation maths at the core of many of my workflows"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -21,36 +21,6 @@ class MTB_AnimationBuilder:
|
||||
RETURN_NAMES = ("frame", "0-1 (scaled)", "count", "loop_ended")
|
||||
CATEGORY = "mtb/animation"
|
||||
FUNCTION = "build_animation"
|
||||
DESCRIPTION = """
|
||||
# Animation Builder
|
||||
|
||||
Check the
|
||||
[wiki page](https://github.com/melMass/comfy_mtb/wiki/nodes-animation-builder)
|
||||
for more info.
|
||||
|
||||
|
||||
- This basic example should help to understand the meaning of
|
||||
its inputs and outputs thanks to the [debug](nodes-debug) node.
|
||||
|
||||

|
||||
|
||||
- In this other example Animation Builder is used in combination with
|
||||
[Batch From History](https://github.com/melMass/comfy_mtb/wiki/nodes-batch-from-history)
|
||||
to create a zoom-in animation on a static image
|
||||
|
||||

|
||||
|
||||
## Inputs
|
||||
|
||||
| name | description |
|
||||
| ---- | :----------:|
|
||||
| total_frames | The number of frame to queue (this is multiplied by the `loop_count`)|
|
||||
| scale_float | Convenience input to scale the normalized `current value` (a float between 0 and 1 lerp over the current queue length) |
|
||||
| loop_count | The number of loops to queue |
|
||||
| **Reset Button** | resets the internal counters, although the node is though around using its queue button it should still work fine when using the regular queue button of comfy |
|
||||
| **Queue Button** | Convenience button to run the queues (`total_frames` * `loop_count`) |
|
||||
|
||||
"""
|
||||
|
||||
def build_animation(
|
||||
self,
|
||||
@@ -71,4 +41,4 @@ to create a zoom-in animation on a static image
|
||||
return (frame, scaled, raw_loop, (frame == (total_frames - 1)))
|
||||
|
||||
|
||||
__nodes__ = [MTB_AnimationBuilder]
|
||||
__nodes__ = [AnimationBuilder]
|
||||
|
||||
-235
@@ -1,235 +0,0 @@
|
||||
from typing import TypedDict
|
||||
|
||||
import torch
|
||||
import torchaudio
|
||||
|
||||
|
||||
class AudioDict(TypedDict):
|
||||
"""Comfy's representation of AUDIO data."""
|
||||
|
||||
sample_rate: int
|
||||
waveform: torch.Tensor
|
||||
|
||||
|
||||
AudioData = AudioDict | list[AudioDict]
|
||||
|
||||
|
||||
class MtbAudio:
|
||||
"""Base class for audio processing."""
|
||||
|
||||
@classmethod
|
||||
def is_stereo(
|
||||
cls,
|
||||
audios: AudioData,
|
||||
) -> bool:
|
||||
if isinstance(audios, list):
|
||||
return any(cls.is_stereo(audio) for audio in audios)
|
||||
else:
|
||||
return audios["waveform"].shape[1] == 2
|
||||
|
||||
@staticmethod
|
||||
def resample(audio: AudioDict, common_sample_rate: int) -> AudioDict:
|
||||
if audio["sample_rate"] != common_sample_rate:
|
||||
resampler = torchaudio.transforms.Resample(
|
||||
orig_freq=audio["sample_rate"], new_freq=common_sample_rate
|
||||
)
|
||||
return {
|
||||
"sample_rate": common_sample_rate,
|
||||
"waveform": resampler(audio["waveform"]),
|
||||
}
|
||||
else:
|
||||
return audio
|
||||
|
||||
@staticmethod
|
||||
def to_stereo(audio: AudioDict) -> AudioDict:
|
||||
if audio["waveform"].shape[1] == 1:
|
||||
return {
|
||||
"sample_rate": audio["sample_rate"],
|
||||
"waveform": torch.cat(
|
||||
[audio["waveform"], audio["waveform"]], dim=1
|
||||
),
|
||||
}
|
||||
else:
|
||||
return audio
|
||||
|
||||
@classmethod
|
||||
def preprocess_audios(
|
||||
cls, audios: list[AudioDict]
|
||||
) -> tuple[list[AudioDict], bool, int]:
|
||||
max_sample_rate = max([audio["sample_rate"] for audio in audios])
|
||||
|
||||
resampled_audios = [
|
||||
cls.resample(audio, max_sample_rate) for audio in audios
|
||||
]
|
||||
|
||||
is_stereo = cls.is_stereo(audios)
|
||||
if is_stereo:
|
||||
audios = [cls.to_stereo(audio) for audio in resampled_audios]
|
||||
|
||||
return (audios, is_stereo, max_sample_rate)
|
||||
|
||||
|
||||
class MTB_AudioCut(MtbAudio):
|
||||
"""Basic audio cutter, values are in ms."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"audio": ("AUDIO",),
|
||||
"length": (
|
||||
("FLOAT"),
|
||||
{
|
||||
"default": 1000.0,
|
||||
"min": 0.0,
|
||||
"max": 999999.0,
|
||||
"step": 1,
|
||||
},
|
||||
),
|
||||
"offset": (
|
||||
("FLOAT"),
|
||||
{"default": 0.0, "min": 0.0, "max": 999999.0, "step": 1},
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("AUDIO",)
|
||||
RETURN_NAMES = ("cut_audio",)
|
||||
CATEGORY = "mtb/audio"
|
||||
FUNCTION = "cut"
|
||||
|
||||
def cut(self, audio: AudioDict, length: float, offset: float):
|
||||
sample_rate = audio["sample_rate"]
|
||||
start_idx = int(offset * sample_rate / 1000)
|
||||
end_idx = min(
|
||||
start_idx + int(length * sample_rate / 1000),
|
||||
audio["waveform"].shape[-1],
|
||||
)
|
||||
cut_waveform = audio["waveform"][:, :, start_idx:end_idx]
|
||||
|
||||
return (
|
||||
{
|
||||
"sample_rate": sample_rate,
|
||||
"waveform": cut_waveform,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class MTB_AudioStack(MtbAudio):
|
||||
"""Stack/Overlay audio inputs (dynamic inputs).
|
||||
|
||||
- pad audios to the longest inputs.
|
||||
- resample audios to the highest sample rate in the inputs.
|
||||
- convert them all to stereo if one of the inputs is.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {"required": {}}
|
||||
|
||||
RETURN_TYPES = ("AUDIO",)
|
||||
RETURN_NAMES = ("stacked_audio",)
|
||||
CATEGORY = "mtb/audio"
|
||||
FUNCTION = "stack"
|
||||
|
||||
def stack(self, **kwargs: AudioDict) -> tuple[AudioDict]:
|
||||
audios, is_stereo, max_rate = self.preprocess_audios(
|
||||
list(kwargs.values())
|
||||
)
|
||||
|
||||
max_length = max([audio["waveform"].shape[-1] for audio in audios])
|
||||
|
||||
padded_audios: list[torch.Tensor] = []
|
||||
for audio in audios:
|
||||
padding = torch.zeros(
|
||||
(
|
||||
1,
|
||||
2 if is_stereo else 1,
|
||||
max_length - audio["waveform"].shape[-1],
|
||||
)
|
||||
)
|
||||
padded_audio = torch.cat([audio["waveform"], padding], dim=-1)
|
||||
padded_audios.append(padded_audio)
|
||||
|
||||
stacked_waveform = torch.stack(padded_audios, dim=0).sum(dim=0)
|
||||
|
||||
return (
|
||||
{
|
||||
"sample_rate": max_rate,
|
||||
"waveform": stacked_waveform,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class MTB_AudioSequence(MtbAudio):
|
||||
"""Sequence audio inputs (dynamic inputs).
|
||||
|
||||
- adding silence_duration between each segment
|
||||
can now also be negative to overlap the clips, safely bound
|
||||
to the the input length.
|
||||
- resample audios to the highest sample rate in the inputs.
|
||||
- convert them all to stereo if one of the inputs is.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"silence_duration": (
|
||||
("FLOAT"),
|
||||
{"default": 0.0, "min": -999.0, "max": 999, "step": 0.01},
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("AUDIO",)
|
||||
RETURN_NAMES = ("sequenced_audio",)
|
||||
CATEGORY = "mtb/audio"
|
||||
FUNCTION = "sequence"
|
||||
|
||||
def sequence(self, silence_duration: float, **kwargs: AudioDict):
|
||||
audios, is_stereo, max_rate = self.preprocess_audios(
|
||||
list(kwargs.values())
|
||||
)
|
||||
|
||||
sequence: list[torch.Tensor] = []
|
||||
for i, audio in enumerate(audios):
|
||||
if i > 0:
|
||||
if silence_duration > 0:
|
||||
silence = torch.zeros(
|
||||
(
|
||||
1,
|
||||
2 if is_stereo else 1,
|
||||
int(silence_duration * max_rate),
|
||||
)
|
||||
)
|
||||
sequence.append(silence)
|
||||
elif silence_duration < 0:
|
||||
overlap = int(abs(silence_duration) * max_rate)
|
||||
previous_audio = sequence[-1]
|
||||
overlap = min(
|
||||
overlap,
|
||||
previous_audio.shape[-1],
|
||||
audio["waveform"].shape[-1],
|
||||
)
|
||||
if overlap > 0:
|
||||
overlap_part = (
|
||||
previous_audio[:, :, -overlap:]
|
||||
+ audio["waveform"][:, :, :overlap]
|
||||
)
|
||||
sequence[-1] = previous_audio[:, :, :-overlap]
|
||||
sequence.append(overlap_part)
|
||||
audio["waveform"] = audio["waveform"][:, :, overlap:]
|
||||
|
||||
sequence.append(audio["waveform"])
|
||||
|
||||
sequenced_waveform = torch.cat(sequence, dim=-1)
|
||||
return (
|
||||
{
|
||||
"sample_rate": max_rate,
|
||||
"waveform": sequenced_waveform,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
__nodes__ = [MTB_AudioSequence, MTB_AudioStack, MTB_AudioCut]
|
||||
-1067
File diff suppressed because it is too large
Load Diff
+21
-178
@@ -1,131 +1,12 @@
|
||||
import csv
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import folder_paths
|
||||
import torch
|
||||
|
||||
from ..log import log
|
||||
from ..utils import here
|
||||
|
||||
Conditioning = list[tuple[torch.Tensor, dict[str, torch.Tensor]]]
|
||||
from ..log import log
|
||||
import folder_paths
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import csv
|
||||
|
||||
|
||||
def check_condition(conditioning: Conditioning):
|
||||
has_cn = False
|
||||
if len(conditioning) > 1:
|
||||
log.warn(
|
||||
"More than one conditioning was provided. Only the first one will be used."
|
||||
)
|
||||
first = conditioning[0]
|
||||
cond, kwargs = first
|
||||
|
||||
log.debug("Conditioning Shape")
|
||||
log.debug(cond.shape)
|
||||
log.debug("Conditioning keys")
|
||||
log.debug([f"\t{k} - {type(kwargs[k])}" for k in kwargs])
|
||||
if "control" in kwargs:
|
||||
log.debug("Conditioning contains a controlnet")
|
||||
has_cn = True
|
||||
if "pooled_output" not in kwargs:
|
||||
raise ValueError(
|
||||
"Conditioning is not valid. Missing 'pooled_output' key."
|
||||
)
|
||||
return has_cn
|
||||
|
||||
|
||||
class MTB_InterpolateCondition:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"blend": (
|
||||
"FLOAT",
|
||||
{"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.01},
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("CONDITIONING",)
|
||||
CATEGORY = "mtb/conditioning"
|
||||
FUNCTION = "execute"
|
||||
|
||||
def execute(
|
||||
self, blend: float, **kwargs: Conditioning
|
||||
) -> tuple[Conditioning]:
|
||||
blend = max(0.0, min(1.0, blend))
|
||||
|
||||
conditions: list[Conditioning] = list(kwargs.values())
|
||||
num_conditions = len(conditions)
|
||||
|
||||
if num_conditions < 2:
|
||||
raise ValueError("At least two conditioning inputs are required.")
|
||||
|
||||
segment_length = 1.0 / (num_conditions - 1)
|
||||
|
||||
segment_index = min(int(blend // segment_length), num_conditions - 2)
|
||||
|
||||
local_blend = (
|
||||
blend - (segment_index * segment_length)
|
||||
) / segment_length
|
||||
|
||||
cond_from = conditions[segment_index]
|
||||
cond_to = conditions[segment_index + 1]
|
||||
|
||||
from_cn = check_condition(cond_from)
|
||||
to_cn = check_condition(cond_to)
|
||||
|
||||
if from_cn and to_cn:
|
||||
raise ValueError(
|
||||
"Interpolating conditions cannot both contain ControlNets"
|
||||
)
|
||||
|
||||
try:
|
||||
interpolated_condition = [
|
||||
(1.0 - local_blend) * c_from + local_blend * c_to
|
||||
for c_from, c_to in zip(
|
||||
cond_from[0][0], cond_to[0][0], strict=False
|
||||
)
|
||||
]
|
||||
except Exception as e:
|
||||
print(f"Error during interpolation: {e}")
|
||||
raise
|
||||
|
||||
pooled_from = cond_from[0][1].get(
|
||||
"pooled_output",
|
||||
torch.zeros_like(
|
||||
next(iter(cond_from[0][1].values()), torch.tensor([]))
|
||||
),
|
||||
)
|
||||
|
||||
pooled_to = cond_to[0][1].get(
|
||||
"pooled_output",
|
||||
torch.zeros_like(
|
||||
next(iter(cond_from[0][1].values()), torch.tensor([]))
|
||||
),
|
||||
)
|
||||
|
||||
interpolated_pooled = (
|
||||
1.0 - local_blend
|
||||
) * pooled_from + local_blend * pooled_to
|
||||
|
||||
res = {"pooled_output": interpolated_pooled}
|
||||
|
||||
if from_cn:
|
||||
res["control"] = cond_from[0][1]["control"]
|
||||
res["control_apply_to_uncond"] = cond_from[0][1][
|
||||
"control_apply_to_uncond"
|
||||
]
|
||||
if to_cn:
|
||||
res["control"] = cond_to[0][1]["control"]
|
||||
res["control_apply_to_uncond"] = cond_to[0][1][
|
||||
"control_apply_to_uncond"
|
||||
]
|
||||
|
||||
return ([(torch.stack(interpolated_condition), res)],)
|
||||
|
||||
|
||||
class MTB_InterpolateClipSequential:
|
||||
class InterpolateClipSequential:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
@@ -146,12 +27,7 @@ class MTB_InterpolateClipSequential:
|
||||
CATEGORY = "mtb/conditioning"
|
||||
|
||||
def interpolate_encodings_sequential(
|
||||
self,
|
||||
base_text,
|
||||
text_to_replace,
|
||||
clip,
|
||||
interpolation_strength,
|
||||
**replacements,
|
||||
self, base_text, text_to_replace, clip, interpolation_strength, **replacements
|
||||
):
|
||||
log.debug(f"Received interpolation_strength: {interpolation_strength}")
|
||||
|
||||
@@ -186,30 +62,20 @@ class MTB_InterpolateClipSequential:
|
||||
log.debug("Using the base text a the base blend")
|
||||
# - Start with the base_text condition
|
||||
tokens = clip.tokenize(base_text)
|
||||
cond_from, pooled_from = clip.encode_from_tokens(
|
||||
tokens, return_pooled=True
|
||||
)
|
||||
cond_from, pooled_from = clip.encode_from_tokens(tokens, return_pooled=True)
|
||||
else:
|
||||
base_replace = list(replacements.values())[segment_index - 1]
|
||||
log.debug(f"Using {base_replace} a the base blend")
|
||||
|
||||
# - Start with the base_text condition replaced by the closest replacement
|
||||
tokens = clip.tokenize(
|
||||
base_text.replace(text_to_replace, base_replace)
|
||||
)
|
||||
cond_from, pooled_from = clip.encode_from_tokens(
|
||||
tokens, return_pooled=True
|
||||
)
|
||||
tokens = clip.tokenize(base_text.replace(text_to_replace, base_replace))
|
||||
cond_from, pooled_from = clip.encode_from_tokens(tokens, return_pooled=True)
|
||||
|
||||
replacement_text = list(replacements.values())[segment_index]
|
||||
|
||||
interpolated_text = base_text.replace(
|
||||
text_to_replace, replacement_text
|
||||
)
|
||||
interpolated_text = base_text.replace(text_to_replace, replacement_text)
|
||||
tokens = clip.tokenize(interpolated_text)
|
||||
cond_to, pooled_to = clip.encode_from_tokens(
|
||||
tokens, return_pooled=True
|
||||
)
|
||||
cond_to, pooled_to = clip.encode_from_tokens(tokens, return_pooled=True)
|
||||
|
||||
# - Linearly interpolate between the two conditions
|
||||
interpolated_condition = (
|
||||
@@ -219,12 +85,10 @@ class MTB_InterpolateClipSequential:
|
||||
1.0 - local_strength
|
||||
) * pooled_from + local_strength * pooled_to
|
||||
|
||||
return (
|
||||
[[interpolated_condition, {"pooled_output": interpolated_pooled}]],
|
||||
)
|
||||
return ([[interpolated_condition, {"pooled_output": interpolated_pooled}]],)
|
||||
|
||||
|
||||
class MTB_SmartStep:
|
||||
class SmartStep:
|
||||
"""Utils to control the steps start/stop of the KAdvancedSampler in percentage"""
|
||||
|
||||
@classmethod
|
||||
@@ -271,7 +135,7 @@ def install_default_styles(force=False):
|
||||
return dest_style
|
||||
|
||||
|
||||
class MTB_StylesLoader:
|
||||
class StylesLoader:
|
||||
"""Load csv files and populate a dropdown from the rows (à la A111)"""
|
||||
|
||||
options = {}
|
||||
@@ -283,33 +147,17 @@ class MTB_StylesLoader:
|
||||
if not input_dir.exists():
|
||||
install_default_styles()
|
||||
|
||||
if not (
|
||||
files := [f for f in input_dir.iterdir() if f.suffix == ".csv"]
|
||||
):
|
||||
if not (files := [f for f in input_dir.iterdir() if f.suffix == ".csv"]):
|
||||
log.warn(
|
||||
"No styles found in the styles folder, place at least one csv file in the styles folder at the root of ComfyUI (for instance ComfyUI/styles/mystyle.csv)"
|
||||
)
|
||||
|
||||
for file in files:
|
||||
with open(file, encoding="utf8") as f:
|
||||
with open(file, "r", encoding="utf8") as f:
|
||||
parsed = csv.reader(f)
|
||||
for i, row in enumerate(parsed):
|
||||
# log.debug(f"Adding style {row[0]}")
|
||||
try:
|
||||
name, positive, negative = (row + [None] * 3)[:3]
|
||||
positive = positive or ""
|
||||
negative = negative or ""
|
||||
if name is not None:
|
||||
cls.options[name] = (positive, negative)
|
||||
else:
|
||||
# Handle the case where 'name' is None
|
||||
log.warning(f"Missing 'name' in row {i}.")
|
||||
|
||||
except Exception as e:
|
||||
log.warning(
|
||||
f"There was an error while parsing {file}, make sure it respects A1111 format, i.e 3 columns name, positive, negative:\n{e}"
|
||||
)
|
||||
continue
|
||||
for row in parsed:
|
||||
log.debug(f"Adding style {row[0]}")
|
||||
cls.options[row[0]] = (row[1], row[2])
|
||||
|
||||
else:
|
||||
log.debug(f"Using cached styles (count: {len(cls.options)})")
|
||||
@@ -330,9 +178,4 @@ class MTB_StylesLoader:
|
||||
return (self.options[style_name][0], self.options[style_name][1])
|
||||
|
||||
|
||||
__nodes__ = [
|
||||
MTB_SmartStep,
|
||||
MTB_StylesLoader,
|
||||
MTB_InterpolateClipSequential,
|
||||
MTB_InterpolateCondition,
|
||||
]
|
||||
__nodes__ = [SmartStep, StylesLoader, InterpolateClipSequential]
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import json
|
||||
|
||||
from ..log import log
|
||||
|
||||
|
||||
class MTB_Constant:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {"Value": ("*",)},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("*",)
|
||||
RETURN_NAMES = ("output",)
|
||||
CATEGORY = "mtb/utils"
|
||||
FUNCTION = "execute"
|
||||
|
||||
def execute(
|
||||
self,
|
||||
**kwargs,
|
||||
):
|
||||
log.debug("Received kwargs")
|
||||
log.debug(json.dumps(kwargs, check_circular=True))
|
||||
return (kwargs.get("Value"),)
|
||||
|
||||
|
||||
# __nodes__ = [MTB_Constant]
|
||||
+29
-123
@@ -1,12 +1,12 @@
|
||||
import numpy as np
|
||||
import torch
|
||||
from PIL import Image, ImageDraw, ImageFilter
|
||||
from ..utils import tensor2pil, pil2tensor, tensor2np, np2tensor
|
||||
from PIL import Image, ImageFilter, ImageDraw, ImageChops
|
||||
import numpy as np
|
||||
|
||||
from ..log import log
|
||||
from ..utils import np2tensor, pil2tensor, tensor2np, tensor2pil
|
||||
|
||||
|
||||
class MTB_Bbox:
|
||||
class Bbox:
|
||||
"""The bounding box (BBOX) custom type used by other nodes"""
|
||||
|
||||
@classmethod
|
||||
@@ -14,14 +14,8 @@ class MTB_Bbox:
|
||||
return {
|
||||
"required": {
|
||||
# "bbox": ("BBOX",),
|
||||
"x": (
|
||||
"INT",
|
||||
{"default": 0, "max": 10000000, "min": 0, "step": 1},
|
||||
),
|
||||
"y": (
|
||||
"INT",
|
||||
{"default": 0, "max": 10000000, "min": 0, "step": 1},
|
||||
),
|
||||
"x": ("INT", {"default": 0, "max": 10000000, "min": 0, "step": 1}),
|
||||
"y": ("INT", {"default": 0, "max": 10000000, "min": 0, "step": 1}),
|
||||
"width": (
|
||||
"INT",
|
||||
{"default": 256, "max": 10000000, "min": 0, "step": 1},
|
||||
@@ -37,59 +31,12 @@ class MTB_Bbox:
|
||||
FUNCTION = "do_crop"
|
||||
CATEGORY = "mtb/crop"
|
||||
|
||||
def do_crop(self, x: int, y: int, width: int, height: int): # bbox
|
||||
return ((x, y, width, height),)
|
||||
def do_crop(self, x, y, width, height): # bbox
|
||||
return (x, y, width, height)
|
||||
# return bbox
|
||||
|
||||
|
||||
class MTB_SplitBbox:
|
||||
"""Split the components of a bbox"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {"bbox": ("BBOX",)},
|
||||
}
|
||||
|
||||
CATEGORY = "mtb/crop"
|
||||
FUNCTION = "split_bbox"
|
||||
RETURN_TYPES = ("INT", "INT", "INT", "INT")
|
||||
RETURN_NAMES = ("x", "y", "width", "height")
|
||||
|
||||
def split_bbox(self, bbox):
|
||||
return (bbox[0], bbox[1], bbox[2], bbox[3])
|
||||
|
||||
|
||||
class MTB_UpscaleBboxBy:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"bbox": ("BBOX",),
|
||||
"scale": ("FLOAT", {"default": 1.0}),
|
||||
},
|
||||
}
|
||||
|
||||
CATEGORY = "mtb/crop"
|
||||
RETURN_TYPES = ("BBOX",)
|
||||
|
||||
FUNCTION = "upscale"
|
||||
|
||||
def upscale(
|
||||
self, bbox: tuple[int, int, int, int], scale: float
|
||||
) -> tuple[tuple[int, int, int, int]]:
|
||||
x, y, width, height = bbox
|
||||
# scaled = (x * scale, y * scale, width * scale, height * scale)
|
||||
scaled = (
|
||||
int(x * scale),
|
||||
int(y * scale),
|
||||
int(width * scale),
|
||||
int(height * scale),
|
||||
)
|
||||
|
||||
return (scaled,)
|
||||
|
||||
|
||||
class MTB_BboxFromMask:
|
||||
class BboxFromMask:
|
||||
"""From a mask extract the bounding box"""
|
||||
|
||||
@classmethod
|
||||
@@ -97,7 +44,6 @@ class MTB_BboxFromMask:
|
||||
return {
|
||||
"required": {
|
||||
"mask": ("MASK",),
|
||||
"invert": ("BOOLEAN", {"default": False}),
|
||||
},
|
||||
"optional": {
|
||||
"image": ("IMAGE",),
|
||||
@@ -115,9 +61,7 @@ class MTB_BboxFromMask:
|
||||
FUNCTION = "extract_bounding_box"
|
||||
CATEGORY = "mtb/crop"
|
||||
|
||||
def extract_bounding_box(
|
||||
self, mask: torch.Tensor, invert: bool, image=None
|
||||
):
|
||||
def extract_bounding_box(self, mask: torch.Tensor, image=None):
|
||||
# if image != None:
|
||||
# if mask.size(0) != image.size(0):
|
||||
# if mask.size(0) != 1:
|
||||
@@ -129,8 +73,9 @@ class MTB_BboxFromMask:
|
||||
# f"Batch count mismatch for mask and image, it can either be 1 mask for X images, or X masks for X images (mask: {mask.shape} | image: {image.shape})"
|
||||
# )
|
||||
|
||||
_mask = tensor2pil(1.0 - mask)[0]
|
||||
|
||||
# we invert it
|
||||
_mask = tensor2pil(1.0 - mask)[0] if invert else tensor2pil(mask)[0]
|
||||
alpha_channel = np.array(_mask)
|
||||
|
||||
non_zero_indices = np.nonzero(alpha_channel)
|
||||
@@ -158,7 +103,7 @@ class MTB_BboxFromMask:
|
||||
)
|
||||
|
||||
|
||||
class MTB_Crop:
|
||||
class Crop:
|
||||
"""Crops an image and an optional mask to a given bounding box
|
||||
|
||||
The bounding box can be given as a tuple of (x, y, width, height) or as a BBOX type
|
||||
@@ -173,14 +118,8 @@ class MTB_Crop:
|
||||
},
|
||||
"optional": {
|
||||
"mask": ("MASK",),
|
||||
"x": (
|
||||
"INT",
|
||||
{"default": 0, "max": 10000000, "min": 0, "step": 1},
|
||||
),
|
||||
"y": (
|
||||
"INT",
|
||||
{"default": 0, "max": 10000000, "min": 0, "step": 1},
|
||||
),
|
||||
"x": ("INT", {"default": 0, "max": 10000000, "min": 0, "step": 1}),
|
||||
"y": ("INT", {"default": 0, "max": 10000000, "min": 0, "step": 1}),
|
||||
"width": (
|
||||
"INT",
|
||||
{"default": 256, "max": 10000000, "min": 0, "step": 1},
|
||||
@@ -199,37 +138,22 @@ class MTB_Crop:
|
||||
CATEGORY = "mtb/crop"
|
||||
|
||||
def do_crop(
|
||||
self,
|
||||
image: torch.Tensor,
|
||||
mask=None,
|
||||
x=0,
|
||||
y=0,
|
||||
width=256,
|
||||
height=256,
|
||||
bbox=None,
|
||||
self, image: torch.Tensor, mask=None, x=0, y=0, width=256, height=256, bbox=None
|
||||
):
|
||||
image = image.numpy()
|
||||
if mask is not None:
|
||||
if mask:
|
||||
mask = mask.numpy()
|
||||
|
||||
if bbox is not None:
|
||||
if bbox != None:
|
||||
x, y, width, height = bbox
|
||||
|
||||
cropped_image = image[:, y : y + height, x : x + width, :]
|
||||
cropped_mask = None
|
||||
if mask is not None:
|
||||
cropped_mask = (
|
||||
mask[:, y : y + height, x : x + width]
|
||||
if mask is not None
|
||||
else None
|
||||
)
|
||||
cropped_mask = mask[y : y + height, x : x + width] if mask != None else None
|
||||
crop_data = (x, y, width, height)
|
||||
|
||||
return (
|
||||
torch.from_numpy(cropped_image),
|
||||
torch.from_numpy(cropped_mask)
|
||||
if cropped_mask is not None
|
||||
else None,
|
||||
torch.from_numpy(cropped_mask) if mask != None else None,
|
||||
crop_data,
|
||||
)
|
||||
|
||||
@@ -266,12 +190,11 @@ def bbox_to_region(bbox, target_size=None):
|
||||
return (bbox[0], bbox[1], bbox[0] + bbox[2], bbox[1] + bbox[3])
|
||||
|
||||
|
||||
class MTB_Uncrop:
|
||||
class Uncrop:
|
||||
"""Uncrops an image to a given bounding box
|
||||
|
||||
The bounding box can be given as a tuple of (x, y, width, height) or as a BBOX type
|
||||
The BBOX input takes precedence over the tuple input
|
||||
"""
|
||||
The BBOX input takes precedence over the tuple input"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -295,15 +218,11 @@ class MTB_Uncrop:
|
||||
def do_crop(self, image, crop_image, bbox, border_blending):
|
||||
def inset_border(image, border_width=20, border_color=(0)):
|
||||
width, height = image.size
|
||||
bordered_image = Image.new(
|
||||
image.mode, (width, height), border_color
|
||||
)
|
||||
bordered_image = Image.new(image.mode, (width, height), border_color)
|
||||
bordered_image.paste(image, (0, 0))
|
||||
draw = ImageDraw.Draw(bordered_image)
|
||||
draw.rectangle(
|
||||
(0, 0, width - 1, height - 1),
|
||||
outline=border_color,
|
||||
width=border_width,
|
||||
(0, 0, width - 1, height - 1), outline=border_color, width=border_width
|
||||
)
|
||||
return bordered_image
|
||||
|
||||
@@ -326,9 +245,7 @@ class MTB_Uncrop:
|
||||
# uncrop the image based on the bounding box
|
||||
bb_x, bb_y, bb_width, bb_height = bbox
|
||||
|
||||
paste_region = bbox_to_region(
|
||||
(bb_x, bb_y, bb_width, bb_height), img.size
|
||||
)
|
||||
paste_region = bbox_to_region((bb_x, bb_y, bb_width, bb_height), img.size)
|
||||
# log.debug(f"Paste region: {paste_region}")
|
||||
# new_region = adjust_paste_region(img.size, paste_region)
|
||||
# log.debug(f"Adjusted paste region: {new_region}")
|
||||
@@ -354,16 +271,12 @@ class MTB_Uncrop:
|
||||
|
||||
mask.paste(mask_block, paste_region)
|
||||
log.debug(f"Blend size: {blend.size} | kind {blend.mode}")
|
||||
log.debug(
|
||||
f"Crop image size: {crop_img.size} | kind {crop_img.mode}"
|
||||
)
|
||||
log.debug(f"Crop image size: {crop_img.size} | kind {crop_img.mode}")
|
||||
log.debug(f"BBox: {paste_region}")
|
||||
blend.paste(crop_img, paste_region)
|
||||
|
||||
mask = mask.filter(ImageFilter.BoxBlur(radius=blend_ratio / 4))
|
||||
mask = mask.filter(
|
||||
ImageFilter.GaussianBlur(radius=blend_ratio / 4)
|
||||
)
|
||||
mask = mask.filter(ImageFilter.GaussianBlur(radius=blend_ratio / 4))
|
||||
|
||||
blend.putalpha(mask)
|
||||
img = Image.alpha_composite(img.convert("RGBA"), blend)
|
||||
@@ -372,11 +285,4 @@ class MTB_Uncrop:
|
||||
return (pil2tensor(out_images),)
|
||||
|
||||
|
||||
__nodes__ = [
|
||||
MTB_BboxFromMask,
|
||||
MTB_Bbox,
|
||||
MTB_Crop,
|
||||
MTB_Uncrop,
|
||||
MTB_SplitBbox,
|
||||
MTB_UpscaleBboxBy,
|
||||
]
|
||||
__nodes__ = [BboxFromMask, Bbox, Crop, Uncrop]
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
import json
|
||||
|
||||
from ..log import log
|
||||
|
||||
|
||||
def deserialize_curve(curve):
|
||||
if isinstance(curve, str):
|
||||
curve = json.loads(curve)
|
||||
return curve
|
||||
|
||||
|
||||
def serialize_curve(curve):
|
||||
if not isinstance(curve, str):
|
||||
curve = json.dumps(curve)
|
||||
return curve
|
||||
|
||||
|
||||
class MTBCurve:
|
||||
"""A basic FLOAT_CURVE input node."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"curve": ("FLOAT_CURVE",),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("FLOAT_CURVE",)
|
||||
FUNCTION = "do_curve"
|
||||
|
||||
CATEGORY = "mtb/curve"
|
||||
|
||||
def do_curve(self, curve):
|
||||
log.debug(f"Curve: {curve}")
|
||||
return (curve,)
|
||||
|
||||
|
||||
class MTB_CurveToFloat:
|
||||
"""Convert a FLOAT_CURVE to a FLOAT or FLOATS"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"curve": ("FLOAT_CURVE", {"forceInput": True}),
|
||||
"steps": ("INT", {"default": 10, "min": 2}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("FLOATS", "FLOAT")
|
||||
FUNCTION = "do_curve"
|
||||
|
||||
CATEGORY = "mtb/curve"
|
||||
|
||||
def do_curve(self, curve, steps):
|
||||
log.debug(f"Curve: {curve}")
|
||||
|
||||
# sort by x (should be handled by the widget)
|
||||
sorted_points = sorted(curve.items(), key=lambda item: item[1]["x"])
|
||||
# Extract X and Y values
|
||||
x_values = [point[1]["x"] for point in sorted_points]
|
||||
y_values = [point[1]["y"] for point in sorted_points]
|
||||
# Calculate step size
|
||||
step_size = (max(x_values) - min(x_values)) / (steps - 1)
|
||||
|
||||
# Interpolate Y values for each step
|
||||
interpolated_y_values = []
|
||||
for step in range(steps):
|
||||
current_x = min(x_values) + step_size * step
|
||||
|
||||
# Find the indices of the two points between which the current_x falls
|
||||
idx1 = max(idx for idx, x in enumerate(x_values) if x <= current_x)
|
||||
idx2 = min(idx for idx, x in enumerate(x_values) if x >= current_x)
|
||||
|
||||
# If the current_x matches one of the points, no interpolation is needed
|
||||
if current_x == x_values[idx1]:
|
||||
interpolated_y_values.append(y_values[idx1])
|
||||
elif current_x == x_values[idx2]:
|
||||
interpolated_y_values.append(y_values[idx2])
|
||||
else:
|
||||
# Interpolate Y value using linear interpolation
|
||||
y1 = y_values[idx1]
|
||||
y2 = y_values[idx2]
|
||||
x1 = x_values[idx1]
|
||||
x2 = x_values[idx2]
|
||||
interpolated_y = y1 + (y2 - y1) * (current_x - x1) / (x2 - x1)
|
||||
interpolated_y_values.append(interpolated_y)
|
||||
|
||||
return (interpolated_y_values, interpolated_y_values)
|
||||
|
||||
|
||||
__nodes__ = [MTBCurve, MTB_CurveToFloat]
|
||||
+41
-135
@@ -1,157 +1,64 @@
|
||||
import base64
|
||||
import io
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
import folder_paths
|
||||
import open3d as o3d
|
||||
import torch
|
||||
|
||||
from ..utils import tensor2pil
|
||||
from ..log import log
|
||||
from ..utils import mesh_to_json, tensor2b64
|
||||
import io, base64
|
||||
import torch
|
||||
import folder_paths
|
||||
from typing import Optional
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# region processors
|
||||
def process_tensor(tensor: torch.Tensor):
|
||||
log.debug(f"Tensor: {tensor.shape}")
|
||||
|
||||
return {"b64_images": tensor2b64(tensor)}
|
||||
|
||||
|
||||
def process_list(anything: list[object]) -> dict[str, list[str]]:
|
||||
text: list[str] = []
|
||||
if not anything:
|
||||
return {"text": []}
|
||||
|
||||
first_element = anything[0]
|
||||
if (
|
||||
isinstance(first_element, list)
|
||||
and first_element
|
||||
and isinstance(first_element[0], torch.Tensor)
|
||||
):
|
||||
text.append(
|
||||
"List of List of Tensors: "
|
||||
+ f"{first_element[0].shape} (x{len(anything)})"
|
||||
)
|
||||
|
||||
elif isinstance(first_element, torch.Tensor):
|
||||
text.append(
|
||||
f"List of Tensors: {first_element.shape} (x{len(anything)})"
|
||||
)
|
||||
else:
|
||||
text.append(f"Array ({len(anything)}): {anything}")
|
||||
|
||||
return {"text": text}
|
||||
|
||||
|
||||
def process_dict(anything: dict[str, dict[str, any]]) -> dict[str, str]:
|
||||
if "mesh" in anything:
|
||||
m = {"geometry": {}}
|
||||
m["geometry"]["mesh"] = mesh_to_json(anything["mesh"])
|
||||
if "material" in anything:
|
||||
m["geometry"]["material"] = anything["material"]
|
||||
return m
|
||||
|
||||
res = []
|
||||
if "samples" in anything:
|
||||
is_empty = (
|
||||
"(empty)" if torch.count_nonzero(anything["samples"]) == 0 else ""
|
||||
)
|
||||
res.append(f"Latent Samples: {anything['samples'].shape} {is_empty}")
|
||||
|
||||
else:
|
||||
text.append(json.dumps(anything, indent=2))
|
||||
|
||||
return {"text": text}
|
||||
|
||||
|
||||
def process_bool(anything: bool) -> dict[str, str]:
|
||||
return {"text": ["True" if anything else "False"]}
|
||||
|
||||
|
||||
def process_text(anything):
|
||||
return {"text": [str(anything)]}
|
||||
|
||||
|
||||
# NOT USED ANYMORE
|
||||
def process_geometry(anything):
|
||||
return {"geometry": [mesh_to_json(anything)]}
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
|
||||
class MTB_Debug:
|
||||
"""Experimental node to debug any Comfy values.
|
||||
|
||||
support for more types and widgets is planned.
|
||||
"""
|
||||
class Debug:
|
||||
"""Experimental node to debug any Comfy values, support for more types and widgets is planned"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {"output_to_console": ("BOOLEAN", {"default": False})},
|
||||
"required": {"anything_1": ("*")},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ()
|
||||
RETURN_TYPES = ("STRING",)
|
||||
FUNCTION = "do_debug"
|
||||
CATEGORY = "mtb/debug"
|
||||
OUTPUT_NODE = True
|
||||
|
||||
def do_debug(self, output_to_console: bool, **kwargs):
|
||||
def do_debug(self, **kwargs):
|
||||
output = {
|
||||
"ui": {"b64_images": [], "text": [], "geometry": []},
|
||||
# "result": ("A"),
|
||||
"ui": {"b64_images": [], "text": []},
|
||||
"result": ("A"),
|
||||
}
|
||||
for k, v in kwargs.items():
|
||||
anything = v
|
||||
text = ""
|
||||
if isinstance(anything, torch.Tensor):
|
||||
log.debug(f"Tensor: {anything.shape}")
|
||||
|
||||
processors = {
|
||||
torch.Tensor: process_tensor,
|
||||
list: process_list,
|
||||
dict: process_dict,
|
||||
bool: process_bool,
|
||||
o3d.geometry.Geometry: process_geometry,
|
||||
}
|
||||
if output_to_console:
|
||||
for k, v in kwargs.items():
|
||||
log.info(f"{k}: {v}")
|
||||
# write the images to temp
|
||||
|
||||
for anything in kwargs.values():
|
||||
processor = processors.get(type(anything))
|
||||
if processor is None:
|
||||
if isinstance(anything, o3d.geometry.Geometry):
|
||||
processor = process_geometry
|
||||
else:
|
||||
processor = process_text
|
||||
log.debug(
|
||||
f"Processing: {anything} with processor: {processor.__name__} for type {type(anything)}"
|
||||
)
|
||||
processed_data = processor(anything)
|
||||
image = tensor2pil(anything)
|
||||
b64_imgs = []
|
||||
for im in image:
|
||||
buffered = io.BytesIO()
|
||||
im.save(buffered, format="PNG")
|
||||
b64_imgs.append(
|
||||
"data:image/png;base64,"
|
||||
+ base64.b64encode(buffered.getvalue()).decode("utf-8")
|
||||
)
|
||||
|
||||
for ui_key, ui_value in processed_data.items():
|
||||
if isinstance(ui_value, list):
|
||||
output["ui"][ui_key].extend(ui_value)
|
||||
else:
|
||||
output["ui"][ui_key].append(ui_value)
|
||||
# log.debug(
|
||||
# f"Processed input {k}, found {len(processed_data.get('b64_images', []))} images and {len(processed_data.get('text', []))} text items."
|
||||
# )
|
||||
|
||||
if output_to_console:
|
||||
from rich.console import Console
|
||||
|
||||
cons = Console()
|
||||
cons.print("OUTPUT:")
|
||||
cons.print(output)
|
||||
output["ui"]["b64_images"] += b64_imgs
|
||||
log.debug(f"Input {k} contains {len(b64_imgs)} images")
|
||||
elif isinstance(anything, bool):
|
||||
log.debug(f"Input {k} contains boolean: {anything}")
|
||||
output["ui"]["text"] += ["True" if anything else "False"]
|
||||
else:
|
||||
text = str(anything)
|
||||
log.debug(f"Input {k} contains text: {text}")
|
||||
output["ui"]["text"] += [text]
|
||||
|
||||
return output
|
||||
|
||||
|
||||
class MTB_SaveTensors:
|
||||
"""Save torch tensors (image, mask or latent) to disk.
|
||||
|
||||
useful to debug things outside comfy.
|
||||
"""
|
||||
class SaveTensors:
|
||||
"""Save torch tensors (image, mask or latent) to disk, useful to debug things outside comfy"""
|
||||
|
||||
def __init__(self):
|
||||
self.output_dir = folder_paths.get_output_directory()
|
||||
@@ -206,10 +113,9 @@ class MTB_SaveTensors:
|
||||
torch.save(latent, full_output_folder / latent_file)
|
||||
# pickle.dump(latent, open(full_output_folder/ latent_file, "wb"))
|
||||
|
||||
# np.save(full_output_folder / latent_file,
|
||||
# latent[""].cpu().numpy())
|
||||
# np.save(full_output_folder/ latent_file, latent[""].cpu().numpy())
|
||||
|
||||
return f"{filename_prefix}_{counter:05}"
|
||||
|
||||
|
||||
__nodes__ = [MTB_Debug, MTB_SaveTensors]
|
||||
__nodes__ = [Debug, SaveTensors]
|
||||
|
||||
+52
-158
@@ -1,49 +1,23 @@
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import onnxruntime as ort
|
||||
import torch
|
||||
from PIL import Image
|
||||
|
||||
from ..errors import ModelNotFound
|
||||
from ..log import mklog
|
||||
from ..utils import (
|
||||
get_model_path,
|
||||
tensor2pil,
|
||||
tiles_infer,
|
||||
tiles_merge,
|
||||
tiles_split,
|
||||
)
|
||||
import numpy as np
|
||||
import pathlib
|
||||
import onnxruntime as ort
|
||||
import numpy as np
|
||||
from .. import utils as utils_inference
|
||||
from ..log import log
|
||||
|
||||
# Disable MS telemetry
|
||||
ort.disable_telemetry_events()
|
||||
log = mklog(__name__)
|
||||
|
||||
|
||||
# - COLOR to NORMALS
|
||||
def color_to_normals(
|
||||
color_img, overlap, progress_callback, *, save_temp=False
|
||||
):
|
||||
"""Compute a normal map from the given color map.
|
||||
|
||||
'color_img' must be a numpy array in C,H,W format (with C as RGB).
|
||||
'overlap' must be one of 'SMALL', 'MEDIUM', 'LARGE'.
|
||||
def color_to_normals(color_img, overlap, progress_callback):
|
||||
"""Computes a normal map from the given color map. 'color_img' must be a numpy array
|
||||
in C,H,W format (with C as RGB). 'overlap' must be one of 'SMALL', 'MEDIUM', 'LARGE'.
|
||||
"""
|
||||
temp_dir = Path(tempfile.mkdtemp()) if save_temp else None
|
||||
|
||||
# Remove alpha & convert to grayscale
|
||||
img = np.mean(color_img[:3], axis=0, keepdims=True)
|
||||
|
||||
if temp_dir:
|
||||
Image.fromarray((img[0] * 255).astype(np.uint8)).save(
|
||||
temp_dir / "grayscale_img.png"
|
||||
)
|
||||
|
||||
log.debug(
|
||||
"Converting color image to grayscale by taking "
|
||||
f"the mean over color channels: {img.shape}"
|
||||
)
|
||||
img = np.mean(color_img[:3], axis=0, keepdimss=True)
|
||||
|
||||
# Split image in tiles
|
||||
log.debug("DeepBump Color → Normals : tilling")
|
||||
@@ -54,124 +28,72 @@ def color_to_normals(
|
||||
"LARGE": tile_size // 2,
|
||||
}
|
||||
stride_size = tile_size - overlaps[overlap]
|
||||
tiles, paddings = tiles_split(
|
||||
tiles, paddings = utils_inference.tiles_split(
|
||||
img, (tile_size, tile_size), (stride_size, stride_size)
|
||||
)
|
||||
if temp_dir:
|
||||
for i, tile in enumerate(tiles):
|
||||
Image.fromarray((tile[0] * 255).astype(np.uint8)).save(
|
||||
temp_dir / f"tile_{i}.png"
|
||||
)
|
||||
|
||||
# Load model
|
||||
log.debug("DeepBump Color → Normals : loading model")
|
||||
model = get_model_path("deepbump", "deepbump256.onnx")
|
||||
if not model or not model.exists():
|
||||
raise ModelNotFound(f"deepbump ({model})")
|
||||
|
||||
providers = [
|
||||
"TensorrtExecutionProvider",
|
||||
"CUDAExecutionProvider",
|
||||
"CoreMLProvider",
|
||||
"CPUExecutionProvider",
|
||||
]
|
||||
available_providers = [
|
||||
provider
|
||||
for provider in providers
|
||||
if provider in ort.get_available_providers()
|
||||
]
|
||||
|
||||
if not available_providers:
|
||||
raise RuntimeError(
|
||||
"No valid ONNX Runtime providers available on this machine."
|
||||
)
|
||||
log.debug(f"Using ONNX providers: {available_providers}")
|
||||
ort_session = ort.InferenceSession(
|
||||
model.as_posix(), providers=available_providers
|
||||
)
|
||||
addon_path = str(pathlib.Path(__file__).parent.absolute())
|
||||
ort_session = ort.InferenceSession(f"{addon_path}/models/deepbump256.onnx")
|
||||
|
||||
# Predict normal map for each tile
|
||||
log.debug("DeepBump Color → Normals : generating")
|
||||
pred_tiles = tiles_infer(
|
||||
pred_tiles = utils_inference.tiles_infer(
|
||||
tiles, ort_session, progress_callback=progress_callback
|
||||
)
|
||||
|
||||
if temp_dir:
|
||||
for i, pred_tile in enumerate(pred_tiles):
|
||||
Image.fromarray(
|
||||
(pred_tile.transpose(1, 2, 0) * 255).astype(np.uint8)
|
||||
).save(temp_dir / f"pred_tile_{i}.png")
|
||||
|
||||
# Merge tiles
|
||||
log.debug("DeepBump Color → Normals : merging")
|
||||
pred_img = tiles_merge(
|
||||
pred_img = utils_inference.tiles_merge(
|
||||
pred_tiles,
|
||||
(stride_size, stride_size),
|
||||
(3, img.shape[1], img.shape[2]),
|
||||
paddings,
|
||||
)
|
||||
|
||||
if temp_dir:
|
||||
Image.fromarray(
|
||||
(pred_img.transpose(1, 2, 0) * 255).astype(np.uint8)
|
||||
).save(temp_dir / "merged_img.png")
|
||||
|
||||
# Normalize each pixel to unit vector
|
||||
pred_img = normalize(pred_img)
|
||||
|
||||
if temp_dir:
|
||||
Image.fromarray(
|
||||
(pred_img.transpose(1, 2, 0) * 255).astype(np.uint8)
|
||||
).save(temp_dir / "final_img.png")
|
||||
|
||||
log.debug(f"Debug images saved in {temp_dir}")
|
||||
pred_img = utils_inference.normalize(pred_img)
|
||||
|
||||
return pred_img
|
||||
|
||||
|
||||
# - NORMALS to CURVATURE
|
||||
def conv_1d(array, kernel_1d):
|
||||
"""Perform row by row 1D convolutions.
|
||||
"""Performs row by row 1D convolutions of the given 2D image with the given 1D kernel."""
|
||||
|
||||
of the given 2D image with the given 1D kernel.
|
||||
"""
|
||||
# Input kernel length must be odd
|
||||
k_l = len(kernel_1d)
|
||||
|
||||
assert k_l % 2 != 0
|
||||
# Convolution is repeat-padded
|
||||
extended = np.pad(array, k_l // 2, mode="wrap")
|
||||
# Output has same size as input (padded, valid-mode convolution)
|
||||
output = np.empty(array.shape)
|
||||
for i in range(array.shape[0]):
|
||||
output[i] = np.convolve(
|
||||
extended[i + (k_l // 2)], kernel_1d, mode="valid"
|
||||
)
|
||||
output[i] = np.convolve(extended[i + (k_l // 2)], kernel_1d, mode="valid")
|
||||
|
||||
return output * -1
|
||||
|
||||
|
||||
def gaussian_kernel(length, sigma):
|
||||
"""Return a 1D gaussian kernel of size 'length'."""
|
||||
"""Returns a 1D gaussian kernel of size 'length'."""
|
||||
|
||||
space = np.linspace(-(length - 1) / 2, (length - 1) / 2, length)
|
||||
kernel = np.exp(-0.5 * np.square(space) / np.square(sigma))
|
||||
return kernel / np.sum(kernel)
|
||||
|
||||
|
||||
def normalize(np_array):
|
||||
"""Normalize all elements of the given numpy array to [0,1]."""
|
||||
return (np_array - np.min(np_array)) / (
|
||||
np.max(np_array) - np.min(np_array)
|
||||
)
|
||||
"""Normalize all elements of the given numpy array to [0,1]"""
|
||||
|
||||
return (np_array - np.min(np_array)) / (np.max(np_array) - np.min(np_array))
|
||||
|
||||
|
||||
def normals_to_curvature(normals_img, blur_radius, progress_callback):
|
||||
"""Compute a curvature map from the given normal map.
|
||||
"""Computes a curvature map from the given normal map. 'normals_img' must be a numpy array
|
||||
in C,H,W format (with C as RGB). 'blur_radius' must be one of 'SMALLEST', 'SMALLER', 'SMALL',
|
||||
'MEDIUM', 'LARGE', 'LARGER', 'LARGEST'."""
|
||||
|
||||
'normals_img' must be a numpy array in C,H,W format (with C as RGB).
|
||||
'blur_radius' must be one of:
|
||||
'SMALLEST', 'SMALLER', 'SMALL', 'MEDIUM', 'LARGE', 'LARGER', 'LARGEST'.
|
||||
"""
|
||||
# Convolutions on normal map red & green channels
|
||||
if progress_callback is not None:
|
||||
progress_callback(0, 4)
|
||||
@@ -196,12 +118,8 @@ def normals_to_curvature(normals_img, blur_radius, progress_callback):
|
||||
"LARGER": 1 / 8,
|
||||
"LARGEST": 1 / 4,
|
||||
}
|
||||
if blur_radius not in blur_factors:
|
||||
raise ValueError(f"{blur_radius} not found in {blur_factors}")
|
||||
|
||||
blur_radius_px = int(
|
||||
np.mean(normals_img.shape[1:3]) * blur_factors[blur_radius]
|
||||
)
|
||||
assert blur_radius in blur_factors
|
||||
blur_radius_px = int(np.mean(normals_img.shape[1:3]) * blur_factors[blur_radius])
|
||||
|
||||
# If blur radius too small, do not blur
|
||||
if blur_radius_px < 2:
|
||||
@@ -238,9 +156,8 @@ def normals_to_grad(normals_img):
|
||||
|
||||
def copy_flip(grad_x, grad_y):
|
||||
"""Concat 4 flipped copies of input gradients (makes them wrap).
|
||||
Output is twice bigger in both dimensions."""
|
||||
|
||||
Output is twice bigger in both dimensions.
|
||||
"""
|
||||
grad_x_top = np.hstack([grad_x, -np.flip(grad_x, axis=1)])
|
||||
grad_x_bottom = np.hstack([np.flip(grad_x, axis=0), -np.flip(grad_x)])
|
||||
new_grad_x = np.vstack([grad_x_top, grad_x_bottom])
|
||||
@@ -254,6 +171,7 @@ def copy_flip(grad_x, grad_y):
|
||||
|
||||
def frankot_chellappa(grad_x, grad_y, progress_callback=None):
|
||||
"""Frankot-Chellappa depth-from-gradient algorithm."""
|
||||
|
||||
if progress_callback is not None:
|
||||
progress_callback(0, 3)
|
||||
|
||||
@@ -293,8 +211,8 @@ def frankot_chellappa(grad_x, grad_y, progress_callback=None):
|
||||
def normals_to_height(normals_img, seamless, progress_callback):
|
||||
"""Computes a height map from the given normal map. 'normals_img' must be a numpy array
|
||||
in C,H,W format (with C as RGB). 'seamless' is a bool that should indicates if 'normals_img'
|
||||
is seamless.
|
||||
"""
|
||||
is seamless."""
|
||||
|
||||
# Flip height axis
|
||||
flip_img = np.flip(normals_img, axis=1)
|
||||
|
||||
@@ -308,9 +226,7 @@ def normals_to_height(normals_img, seamless, progress_callback):
|
||||
grad_x, grad_y = copy_flip(grad_x, grad_y)
|
||||
|
||||
# Compute height
|
||||
pred_img = frankot_chellappa(
|
||||
-grad_x, grad_y, progress_callback=progress_callback
|
||||
)
|
||||
pred_img = frankot_chellappa(-grad_x, grad_y, progress_callback=progress_callback)
|
||||
|
||||
# Cut to valid part if gradients were expanded
|
||||
if not seamless:
|
||||
@@ -322,7 +238,7 @@ def normals_to_height(normals_img, seamless, progress_callback):
|
||||
|
||||
|
||||
# - ADDON
|
||||
class MTB_DeepBump:
|
||||
class DeepBump:
|
||||
"""Normal & height maps generation from single pictures"""
|
||||
|
||||
@classmethod
|
||||
@@ -331,11 +247,7 @@ class MTB_DeepBump:
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"mode": (
|
||||
[
|
||||
"Color to Normals",
|
||||
"Normals to Curvature",
|
||||
"Normals to Height",
|
||||
],
|
||||
["Color to Normals", "Normals to Curvature", "Normals to Height"],
|
||||
),
|
||||
"color_to_normals_overlap": (["SMALL", "MEDIUM", "LARGE"],),
|
||||
"normals_to_curvature_blur_radius": (
|
||||
@@ -349,7 +261,7 @@ class MTB_DeepBump:
|
||||
"LARGEST",
|
||||
],
|
||||
),
|
||||
"normals_to_height_seamless": ("BOOLEAN", {"default": True}),
|
||||
"normals_to_height_seamless": ("BOOLEAN", {"default": False}),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -360,49 +272,31 @@ class MTB_DeepBump:
|
||||
|
||||
def apply(
|
||||
self,
|
||||
*,
|
||||
image,
|
||||
mode="Color to Normals",
|
||||
color_to_normals_overlap="SMALL",
|
||||
normals_to_curvature_blur_radius="SMALL",
|
||||
normals_to_height_seamless=True,
|
||||
):
|
||||
images = tensor2pil(image)
|
||||
out_images = []
|
||||
image = utils_inference.tensor2pil(image)
|
||||
|
||||
for image in images:
|
||||
log.debug(f"Input image shape: {image}")
|
||||
in_img = np.transpose(image, (2, 0, 1)) / 255
|
||||
|
||||
in_img = np.transpose(image, (2, 0, 1)) / 255
|
||||
log.debug(f"transposed for deep image shape: {in_img.shape}")
|
||||
out_img = None
|
||||
log.debug(f"Input image shape: {in_img.shape}")
|
||||
|
||||
# Apply processing
|
||||
if mode == "Color to Normals":
|
||||
out_img = color_to_normals(
|
||||
in_img, color_to_normals_overlap, None
|
||||
)
|
||||
if mode == "Normals to Curvature":
|
||||
out_img = normals_to_curvature(
|
||||
in_img, normals_to_curvature_blur_radius, None
|
||||
)
|
||||
if mode == "Normals to Height":
|
||||
out_img = normals_to_height(
|
||||
in_img, normals_to_height_seamless, None
|
||||
)
|
||||
# Apply processing
|
||||
if mode == "Color to Normals":
|
||||
out_img = color_to_normals(in_img, color_to_normals_overlap, None)
|
||||
if mode == "Normals to Curvature":
|
||||
out_img = normals_to_curvature(
|
||||
in_img, normals_to_curvature_blur_radius, None
|
||||
)
|
||||
if mode == "Normals to Height":
|
||||
out_img = normals_to_height(in_img, normals_to_height_seamless, None)
|
||||
|
||||
if out_img is not None:
|
||||
log.debug(f"Output image shape: {out_img.shape}")
|
||||
out_images.append(
|
||||
torch.from_numpy(
|
||||
np.transpose(out_img, (1, 2, 0)).astype(np.float32)
|
||||
).unsqueeze(0)
|
||||
)
|
||||
else:
|
||||
log.error("No out img... This should not happen")
|
||||
for outi in out_images:
|
||||
log.debug(f"Shape fed to utils: {outi.shape}")
|
||||
return (torch.cat(out_images, dim=0),)
|
||||
out_img = (np.transpose(out_img, (1, 2, 0)) * 255).astype(np.uint8)
|
||||
|
||||
return (utils_inference.pil2tensor(out_img),)
|
||||
|
||||
|
||||
__nodes__ = [MTB_DeepBump]
|
||||
__nodes__ = [DeepBump]
|
||||
|
||||
+46
-78
@@ -1,19 +1,24 @@
|
||||
from gfpgan import GFPGANer
|
||||
import cv2
|
||||
import numpy as np
|
||||
import os
|
||||
from pathlib import Path
|
||||
import folder_paths
|
||||
from ..utils import pil2tensor, np2tensor, tensor2np
|
||||
|
||||
from basicsr.utils import imwrite
|
||||
|
||||
|
||||
from PIL import Image
|
||||
import torch
|
||||
from ..log import NullWriter, log
|
||||
from comfy import model_management
|
||||
import comfy
|
||||
import comfy.utils
|
||||
import cv2
|
||||
import folder_paths
|
||||
import numpy as np
|
||||
import torch
|
||||
from comfy import model_management
|
||||
from PIL import Image
|
||||
|
||||
from ..log import NullWriter, log
|
||||
from ..utils import get_model_path, np2tensor, pil2tensor, tensor2np
|
||||
from typing import Tuple
|
||||
|
||||
|
||||
class MTB_LoadFaceEnhanceModel:
|
||||
class LoadFaceEnhanceModel:
|
||||
"""Loads a GFPGan or RestoreFormer model for face enhancement."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
@@ -21,12 +26,11 @@ class MTB_LoadFaceEnhanceModel:
|
||||
|
||||
@classmethod
|
||||
def get_models_root(cls):
|
||||
fr = get_model_path("face_restore")
|
||||
# fr = Path(folder_paths.models_dir) / "face_restore"
|
||||
fr = Path(folder_paths.models_dir) / "face_restore"
|
||||
if fr.exists():
|
||||
return (fr, None)
|
||||
|
||||
um = get_model_path("upscale_models")
|
||||
um = Path(folder_paths.models_dir) / "upscale_models"
|
||||
return (fr, um) if um.exists() else (None, None)
|
||||
|
||||
@classmethod
|
||||
@@ -34,12 +38,15 @@ class MTB_LoadFaceEnhanceModel:
|
||||
fr_models_path, um_models_path = cls.get_models_root()
|
||||
|
||||
if fr_models_path is None and um_models_path is None:
|
||||
if not hasattr(cls, "_warned"):
|
||||
log.warning("Face restoration models not found.")
|
||||
cls._warned = True
|
||||
log.warning("Face restoration models not found.")
|
||||
return []
|
||||
if not fr_models_path.exists():
|
||||
# - fallback to upscale_models
|
||||
log.warning(
|
||||
f"No Face Restore checkpoints found at {fr_models_path} (if you've used mtb before these checkpoints were saved in upscale_models before)"
|
||||
)
|
||||
log.warning(
|
||||
"For now we fallback to upscale_models but this will be removed in a future version"
|
||||
)
|
||||
if um_models_path.exists():
|
||||
return [
|
||||
x
|
||||
@@ -73,11 +80,8 @@ class MTB_LoadFaceEnhanceModel:
|
||||
RETURN_NAMES = ("model",)
|
||||
FUNCTION = "load_model"
|
||||
CATEGORY = "mtb/facetools"
|
||||
DEPRECATED = True
|
||||
|
||||
def load_model(self, model_name, upscale=2, bg_upsampler=None):
|
||||
from gfpgan import GFPGANer
|
||||
|
||||
basic = "RestoreFormer" not in model_name
|
||||
|
||||
fr_root, um_root = self.get_models_root()
|
||||
@@ -95,9 +99,7 @@ class MTB_LoadFaceEnhanceModel:
|
||||
(fr_root if fr_root.exists() else um_root) / model_name
|
||||
).as_posix(),
|
||||
upscale=upscale,
|
||||
arch="clean"
|
||||
if basic
|
||||
else "RestoreFormer", # or original for v1.0 only
|
||||
arch="clean" if basic else "RestoreFormer", # or original for v1.0 only
|
||||
channel_multiplier=2, # 1 for v1.0 only
|
||||
bg_upsampler=bg_upsampler,
|
||||
)
|
||||
@@ -117,15 +119,11 @@ class BGUpscaleWrapper:
|
||||
tile = 128 + 64
|
||||
overlap = 8
|
||||
|
||||
imgt = pil2tensor(img)
|
||||
imgt = np2tensor(img)
|
||||
imgt = imgt.movedim(-1, -3).to(device)
|
||||
|
||||
steps = imgt.shape[0] * comfy.utils.get_tiled_scale_steps(
|
||||
imgt.shape[3],
|
||||
imgt.shape[2],
|
||||
tile_x=tile,
|
||||
tile_y=tile,
|
||||
overlap=overlap,
|
||||
imgt.shape[3], imgt.shape[2], tile_x=tile, tile_y=tile, overlap=overlap
|
||||
)
|
||||
|
||||
log.debug(f"Steps: {steps}")
|
||||
@@ -147,7 +145,10 @@ class BGUpscaleWrapper:
|
||||
return (tensor2np(s)[0],)
|
||||
|
||||
|
||||
class MTB_RestoreFace:
|
||||
import sys
|
||||
|
||||
|
||||
class RestoreFace:
|
||||
"""Uses GFPGan to restore faces"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
@@ -156,7 +157,6 @@ class MTB_RestoreFace:
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "restore"
|
||||
CATEGORY = "mtb/facetools"
|
||||
DEPRECATED = True
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -171,33 +171,22 @@ class MTB_RestoreFace:
|
||||
# Adjustable weights
|
||||
"weight": ("FLOAT", {"default": 0.5}),
|
||||
"save_tmp_steps": ("BOOLEAN", {"default": True}),
|
||||
},
|
||||
"optional": {
|
||||
"preserve_alpha": ("BOOLEAN", {"default": True}),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
def do_restore(
|
||||
self,
|
||||
image: torch.Tensor,
|
||||
model,
|
||||
model: GFPGANer,
|
||||
aligned,
|
||||
only_center_face,
|
||||
weight,
|
||||
save_tmp_steps,
|
||||
preserve_alpha: bool = False,
|
||||
) -> torch.Tensor:
|
||||
pimage = tensor2np(image)[0]
|
||||
width, height = pimage.shape[1], pimage.shape[0]
|
||||
source_img = cv2.cvtColor(np.array(pimage), cv2.COLOR_RGB2BGR)
|
||||
|
||||
alpha_channel = None
|
||||
if (
|
||||
preserve_alpha and image.size(-1) == 4
|
||||
): # Check if the image has an alpha channel
|
||||
alpha_channel = pimage[:, :, 3]
|
||||
pimage = pimage[:, :, :3] # Remove alpha channel for processing
|
||||
|
||||
sys.stdout = NullWriter()
|
||||
cropped_faces, restored_faces, restored_img = model.enhance(
|
||||
source_img,
|
||||
@@ -211,49 +200,30 @@ class MTB_RestoreFace:
|
||||
log.warning(f"Weight value has no effect for now. (value: {weight})")
|
||||
|
||||
if save_tmp_steps:
|
||||
self.save_intermediate_images(
|
||||
cropped_faces, restored_faces, height, width
|
||||
)
|
||||
self.save_intermediate_images(cropped_faces, restored_faces, height, width)
|
||||
output = None
|
||||
if restored_img is not None:
|
||||
restored_img = cv2.cvtColor(restored_img, cv2.COLOR_BGR2RGB)
|
||||
output = Image.fromarray(restored_img)
|
||||
|
||||
if alpha_channel is not None:
|
||||
alpha_resized = Image.fromarray(alpha_channel).resize(
|
||||
output.size, Image.LANCZOS
|
||||
)
|
||||
output.putalpha(alpha_resized)
|
||||
output = Image.fromarray(cv2.cvtColor(restored_img, cv2.COLOR_BGR2RGB))
|
||||
# imwrite(restored_img, save_restore_path)
|
||||
return pil2tensor(output)
|
||||
log.warning("No restored image found")
|
||||
|
||||
return pil2tensor(output)
|
||||
|
||||
def restore(
|
||||
self,
|
||||
image: torch.Tensor,
|
||||
model,
|
||||
model: GFPGANer,
|
||||
aligned=False,
|
||||
only_center_face=False,
|
||||
weight=0.5,
|
||||
save_tmp_steps=True,
|
||||
preserve_alpha: bool = False,
|
||||
) -> tuple[torch.Tensor]:
|
||||
) -> Tuple[torch.Tensor]:
|
||||
out = [
|
||||
self.do_restore(
|
||||
image[i],
|
||||
model,
|
||||
aligned,
|
||||
only_center_face,
|
||||
weight,
|
||||
save_tmp_steps,
|
||||
preserve_alpha,
|
||||
image[i], model, aligned, only_center_face, weight, save_tmp_steps
|
||||
)
|
||||
for i in range(image.size(0))
|
||||
]
|
||||
|
||||
if len(out) == 0:
|
||||
raise ValueError("No faces restored")
|
||||
print(f"Restored {len(out)} faces")
|
||||
return (torch.cat(out, dim=0),)
|
||||
|
||||
def get_step_image_path(self, step, idx):
|
||||
@@ -271,24 +241,22 @@ class MTB_RestoreFace:
|
||||
|
||||
return os.path.join(full_output_folder, file)
|
||||
|
||||
def save_intermediate_images(
|
||||
self, cropped_faces, restored_faces, height, width
|
||||
):
|
||||
def save_intermediate_images(self, cropped_faces, restored_faces, height, width):
|
||||
for idx, (cropped_face, restored_face) in enumerate(
|
||||
zip(cropped_faces, restored_faces, strict=False)
|
||||
zip(cropped_faces, restored_faces)
|
||||
):
|
||||
face_id = idx + 1
|
||||
file = self.get_step_image_path("cropped_faces", face_id)
|
||||
cv2.imwrite(file, cropped_face)
|
||||
imwrite(cropped_face, file)
|
||||
|
||||
file = self.get_step_image_path("cropped_faces_restored", face_id)
|
||||
cv2.imwrite(file, restored_face)
|
||||
imwrite(restored_face, file)
|
||||
|
||||
file = self.get_step_image_path("cropped_faces_compare", face_id)
|
||||
|
||||
# save comparison image
|
||||
cmp_img = np.concatenate((cropped_face, restored_face), axis=1)
|
||||
cv2.imwrite(file, cmp_img)
|
||||
imwrite(cmp_img, file)
|
||||
|
||||
|
||||
__nodes__ = [MTB_RestoreFace, MTB_LoadFaceEnhanceModel]
|
||||
__nodes__ = [RestoreFace, LoadFaceEnhanceModel]
|
||||
|
||||
+43
-65
@@ -1,31 +1,41 @@
|
||||
# Optional face enhance nodes
|
||||
# region imports
|
||||
import sys
|
||||
import onnxruntime
|
||||
from pathlib import Path
|
||||
|
||||
import comfy.model_management as model_management
|
||||
from PIL import Image
|
||||
from typing import List, Set, Union, Optional
|
||||
import cv2
|
||||
import folder_paths
|
||||
import glob
|
||||
import insightface
|
||||
import numpy as np
|
||||
import onnxruntime
|
||||
import os
|
||||
import torch
|
||||
from insightface.model_zoo.inswapper import INSwapper
|
||||
from PIL import Image
|
||||
from ..utils import pil2tensor, tensor2pil, download_antelopev2
|
||||
from ..log import mklog, NullWriter
|
||||
import sys
|
||||
import comfy.model_management as model_management
|
||||
|
||||
from ..errors import ModelNotFound
|
||||
from ..log import NullWriter, mklog
|
||||
from ..utils import download_antelopev2, get_model_path, pil2tensor, tensor2pil
|
||||
|
||||
# endregion
|
||||
|
||||
log = mklog(__name__)
|
||||
|
||||
|
||||
class MTB_LoadFaceAnalysisModel:
|
||||
class LoadFaceAnalysisModel:
|
||||
"""Loads a face analysis model"""
|
||||
|
||||
models = []
|
||||
|
||||
@staticmethod
|
||||
def get_models() -> List[str]:
|
||||
models_path = os.path.join(folder_paths.models_dir, "insightface/*")
|
||||
models = glob.glob(models_path)
|
||||
models = [
|
||||
Path(x).name for x in models if x.endswith(".onnx") or x.endswith(".pth")
|
||||
]
|
||||
return models
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
@@ -40,7 +50,6 @@ class MTB_LoadFaceAnalysisModel:
|
||||
RETURN_TYPES = ("FACE_ANALYSIS_MODEL",)
|
||||
FUNCTION = "load_model"
|
||||
CATEGORY = "mtb/facetools"
|
||||
DEPRECATED = True
|
||||
|
||||
def load_model(self, faceswap_model: str):
|
||||
if faceswap_model == "antelopev2":
|
||||
@@ -48,21 +57,20 @@ class MTB_LoadFaceAnalysisModel:
|
||||
|
||||
face_analyser = insightface.app.FaceAnalysis(
|
||||
name=faceswap_model,
|
||||
root=get_model_path("insightface").as_posix(),
|
||||
root=os.path.join(folder_paths.models_dir, "insightface"),
|
||||
)
|
||||
return (face_analyser,)
|
||||
|
||||
|
||||
class MTB_LoadFaceSwapModel:
|
||||
class LoadFaceSwapModel:
|
||||
"""Loads a faceswap model"""
|
||||
|
||||
@staticmethod
|
||||
def get_models() -> list[Path]:
|
||||
models_path = get_model_path("insightface")
|
||||
if models_path.exists():
|
||||
models = models_path.iterdir()
|
||||
return [x for x in models if x.suffix in [".onnx", ".pth"]]
|
||||
return []
|
||||
def get_models() -> List[Path]:
|
||||
models_path = os.path.join(folder_paths.models_dir, "insightface/*")
|
||||
models = glob.glob(models_path)
|
||||
models = [Path(x) for x in models if x.endswith(".onnx") or x.endswith(".pth")]
|
||||
return models
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -78,13 +86,11 @@ class MTB_LoadFaceSwapModel:
|
||||
RETURN_TYPES = ("FACESWAP_MODEL",)
|
||||
FUNCTION = "load_model"
|
||||
CATEGORY = "mtb/facetools"
|
||||
DEPRECATED = True
|
||||
|
||||
def load_model(self, faceswap_model: str):
|
||||
model_path = get_model_path("insightface", faceswap_model)
|
||||
if not model_path or not model_path.exists():
|
||||
raise ModelNotFound(f"{faceswap_model} ({model_path})")
|
||||
|
||||
model_path = os.path.join(
|
||||
folder_paths.models_dir, "insightface", faceswap_model
|
||||
)
|
||||
log.info(f"Loading model {model_path}")
|
||||
return (
|
||||
INSwapper(
|
||||
@@ -98,7 +104,7 @@ class MTB_LoadFaceSwapModel:
|
||||
|
||||
|
||||
# region roop node
|
||||
class MTB_FaceSwap:
|
||||
class FaceSwap:
|
||||
"""Face swap using deepinsight/insightface models"""
|
||||
|
||||
model = None
|
||||
@@ -114,21 +120,15 @@ class MTB_FaceSwap:
|
||||
"image": ("IMAGE",),
|
||||
"reference": ("IMAGE",),
|
||||
"faces_index": ("STRING", {"default": "0"}),
|
||||
"faceanalysis_model": (
|
||||
"FACE_ANALYSIS_MODEL",
|
||||
{"default": "None"},
|
||||
),
|
||||
"faceanalysis_model": ("FACE_ANALYSIS_MODEL", {"default": "None"}),
|
||||
"faceswap_model": ("FACESWAP_MODEL", {"default": "None"}),
|
||||
},
|
||||
"optional": {
|
||||
"preserve_alpha": ("BOOLEAN", {"default": True}),
|
||||
},
|
||||
"optional": {},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "swap"
|
||||
CATEGORY = "mtb/facetools"
|
||||
DEPRECATED = True
|
||||
|
||||
def swap(
|
||||
self,
|
||||
@@ -137,30 +137,17 @@ class MTB_FaceSwap:
|
||||
faces_index: str,
|
||||
faceanalysis_model,
|
||||
faceswap_model,
|
||||
preserve_alpha=False,
|
||||
):
|
||||
def do_swap(img):
|
||||
model_management.throw_exception_if_processing_interrupted()
|
||||
img = tensor2pil(img)[0]
|
||||
ref = tensor2pil(reference)[0]
|
||||
|
||||
alpha_channel = None
|
||||
if preserve_alpha and img.mode == "RGBA":
|
||||
alpha_channel = img.getchannel("A")
|
||||
img = img.convert("RGB")
|
||||
|
||||
face_ids = {
|
||||
int(x)
|
||||
for x in faces_index.strip(",").split(",")
|
||||
if x.isnumeric()
|
||||
int(x) for x in faces_index.strip(",").split(",") if x.isnumeric()
|
||||
}
|
||||
sys.stdout = NullWriter()
|
||||
swapped = swap_face(
|
||||
faceanalysis_model, ref, img, faceswap_model, face_ids
|
||||
)
|
||||
swapped = swap_face(faceanalysis_model, ref, img, faceswap_model, face_ids)
|
||||
sys.stdout = sys.__stdout__
|
||||
if alpha_channel:
|
||||
swapped.putalpha(alpha_channel)
|
||||
return pil2tensor(swapped)
|
||||
|
||||
batch_count = image.size(0)
|
||||
@@ -193,10 +180,7 @@ def get_face_single(
|
||||
log.debug("No face ed, trying again with smaller image")
|
||||
det_size_half = (det_size[0] // 2, det_size[1] // 2)
|
||||
return get_face_single(
|
||||
face_analyser,
|
||||
img_data,
|
||||
face_index=face_index,
|
||||
det_size=det_size_half,
|
||||
face_analyser, img_data, face_index=face_index, det_size=det_size_half
|
||||
)
|
||||
|
||||
try:
|
||||
@@ -207,10 +191,10 @@ def get_face_single(
|
||||
|
||||
def swap_face(
|
||||
face_analyser,
|
||||
source_img: Image.Image | list[Image.Image],
|
||||
target_img: Image.Image | list[Image.Image],
|
||||
source_img: Union[Image.Image, List[Image.Image]],
|
||||
target_img: Union[Image.Image, List[Image.Image]],
|
||||
face_swapper_model,
|
||||
faces_index: set[int] | None = None,
|
||||
faces_index: Optional[Set[int]] = None,
|
||||
) -> Image.Image:
|
||||
if faces_index is None:
|
||||
faces_index = {0}
|
||||
@@ -220,9 +204,7 @@ def swap_face(
|
||||
if face_swapper_model is not None:
|
||||
cv_source_img = cv2.cvtColor(np.array(source_img), cv2.COLOR_RGB2BGR)
|
||||
cv_target_img = cv2.cvtColor(np.array(target_img), cv2.COLOR_RGB2BGR)
|
||||
source_face = get_face_single(
|
||||
face_analyser, cv_source_img, face_index=0
|
||||
)
|
||||
source_face = get_face_single(face_analyser, cv_source_img, face_index=0)
|
||||
if source_face is not None:
|
||||
result = cv_target_img
|
||||
|
||||
@@ -232,16 +214,12 @@ def swap_face(
|
||||
)
|
||||
if target_face is not None:
|
||||
sys.stdout = NullWriter()
|
||||
result = face_swapper_model.get(
|
||||
result, target_face, source_face
|
||||
)
|
||||
result = face_swapper_model.get(result, target_face, source_face)
|
||||
sys.stdout = sys.__stdout__
|
||||
else:
|
||||
log.warning(f"No target face found for {face_num}")
|
||||
|
||||
result_image = Image.fromarray(
|
||||
cv2.cvtColor(result, cv2.COLOR_BGR2RGB)
|
||||
)
|
||||
result_image = Image.fromarray(cv2.cvtColor(result, cv2.COLOR_BGR2RGB))
|
||||
else:
|
||||
log.warning("No source face found")
|
||||
else:
|
||||
@@ -252,4 +230,4 @@ def swap_face(
|
||||
# endregion face swap utils
|
||||
|
||||
|
||||
__nodes__ = [MTB_FaceSwap, MTB_LoadFaceSwapModel, MTB_LoadFaceAnalysisModel]
|
||||
__nodes__ = [FaceSwap, LoadFaceSwapModel, LoadFaceAnalysisModel]
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
import torch
|
||||
|
||||
|
||||
class MTBFilterZ:
|
||||
"""Filters an image based on a depth map."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"depth": ("IMAGE",),
|
||||
"to_black": ("BOOLEAN", {"default": True}),
|
||||
"threshold": (
|
||||
"FLOAT",
|
||||
{"default": 0.5, "step": 0.01, "min": 0.0, "max": 1.0},
|
||||
),
|
||||
"invert": ("BOOLEAN", {"default": True}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "filter"
|
||||
CATEGORY = "mtb/filters"
|
||||
|
||||
def filter(
|
||||
self,
|
||||
image: torch.Tensor,
|
||||
depth: torch.Tensor,
|
||||
to_black,
|
||||
threshold: float,
|
||||
invert,
|
||||
):
|
||||
# Normalize depth map to be in range [0, 1]
|
||||
depth_normalized = (depth - depth.min()) / (depth.max() - depth.min())
|
||||
|
||||
# Calculate the difference from the threshold
|
||||
diff_from_threshold = torch.abs(depth_normalized - threshold)
|
||||
|
||||
out_img = None
|
||||
|
||||
if to_black:
|
||||
if invert:
|
||||
soft_mask = diff_from_threshold >= threshold
|
||||
else:
|
||||
soft_mask = diff_from_threshold <= threshold
|
||||
|
||||
out_img = image.clone()
|
||||
out_img[soft_mask] = 0
|
||||
return (out_img,)
|
||||
else:
|
||||
alpha_channel = 1 - diff_from_threshold / threshold
|
||||
alpha_channel = torch.clamp(alpha_channel, 0, 1)
|
||||
|
||||
if invert:
|
||||
# Invert the alpha channel
|
||||
alpha_channel = 1 - alpha_channel
|
||||
|
||||
# Ensure alpha_channel has the correct shape
|
||||
# It should have the shape [batch_size, height, width, 1]
|
||||
alpha_channel = alpha_channel.unsqueeze(-1)
|
||||
|
||||
# Combine RGB channels with alpha channel
|
||||
out_img = torch.cat((image, alpha_channel), dim=-1)
|
||||
|
||||
return (out_img,)
|
||||
|
||||
|
||||
__nodes__ = [MTBFilterZ]
|
||||
+110
-151
@@ -1,7 +1,9 @@
|
||||
import qrcode
|
||||
from ..utils import pil2tensor
|
||||
from ..utils import comfy_dir
|
||||
from typing import cast
|
||||
from PIL import Image
|
||||
|
||||
from ..log import log
|
||||
from ..utils import comfy_dir, create_uv_map_tensor, font_path, pil2tensor
|
||||
|
||||
# class MtbExamples:
|
||||
# """MTB Example Images"""
|
||||
@@ -51,25 +53,16 @@ from ..utils import comfy_dir, create_uv_map_tensor, font_path, pil2tensor
|
||||
# return m.digest().hex()
|
||||
|
||||
|
||||
class MTB_UnsplashImage:
|
||||
class UnsplashImage:
|
||||
"""Unsplash Image given a keyword and a size"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"width": (
|
||||
"INT",
|
||||
{"default": 512, "max": 8096, "min": 0, "step": 1},
|
||||
),
|
||||
"height": (
|
||||
"INT",
|
||||
{"default": 512, "max": 8096, "min": 0, "step": 1},
|
||||
),
|
||||
"random_seed": (
|
||||
"INT",
|
||||
{"default": 0, "max": 1e5, "min": 0, "step": 1},
|
||||
),
|
||||
"width": ("INT", {"default": 512, "max": 8096, "min": 0, "step": 1}),
|
||||
"height": ("INT", {"default": 512, "max": 8096, "min": 0, "step": 1}),
|
||||
"random_seed": ("INT", {"default": 0, "max": 1e5, "min": 0, "step": 1}),
|
||||
},
|
||||
"optional": {
|
||||
"keyword": ("STRING", {"default": "nature"}),
|
||||
@@ -81,9 +74,8 @@ class MTB_UnsplashImage:
|
||||
CATEGORY = "mtb/generate"
|
||||
|
||||
def do_unsplash_image(self, width, height, random_seed, keyword=None):
|
||||
import io
|
||||
|
||||
import requests
|
||||
import io
|
||||
|
||||
base_url = "https://source.unsplash.com/random/"
|
||||
|
||||
@@ -112,6 +104,66 @@ class MTB_UnsplashImage:
|
||||
return (None,)
|
||||
|
||||
|
||||
class QrCode:
|
||||
"""Basic QR Code generator"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"url": ("STRING", {"default": "https://www.github.com"}),
|
||||
"width": (
|
||||
"INT",
|
||||
{"default": 256, "max": 8096, "min": 0, "step": 1},
|
||||
),
|
||||
"height": (
|
||||
"INT",
|
||||
{"default": 256, "max": 8096, "min": 0, "step": 1},
|
||||
),
|
||||
"error_correct": (("L", "M", "Q", "H"), {"default": "L"}),
|
||||
"box_size": ("INT", {"default": 10, "max": 8096, "min": 0, "step": 1}),
|
||||
"border": ("INT", {"default": 4, "max": 8096, "min": 0, "step": 1}),
|
||||
"invert": (("BOOLEAN",), {"default": False}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "do_qr"
|
||||
CATEGORY = "mtb/generate"
|
||||
|
||||
def do_qr(self, url, width, height, error_correct, box_size, border, invert):
|
||||
log.warning(
|
||||
"This node will soon be deprecated, there are much better alternatives like https://github.com/coreyryanhanson/comfy-qr"
|
||||
)
|
||||
if error_correct == "L" or error_correct not in ["M", "Q", "H"]:
|
||||
error_correct = qrcode.constants.ERROR_CORRECT_L
|
||||
elif error_correct == "M":
|
||||
error_correct = qrcode.constants.ERROR_CORRECT_M
|
||||
elif error_correct == "Q":
|
||||
error_correct = qrcode.constants.ERROR_CORRECT_Q
|
||||
else:
|
||||
error_correct = qrcode.constants.ERROR_CORRECT_H
|
||||
|
||||
qr = qrcode.QRCode(
|
||||
version=1,
|
||||
error_correction=error_correct,
|
||||
box_size=box_size,
|
||||
border=border,
|
||||
)
|
||||
qr.add_data(url)
|
||||
qr.make(fit=True)
|
||||
|
||||
back_color = (255, 255, 255) if invert else (0, 0, 0)
|
||||
fill_color = (0, 0, 0) if invert else (255, 255, 255)
|
||||
|
||||
code = img = qr.make_image(back_color=back_color, fill_color=fill_color)
|
||||
|
||||
# that we now resize without filtering
|
||||
code = code.resize((width, height), Image.NEAREST)
|
||||
|
||||
return (pil2tensor(code),)
|
||||
|
||||
|
||||
def bbox_dim(bbox):
|
||||
left, upper, right, lower = bbox
|
||||
width = right - left
|
||||
@@ -119,46 +171,37 @@ def bbox_dim(bbox):
|
||||
return width, height
|
||||
|
||||
|
||||
# TODO: Auto install the base font to ComfyUI/fonts
|
||||
class TextToImage:
|
||||
"""Utils to convert text to image using a font
|
||||
|
||||
|
||||
class MTB_TextToImage:
|
||||
"""Utils to convert text to image using a font.
|
||||
|
||||
The tool looks for any .ttf file in the Comfy folder hierarchy.
|
||||
"""
|
||||
|
||||
fonts = {}
|
||||
DESCRIPTION = """# Text to Image
|
||||
|
||||
This node look for any font files in comfy_dir/fonts.
|
||||
by default it fallsback to a default font.
|
||||
|
||||

|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
# - This is executed when the graph is executed,
|
||||
# - we could conditionaly reload fonts there
|
||||
# - This is executed when the graph is executed, we could conditionaly reload fonts there
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def CACHE_FONTS(cls):
|
||||
font_extensions = ["*.ttf", "*.otf", "*.woff", "*.woff2", "*.eot"]
|
||||
fonts = [font_path]
|
||||
fonts = []
|
||||
|
||||
for extension in font_extensions:
|
||||
try:
|
||||
if comfy_dir.exists():
|
||||
fonts.extend(comfy_dir.glob(f"fonts/**/{extension}"))
|
||||
else:
|
||||
log.warn(f"Directory {comfy_dir} does not exist.")
|
||||
except Exception as e:
|
||||
log.error(f"Error during font caching: {e}")
|
||||
fonts.extend(comfy_dir.glob(f"**/{extension}"))
|
||||
|
||||
if not fonts:
|
||||
log.warn(
|
||||
"> No fonts found in the comfy folder, place at least one font file somewhere in ComfyUI's hierarchy"
|
||||
)
|
||||
else:
|
||||
log.debug(f"> Found {len(fonts)} fonts")
|
||||
|
||||
for font in fonts:
|
||||
log.debug(f"Adding font {font}")
|
||||
MTB_TextToImage.fonts[font.stem] = font.as_posix()
|
||||
cls.fonts[font.stem] = font.as_posix()
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -173,15 +216,13 @@ by default it fallsback to a default font.
|
||||
{"default": "Hello world!"},
|
||||
),
|
||||
"font": ((sorted(cls.fonts.keys())),),
|
||||
"wrap": ("BOOLEAN", {"default": True}),
|
||||
"trim": ("BOOLEAN", {"default": True}),
|
||||
"line_height": (
|
||||
"FLOAT",
|
||||
{"default": 1.0, "min": 0, "step": 0.1},
|
||||
"wrap": (
|
||||
"INT",
|
||||
{"default": 120, "min": 0, "max": 8096, "step": 1},
|
||||
),
|
||||
"font_size": (
|
||||
"INT",
|
||||
{"default": 32, "min": 1, "max": 2500, "step": 1},
|
||||
{"default": 12, "min": 1, "max": 2500, "step": 1},
|
||||
),
|
||||
"width": (
|
||||
"INT",
|
||||
@@ -191,27 +232,14 @@ by default it fallsback to a default font.
|
||||
"INT",
|
||||
{"default": 512, "min": 1, "max": 8096, "step": 1},
|
||||
),
|
||||
# "position": (["INT"], {"default": 0, "min": 0, "max": 100, "step": 1}),
|
||||
"color": (
|
||||
"COLOR",
|
||||
{"default": "#000000"},
|
||||
{"default": "black"},
|
||||
),
|
||||
"background": (
|
||||
"COLOR",
|
||||
{"default": "#FFFFFF"},
|
||||
),
|
||||
"h_align": (("left", "center", "right"), {"default": "left"}),
|
||||
"v_align": (("top", "center", "bottom"), {"default": "top"}),
|
||||
"h_offset": (
|
||||
"INT",
|
||||
{"default": 0, "min": 0, "max": 8096, "step": 1},
|
||||
),
|
||||
"v_offset": (
|
||||
"INT",
|
||||
{"default": 0, "min": 0, "max": 8096, "step": 1},
|
||||
),
|
||||
"h_coverage": (
|
||||
"INT",
|
||||
{"default": 100, "min": 1, "max": 100, "step": 1},
|
||||
{"default": "white"},
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -222,106 +250,37 @@ by default it fallsback to a default font.
|
||||
CATEGORY = "mtb/generate"
|
||||
|
||||
def text_to_image(
|
||||
self,
|
||||
text: str,
|
||||
font,
|
||||
wrap,
|
||||
trim,
|
||||
line_height,
|
||||
font_size,
|
||||
width,
|
||||
height,
|
||||
color,
|
||||
background,
|
||||
h_align="left",
|
||||
v_align="top",
|
||||
h_offset=0,
|
||||
v_offset=0,
|
||||
h_coverage=100,
|
||||
self, text, font, wrap, font_size, width, height, color, background
|
||||
):
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import textwrap
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
font_path = self.fonts[font]
|
||||
|
||||
text = (
|
||||
text.encode("ascii", "ignore").decode().strip() if trim else text
|
||||
)
|
||||
# Handle word wrapping
|
||||
if wrap:
|
||||
wrap_width = (((width / 100) * h_coverage) / font_size) * 2
|
||||
lines = textwrap.wrap(text, width=wrap_width)
|
||||
else:
|
||||
lines = [text]
|
||||
font = ImageFont.truetype(font_path, size=font_size)
|
||||
font = self.fonts[font]
|
||||
font = cast(ImageFont.FreeTypeFont, ImageFont.truetype(font, font_size))
|
||||
if wrap == 0:
|
||||
wrap = width / font_size
|
||||
lines = textwrap.wrap(text, width=wrap)
|
||||
log.debug(f"Lines: {lines}")
|
||||
img = Image.new("RGBA", (width, height), background)
|
||||
line_height = bbox_dim(font.getbbox("hg"))[1]
|
||||
img_height = height # line_height * len(lines)
|
||||
img_width = width # max(font.getsize(line)[0] for line in lines)
|
||||
|
||||
img = Image.new("RGBA", (img_width, img_height), background)
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
line_height_px = line_height * font_size
|
||||
|
||||
# Vertical alignment
|
||||
if v_align == "top":
|
||||
y_text = v_offset
|
||||
elif v_align == "center":
|
||||
y_text = ((height - (line_height_px * len(lines))) // 2) + v_offset
|
||||
else: # bottom
|
||||
y_text = (height - (line_height_px * len(lines))) - v_offset
|
||||
|
||||
def get_width(line):
|
||||
if hasattr(font, "getsize"):
|
||||
return font.getsize(line)[0]
|
||||
else:
|
||||
return font.getlength(line)
|
||||
|
||||
# Draw each line of text
|
||||
y_text = 0
|
||||
# - bbox is [left, upper, right, lower]
|
||||
for line in lines:
|
||||
line_width = get_width(line)
|
||||
# Horizontal alignment
|
||||
if h_align == "left":
|
||||
x_text = h_offset
|
||||
elif h_align == "center":
|
||||
x_text = ((width - line_width) // 2) + h_offset
|
||||
else: # right
|
||||
x_text = (width - line_width) - h_offset
|
||||
|
||||
draw.text((x_text, y_text), line, fill=color, font=font)
|
||||
y_text += line_height_px
|
||||
width, height = bbox_dim(font.getbbox(line))
|
||||
draw.text((0, y_text), line, color, font=font)
|
||||
y_text += height
|
||||
|
||||
# img.save(os.path.join(folder_paths.base_path, f'{str(uuid.uuid4())}.png'))
|
||||
return (pil2tensor(img),)
|
||||
|
||||
|
||||
class MTB_UvMap:
|
||||
"""Generates a UV Map tensor given a widht and height"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"width": (
|
||||
"INT",
|
||||
{"default": 512, "min": 1, "max": 8096, "step": 1},
|
||||
),
|
||||
"height": (
|
||||
"INT",
|
||||
{"default": 512, "min": 1, "max": 8096, "step": 1},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("UV_MAP",)
|
||||
RETURN_NAMES = ("uv_map",)
|
||||
FUNCTION = "create_uv_map"
|
||||
CATEGORY = "mtb/generate"
|
||||
|
||||
def create_uv_map(self, width, height):
|
||||
return (create_uv_map_tensor(width, height),)
|
||||
|
||||
|
||||
__nodes__ = [
|
||||
MTB_UnsplashImage,
|
||||
MTB_TextToImage,
|
||||
MTB_UvMap,
|
||||
QrCode,
|
||||
UnsplashImage,
|
||||
TextToImage
|
||||
# MtbExamples,
|
||||
]
|
||||
|
||||
@@ -1,576 +0,0 @@
|
||||
import os
|
||||
|
||||
import numpy as np
|
||||
import open3d as o3d
|
||||
|
||||
from ..utils import (
|
||||
create_box,
|
||||
get_transformation_matrix,
|
||||
log,
|
||||
spread_geo,
|
||||
tensor2b64,
|
||||
)
|
||||
|
||||
# create_grid,
|
||||
# create_sphere,
|
||||
# create_torus,
|
||||
# mesh_to_json,
|
||||
# json_to_mesh
|
||||
# rotate_mesh,
|
||||
# euler_to_rotation_matrix,
|
||||
|
||||
|
||||
# class GeoPrimitive:
|
||||
# """Primitive 3D geometry"""
|
||||
|
||||
# @classmethod
|
||||
# def INPUT_TYPES(cls):
|
||||
# return {
|
||||
# "required": {
|
||||
# "kind": (["Box", "Sphere", "Cylinder", "Torus"], {"default": "Box"})
|
||||
# }
|
||||
# }
|
||||
|
||||
# RETURN_TYPES = ("UV_MAP",)
|
||||
# RETURN_NAMES = ("uv_map",)
|
||||
# FUNCTION = "distort_uvs"
|
||||
# CATEGORY = "mtb/uv"
|
||||
|
||||
|
||||
def default_material(color=None):
|
||||
return {
|
||||
"color": color or "#00ff00",
|
||||
"roughness": 1.0,
|
||||
"metalness": 0.0,
|
||||
"emissive": "#000000",
|
||||
"displacementScale": 1.0,
|
||||
"displacementMap": None,
|
||||
}
|
||||
|
||||
|
||||
class MTB_Camera:
|
||||
"""Make a Camera."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
base = default_material()
|
||||
return {
|
||||
"required": {
|
||||
"color": ("COLOR", {"default": base["color"]}),
|
||||
"roughness": (
|
||||
"FLOAT",
|
||||
{
|
||||
"default": base["roughness"],
|
||||
"min": 0.005,
|
||||
"max": 4.0,
|
||||
"step": 0.01,
|
||||
},
|
||||
),
|
||||
"flatShading": ("BOOLEAN",),
|
||||
"metalness": (
|
||||
"FLOAT",
|
||||
{
|
||||
"default": base["metalness"],
|
||||
"min": 0.0,
|
||||
"max": 1.0,
|
||||
"step": 0.01,
|
||||
},
|
||||
),
|
||||
"emissive": ("COLOR", {"default": base["emissive"]}),
|
||||
"displacementScale": (
|
||||
"FLOAT",
|
||||
{"default": 1.0, "min": -10.0, "max": 10.0},
|
||||
),
|
||||
},
|
||||
"optional": {"displacementMap": ("IMAGE",)},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("CAMERA",)
|
||||
RETURN_NAMES = ("camera",)
|
||||
FUNCTION = "make_camera"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def make_camera(self, **kwargs):
|
||||
return (kwargs,)
|
||||
|
||||
|
||||
class MTB_GeometryDraw:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"geometry": ("GEOMETRY",),
|
||||
},
|
||||
"optional": {
|
||||
"camera": ("CAMERA",),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("rendered_image",)
|
||||
FUNCTION = "render"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def render(self, geometry, camera):
|
||||
mesh, material = spread_geo(geometry)
|
||||
o3d.visualization.draw_geometries([mesh], **camera)
|
||||
|
||||
|
||||
# class MTB_RGBD_Image:
|
||||
# @classmethod
|
||||
# def INPUT_TYPES(cls):
|
||||
# return {
|
||||
# "required": {
|
||||
# "image": ("IMAGE",),
|
||||
# "depth": ("IMAGE",),
|
||||
# }
|
||||
# }
|
||||
|
||||
# RETURN_TYPES = ("RGBD_IMAGE",)
|
||||
# RETURN_NAMES = ("rgbd",)
|
||||
# FUNCTION = "make_rgbd"
|
||||
# CATEGORY = "mtb/3D"
|
||||
|
||||
# def make_rgbd(self, image, depth):
|
||||
# color_raw = o3d.io.read_image("../../test_data/RGBD/color/00000.jpg")
|
||||
# depth_raw = o3d.io.read_image("../../test_data/RGBD/depth/00000.png")
|
||||
# rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(
|
||||
# color_raw, depth_raw
|
||||
# )
|
||||
# print(rgbd_image)
|
||||
|
||||
|
||||
class MTB_GeometryMaterial:
|
||||
"""Make a std material."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
base = default_material()
|
||||
return {
|
||||
"required": {
|
||||
"color": ("COLOR", {"default": base["color"]}),
|
||||
"roughness": (
|
||||
"FLOAT",
|
||||
{
|
||||
"default": base["roughness"],
|
||||
"min": 0.005,
|
||||
"max": 4.0,
|
||||
"step": 0.01,
|
||||
},
|
||||
),
|
||||
"flatShading": ("BOOLEAN",),
|
||||
"metalness": (
|
||||
"FLOAT",
|
||||
{
|
||||
"default": base["metalness"],
|
||||
"min": 0.0,
|
||||
"max": 1.0,
|
||||
"step": 0.01,
|
||||
},
|
||||
),
|
||||
"emissive": ("COLOR", {"default": base["emissive"]}),
|
||||
"displacementScale": (
|
||||
"FLOAT",
|
||||
{"default": 1.0, "min": -10.0, "max": 10.0},
|
||||
),
|
||||
},
|
||||
"optional": {"displacementMap": ("IMAGE",)},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("GEO_MATERIAL",)
|
||||
RETURN_NAMES = ("material",)
|
||||
FUNCTION = "make_material"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def make_material(
|
||||
self, **kwargs
|
||||
): # color, roughness, metalness, emissive, displacementScalen displacementMap=None):
|
||||
# TODO: convert image to b64 and remove the key/add the B64 one
|
||||
# TODO: we can just use the "wireframe" property instead of my current solution
|
||||
if kwargs.get("displacementMap") is not None:
|
||||
tens = kwargs.pop("displacementMap")
|
||||
# TODO: alert about batch size > 1 ?
|
||||
b64images = tensor2b64(tens)[0]
|
||||
kwargs["displacementB64"] = b64images
|
||||
|
||||
return (kwargs,)
|
||||
|
||||
|
||||
class MTB_GeometryApplyMaterial:
|
||||
"""Apply a Material to a geometry."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"geometry": ("GEOMETRY",),
|
||||
"color": ("COLOR", {"default": "#000000"}),
|
||||
},
|
||||
"optional": {"material": ("GEO_MATERIAL",)},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("GEOMETRY",)
|
||||
RETURN_NAMES = ("geometry",)
|
||||
FUNCTION = "apply"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def apply(
|
||||
self,
|
||||
geometry,
|
||||
color,
|
||||
material=None,
|
||||
):
|
||||
if material is None:
|
||||
material = default_material(color)
|
||||
#
|
||||
geometry["material"] = material
|
||||
|
||||
return (geometry,)
|
||||
|
||||
|
||||
class MTB_GeometryTransform:
|
||||
"""Transforms the input geometry."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"mesh": ("GEOMETRY",),
|
||||
"position_x": (
|
||||
"FLOAT",
|
||||
{"default": 0.0, "step": 0.1, "min": -10000, "max": 10000},
|
||||
),
|
||||
"position_y": (
|
||||
"FLOAT",
|
||||
{"default": 0.0, "step": 0.1, "min": -10000, "max": 10000},
|
||||
),
|
||||
"position_z": (
|
||||
"FLOAT",
|
||||
{"default": 0.0, "step": 0.1, "min": -10000, "max": 10000},
|
||||
),
|
||||
"rotation_x": (
|
||||
"FLOAT",
|
||||
{"default": 0.0, "step": 1, "min": -10000, "max": 10000},
|
||||
),
|
||||
"rotation_y": (
|
||||
"FLOAT",
|
||||
{"default": 0.0, "step": 1, "min": -10000, "max": 10000},
|
||||
),
|
||||
"rotation_z": (
|
||||
"FLOAT",
|
||||
{"default": 0.0, "step": 1, "min": -10000, "max": 10000},
|
||||
),
|
||||
"scale_x": ("FLOAT", {"default": 1.0, "step": 0.1}),
|
||||
"scale_y": ("FLOAT", {"default": 1.0, "step": 0.1}),
|
||||
"scale_z": ("FLOAT", {"default": 1.0, "step": 0.1}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("GEOMETRY",)
|
||||
RETURN_NAMES = ("geometry",)
|
||||
FUNCTION = "transform_geometry"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def transform_geometry(
|
||||
self,
|
||||
mesh: o3d.geometry.TriangleMesh,
|
||||
position_x=0.0,
|
||||
position_y=0.0,
|
||||
position_z=0.0,
|
||||
rotation_x=0,
|
||||
rotation_y=0,
|
||||
rotation_z=0,
|
||||
scale_x=1,
|
||||
scale_y=1,
|
||||
scale_z=1,
|
||||
):
|
||||
# mesh = o3d.geometry.TriangleMesh.create_box(
|
||||
# width,
|
||||
# height,
|
||||
# depth,
|
||||
|
||||
# )
|
||||
# mesh.compute_vertex_normals()
|
||||
|
||||
position = np.array([position_x, position_y, position_z])
|
||||
rotation = (rotation_x, rotation_y, rotation_z)
|
||||
scale = np.array([scale_x, scale_y, scale_z])
|
||||
|
||||
transformation_matrix = get_transformation_matrix(
|
||||
position, rotation, scale
|
||||
)
|
||||
mesh, material = spread_geo(mesh, cp=True)
|
||||
|
||||
return (
|
||||
{
|
||||
"mesh": mesh.transform(transformation_matrix),
|
||||
"material": material,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class MTB_GeometrySphere:
|
||||
"""Makes a Sphere 3D geometry.."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"create_uv_map": ("BOOLEAN", {"default": True}),
|
||||
"radius": ("FLOAT", {"default": 1.0, "step": 0.1}),
|
||||
"resolution": ("INT", {"default": 20, "min": 1}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("GEOMETRY",)
|
||||
RETURN_NAMES = ("geometry",)
|
||||
FUNCTION = "make_sphere"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def make_sphere(self, create_uv_map, radius, resolution):
|
||||
mesh = o3d.geometry.TriangleMesh.create_sphere(
|
||||
radius,
|
||||
resolution,
|
||||
create_uv_map,
|
||||
)
|
||||
mesh.compute_vertex_normals()
|
||||
|
||||
return ({"mesh": mesh},)
|
||||
|
||||
|
||||
class MTB_GeometryTest:
|
||||
"""Fetches an Open3D data geometry.."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"name": (
|
||||
[
|
||||
"ArmadilloMesh",
|
||||
"AvocadoModel",
|
||||
"BunnyMesh",
|
||||
"CrateModel",
|
||||
"DamagedHelmetModel",
|
||||
"FlightHelmetModel",
|
||||
"KnotMesh",
|
||||
"MonkeyModel",
|
||||
"SwordModel",
|
||||
],
|
||||
{
|
||||
"default": "KnotMesh",
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("GEOMETRY",)
|
||||
RETURN_NAMES = ("geometry",)
|
||||
FUNCTION = "fetch_data"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def fetch_data(self, name):
|
||||
model = getattr(o3d.data, name)()
|
||||
mesh = o3d.io.read_triangle_mesh(model.path)
|
||||
mesh.compute_vertex_normals()
|
||||
return ({"mesh": mesh},)
|
||||
|
||||
|
||||
class MTB_GeometryBox:
|
||||
"""Makes a Box 3D geometry."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
# "create_uv_map": ("BOOLEAN", {"default": True}),
|
||||
"uniform_scale": ("FLOAT", {"default": 1.0, "step": 0.1}),
|
||||
"width": ("FLOAT", {"default": 1.0, "step": 0.05}),
|
||||
"height": ("FLOAT", {"default": 1.0, "step": 0.05}),
|
||||
"depth": ("FLOAT", {"default": 1.0, "step": 0.05}),
|
||||
"divisions_x": ("INT", {"default": 1}),
|
||||
"divisions_y": ("INT", {"default": 1}),
|
||||
"divisions_z": ("INT", {"default": 1}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("GEOMETRY",)
|
||||
RETURN_NAMES = ("geometry",)
|
||||
FUNCTION = "make_box"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def make_box(
|
||||
self,
|
||||
uniform_scale,
|
||||
width,
|
||||
height,
|
||||
depth,
|
||||
divisions_x,
|
||||
divisions_y,
|
||||
divisions_z,
|
||||
):
|
||||
width, height, depth = (width, height, depth) * uniform_scale
|
||||
|
||||
# mesh = o3d.geometry.TriangleMesh.create_box(
|
||||
# width,
|
||||
# height,
|
||||
# depth,
|
||||
|
||||
# )
|
||||
# mesh.compute_vertex_normals()
|
||||
|
||||
mesh = create_box(
|
||||
(width, height, depth), (divisions_x, divisions_y, divisions_z)
|
||||
)
|
||||
|
||||
return ({"mesh": mesh},)
|
||||
|
||||
|
||||
class MTB_GeometryLoad:
|
||||
"""Load a 3D geometry."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {"required": {"path": ("STRING", {"default": ""})}}
|
||||
|
||||
RETURN_TYPES = ("GEOMETRY",)
|
||||
RETURN_NAMES = ("geometry",)
|
||||
FUNCTION = "load_geo"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def load_geo(self, path):
|
||||
if not os.path.exists(path):
|
||||
raise ValueError(f"Path {path} does not exist")
|
||||
|
||||
mesh = o3d.io.read_triangle_mesh(path)
|
||||
|
||||
if len(mesh.vertices) == 0:
|
||||
mesh = o3d.io.read_triangle_model(path)
|
||||
mesh_count = len(mesh.meshes)
|
||||
if mesh_count == 0:
|
||||
raise ValueError("Couldn't parse input file")
|
||||
|
||||
if mesh_count > 1:
|
||||
log.warn(
|
||||
f"Found {mesh_count} meshes, only the first will be used..."
|
||||
)
|
||||
|
||||
mesh = mesh.meshes[0].mesh
|
||||
|
||||
mesh.compute_vertex_normals()
|
||||
|
||||
return {
|
||||
"result": ({"mesh": mesh},),
|
||||
}
|
||||
|
||||
|
||||
class MTB_GeometryInfo:
|
||||
"""Retrieve information about a 3D geometry."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {"required": {"geometry": ("GEOMETRY", {})}}
|
||||
|
||||
RETURN_TYPES = ("INT", "INT", "MATERIAL")
|
||||
RETURN_NAMES = ("num_vertices", "num_triangles", "material")
|
||||
FUNCTION = "get_info"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def get_info(self, geometry):
|
||||
mesh, material = spread_geo(geometry)
|
||||
log.debug(mesh)
|
||||
return (len(mesh.vertices), len(mesh.triangles), material)
|
||||
|
||||
|
||||
class MTB_GeometryDecimater:
|
||||
"""Optimized the geometry to match the target number of triangles."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"mesh": ("GEOMETRY", {}),
|
||||
"target": ("INT", {"default": 1500, "min": 3, "max": 500000}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("GEOMETRY",)
|
||||
RETURN_NAMES = ("geometry",)
|
||||
FUNCTION = "decimate"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def decimate(self, mesh, target):
|
||||
mesh = mesh.simplify_quadric_decimation(
|
||||
target_number_of_triangles=target
|
||||
)
|
||||
mesh.compute_vertex_normals()
|
||||
|
||||
return ({"mesh": mesh},)
|
||||
|
||||
|
||||
class MTB_GeometrySceneSetup:
|
||||
"""Scene setup for the renderer."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"geometry": ("GEOMETRY",),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("SCENE",)
|
||||
RETURN_NAMES = ("scene",)
|
||||
FUNCTION = "setup"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def setup(self, mesh, target):
|
||||
return ({"geometry": {"mesh": mesh}, "camera": cam},)
|
||||
|
||||
|
||||
class MTB_GeometryRender:
|
||||
"""Renders a Geometry to an image."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"geometry": ("SCENE", {}),
|
||||
"width": ("INT", {"default": 512, "min": 1}),
|
||||
"height": ("INT", {"default": 512, "min": 1}),
|
||||
"background": ("COLOR", {"default": [0.0, 0.0, 0.0]}),
|
||||
"camera": ("CAMERA",),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("image",)
|
||||
FUNCTION = "render"
|
||||
CATEGORY = "mtb/3D"
|
||||
|
||||
def render(self, geometry, width, height, background, camera):
|
||||
# create a renderer
|
||||
renderer = o3d.visualization.rendering.OffscreenRenderer(width, height)
|
||||
renderer.set_camera(camera)
|
||||
renderer.clear(background)
|
||||
renderer.add_geometry(geometry)
|
||||
renderer.render()
|
||||
image = renderer.get_image()
|
||||
return (image,)
|
||||
|
||||
|
||||
__nodes__ = [
|
||||
MTB_Camera,
|
||||
MTB_GeometryApplyMaterial,
|
||||
MTB_GeometryBox,
|
||||
MTB_GeometryDecimater,
|
||||
MTB_GeometryDraw,
|
||||
MTB_GeometryInfo,
|
||||
MTB_GeometryLoad,
|
||||
MTB_GeometryMaterial,
|
||||
MTB_GeometryRender,
|
||||
MTB_GeometrySceneSetup,
|
||||
MTB_GeometrySphere,
|
||||
MTB_GeometryTest,
|
||||
MTB_GeometryTransform,
|
||||
]
|
||||
+85
-537
@@ -1,334 +1,29 @@
|
||||
import io
|
||||
import json
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
from math import pi
|
||||
|
||||
import comfy.model_management as model_management
|
||||
import comfy.utils
|
||||
import numpy as np
|
||||
import torch
|
||||
from PIL import Image
|
||||
|
||||
from ..log import log
|
||||
from ..utils import (
|
||||
EASINGS,
|
||||
apply_easing,
|
||||
get_server_info,
|
||||
numpy_NFOV,
|
||||
pil2tensor,
|
||||
tensor2np,
|
||||
)
|
||||
from PIL import Image
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
import torch
|
||||
import json
|
||||
from comfy.cli_args import args
|
||||
from ..utils import pil2tensor, apply_easing
|
||||
import io
|
||||
import numpy as np
|
||||
|
||||
|
||||
def get_image(filename, subfolder, folder_type):
|
||||
"""Use the comfyUI "/view" endpoint to get an image from the server."""
|
||||
log.debug(
|
||||
f"Getting image {filename} from foldertype {folder_type} {f'in subfolder: {subfolder}' if subfolder else ''}" # noqa: E501
|
||||
)
|
||||
log.debug(f"Getting image {filename} from {subfolder} of {folder_type}")
|
||||
data = {"filename": filename, "subfolder": subfolder, "type": folder_type}
|
||||
base_url, port = get_server_info()
|
||||
|
||||
url_values = urllib.parse.urlencode(data)
|
||||
url = f"http://{base_url}:{port}/view?{url_values}"
|
||||
log.debug(f"Fetching image from {url}")
|
||||
|
||||
with urllib.request.urlopen(url) as response: # noqa: S310
|
||||
with urllib.request.urlopen(
|
||||
f"http://{args.listen}:{args.port}/view?{url_values}"
|
||||
) as response:
|
||||
return io.BytesIO(response.read())
|
||||
|
||||
|
||||
class MTB_ToDevice:
|
||||
"""Send a image or mask tensor to the given device."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
devices = ["cpu"]
|
||||
if torch.backends.mps.is_available():
|
||||
devices.append("mps")
|
||||
if torch.cuda.is_available():
|
||||
devices.append("cuda")
|
||||
for i in range(torch.cuda.device_count()):
|
||||
devices.append(f"cuda{i}")
|
||||
|
||||
return {
|
||||
"required": {
|
||||
"ignore_errors": ("BOOLEAN", {"default": False}),
|
||||
"device": (devices, {"default": "cpu"}),
|
||||
},
|
||||
"optional": {
|
||||
"image": ("IMAGE",),
|
||||
"mask": ("MASK",),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE", "MASK")
|
||||
RETURN_NAMES = ("images", "masks")
|
||||
CATEGORY = "mtb/utils"
|
||||
FUNCTION = "to_device"
|
||||
|
||||
def to_device(
|
||||
self,
|
||||
*,
|
||||
ignore_errors=False,
|
||||
device="cuda",
|
||||
image: torch.Tensor | None = None,
|
||||
mask: torch.Tensor | None = None,
|
||||
):
|
||||
if not ignore_errors and image is None and mask is None:
|
||||
raise ValueError(
|
||||
"You must either provide an image or a mask,"
|
||||
" use ignore_error to passthrough"
|
||||
)
|
||||
if image is not None:
|
||||
image = image.to(device)
|
||||
if mask is not None:
|
||||
mask = mask.to(device)
|
||||
return (image, mask)
|
||||
|
||||
|
||||
# class MTB_ApplyTextTemplate:
|
||||
class MTB_ApplyTextTemplate:
|
||||
"""
|
||||
Experimental node to interpolate strings from inputs.
|
||||
|
||||
Interpolation just requires {}, for instance:
|
||||
|
||||
Some string {var_1} and {var_2}
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"template": ("STRING", {"default": "", "multiline": True}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("string",)
|
||||
CATEGORY = "mtb/utils"
|
||||
FUNCTION = "execute"
|
||||
|
||||
def execute(self, *, template: str, **kwargs):
|
||||
res = f"{template}"
|
||||
for k, v in kwargs.items():
|
||||
res = res.replace(f"{{{k}}}", f"{v}")
|
||||
|
||||
return (res,)
|
||||
|
||||
|
||||
class MTB_MatchDimensions:
|
||||
"""Match images dimensions along the given dimension, preserving aspect ratio."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"source": ("IMAGE",),
|
||||
"reference": ("IMAGE",),
|
||||
"match": (["height", "width"], {"default": "height"}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE", "INT", "INT")
|
||||
RETURN_NAMES = ("image", "new_width", "new_height")
|
||||
CATEGORY = "mtb/utils"
|
||||
FUNCTION = "execute"
|
||||
|
||||
def execute(
|
||||
self, source: torch.Tensor, reference: torch.Tensor, match: str
|
||||
):
|
||||
import torchvision.transforms.functional as VF
|
||||
|
||||
_batch_size, height, width, _channels = source.shape
|
||||
_rbatch_size, rheight, rwidth, _rchannels = reference.shape
|
||||
|
||||
source_aspect_ratio = width / height
|
||||
# reference_aspect_ratio = rwidth / rheight
|
||||
|
||||
source = source.permute(0, 3, 1, 2)
|
||||
reference = reference.permute(0, 3, 1, 2)
|
||||
|
||||
if match == "height":
|
||||
new_height = rheight
|
||||
new_width = int(rheight * source_aspect_ratio)
|
||||
else:
|
||||
new_width = rwidth
|
||||
new_height = int(rwidth / source_aspect_ratio)
|
||||
|
||||
resized_images = [
|
||||
VF.resize(
|
||||
source[i],
|
||||
(new_height, new_width),
|
||||
antialias=True,
|
||||
interpolation=Image.BICUBIC,
|
||||
)
|
||||
for i in range(_batch_size)
|
||||
]
|
||||
resized_source = torch.stack(resized_images, dim=0)
|
||||
resized_source = resized_source.permute(0, 2, 3, 1)
|
||||
|
||||
return (resized_source, new_width, new_height)
|
||||
|
||||
|
||||
class MTB_FloatToFloats:
|
||||
"""Conversion utility for compatibility with other extensions (AD, IPA, Fitz are using FLOAT to represent list of floats.)"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"float": ("FLOAT", {"default": 0.0, "forceInput": True}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("FLOATS",)
|
||||
RETURN_NAMES = ("floats",)
|
||||
CATEGORY = "mtb/utils"
|
||||
FUNCTION = "convert"
|
||||
|
||||
def convert(self, float: float):
|
||||
return (float,)
|
||||
|
||||
|
||||
class MTB_FloatsToInts:
|
||||
"""Conversion utility for compatibility with frame interpolation."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"floats": ("FLOATS", {"forceInput": True}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("INTS", "INT")
|
||||
CATEGORY = "mtb/utils"
|
||||
FUNCTION = "convert"
|
||||
|
||||
def convert(self, floats: list[float]):
|
||||
vals = [int(x) for x in floats]
|
||||
return (vals, vals)
|
||||
|
||||
|
||||
class MTB_FloatsToFloat:
|
||||
"""Conversion utility for compatibility with other extensions (AD, IPA, Fitz are using FLOAT to represent list of floats.)"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"floats": ("FLOATS",),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("FLOAT",)
|
||||
RETURN_NAMES = ("float",)
|
||||
CATEGORY = "mtb/utils"
|
||||
FUNCTION = "convert"
|
||||
|
||||
def convert(self, floats):
|
||||
return (floats,)
|
||||
|
||||
|
||||
class MTB_AutoPanEquilateral:
|
||||
"""Generate a 360 panning video from an equilateral image."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"equilateral_image": ("IMAGE",),
|
||||
"fovX": ("FLOAT", {"default": 45.0}),
|
||||
"fovY": ("FLOAT", {"default": 45.0}),
|
||||
"elevation": ("FLOAT", {"default": 0.5}),
|
||||
"frame_count": ("INT", {"default": 100}),
|
||||
"width": ("INT", {"default": 768}),
|
||||
"height": ("INT", {"default": 512}),
|
||||
},
|
||||
"optional": {
|
||||
"floats_fovX": ("FLOATS",),
|
||||
"floats_fovY": ("FLOATS",),
|
||||
"floats_elevation": ("FLOATS",),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("image",)
|
||||
CATEGORY = "mtb/utils"
|
||||
FUNCTION = "generate_frames"
|
||||
|
||||
def check_floats(self, f: list[float] | None, expected_count: int):
|
||||
if f:
|
||||
if len(f) == expected_count:
|
||||
return True
|
||||
return False
|
||||
return True
|
||||
|
||||
def generate_frames(
|
||||
self,
|
||||
equilateral_image: torch.Tensor,
|
||||
fovX: float,
|
||||
fovY: float,
|
||||
elevation: float,
|
||||
frame_count: int,
|
||||
width: int,
|
||||
height: int,
|
||||
floats_fovX: list[float] | None = None,
|
||||
floats_fovY: list[float] | None = None,
|
||||
floats_elevation: list[float] | None = None,
|
||||
):
|
||||
source = tensor2np(equilateral_image)
|
||||
|
||||
if len(source) > 1:
|
||||
log.warn(
|
||||
"You provided more than one image in the equilateral_image input, only the first will be used."
|
||||
)
|
||||
if not all(
|
||||
[
|
||||
self.check_floats(x, frame_count)
|
||||
for x in [floats_fovX, floats_fovY, floats_elevation]
|
||||
]
|
||||
):
|
||||
raise ValueError(
|
||||
"You provided less than the expected number of fovX, fovY, or elevation values."
|
||||
)
|
||||
|
||||
source = source[0]
|
||||
frames = []
|
||||
|
||||
pbar = comfy.utils.ProgressBar(frame_count)
|
||||
for i in range(frame_count):
|
||||
rotation_angle = (i / frame_count) * 2 * pi
|
||||
|
||||
if floats_elevation:
|
||||
elevation = floats_elevation[i]
|
||||
|
||||
if floats_fovX:
|
||||
fovX = floats_fovX[i]
|
||||
|
||||
if floats_fovY:
|
||||
fovY = floats_fovY[i]
|
||||
|
||||
fov = [fovX / 100, fovY / 100]
|
||||
center_point = [rotation_angle / (2 * pi), elevation]
|
||||
|
||||
nfov = numpy_NFOV(fov, height, width)
|
||||
frame = nfov.to_nfov(source, center_point=center_point)
|
||||
|
||||
frames.append(frame)
|
||||
|
||||
model_management.throw_exception_if_processing_interrupted()
|
||||
pbar.update(1)
|
||||
|
||||
return (pil2tensor(frames),)
|
||||
|
||||
|
||||
class MTB_GetBatchFromHistory:
|
||||
class GetBatchFromHistory:
|
||||
"""Very experimental node to load images from the history of the server.
|
||||
|
||||
Queue items without output are ignored in the count.
|
||||
"""
|
||||
Queue items without output are ignored in the count."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -351,7 +46,6 @@ class MTB_GetBatchFromHistory:
|
||||
|
||||
def load_from_history(
|
||||
self,
|
||||
*,
|
||||
enable=True,
|
||||
count=0,
|
||||
offset=0,
|
||||
@@ -366,18 +60,10 @@ class MTB_GetBatchFromHistory:
|
||||
return (torch.zeros(0),)
|
||||
frames = []
|
||||
|
||||
base_url, port = get_server_info()
|
||||
|
||||
history_url = f"http://{base_url}:{port}/history"
|
||||
log.debug(f"Fetching history from {history_url}")
|
||||
output = torch.zeros(0)
|
||||
with urllib.request.urlopen(history_url) as response: # noqa: S310
|
||||
output = self.load_batch_frames(response, offset, count, frames)
|
||||
|
||||
if output.size(0) == 0:
|
||||
log.warn("No output found in history")
|
||||
|
||||
return (output,)
|
||||
with urllib.request.urlopen(
|
||||
f"http://{args.listen}:{args.port}/history"
|
||||
) as response:
|
||||
return self.load_batch_frames(response, offset, count, frames)
|
||||
|
||||
def load_batch_frames(self, response, offset, count, frames):
|
||||
history = json.loads(response.read())
|
||||
@@ -389,14 +75,12 @@ class MTB_GetBatchFromHistory:
|
||||
if "images" in node_output:
|
||||
for image in node_output["images"]:
|
||||
image_data = get_image(
|
||||
image["filename"],
|
||||
image["subfolder"],
|
||||
image["type"],
|
||||
image["filename"], image["subfolder"], image["type"]
|
||||
)
|
||||
output_images.append(image_data)
|
||||
|
||||
if not output_images:
|
||||
return torch.zeros(0)
|
||||
return (torch.zeros(0),)
|
||||
|
||||
# Directly get desired range of images
|
||||
start_index = max(len(output_images) - offset - count, 0)
|
||||
@@ -406,56 +90,48 @@ class MTB_GetBatchFromHistory:
|
||||
frames = [Image.open(image) for image in selected_images]
|
||||
|
||||
if not frames:
|
||||
return torch.zeros(0)
|
||||
return (torch.zeros(0),)
|
||||
elif len(frames) != count:
|
||||
log.warning(f"Expected {count} images, got {len(frames)} instead")
|
||||
|
||||
return pil2tensor(frames)
|
||||
output = pil2tensor(frames)
|
||||
|
||||
return (output,)
|
||||
|
||||
|
||||
class MTB_AnyToString:
|
||||
"""Tries to take any input and convert it to a string."""
|
||||
class AnyToString:
|
||||
"""Tries to take any input and convert it to a string"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {"input_value": ("*",)},
|
||||
"required": {"input": ("*")},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
FUNCTION = "do_str"
|
||||
CATEGORY = "mtb/converters"
|
||||
|
||||
def do_str(self, input_value):
|
||||
if isinstance(input_value, str):
|
||||
return (input_value,)
|
||||
elif isinstance(input_value, torch.Tensor):
|
||||
return (
|
||||
f"Tensor of shape {input_value.shape} and dtype {input_value.dtype}",
|
||||
)
|
||||
elif isinstance(input_value, Image.Image):
|
||||
return (
|
||||
f"PIL Image of size {input_value.size} and mode {input_value.mode}",
|
||||
)
|
||||
elif isinstance(input_value, np.ndarray):
|
||||
return (
|
||||
f"Numpy array of shape {input_value.shape} and dtype {input_value.dtype}",
|
||||
)
|
||||
def do_str(self, input):
|
||||
if isinstance(input, str):
|
||||
return (input,)
|
||||
elif isinstance(input, torch.Tensor):
|
||||
return (f"Tensor of shape {input.shape} and dtype {input.dtype}",)
|
||||
elif isinstance(input, Image.Image):
|
||||
return (f"PIL Image of size {input.size} and mode {input.mode}",)
|
||||
elif isinstance(input, np.ndarray):
|
||||
return (f"Numpy array of shape {input.shape} and dtype {input.dtype}",)
|
||||
|
||||
elif isinstance(input_value, dict):
|
||||
return (
|
||||
f"Dictionary of {len(input_value)} items, with keys {input_value.keys()}",
|
||||
)
|
||||
elif isinstance(input, dict):
|
||||
return (f"Dictionary of {len(input)} items, with keys {input.keys()}",)
|
||||
|
||||
else:
|
||||
log.debug(f"Falling back to string conversion of {input_value}")
|
||||
return (str(input_value),)
|
||||
log.debug(f"Falling back to string conversion of {input}")
|
||||
return (str(input),)
|
||||
|
||||
|
||||
class MTB_StringReplace:
|
||||
"""Basic string replacement."""
|
||||
|
||||
"""Basic string replacement."""
|
||||
class StringReplace:
|
||||
"""Basic string replacement"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -483,57 +159,7 @@ class MTB_StringReplace:
|
||||
return (string,)
|
||||
|
||||
|
||||
class MTB_MathExpression:
|
||||
"""Node to evaluate a simple math expression string."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"expression": ("STRING", {"default": "", "multiline": True}),
|
||||
}
|
||||
}
|
||||
|
||||
FUNCTION = "eval_expression"
|
||||
RETURN_TYPES = ("FLOAT", "INT")
|
||||
RETURN_NAMES = ("result (float)", "result (int)")
|
||||
CATEGORY = "mtb/math"
|
||||
DESCRIPTION = (
|
||||
"evaluate a simple math expression string, only supports literal_eval"
|
||||
)
|
||||
|
||||
def eval_expression(self, expression: str, **kwargs):
|
||||
from ast import literal_eval
|
||||
|
||||
for key, value in kwargs.items():
|
||||
log.debug(f"Replacing placeholder <{key}> with value {value}")
|
||||
expression = expression.replace(f"<{key}>", str(value))
|
||||
|
||||
result = -1
|
||||
try:
|
||||
result = literal_eval(expression)
|
||||
except SyntaxError as e:
|
||||
raise ValueError(
|
||||
f"The expression syntax is wrong '{expression}': {e}"
|
||||
) from e
|
||||
|
||||
except Exception as e:
|
||||
raise ValueError(
|
||||
f"Math expression only support literal_eval now: {e}"
|
||||
)
|
||||
except ValueError:
|
||||
try:
|
||||
expression = expression.replace("^", "**")
|
||||
result = eval(expression) # noqa: S307
|
||||
except Exception as e:
|
||||
raise ValueError(
|
||||
f"Error evaluating expression '{expression}': {e}"
|
||||
) from e
|
||||
|
||||
return (result, int(result))
|
||||
|
||||
|
||||
class MTB_FitNumber:
|
||||
class FitNumber:
|
||||
"""Fit the input float using a source and target range"""
|
||||
|
||||
@classmethod
|
||||
@@ -542,24 +168,35 @@ class MTB_FitNumber:
|
||||
"required": {
|
||||
"value": ("FLOAT", {"default": 0, "forceInput": True}),
|
||||
"clamp": ("BOOLEAN", {"default": False}),
|
||||
"source_min": (
|
||||
"FLOAT",
|
||||
{"default": 0.0, "step": 0.01, "min": -1e5},
|
||||
),
|
||||
"source_max": (
|
||||
"FLOAT",
|
||||
{"default": 1.0, "step": 0.01, "min": -1e5},
|
||||
),
|
||||
"target_min": (
|
||||
"FLOAT",
|
||||
{"default": 0.0, "step": 0.01, "min": -1e5},
|
||||
),
|
||||
"target_max": (
|
||||
"FLOAT",
|
||||
{"default": 1.0, "step": 0.01, "min": -1e5},
|
||||
),
|
||||
"source_min": ("FLOAT", {"default": 0.0}),
|
||||
"source_max": ("FLOAT", {"default": 1.0}),
|
||||
"target_min": ("FLOAT", {"default": 0.0}),
|
||||
"target_max": ("FLOAT", {"default": 1.0}),
|
||||
"easing": (
|
||||
EASINGS,
|
||||
[
|
||||
"Linear",
|
||||
"Sine In",
|
||||
"Sine Out",
|
||||
"Sine In/Out",
|
||||
"Quart In",
|
||||
"Quart Out",
|
||||
"Quart In/Out",
|
||||
"Cubic In",
|
||||
"Cubic Out",
|
||||
"Cubic In/Out",
|
||||
"Circ In",
|
||||
"Circ Out",
|
||||
"Circ In/Out",
|
||||
"Back In",
|
||||
"Back Out",
|
||||
"Back In/Out",
|
||||
"Elastic In",
|
||||
"Elastic Out",
|
||||
"Elastic In/Out",
|
||||
"Bounce In",
|
||||
"Bounce Out",
|
||||
"Bounce In/Out",
|
||||
],
|
||||
{"default": "Linear"},
|
||||
),
|
||||
}
|
||||
@@ -568,120 +205,31 @@ class MTB_FitNumber:
|
||||
FUNCTION = "set_range"
|
||||
RETURN_TYPES = ("FLOAT",)
|
||||
CATEGORY = "mtb/math"
|
||||
DESCRIPTION = "Fit the input float using a source and target range"
|
||||
|
||||
def set_range(
|
||||
self,
|
||||
*,
|
||||
value: float,
|
||||
clamp: bool,
|
||||
source_min=0.0,
|
||||
source_max=1.0,
|
||||
target_min=0.0,
|
||||
target_max=1.0,
|
||||
easing="Linear",
|
||||
source_min: float,
|
||||
source_max: float,
|
||||
target_min: float,
|
||||
target_max: float,
|
||||
easing: str,
|
||||
):
|
||||
if source_min == source_max:
|
||||
normalized_value = 0
|
||||
else:
|
||||
normalized_value = (value - source_min) / (source_max - source_min)
|
||||
if clamp:
|
||||
normalized_value = max(min(normalized_value, 1), 0)
|
||||
normalized_value = (value - source_min) / (source_max - source_min)
|
||||
|
||||
eased_value = apply_easing(normalized_value, easing)
|
||||
|
||||
# - Convert the eased value to the target range
|
||||
res = target_min + (target_max - target_min) * eased_value
|
||||
|
||||
if clamp:
|
||||
if target_min > target_max:
|
||||
res = max(min(res, target_min), target_max)
|
||||
else:
|
||||
res = max(min(res, target_max), target_min)
|
||||
|
||||
return (res,)
|
||||
|
||||
|
||||
class MTB_ConcatImages:
|
||||
"""Add images to batch."""
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "concatenate_tensors"
|
||||
CATEGORY = "mtb/image"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {"reverse": ("BOOLEAN", {"default": False})},
|
||||
"optional": {
|
||||
"on_mismatch": (
|
||||
["Error", "Smallest", "Largest"],
|
||||
{"default": "Smallest"},
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
def concatenate_tensors(
|
||||
self,
|
||||
reverse: bool,
|
||||
on_mismatch: str = "Smallest",
|
||||
**kwargs: torch.Tensor,
|
||||
) -> tuple[torch.Tensor]:
|
||||
tensors = list(kwargs.values())
|
||||
|
||||
if on_mismatch == "Error":
|
||||
shapes = [tensor.shape for tensor in tensors]
|
||||
if not all(shape == shapes[0] for shape in shapes):
|
||||
raise ValueError(
|
||||
"All input tensors must have the same shape when on_mismatch is 'Error'."
|
||||
)
|
||||
|
||||
else:
|
||||
import torch.nn.functional as F
|
||||
|
||||
if on_mismatch == "Smallest":
|
||||
target_shape = min(
|
||||
(tensor.shape for tensor in tensors),
|
||||
key=lambda s: (s[1], s[2]),
|
||||
)
|
||||
else: # on_mismatch == "Largest"
|
||||
target_shape = max(
|
||||
(tensor.shape for tensor in tensors),
|
||||
key=lambda s: (s[1], s[2]),
|
||||
)
|
||||
|
||||
target_height, target_width = target_shape[1], target_shape[2]
|
||||
|
||||
resized_tensors = []
|
||||
for tensor in tensors:
|
||||
if (
|
||||
tensor.shape[1] != target_height
|
||||
or tensor.shape[2] != target_width
|
||||
):
|
||||
resized_tensor = F.interpolate(
|
||||
tensor.permute(0, 3, 1, 2),
|
||||
size=(target_height, target_width),
|
||||
mode="bilinear",
|
||||
align_corners=False,
|
||||
)
|
||||
resized_tensor = resized_tensor.permute(0, 2, 3, 1)
|
||||
resized_tensors.append(resized_tensor)
|
||||
else:
|
||||
resized_tensors.append(tensor)
|
||||
|
||||
tensors = resized_tensors
|
||||
|
||||
concatenated = torch.cat(tensors, dim=0)
|
||||
|
||||
return (concatenated,)
|
||||
|
||||
|
||||
__nodes__ = [
|
||||
MTB_StringReplace,
|
||||
MTB_FitNumber,
|
||||
MTB_GetBatchFromHistory,
|
||||
MTB_AnyToString,
|
||||
MTB_ConcatImages,
|
||||
MTB_MathExpression,
|
||||
MTB_ToDevice,
|
||||
MTB_ApplyTextTemplate,
|
||||
MTB_MatchDimensions,
|
||||
MTB_AutoPanEquilateral,
|
||||
MTB_FloatsToFloat,
|
||||
MTB_FloatToFloats,
|
||||
MTB_FloatsToInts,
|
||||
]
|
||||
__nodes__ = [StringReplace, FitNumber, GetBatchFromHistory, AnyToString]
|
||||
|
||||
@@ -1,29 +1,27 @@
|
||||
from typing import List
|
||||
from pathlib import Path
|
||||
|
||||
import comfy
|
||||
import comfy.model_management as model_management
|
||||
import comfy.utils
|
||||
import numpy as np
|
||||
import tensorflow as tf
|
||||
import torch
|
||||
from frame_interpolation.eval import interpolator, util
|
||||
|
||||
from ..errors import ModelNotFound
|
||||
import os
|
||||
import glob
|
||||
import folder_paths
|
||||
from ..log import log
|
||||
from ..utils import get_model_path
|
||||
import torch
|
||||
from frame_interpolation.eval import util, interpolator
|
||||
import numpy as np
|
||||
import comfy
|
||||
import comfy.utils
|
||||
import tensorflow as tf
|
||||
import comfy.model_management as model_management
|
||||
|
||||
|
||||
class MTB_LoadFilmModel:
|
||||
"""Loads a FILM model.
|
||||
|
||||
[DEPRECATED] Use ComfyUI-FrameInterpolation instead
|
||||
"""
|
||||
class LoadFilmModel:
|
||||
"""Loads a FILM model"""
|
||||
|
||||
@staticmethod
|
||||
def get_models() -> list[Path]:
|
||||
models_paths = get_model_path("FILM").iterdir()
|
||||
|
||||
return [x for x in models_paths if x.suffix in [".onnx", ".pth"]]
|
||||
def get_models() -> List[Path]:
|
||||
models_path = os.path.join(folder_paths.models_dir, "FILM/*")
|
||||
models = glob.glob(models_path)
|
||||
models = [Path(x) for x in models if x.endswith(".onnx") or x.endswith(".pth")]
|
||||
return models
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -39,13 +37,9 @@ class MTB_LoadFilmModel:
|
||||
RETURN_TYPES = ("FILM_MODEL",)
|
||||
FUNCTION = "load_model"
|
||||
CATEGORY = "mtb/frame iterpolation"
|
||||
DEPRECATED = True
|
||||
|
||||
def load_model(self, film_model: str):
|
||||
model_path = get_model_path("FILM", film_model)
|
||||
if not model_path or not model_path.exists():
|
||||
raise ModelNotFound(f"FILM ({model_path})")
|
||||
|
||||
model_path = Path(folder_paths.models_dir) / "FILM" / film_model
|
||||
if not (model_path / "saved_model.pb").exists():
|
||||
model_path = model_path / "saved_model"
|
||||
|
||||
@@ -58,11 +52,8 @@ class MTB_LoadFilmModel:
|
||||
return (interpolator.Interpolator(model_path.as_posix(), None),)
|
||||
|
||||
|
||||
class MTB_FilmInterpolation:
|
||||
"""Google Research FILM frame interpolation for large motion.
|
||||
|
||||
[DEPRECATED] Use ComfyUI-FrameInterpolation instead
|
||||
"""
|
||||
class FilmInterpolation:
|
||||
"""Google Research FILM frame interpolation for large motion"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -77,7 +68,6 @@ class MTB_FilmInterpolation:
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "do_interpolation"
|
||||
CATEGORY = "mtb/frame iterpolation"
|
||||
DEPRECATED = True
|
||||
|
||||
def do_interpolation(
|
||||
self,
|
||||
@@ -108,21 +98,15 @@ class MTB_FilmInterpolation:
|
||||
pbar = comfy.utils.ProgressBar(num_frames)
|
||||
|
||||
for frame in util.interpolate_recursively_from_memory(
|
||||
in_frames, # type: ignore
|
||||
interpolate,
|
||||
film_model,
|
||||
in_frames, interpolate, film_model
|
||||
):
|
||||
out_tensors.append(
|
||||
torch.from_numpy(frame)
|
||||
if isinstance(frame, np.ndarray)
|
||||
else frame
|
||||
torch.from_numpy(frame) if isinstance(frame, np.ndarray) else frame
|
||||
)
|
||||
model_management.throw_exception_if_processing_interrupted()
|
||||
pbar.update(1)
|
||||
|
||||
out_tensors = torch.cat(
|
||||
[tens.unsqueeze(0) for tens in out_tensors], dim=0
|
||||
)
|
||||
out_tensors = torch.cat([tens.unsqueeze(0) for tens in out_tensors], dim=0)
|
||||
|
||||
log.debug(f"Returning {len(out_tensors)} tensors")
|
||||
log.debug(f"Output shape {out_tensors.shape}")
|
||||
@@ -130,4 +114,41 @@ class MTB_FilmInterpolation:
|
||||
return (out_tensors,)
|
||||
|
||||
|
||||
__nodes__ = [MTB_LoadFilmModel, MTB_FilmInterpolation]
|
||||
class ConcatImages:
|
||||
"""Add images to batch"""
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "concat_images"
|
||||
CATEGORY = "mtb/image"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"imageA": ("IMAGE",),
|
||||
"imageB": ("IMAGE",),
|
||||
},
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def concatenate_tensors(cls, A: torch.Tensor, B: torch.Tensor):
|
||||
# Get the batch sizes of A and B
|
||||
batch_size_A = A.size(0)
|
||||
batch_size_B = B.size(0)
|
||||
|
||||
# Concatenate the tensors along the batch dimension
|
||||
concatenated = torch.cat((A, B), dim=0)
|
||||
|
||||
# Update the batch size in the concatenated tensor
|
||||
concatenated_size = list(concatenated.size())
|
||||
concatenated_size[0] = batch_size_A + batch_size_B
|
||||
concatenated = concatenated.view(*concatenated_size)
|
||||
|
||||
return concatenated
|
||||
|
||||
def concat_images(self, imageA: torch.Tensor, imageB: torch.Tensor):
|
||||
log.debug(f"Concatenating A ({imageA.shape}) and B ({imageB.shape})")
|
||||
return (self.concatenate_tensors(imageA, imageB),)
|
||||
|
||||
|
||||
__nodes__ = [LoadFilmModel, FilmInterpolation, ConcatImages]
|
||||
|
||||
+87
-765
File diff suppressed because it is too large
Load Diff
@@ -1,130 +0,0 @@
|
||||
import torch
|
||||
|
||||
from ..log import log
|
||||
|
||||
|
||||
class MTB_StackImages:
|
||||
"""Stack the input images horizontally or vertically."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {"required": {"vertical": ("BOOLEAN", {"default": False})}}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "stack"
|
||||
CATEGORY = "mtb/image utils"
|
||||
|
||||
def stack(self, vertical, **kwargs):
|
||||
if not kwargs:
|
||||
raise ValueError("At least one tensor must be provided.")
|
||||
|
||||
tensors = list(kwargs.values())
|
||||
log.debug(
|
||||
f"Stacking {len(tensors)} tensors "
|
||||
f"{'vertically' if vertical else 'horizontally'}"
|
||||
)
|
||||
|
||||
normalized_tensors = [
|
||||
self.normalize_to_rgba(tensor) for tensor in tensors
|
||||
]
|
||||
max_batch_size = max(tensor.shape[0] for tensor in normalized_tensors)
|
||||
normalized_tensors = [
|
||||
self.duplicate_frames(tensor, max_batch_size)
|
||||
for tensor in normalized_tensors
|
||||
]
|
||||
|
||||
if vertical:
|
||||
width = normalized_tensors[0].shape[2]
|
||||
if any(tensor.shape[2] != width for tensor in normalized_tensors):
|
||||
raise ValueError(
|
||||
"All tensors must have the same width "
|
||||
"for vertical stacking."
|
||||
)
|
||||
dim = 1
|
||||
else:
|
||||
height = normalized_tensors[0].shape[1]
|
||||
if any(tensor.shape[1] != height for tensor in normalized_tensors):
|
||||
raise ValueError(
|
||||
"All tensors must have the same height "
|
||||
"for horizontal stacking."
|
||||
)
|
||||
dim = 2
|
||||
|
||||
stacked_tensor = torch.cat(normalized_tensors, dim=dim)
|
||||
|
||||
return (stacked_tensor,)
|
||||
|
||||
def normalize_to_rgba(self, tensor):
|
||||
"""Normalize tensor to have 4 channels (RGBA)."""
|
||||
_, _, _, channels = tensor.shape
|
||||
# already RGBA
|
||||
if channels == 4:
|
||||
return tensor
|
||||
# RGB to RGBA
|
||||
elif channels == 3:
|
||||
alpha_channel = torch.ones(
|
||||
tensor.shape[:-1] + (1,), device=tensor.device
|
||||
) # Add an alpha channel
|
||||
return torch.cat((tensor, alpha_channel), dim=-1)
|
||||
else:
|
||||
raise ValueError(
|
||||
"Tensor has an unsupported number of channels: "
|
||||
"expected 3 (RGB) or 4 (RGBA)."
|
||||
)
|
||||
|
||||
def duplicate_frames(self, tensor, target_batch_size):
|
||||
"""Duplicate frames in tensor to match the target batch size."""
|
||||
current_batch_size = tensor.shape[0]
|
||||
if current_batch_size < target_batch_size:
|
||||
duplication_factors: int = target_batch_size // current_batch_size
|
||||
duplicated_tensor = tensor.repeat(duplication_factors, 1, 1, 1)
|
||||
remaining_frames = target_batch_size % current_batch_size
|
||||
if remaining_frames > 0:
|
||||
duplicated_tensor = torch.cat(
|
||||
(duplicated_tensor, tensor[:remaining_frames]), dim=0
|
||||
)
|
||||
return duplicated_tensor
|
||||
else:
|
||||
return tensor
|
||||
|
||||
|
||||
class MTB_PickFromBatch:
|
||||
"""Pick a specific number of images from a batch.
|
||||
|
||||
either from the start or end.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"from_direction": (["end", "start"], {"default": "start"}),
|
||||
"count": ("INT", {"default": 1}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "pick_from_batch"
|
||||
CATEGORY = "mtb/image utils"
|
||||
|
||||
def pick_from_batch(self, image, from_direction, count):
|
||||
batch_size = image.size(0)
|
||||
|
||||
# Limit count to the available number of images in the batch
|
||||
count = min(count, batch_size)
|
||||
if count < batch_size:
|
||||
log.warning(
|
||||
f"Requested {count} images, "
|
||||
f"but only {batch_size} are available."
|
||||
)
|
||||
|
||||
if from_direction == "end":
|
||||
selected_tensors = image[-count:]
|
||||
else:
|
||||
selected_tensors = image[:count]
|
||||
|
||||
return (selected_tensors,)
|
||||
|
||||
|
||||
__nodes__ = [MTB_StackImages, MTB_PickFromBatch]
|
||||
+47
-291
@@ -1,268 +1,67 @@
|
||||
import json
|
||||
import subprocess
|
||||
from ..utils import tensor2np, PIL_FILTER_MAP
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
|
||||
import comfy.model_management as model_management
|
||||
import comfy.utils
|
||||
import folder_paths
|
||||
import numpy as np
|
||||
import torch
|
||||
from PIL import Image
|
||||
|
||||
from ..log import log
|
||||
from ..utils import PIL_FILTER_MAP, output_dir, session_id, tensor2np
|
||||
import comfy.model_management as model_management
|
||||
import subprocess
|
||||
import torch
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
from typing import Optional, List
|
||||
|
||||
|
||||
def get_playlist_path(playlist_name: str, persistant_playlist=False):
|
||||
if persistant_playlist:
|
||||
return output_dir / "playlists" / f"{playlist_name}.json"
|
||||
|
||||
return output_dir / "playlists" / session_id / f"{playlist_name}.json"
|
||||
|
||||
|
||||
class MTB_ReadPlaylist:
|
||||
"""Read a playlist"""
|
||||
class ExportWithFfmpeg:
|
||||
"""Export with FFmpeg (Experimental)"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"enable": ("BOOLEAN", {"default": True}),
|
||||
"persistant_playlist": ("BOOLEAN", {"default": False}),
|
||||
"playlist_name": (
|
||||
"STRING",
|
||||
{"default": "playlist_{index:04d}"},
|
||||
),
|
||||
"index": ("INT", {"default": 0, "min": 0}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("PLAYLIST",)
|
||||
FUNCTION = "read_playlist"
|
||||
CATEGORY = "mtb/IO"
|
||||
EXPERIMENTAL = True
|
||||
|
||||
def read_playlist(
|
||||
self,
|
||||
enable: bool,
|
||||
persistant_playlist: bool,
|
||||
playlist_name: str,
|
||||
index: int,
|
||||
):
|
||||
playlist_name = playlist_name.format(index=index)
|
||||
playlist_path = get_playlist_path(playlist_name, persistant_playlist)
|
||||
if not enable:
|
||||
return (None,)
|
||||
|
||||
if not playlist_path.exists():
|
||||
log.warning(f"Playlist {playlist_path} does not exist, skipping")
|
||||
return (None,)
|
||||
|
||||
log.debug(f"Reading playlist {playlist_path}")
|
||||
return (json.loads(playlist_path.read_text(encoding="utf-8")),)
|
||||
|
||||
|
||||
class MTB_AddToPlaylist:
|
||||
"""Add a video to the playlist"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"relative_paths": ("BOOLEAN", {"default": False}),
|
||||
"persistant_playlist": ("BOOLEAN", {"default": False}),
|
||||
"playlist_name": (
|
||||
"STRING",
|
||||
{"default": "playlist_{index:04d}"},
|
||||
),
|
||||
"index": ("INT", {"default": 0, "min": 0}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ()
|
||||
OUTPUT_NODE = True
|
||||
FUNCTION = "add_to_playlist"
|
||||
CATEGORY = "mtb/IO"
|
||||
EXPERIMENTAL = True
|
||||
|
||||
def add_to_playlist(
|
||||
self,
|
||||
relative_paths: bool,
|
||||
persistant_playlist: bool,
|
||||
playlist_name: str,
|
||||
index: int,
|
||||
**kwargs,
|
||||
):
|
||||
playlist_name = playlist_name.format(index=index)
|
||||
playlist_path = get_playlist_path(playlist_name, persistant_playlist)
|
||||
|
||||
if not playlist_path.parent.exists():
|
||||
playlist_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
playlist = []
|
||||
if not playlist_path.exists():
|
||||
playlist_path.write_text("[]")
|
||||
else:
|
||||
playlist = json.loads(playlist_path.read_text())
|
||||
log.debug(f"Playlist {playlist_path} has {len(playlist)} items")
|
||||
for video in kwargs.values():
|
||||
if relative_paths:
|
||||
video = Path(video).relative_to(output_dir).as_posix()
|
||||
|
||||
log.debug(f"Adding {video} to playlist")
|
||||
playlist.append(video)
|
||||
|
||||
log.debug(f"Writing playlist {playlist_path}")
|
||||
playlist_path.write_text(json.dumps(playlist), encoding="utf-8")
|
||||
return ()
|
||||
|
||||
|
||||
class MTB_ExportWithFfmpeg:
|
||||
"""Export with FFmpeg (Experimental).
|
||||
|
||||
[DEPRACATED] Use VHS nodes instead
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"optional": {
|
||||
"images": ("IMAGE",),
|
||||
"playlist": ("PLAYLIST",),
|
||||
},
|
||||
"required": {
|
||||
# "frames": ("FRAMES",),
|
||||
"fps": ("FLOAT", {"default": 24, "min": 1}),
|
||||
"prefix": ("STRING", {"default": "export"}),
|
||||
"format": (
|
||||
["mov", "mp4", "mkv", "gif", "avi"],
|
||||
{"default": "mov"},
|
||||
),
|
||||
"format": (["mov", "mp4", "mkv", "avi"], {"default": "mov"}),
|
||||
"codec": (
|
||||
["prores_ks", "libx264", "libx265", "gif"],
|
||||
["prores_ks", "libx264", "libx265"],
|
||||
{"default": "prores_ks"},
|
||||
),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("VIDEO",)
|
||||
OUTPUT_NODE = True
|
||||
FUNCTION = "export_prores"
|
||||
DEPRECATED = True
|
||||
CATEGORY = "mtb/IO"
|
||||
|
||||
def export_prores(
|
||||
self,
|
||||
images: torch.Tensor,
|
||||
fps: float,
|
||||
prefix: str,
|
||||
format: str,
|
||||
codec: str,
|
||||
images: torch.Tensor | None = None,
|
||||
playlist: list[str] | None = None,
|
||||
):
|
||||
if images.size(0) == 0:
|
||||
return ("",)
|
||||
output_dir = Path(folder_paths.get_output_directory())
|
||||
pix_fmt = "rgb48le" if codec == "prores_ks" else "yuv420p"
|
||||
file_ext = format
|
||||
file_id = f"{prefix}_{uuid.uuid4()}.{file_ext}"
|
||||
|
||||
if playlist is not None and images is not None:
|
||||
log.info(f"Exporting to {output_dir / file_id}")
|
||||
|
||||
if playlist is not None:
|
||||
if len(playlist) == 0:
|
||||
log.debug("Playlist is empty, skipping")
|
||||
return ("",)
|
||||
|
||||
temp_playlist_path = (
|
||||
output_dir / f"temp_playlist_{uuid.uuid4()}.txt"
|
||||
)
|
||||
log.debug(
|
||||
f"Create a temporary file to list the videos for concatenation to {temp_playlist_path}"
|
||||
)
|
||||
|
||||
with open(temp_playlist_path, "w") as f:
|
||||
for video_path in playlist:
|
||||
f.write(f"file '{video_path}'\n")
|
||||
|
||||
out_path = (output_dir / file_id).as_posix()
|
||||
|
||||
# Prepare the FFmpeg command for concatenating videos from the playlist
|
||||
command = [
|
||||
"ffmpeg",
|
||||
"-f",
|
||||
"concat",
|
||||
"-safe",
|
||||
"0",
|
||||
"-i",
|
||||
temp_playlist_path.as_posix(),
|
||||
"-c",
|
||||
"copy",
|
||||
"-y",
|
||||
out_path,
|
||||
]
|
||||
log.debug(f"Executing {command}")
|
||||
subprocess.run(command)
|
||||
|
||||
temp_playlist_path.unlink()
|
||||
|
||||
return (out_path,)
|
||||
|
||||
if (
|
||||
images is None or images.size(0) == 0
|
||||
): # the is None check is just for the type checker
|
||||
return ("",)
|
||||
log.debug(f"Exporting to {output_dir / file_id}")
|
||||
|
||||
frames = tensor2np(images)
|
||||
log.debug(f"Frames type {type(frames[0])}")
|
||||
log.debug(f"Exporting {len(frames)} frames")
|
||||
height, width, channels = frames[0].shape
|
||||
has_alpha = channels == 4
|
||||
|
||||
frames = [frame.astype(np.uint16) * 257 for frame in frames]
|
||||
|
||||
height, width, _ = frames[0].shape
|
||||
|
||||
out_path = (output_dir / file_id).as_posix()
|
||||
|
||||
if codec == "gif":
|
||||
command = [
|
||||
"ffmpeg",
|
||||
"-f",
|
||||
"image2pipe",
|
||||
"-vcodec",
|
||||
"png",
|
||||
"-r",
|
||||
str(fps),
|
||||
"-i",
|
||||
"-",
|
||||
"-vcodec",
|
||||
"gif",
|
||||
"-y",
|
||||
out_path,
|
||||
]
|
||||
process = subprocess.Popen(command, stdin=subprocess.PIPE)
|
||||
for frame in frames:
|
||||
model_management.throw_exception_if_processing_interrupted()
|
||||
Image.fromarray(frame).save(process.stdin, "PNG")
|
||||
|
||||
process.stdin.close()
|
||||
process.wait()
|
||||
return (out_path,)
|
||||
else:
|
||||
if has_alpha:
|
||||
if codec in ["prores_ks", "libx264", "libx265"]:
|
||||
pix_fmt = (
|
||||
"yuva444p" if codec == "prores_ks" else "yuva420p"
|
||||
)
|
||||
frames = [
|
||||
frame.astype(np.uint16) * 257 for frame in frames
|
||||
]
|
||||
else:
|
||||
log.warning(
|
||||
f"Alpha channel not supported for codec {codec}. Alpha will be ignored."
|
||||
)
|
||||
frames = [
|
||||
frame[:, :, :3].astype(np.uint16) * 257
|
||||
for frame in frames
|
||||
]
|
||||
pix_fmt = "rgb48le" if codec == "prores_ks" else "yuv420p"
|
||||
else:
|
||||
pix_fmt = "rgb48le" if codec == "prores_ks" else "yuv420p"
|
||||
frames = [frame.astype(np.uint16) * 257 for frame in frames]
|
||||
|
||||
# Prepare the FFmpeg command
|
||||
command = [
|
||||
"ffmpeg",
|
||||
@@ -281,26 +80,17 @@ class MTB_ExportWithFfmpeg:
|
||||
"-",
|
||||
"-c:v",
|
||||
codec,
|
||||
"-r",
|
||||
str(fps),
|
||||
"-y",
|
||||
out_path,
|
||||
]
|
||||
if codec == "prores_ks":
|
||||
command.extend(["-profile:v", "4444"])
|
||||
|
||||
command.extend(
|
||||
[
|
||||
"-r",
|
||||
str(fps),
|
||||
"-y",
|
||||
out_path,
|
||||
]
|
||||
)
|
||||
|
||||
process = subprocess.Popen(command, stdin=subprocess.PIPE)
|
||||
|
||||
pbar = comfy.utils.ProgressBar(len(frames))
|
||||
|
||||
for frame in frames:
|
||||
model_management.throw_exception_if_processing_interrupted()
|
||||
process.stdin.write(frame.tobytes())
|
||||
pbar.update(1)
|
||||
|
||||
process.stdin.close()
|
||||
process.wait()
|
||||
@@ -312,9 +102,9 @@ def prepare_animated_batch(
|
||||
batch: torch.Tensor,
|
||||
pingpong=False,
|
||||
resize_by=1.0,
|
||||
resample_filter: Image.Resampling | None = None,
|
||||
resample_filter: Optional[Image.Resampling] = None,
|
||||
image_type=np.uint8,
|
||||
) -> list[Image.Image]:
|
||||
) -> List[Image.Image]:
|
||||
images = tensor2np(batch)
|
||||
images = [frame.astype(image_type) for frame in images]
|
||||
|
||||
@@ -339,11 +129,8 @@ def prepare_animated_batch(
|
||||
|
||||
|
||||
# todo: deprecate for apng
|
||||
class MTB_SaveGif:
|
||||
"""Save the images from the batch as a GIF.
|
||||
|
||||
[DEPRACATED] Use VHS nodes instead
|
||||
"""
|
||||
class SaveGif:
|
||||
"""Save the images from the batch as a GIF"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
@@ -354,8 +141,9 @@ class MTB_SaveGif:
|
||||
"resize_by": ("FLOAT", {"default": 1.0, "min": 0.1}),
|
||||
"optimize": ("BOOLEAN", {"default": False}),
|
||||
"pingpong": ("BOOLEAN", {"default": False}),
|
||||
},
|
||||
"optional": {
|
||||
"resample_filter": (list(PIL_FILTER_MAP.keys()),),
|
||||
"use_ffmpeg": ("BOOLEAN", {"default": False}),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -363,7 +151,6 @@ class MTB_SaveGif:
|
||||
OUTPUT_NODE = True
|
||||
CATEGORY = "mtb/IO"
|
||||
FUNCTION = "save_gif"
|
||||
DEPRECATED = True
|
||||
|
||||
def save_gif(
|
||||
self,
|
||||
@@ -373,7 +160,6 @@ class MTB_SaveGif:
|
||||
optimize=False,
|
||||
pingpong=False,
|
||||
resample_filter=None,
|
||||
use_ffmpeg=False,
|
||||
):
|
||||
if image.size(0) == 0:
|
||||
return ("",)
|
||||
@@ -392,48 +178,18 @@ class MTB_SaveGif:
|
||||
ruuid = ruuid.hex[:10]
|
||||
out_path = f"{folder_paths.output_directory}/{ruuid}.gif"
|
||||
|
||||
if use_ffmpeg:
|
||||
# Use FFmpeg to create the GIF from PIL images
|
||||
command = [
|
||||
"ffmpeg",
|
||||
"-f",
|
||||
"image2pipe",
|
||||
"-vcodec",
|
||||
"png",
|
||||
"-r",
|
||||
str(fps),
|
||||
"-i",
|
||||
"-",
|
||||
"-vcodec",
|
||||
"gif",
|
||||
"-y",
|
||||
out_path,
|
||||
]
|
||||
process = subprocess.Popen(command, stdin=subprocess.PIPE)
|
||||
for image in pil_images:
|
||||
model_management.throw_exception_if_processing_interrupted()
|
||||
image.save(process.stdin, "PNG")
|
||||
process.stdin.close()
|
||||
process.wait()
|
||||
# Create the GIF from PIL images
|
||||
pil_images[0].save(
|
||||
out_path,
|
||||
save_all=True,
|
||||
append_images=pil_images[1:],
|
||||
optimize=optimize,
|
||||
duration=int(1000 / fps),
|
||||
loop=0,
|
||||
)
|
||||
|
||||
else:
|
||||
pil_images[0].save(
|
||||
out_path,
|
||||
save_all=True,
|
||||
append_images=pil_images[1:],
|
||||
optimize=optimize,
|
||||
duration=int(1000 / fps),
|
||||
loop=0,
|
||||
)
|
||||
results = [
|
||||
{"filename": f"{ruuid}.gif", "subfolder": "", "type": "output"}
|
||||
]
|
||||
results = [{"filename": f"{ruuid}.gif", "subfolder": "", "type": "output"}]
|
||||
return {"ui": {"gif": results}}
|
||||
|
||||
|
||||
__nodes__ = [
|
||||
MTB_SaveGif,
|
||||
MTB_ExportWithFfmpeg,
|
||||
MTB_AddToPlaylist,
|
||||
MTB_ReadPlaylist,
|
||||
]
|
||||
__nodes__ = [SaveGif, ExportWithFfmpeg]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import torch
|
||||
|
||||
|
||||
class MTB_LatentLerp:
|
||||
class LatentLerp:
|
||||
"""Linear interpolation (blend) between two latent vectors"""
|
||||
|
||||
@classmethod
|
||||
@@ -10,10 +10,7 @@ class MTB_LatentLerp:
|
||||
"required": {
|
||||
"A": ("LATENT",),
|
||||
"B": ("LATENT",),
|
||||
"t": (
|
||||
"FLOAT",
|
||||
{"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01},
|
||||
),
|
||||
"t": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,5 +29,5 @@ class MTB_LatentLerp:
|
||||
|
||||
|
||||
__nodes__ = [
|
||||
MTB_LatentLerp,
|
||||
LatentLerp,
|
||||
]
|
||||
|
||||
-157
@@ -1,157 +0,0 @@
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
from PIL import Image
|
||||
|
||||
from ..log import log
|
||||
|
||||
|
||||
class ImageH264Compression:
|
||||
"""Encodes the input with h264 compression using a configurable CRF."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"image": (
|
||||
"IMAGE",
|
||||
{
|
||||
"tooltip": "The input image tensor to be compressed and decompressed."
|
||||
},
|
||||
),
|
||||
"crf": (
|
||||
"INT",
|
||||
{
|
||||
"default": 23,
|
||||
"min": 0,
|
||||
"max": 51,
|
||||
"step": 1,
|
||||
"tooltip": "Constant Rate Factor for h264 encoding (lower values mean higher quality).",
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "compress_and_decompress"
|
||||
|
||||
CATEGORY = "image"
|
||||
DESCRIPTION = """
|
||||
**Encodes the input with h264 compression using a configurable CRF**.
|
||||
|
||||
> [!NOTE]
|
||||
> This was recommended by the creators of LTX over banodoco's discord.
|
||||
|
||||
*Orginal code from [mix](https://github.com/XmYx)*"""
|
||||
|
||||
def _compress_decompress_ffmpeg(self, img_array, crf):
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
input_path = os.path.join(temp_dir, "input.png")
|
||||
output_path = os.path.join(temp_dir, "output.mp4")
|
||||
decoded_path = os.path.join(temp_dir, "decoded.png")
|
||||
|
||||
Image.fromarray(img_array).save(input_path)
|
||||
|
||||
encode_command = [
|
||||
"ffmpeg",
|
||||
"-y",
|
||||
"-i",
|
||||
input_path,
|
||||
"-c:v",
|
||||
"libx264",
|
||||
"-crf",
|
||||
str(crf),
|
||||
"-pix_fmt",
|
||||
"yuv420p",
|
||||
"-frames:v",
|
||||
"1",
|
||||
output_path,
|
||||
]
|
||||
subprocess.run(encode_command, capture_output=True)
|
||||
|
||||
decode_command = [
|
||||
"ffmpeg",
|
||||
"-y",
|
||||
"-i",
|
||||
output_path,
|
||||
"-frames:v",
|
||||
"1",
|
||||
decoded_path,
|
||||
]
|
||||
subprocess.run(decode_command, capture_output=True)
|
||||
|
||||
decoded_img = np.array(Image.open(decoded_path))
|
||||
return decoded_img
|
||||
|
||||
def compress_and_decompress(self, image, crf):
|
||||
import io
|
||||
|
||||
output_images = []
|
||||
|
||||
try:
|
||||
import av
|
||||
|
||||
for img_tensor in image:
|
||||
img_array = img_tensor.cpu().numpy()
|
||||
img_array = (img_array * 255).astype(np.uint8)
|
||||
img_array = img_array.copy(
|
||||
order="C"
|
||||
) # Ensure contiguous array
|
||||
|
||||
output = io.BytesIO()
|
||||
|
||||
# Encode the image to h264 with the given CRF
|
||||
container = av.open(output, mode="w", format="mp4")
|
||||
stream = container.add_stream("h264", rate=1)
|
||||
stream.width = img_array.shape[1]
|
||||
stream.height = img_array.shape[0]
|
||||
stream.pix_fmt = "yuv420p"
|
||||
stream.options = {"crf": str(crf)}
|
||||
|
||||
frame = av.VideoFrame.from_ndarray(img_array, format="rgb24")
|
||||
for packet in stream.encode(frame):
|
||||
container.mux(packet)
|
||||
for packet in stream.encode():
|
||||
container.mux(packet)
|
||||
container.close()
|
||||
|
||||
# Decode the video back to an image
|
||||
output.seek(0)
|
||||
container = av.open(output, mode="r", format="mp4")
|
||||
decoded_frames = []
|
||||
for frame in container.decode(video=0):
|
||||
img_decoded = frame.to_ndarray(format="rgb24")
|
||||
decoded_frames.append(img_decoded)
|
||||
container.close()
|
||||
|
||||
if len(decoded_frames) > 0:
|
||||
img_decoded = decoded_frames[0]
|
||||
img_decoded = torch.from_numpy(
|
||||
img_decoded.astype(np.float32) / 255.0
|
||||
)
|
||||
output_images.append(img_decoded)
|
||||
else:
|
||||
# If decoding failed, use the original image
|
||||
output_images.append(img_tensor)
|
||||
except ImportError:
|
||||
log.warning(
|
||||
"PyAv is not installed... Falling back to the ffmpeg cli"
|
||||
)
|
||||
for img_tensor in image:
|
||||
img_array = (img_tensor.cpu().numpy() * 255).astype(np.uint8)
|
||||
decoded_img = self._compress_decompress_ffmpeg(img_array, crf)
|
||||
img_decoded = torch.from_numpy(
|
||||
decoded_img.astype(np.float32) / 255.0
|
||||
)
|
||||
output_images.append(img_decoded)
|
||||
|
||||
output_images = torch.stack(output_images).to(image.device)
|
||||
return (output_images,)
|
||||
|
||||
# fmt: off
|
||||
__nodes__ = [
|
||||
ImageH264Compression
|
||||
]
|
||||
+6
-14
@@ -1,10 +1,10 @@
|
||||
import comfy.utils
|
||||
from PIL import Image
|
||||
|
||||
from rembg import remove
|
||||
from ..utils import pil2tensor, tensor2pil
|
||||
from PIL import Image
|
||||
import comfy.utils
|
||||
|
||||
|
||||
class MTB_ImageRemoveBackgroundRembg:
|
||||
class ImageRemoveBackgroundRembg:
|
||||
"""Removes the background from the input using Rembg."""
|
||||
|
||||
@classmethod
|
||||
@@ -63,8 +63,6 @@ class MTB_ImageRemoveBackgroundRembg:
|
||||
post_process_mask,
|
||||
bgcolor,
|
||||
):
|
||||
from rembg import remove
|
||||
|
||||
pbar = comfy.utils.ProgressBar(image.size(0))
|
||||
images = tensor2pil(image)
|
||||
|
||||
@@ -93,21 +91,15 @@ class MTB_ImageRemoveBackgroundRembg:
|
||||
|
||||
image_on_bg.paste(img_rm, mask=mask)
|
||||
|
||||
image_on_bg = image_on_bg.convert("RGB")
|
||||
|
||||
out_img.append(img_rm)
|
||||
out_mask.append(mask)
|
||||
out_img_on_bg.append(image_on_bg)
|
||||
|
||||
pbar.update(1)
|
||||
|
||||
return (
|
||||
pil2tensor(out_img),
|
||||
pil2tensor(out_mask),
|
||||
pil2tensor(out_img_on_bg),
|
||||
)
|
||||
return (pil2tensor(out_img), pil2tensor(out_mask), pil2tensor(out_img_on_bg))
|
||||
|
||||
|
||||
__nodes__ = [
|
||||
MTB_ImageRemoveBackgroundRembg,
|
||||
ImageRemoveBackgroundRembg,
|
||||
]
|
||||
|
||||
-155
@@ -1,155 +0,0 @@
|
||||
import copy
|
||||
|
||||
import torch
|
||||
from torch.nn import functional as F
|
||||
from torch.nn.modules.utils import _pair
|
||||
|
||||
from ..log import log
|
||||
|
||||
|
||||
class MTB_VaeDecode:
|
||||
"""Wrapper for the 2 core decoders but also adding the sd seamless hack, taken from: FlyingFireCo/tiled_ksampler"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"samples": ("LATENT",),
|
||||
"vae": ("VAE",),
|
||||
"seamless_model": ("BOOLEAN", {"default": False}),
|
||||
"use_tiling_decoder": ("BOOLEAN", {"default": True}),
|
||||
"tile_size": (
|
||||
"INT",
|
||||
{"default": 512, "min": 320, "max": 4096, "step": 64},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "decode"
|
||||
|
||||
CATEGORY = "mtb/decode"
|
||||
|
||||
def decode(
|
||||
self,
|
||||
vae,
|
||||
samples,
|
||||
seamless_model,
|
||||
use_tiling_decoder=True,
|
||||
tile_size=512,
|
||||
):
|
||||
if seamless_model:
|
||||
if use_tiling_decoder:
|
||||
log.error(
|
||||
"You cannot use seamless mode with tiling decoder together, skipping tiling."
|
||||
)
|
||||
use_tiling_decoder = False
|
||||
for layer in [
|
||||
layer
|
||||
for layer in vae.first_stage_model.modules()
|
||||
if isinstance(layer, torch.nn.Conv2d)
|
||||
]:
|
||||
layer.padding_mode = "circular"
|
||||
if use_tiling_decoder:
|
||||
return (
|
||||
vae.decode_tiled(
|
||||
samples["samples"],
|
||||
tile_x=tile_size // 8,
|
||||
tile_y=tile_size // 8,
|
||||
),
|
||||
)
|
||||
else:
|
||||
return (vae.decode(samples["samples"]),)
|
||||
|
||||
|
||||
def conv_forward(lyr, tensor, weight, bias):
|
||||
step = lyr.timestep
|
||||
if (lyr.paddingStartStep < 0 or step >= lyr.paddingStartStep) and (
|
||||
lyr.paddingStopStep < 0 or step <= lyr.paddingStopStep
|
||||
):
|
||||
working = F.pad(tensor, lyr.paddingX, mode=lyr.padding_modeX)
|
||||
working = F.pad(working, lyr.paddingY, mode=lyr.padding_modeY)
|
||||
else:
|
||||
working = F.pad(tensor, lyr.paddingX, mode="constant")
|
||||
working = F.pad(working, lyr.paddingY, mode="constant")
|
||||
|
||||
lyr.timestep += 1
|
||||
|
||||
return F.conv2d(
|
||||
working, weight, bias, lyr.stride, _pair(0), lyr.dilation, lyr.groups
|
||||
)
|
||||
|
||||
|
||||
class MTB_ModelPatchSeamless:
|
||||
"""Uses the stable diffusion 'hack' to infer seamless images by setting the model layers padding mode to circular (experimental)"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"model": ("MODEL",),
|
||||
"startStep": ("INT", {"default": 0}),
|
||||
"stopStep": ("INT", {"default": 999}),
|
||||
"tilingX": (
|
||||
"BOOLEAN",
|
||||
{"default": True},
|
||||
),
|
||||
"tilingY": (
|
||||
"BOOLEAN",
|
||||
{"default": True},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("MODEL", "MODEL")
|
||||
RETURN_NAMES = (
|
||||
"Original Model (passthrough)",
|
||||
"Patched Model",
|
||||
)
|
||||
FUNCTION = "hack"
|
||||
|
||||
CATEGORY = "mtb/textures"
|
||||
|
||||
def apply_circular(self, model, startStep, stopStep, x, y):
|
||||
for layer in [
|
||||
layer
|
||||
for layer in model.modules()
|
||||
if isinstance(layer, torch.nn.Conv2d)
|
||||
]:
|
||||
layer.padding_modeX = "circular" if x else "constant"
|
||||
layer.padding_modeY = "circular" if y else "constant"
|
||||
layer.paddingX = (
|
||||
layer._reversed_padding_repeated_twice[0],
|
||||
layer._reversed_padding_repeated_twice[1],
|
||||
0,
|
||||
0,
|
||||
)
|
||||
layer.paddingY = (
|
||||
0,
|
||||
0,
|
||||
layer._reversed_padding_repeated_twice[2],
|
||||
layer._reversed_padding_repeated_twice[3],
|
||||
)
|
||||
layer.paddingStartStep = startStep
|
||||
layer.paddingStopStep = stopStep
|
||||
layer.timestep = 0
|
||||
layer._conv_forward = conv_forward.__get__(layer, torch.nn.Conv2d)
|
||||
|
||||
return model
|
||||
|
||||
def hack(
|
||||
self,
|
||||
model,
|
||||
startStep,
|
||||
stopStep,
|
||||
tilingX,
|
||||
tilingY,
|
||||
):
|
||||
hacked_model = copy.deepcopy(model)
|
||||
self.apply_circular(
|
||||
hacked_model.model, startStep, stopStep, tilingX, tilingY
|
||||
)
|
||||
return (model, hacked_model)
|
||||
|
||||
|
||||
__nodes__ = [MTB_ModelPatchSeamless, MTB_VaeDecode]
|
||||
+8
-6
@@ -1,4 +1,4 @@
|
||||
class MTB_IntToBool:
|
||||
class IntToBool:
|
||||
"""Basic int to bool conversion"""
|
||||
|
||||
@classmethod
|
||||
@@ -22,7 +22,7 @@ class MTB_IntToBool:
|
||||
return (bool(int),)
|
||||
|
||||
|
||||
class MTB_IntToNumber:
|
||||
class IntToNumber:
|
||||
"""Node addon for the WAS Suite. Converts a "comfy" INT to a NUMBER."""
|
||||
|
||||
@classmethod
|
||||
@@ -50,7 +50,7 @@ class MTB_IntToNumber:
|
||||
return (int,)
|
||||
|
||||
|
||||
class MTB_FloatToNumber:
|
||||
class FloatToNumber:
|
||||
"""Node addon for the WAS Suite. Converts a "comfy" FLOAT to a NUMBER."""
|
||||
|
||||
@classmethod
|
||||
@@ -77,9 +77,11 @@ class MTB_FloatToNumber:
|
||||
def float_to_number(self, float):
|
||||
return (float,)
|
||||
|
||||
return (int,)
|
||||
|
||||
|
||||
__nodes__ = [
|
||||
MTB_FloatToNumber,
|
||||
MTB_IntToBool,
|
||||
MTB_IntToNumber,
|
||||
FloatToNumber,
|
||||
IntToBool,
|
||||
IntToNumber,
|
||||
]
|
||||
|
||||
@@ -1,351 +0,0 @@
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
import comfy.utils
|
||||
import torch
|
||||
|
||||
from ..log import log
|
||||
from ..utils import nextAvailable, tensor2pil
|
||||
|
||||
RELATIVE_NOTICE = """
|
||||
Absolute paths are kept as is, relatives are from the output directory.
|
||||
"""
|
||||
|
||||
|
||||
class MTB_PostshotTrain:
|
||||
CATEGORY = "mtb/postshot"
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"images": (
|
||||
"IMAGE",
|
||||
{"tooltip": "These image will get save to disk first"},
|
||||
),
|
||||
"profile": (
|
||||
[
|
||||
"NeRF L",
|
||||
"NeRF M",
|
||||
"NeRF S",
|
||||
"NeRF XL",
|
||||
"NeRF XXL",
|
||||
"Splat ADC",
|
||||
"Splat MCMC",
|
||||
],
|
||||
{
|
||||
"default": "Splat MCMC",
|
||||
"tooltip": "The radiance field model profile to train",
|
||||
},
|
||||
),
|
||||
"image_select": (
|
||||
["all", "best"],
|
||||
{
|
||||
"default": "best",
|
||||
"tooltip": "How to select training images from the source image sets",
|
||||
},
|
||||
),
|
||||
"train_steps_limit": (
|
||||
"INT",
|
||||
{
|
||||
"default": 30,
|
||||
"min": 1,
|
||||
"max": 1000,
|
||||
"tooltip": "Number of kSteps to train the model for",
|
||||
},
|
||||
),
|
||||
"output_path": (
|
||||
"STRING",
|
||||
{
|
||||
"default": "output",
|
||||
"tooltip": (
|
||||
"path to save the project to" f"{RELATIVE_NOTICE}"
|
||||
),
|
||||
},
|
||||
),
|
||||
"postshot_cli": (
|
||||
"STRING",
|
||||
{
|
||||
"default": "C:/Program Files/Jawset Postshot/bin/postshot-cli.exe"
|
||||
},
|
||||
),
|
||||
},
|
||||
"optional": {
|
||||
"gpu": (
|
||||
"INT",
|
||||
{
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"max": 255,
|
||||
"tooltip": "Specify the index of the GPU to use",
|
||||
},
|
||||
),
|
||||
"num_train_images": (
|
||||
"INT",
|
||||
{
|
||||
"default": 0,
|
||||
"min": 0,
|
||||
"tooltip": "If image-select best is used, specifies the number of training images to select",
|
||||
},
|
||||
),
|
||||
"max_image_size": (
|
||||
"INT",
|
||||
{
|
||||
"default": 1600,
|
||||
"min": 0,
|
||||
"tooltip": "Downscale training images such that their longer edge is at most this value in pixels. Disabled if zero.",
|
||||
},
|
||||
),
|
||||
"max_num_features": (
|
||||
"INT",
|
||||
{
|
||||
"default": 8,
|
||||
"min": 1,
|
||||
"tooltip": "Maximum number of 2D kFeatures extracted from each image.",
|
||||
},
|
||||
),
|
||||
"splat_density": (
|
||||
"FLOAT",
|
||||
{
|
||||
"default": 1.0,
|
||||
"min": 0.125,
|
||||
"max": 8.0,
|
||||
"tooltip": (
|
||||
"Controls how much additional splats "
|
||||
"are generated during training."
|
||||
"Applies only in 'Splat ADC' profile."
|
||||
),
|
||||
},
|
||||
),
|
||||
"max_num_splats": (
|
||||
"INT",
|
||||
{
|
||||
"default": 3000,
|
||||
"min": 1,
|
||||
"tooltip": (
|
||||
"Sets the maximum number of splats (in kSplats)"
|
||||
" created during training. "
|
||||
"Applies only in 'Splat MCMC' profile."
|
||||
),
|
||||
},
|
||||
),
|
||||
"export_splat_ply": (
|
||||
"STRING",
|
||||
{
|
||||
"default": "",
|
||||
"tooltip": (
|
||||
"If not empty will also save a ply file."
|
||||
f"{RELATIVE_NOTICE}"
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
OUTPUT_NODE = True
|
||||
RETURN_NAMES = ("project_file_path",)
|
||||
FUNCTION = "train_model"
|
||||
|
||||
def train_model(
|
||||
self,
|
||||
images: torch.Tensor,
|
||||
profile: str,
|
||||
image_select: str,
|
||||
train_steps_limit: int,
|
||||
output_path: str,
|
||||
gpu=0,
|
||||
num_train_images=0,
|
||||
max_image_size=1600,
|
||||
max_num_features=8,
|
||||
splat_density=1.0,
|
||||
max_num_splats=3000,
|
||||
export_splat_ply="",
|
||||
postshot_cli="",
|
||||
):
|
||||
if not output_path.endswith(".psht"):
|
||||
output_path += ".psht"
|
||||
|
||||
output_path = nextAvailable(output_path)
|
||||
output_path.parent.mkdir(exist_ok=True)
|
||||
|
||||
pbar = comfy.utils.ProgressBar(200 + images.size(0))
|
||||
|
||||
try:
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
image_paths = []
|
||||
images_pil = tensor2pil(images)
|
||||
for i, img in enumerate(images_pil):
|
||||
try:
|
||||
img_path = os.path.join(temp_dir, f"image_{i:04d}.png")
|
||||
img.save(img_path)
|
||||
image_paths.append(img_path)
|
||||
except Exception as e:
|
||||
raise RuntimeError(
|
||||
f"Failed to save image {i}: {str(e)}"
|
||||
) from e
|
||||
pbar.update(1)
|
||||
|
||||
if not image_paths:
|
||||
raise ValueError("No valid images to process")
|
||||
|
||||
cmd = [postshot_cli, "train"]
|
||||
|
||||
for img_path in image_paths:
|
||||
cmd.extend(["-i", img_path])
|
||||
|
||||
cmd.extend(
|
||||
[
|
||||
"-p",
|
||||
profile,
|
||||
"--image-select",
|
||||
image_select,
|
||||
"-s",
|
||||
str(train_steps_limit),
|
||||
"-o",
|
||||
output_path.as_posix(),
|
||||
]
|
||||
)
|
||||
|
||||
if gpu is not None:
|
||||
cmd.extend(["--gpu", str(gpu)])
|
||||
if num_train_images > 0 and image_select == "best":
|
||||
cmd.extend(["--num-train-images", str(num_train_images)])
|
||||
if max_image_size > 0:
|
||||
cmd.extend(["--max-image-size", str(max_image_size)])
|
||||
if max_num_features != 8:
|
||||
cmd.extend(["--max-num-features", str(max_num_features)])
|
||||
if profile == "Splat ADC" and splat_density != 1.0:
|
||||
cmd.extend(["--splat-density", str(splat_density)])
|
||||
if profile == "Splat MCMC" and max_num_splats != 3000:
|
||||
cmd.extend(["--max-num-splats", str(max_num_splats)])
|
||||
if export_splat_ply:
|
||||
export_splat_ply = nextAvailable(export_splat_ply)
|
||||
cmd.extend(
|
||||
["--export-splat-ply", export_splat_ply.as_posix()]
|
||||
)
|
||||
|
||||
log.debug(f"Running {cmd}")
|
||||
|
||||
process = subprocess.Popen(
|
||||
cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
)
|
||||
|
||||
last_step_c = 0
|
||||
last_step_t = 0
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
if output == "" and process.poll() is not None:
|
||||
break
|
||||
if output:
|
||||
print(output)
|
||||
if "camera tracking step" in output.lower():
|
||||
try:
|
||||
current_step = int(
|
||||
output.split("%")[0].split(":")[1].strip()
|
||||
)
|
||||
if current_step > last_step_c:
|
||||
pbar.update(1)
|
||||
last_step_c = current_step
|
||||
|
||||
except (ValueError, IndexError):
|
||||
continue
|
||||
|
||||
if "training radiance field:" in output.lower():
|
||||
try:
|
||||
current_step = int(
|
||||
output.split("%")[0].split(":")[1].strip()
|
||||
)
|
||||
if current_step > last_step_t:
|
||||
pbar.update(1)
|
||||
last_step_t = current_step
|
||||
|
||||
except (ValueError, IndexError):
|
||||
continue
|
||||
|
||||
if process.returncode != 0:
|
||||
_, stderr = process.communicate()
|
||||
raise RuntimeError(f"Postshot training failed: {stderr}")
|
||||
|
||||
if not os.path.exists(output_path):
|
||||
raise RuntimeError("Output file was not created")
|
||||
|
||||
return (output_path.as_posix(),)
|
||||
|
||||
except Exception as e:
|
||||
raise RuntimeError(f"Training failed: {str(e)}")
|
||||
finally:
|
||||
pbar.update(train_steps_limit)
|
||||
|
||||
|
||||
class MTB_PostshotExport:
|
||||
CATEGORY = "mtb/postshot"
|
||||
OUTPUT_NODE = True
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"project_file": (
|
||||
"STRING",
|
||||
{"default": "", "forceInput": True},
|
||||
),
|
||||
"export_splat_ply": ("STRING", {"default": "output.ply"}),
|
||||
"postshot_cli": (
|
||||
"STRING",
|
||||
{
|
||||
"default": "C:/Program Files/Jawset Postshot/bin/postshot-cli.exe"
|
||||
},
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("exported_ply_path",)
|
||||
FUNCTION = "export_model"
|
||||
|
||||
def export_model(
|
||||
self, project_file: str, export_splat_ply: str, postshot_cli: str
|
||||
):
|
||||
if not project_file.endswith(".psht"):
|
||||
raise ValueError("Project file must have .psht extension")
|
||||
|
||||
if not os.path.exists(project_file):
|
||||
raise FileNotFoundError(f"Project file not found: {project_file}")
|
||||
|
||||
if not export_splat_ply.endswith(".ply"):
|
||||
export_splat_ply += ".ply"
|
||||
|
||||
_export_splat_ply = nextAvailable(export_splat_ply)
|
||||
_export_splat_ply.parent.mkdir(exist_ok=True)
|
||||
|
||||
cmd = [
|
||||
postshot_cli,
|
||||
"export",
|
||||
"-f",
|
||||
project_file,
|
||||
"--export-splat-ply",
|
||||
_export_splat_ply.as_posix(),
|
||||
]
|
||||
|
||||
try:
|
||||
_result = subprocess.run(
|
||||
cmd, check=True, capture_output=True, text=True
|
||||
)
|
||||
|
||||
if not _export_splat_ply.exists():
|
||||
log.error("Export file was not created")
|
||||
|
||||
return (_export_splat_ply.as_posix(),)
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
raise RuntimeError(f"Export failed: {e.stderr}")
|
||||
except Exception as e:
|
||||
raise RuntimeError(f"Export failed: {str(e)}")
|
||||
|
||||
|
||||
__nodes__ = [MTB_PostshotExport, MTB_PostshotTrain]
|
||||
-360
@@ -1,360 +0,0 @@
|
||||
from pathlib import Path
|
||||
|
||||
import safetensors.torch
|
||||
import torch
|
||||
import tqdm
|
||||
|
||||
from ..log import log
|
||||
from ..utils import Operation, Precision
|
||||
from ..utils import output_dir as comfy_out_dir
|
||||
|
||||
PRUNE_DATA = {
|
||||
"known_junk_prefix": [
|
||||
"embedding_manager.embedder.",
|
||||
"lora_te_text_model",
|
||||
"control_model.",
|
||||
],
|
||||
"nai_keys": {
|
||||
"cond_stage_model.transformer.embeddings.": "cond_stage_model.transformer.text_model.embeddings.",
|
||||
"cond_stage_model.transformer.encoder.": "cond_stage_model.transformer.text_model.encoder.",
|
||||
"cond_stage_model.transformer.final_layer_norm.": "cond_stage_model.transformer.text_model.final_layer_norm.",
|
||||
},
|
||||
}
|
||||
|
||||
# position_ids in clip is int64. model_ema.num_updates is int32
|
||||
dtypes_to_fp16 = {torch.float32, torch.float64, torch.bfloat16}
|
||||
dtypes_to_bf16 = {torch.float32, torch.float64, torch.float16}
|
||||
dtypes_to_fp8 = {torch.float32, torch.float64, torch.bfloat16, torch.float16}
|
||||
|
||||
|
||||
class MTB_ModelPruner:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"optional": {
|
||||
"unet": ("MODEL",),
|
||||
"clip": ("CLIP",),
|
||||
"vae": ("VAE",),
|
||||
},
|
||||
"required": {
|
||||
"save_separately": ("BOOLEAN", {"default": False}),
|
||||
"save_folder": ("STRING", {"default": "checkpoints/ComfyUI"}),
|
||||
"fix_clip": ("BOOLEAN", {"default": True}),
|
||||
"remove_junk": ("BOOLEAN", {"default": True}),
|
||||
"ema_mode": (
|
||||
("disabled", "remove_ema", "ema_only"),
|
||||
{"default": "remove_ema"},
|
||||
),
|
||||
"precision_unet": (
|
||||
Precision.list_members(),
|
||||
{"default": Precision.FULL.value},
|
||||
),
|
||||
"operation_unet": (
|
||||
Operation.list_members(),
|
||||
{"default": Operation.CONVERT.value},
|
||||
),
|
||||
"precision_clip": (
|
||||
Precision.list_members(),
|
||||
{"default": Precision.FULL.value},
|
||||
),
|
||||
"operation_clip": (
|
||||
Operation.list_members(),
|
||||
{"default": Operation.CONVERT.value},
|
||||
),
|
||||
"precision_vae": (
|
||||
Precision.list_members(),
|
||||
{"default": Precision.FULL.value},
|
||||
),
|
||||
"operation_vae": (
|
||||
Operation.list_members(),
|
||||
{"default": Operation.CONVERT.value},
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
OUTPUT_NODE = True
|
||||
RETURN_TYPES = ()
|
||||
CATEGORY = "mtb/prune"
|
||||
FUNCTION = "prune"
|
||||
|
||||
def convert_precision(self, tensor: torch.Tensor, precision: Precision):
|
||||
precision = Precision.from_str(precision)
|
||||
log.debug(f"Converting to {precision}")
|
||||
match precision:
|
||||
case Precision.FP8:
|
||||
if tensor.dtype in dtypes_to_fp8:
|
||||
return tensor.to(torch.float8_e4m3fn)
|
||||
log.error(f"Cannot convert {tensor.dtype} to fp8")
|
||||
return tensor
|
||||
case Precision.FP16:
|
||||
if tensor.dtype in dtypes_to_fp16:
|
||||
return tensor.half()
|
||||
log.error(f"Cannot convert {tensor.dtype} to f16")
|
||||
return tensor
|
||||
case Precision.BF16:
|
||||
if tensor.dtype in dtypes_to_bf16:
|
||||
return tensor.bfloat16()
|
||||
log.error(f"Cannot convert {tensor.dtype} to bf16")
|
||||
return tensor
|
||||
case Precision.FULL | Precision.FP32:
|
||||
return tensor
|
||||
|
||||
def is_sdxl_model(self, clip: dict[str, torch.Tensor] | None):
|
||||
if clip:
|
||||
return (any(k.startswith("conditioner.embedders") for k in clip),)
|
||||
return False
|
||||
|
||||
def has_ema(self, unet: dict[str, torch.Tensor]):
|
||||
return any(k.startswith("model_ema") for k in unet)
|
||||
|
||||
def fix_clip(self, clip: dict[str, torch.Tensor] | None):
|
||||
if self.is_sdxl_model(clip):
|
||||
log.warn("[fix clip] SDXL not supported")
|
||||
return
|
||||
|
||||
if clip is None:
|
||||
return
|
||||
|
||||
position_id_key = (
|
||||
"cond_stage_model.transformer.text_model.embeddings.position_ids"
|
||||
)
|
||||
if position_id_key in clip:
|
||||
correct = torch.Tensor([list(range(77))]).to(torch.int64)
|
||||
now = clip[position_id_key].to(torch.int64)
|
||||
|
||||
broken = correct.ne(now)
|
||||
broken = [i for i in range(77) if broken[0][i]]
|
||||
|
||||
if len(broken) != 0:
|
||||
clip[position_id_key] = correct
|
||||
log.info(f"[Converter] Fixed broken clip\n{broken}")
|
||||
else:
|
||||
log.info(
|
||||
"[Converter] Clip in this model is fine, skip fixing..."
|
||||
)
|
||||
|
||||
else:
|
||||
log.info("[Converter] Missing position id in model, try fixing...")
|
||||
clip[position_id_key] = torch.Tensor([list(range(77))]).to(
|
||||
torch.int64
|
||||
)
|
||||
return clip
|
||||
|
||||
def get_dicts(self, unet, clip, vae):
|
||||
clip_sd = clip.get_sd()
|
||||
state_dict = unet.model.state_dict_for_saving(
|
||||
clip_sd, vae.get_sd(), None
|
||||
)
|
||||
|
||||
unet = {
|
||||
k: v
|
||||
for k, v in state_dict.items()
|
||||
if k.startswith("model.diffusion_model")
|
||||
}
|
||||
clip = {
|
||||
k: v
|
||||
for k, v in state_dict.items()
|
||||
if k.startswith("cond_stage_model")
|
||||
or k.startswith("conditioner.embedders")
|
||||
}
|
||||
vae = {
|
||||
k: v
|
||||
for k, v in state_dict.items()
|
||||
if k.startswith("first_stage_model")
|
||||
}
|
||||
|
||||
other = {
|
||||
k: v
|
||||
for k, v in state_dict.items()
|
||||
if k not in unet and k not in vae and k not in clip
|
||||
}
|
||||
|
||||
return (unet, clip, vae, other)
|
||||
|
||||
def do_remove_junk(self, tensors: dict[str, dict[str, torch.Tensor]]):
|
||||
need_delete: list[str] = []
|
||||
for layer in tensors:
|
||||
for key in layer:
|
||||
for jk in PRUNE_DATA["known_junk_prefix"]:
|
||||
if key.startswith(jk):
|
||||
need_delete.append(".".join([layer, key]))
|
||||
|
||||
for k in need_delete:
|
||||
log.info(f"Removing junk data: {k}")
|
||||
del tensors[k]
|
||||
|
||||
return tensors
|
||||
|
||||
def prune(
|
||||
self,
|
||||
*,
|
||||
save_separately: bool,
|
||||
save_folder: str,
|
||||
fix_clip: bool,
|
||||
remove_junk: bool,
|
||||
ema_mode: str,
|
||||
precision_unet: Precision,
|
||||
precision_clip: Precision,
|
||||
precision_vae: Precision,
|
||||
operation_unet: str,
|
||||
operation_clip: str,
|
||||
operation_vae: str,
|
||||
unet: dict[str, torch.Tensor] | None = None,
|
||||
clip: dict[str, torch.Tensor] | None = None,
|
||||
vae: dict[str, torch.Tensor] | None = None,
|
||||
):
|
||||
operation = {
|
||||
"unet": Operation.from_str(operation_unet),
|
||||
"clip": Operation.from_str(operation_clip),
|
||||
"vae": Operation.from_str(operation_vae),
|
||||
}
|
||||
precision = {
|
||||
"unet": Precision.from_str(precision_unet),
|
||||
"clip": Precision.from_str(precision_clip),
|
||||
"vae": Precision.from_str(precision_vae),
|
||||
}
|
||||
|
||||
unet, clip, vae, _other = self.get_dicts(unet, clip, vae)
|
||||
|
||||
out_dir = Path(save_folder)
|
||||
folder = out_dir.parent
|
||||
if not out_dir.is_absolute():
|
||||
folder = (comfy_out_dir / save_folder).parent
|
||||
|
||||
if not folder.exists():
|
||||
if folder.parent.exists():
|
||||
folder.mkdir()
|
||||
else:
|
||||
raise FileNotFoundError(
|
||||
f"Folder {folder.parent} does not exist"
|
||||
)
|
||||
|
||||
name = out_dir.name
|
||||
save_name = f"{name}-{precision_unet}"
|
||||
if ema_mode != "disabled":
|
||||
save_name += f"-{ema_mode}"
|
||||
if fix_clip:
|
||||
save_name += "-clip-fix"
|
||||
|
||||
if (
|
||||
any(o == Operation.CONVERT for o in operation.values())
|
||||
and any(p == Precision.FP8 for p in precision.values())
|
||||
and torch.__version__ < "2.1.0"
|
||||
):
|
||||
raise NotImplementedError(
|
||||
"PyTorch 2.1.0 or newer is required for fp8 conversion"
|
||||
)
|
||||
|
||||
if not self.is_sdxl_model(clip):
|
||||
for part in [unet, vae, clip]:
|
||||
if part:
|
||||
nai_keys = PRUNE_DATA["nai_keys"]
|
||||
for k in list(part.keys()):
|
||||
for r in nai_keys:
|
||||
if isinstance(k, str) and k.startswith(r):
|
||||
new_key = k.replace(r, nai_keys[r])
|
||||
part[new_key] = part[k]
|
||||
del part[k]
|
||||
log.info(
|
||||
f"[Converter] Fixed novelai error key {k}"
|
||||
)
|
||||
break
|
||||
|
||||
if fix_clip:
|
||||
clip = self.fix_clip(clip)
|
||||
|
||||
ok: dict[str, dict[str, torch.Tensor]] = {
|
||||
"unet": {},
|
||||
"clip": {},
|
||||
"vae": {},
|
||||
}
|
||||
|
||||
def _hf(part: str, wk: str, t: torch.Tensor):
|
||||
if not isinstance(t, torch.Tensor):
|
||||
log.debug("Not a torch tensor, skipping key")
|
||||
return
|
||||
|
||||
log.debug(f"Operation {operation[part]}")
|
||||
if operation[part] == Operation.CONVERT:
|
||||
ok[part][wk] = self.convert_precision(
|
||||
t, precision[part]
|
||||
) # conv_func(t)
|
||||
elif operation[part] == Operation.COPY:
|
||||
ok[part][wk] = t
|
||||
elif operation[part] == Operation.DELETE:
|
||||
return
|
||||
|
||||
log.info("[Converter] Converting model...")
|
||||
|
||||
for part_name, part in zip(
|
||||
["unet", "vae", "clip", "other"],
|
||||
[unet, vae, clip],
|
||||
strict=False,
|
||||
):
|
||||
if part:
|
||||
match ema_mode:
|
||||
case "remove_ema":
|
||||
for k, v in tqdm.tqdm(part.items()):
|
||||
if "model_ema." not in k:
|
||||
_hf(part_name, k, v)
|
||||
case "ema_only":
|
||||
if not self.has_ema(part):
|
||||
log.warn("No EMA to extract")
|
||||
return
|
||||
for k in tqdm.tqdm(part):
|
||||
ema_k = "___"
|
||||
try:
|
||||
ema_k = "model_ema." + k[6:].replace(".", "")
|
||||
except Exception:
|
||||
pass
|
||||
if ema_k in part:
|
||||
_hf(part_name, k, part[ema_k])
|
||||
elif not k.startswith("model_ema.") or k in [
|
||||
"model_ema.num_updates",
|
||||
"model_ema.decay",
|
||||
]:
|
||||
_hf(part_name, k, part[k])
|
||||
case "disabled" | _:
|
||||
for k, v in tqdm.tqdm(part.items()):
|
||||
_hf(part_name, k, v)
|
||||
|
||||
if save_separately:
|
||||
if remove_junk:
|
||||
ok = self.do_remove_junk(ok)
|
||||
|
||||
flat_ok = {
|
||||
k: v
|
||||
for _, subdict in ok.items()
|
||||
for k, v in subdict.items()
|
||||
}
|
||||
save_path = (
|
||||
folder / f"{part_name}-{save_name}.safetensors"
|
||||
).as_posix()
|
||||
safetensors.torch.save_file(flat_ok, save_path)
|
||||
ok: dict[str, dict[str, torch.Tensor]] = {
|
||||
"unet": {},
|
||||
"clip": {},
|
||||
"vae": {},
|
||||
}
|
||||
|
||||
if save_separately:
|
||||
return ()
|
||||
|
||||
if remove_junk:
|
||||
ok = self.do_remove_junk(ok)
|
||||
|
||||
flat_ok = {
|
||||
k: v for _, subdict in ok.items() for k, v in subdict.items()
|
||||
}
|
||||
|
||||
try:
|
||||
safetensors.torch.save_file(
|
||||
flat_ok, (folder / f"{save_name}.safetensors").as_posix()
|
||||
)
|
||||
except Exception as e:
|
||||
log.error(e)
|
||||
|
||||
return ()
|
||||
|
||||
|
||||
__nodes__ = [MTB_ModelPruner]
|
||||
@@ -0,0 +1,89 @@
|
||||
from pytoshop.user import nested_layers
|
||||
|
||||
# from pytoshop.image_data import ImageData
|
||||
from .. import utils
|
||||
from ..log import log
|
||||
from uuid import uuid4
|
||||
from pathlib import Path
|
||||
import folder_paths
|
||||
from importlib import reload
|
||||
|
||||
|
||||
class PsdSave:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"input_1": ("PSDLAYER",),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ()
|
||||
FUNCTION = "psd_save"
|
||||
CATEGORY = "psd"
|
||||
OUTPUT_NODE = True
|
||||
|
||||
def psd_save(self, **kwargs):
|
||||
groups = {
|
||||
"main": [],
|
||||
}
|
||||
out_layers = []
|
||||
for input, item in kwargs.items():
|
||||
for group, layer in item.items():
|
||||
if group not in groups:
|
||||
groups[group] = []
|
||||
groups[group].append(layer)
|
||||
|
||||
for group, layers in groups.items():
|
||||
current_group = nested_layers.Group(
|
||||
group, visible=True, opacity=255, layers=layers, closed=False
|
||||
)
|
||||
out_layers.append(current_group)
|
||||
|
||||
out_layers = nested_layers.nested_layers_to_psd(out_layers, color_mode=3)
|
||||
output_name = f"{uuid4()}.psd"
|
||||
output_path = Path(folder_paths.output_directory) / output_name
|
||||
|
||||
log.info(f"Saving PSD to {output_name}")
|
||||
|
||||
with open(output_path, "wb") as f:
|
||||
out_layers.write(f)
|
||||
|
||||
return ()
|
||||
|
||||
|
||||
class PsdLayer:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"layer_name": ("STRING", {"default": "layer"}),
|
||||
"image": ("IMAGE",),
|
||||
},
|
||||
"optional": {"mask": ("MASK",)},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("PSDLAYER",)
|
||||
FUNCTION = "psd_layer"
|
||||
CATEGORY = "psd"
|
||||
|
||||
def psd_layer(self, layer_name, image, mask=None):
|
||||
reload(utils)
|
||||
group = "main"
|
||||
if "/" in layer_name:
|
||||
sepname = layer_name.split("/")
|
||||
# layer_name = sepname.pop() # todo: support nesting?
|
||||
group = sepname[0]
|
||||
layer_name = sepname[1]
|
||||
psd = utils.tensor2pytolayer(image, layer_name, mask=mask)
|
||||
# log.warning("Mask is currently ignored for PSD Layers...")
|
||||
return ({group: psd},)
|
||||
|
||||
|
||||
__nodes__ = [PsdLayer, PsdSave]
|
||||
@@ -1,85 +0,0 @@
|
||||
import qrcode
|
||||
import torch
|
||||
from PIL import Image
|
||||
|
||||
from ..log import log
|
||||
from ..utils import pil2tensor
|
||||
|
||||
|
||||
class MTB_QrCode:
|
||||
"""Basic QR Code generator."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"url": ("STRING", {"default": "https://www.github.com"}),
|
||||
"width": (
|
||||
"INT",
|
||||
{"default": 256, "max": 8096, "min": 0, "step": 1},
|
||||
),
|
||||
"height": (
|
||||
"INT",
|
||||
{"default": 256, "max": 8096, "min": 0, "step": 1},
|
||||
),
|
||||
"error_correct": (("L", "M", "Q", "H"), {"default": "L"}),
|
||||
"box_size": (
|
||||
"INT",
|
||||
{"default": 10, "max": 8096, "min": 0, "step": 1},
|
||||
),
|
||||
"border": (
|
||||
"INT",
|
||||
{"default": 4, "max": 8096, "min": 0, "step": 1},
|
||||
),
|
||||
"invert": (("BOOLEAN",), {"default": False}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "do_qr"
|
||||
CATEGORY = "mtb/generate"
|
||||
|
||||
def do_qr(
|
||||
self,
|
||||
*,
|
||||
url: str,
|
||||
width: int,
|
||||
height: int,
|
||||
error_correct: str,
|
||||
box_size: int,
|
||||
border: int,
|
||||
invert: bool,
|
||||
) -> tuple[torch.Tensor]:
|
||||
log.warning(
|
||||
"This node will soon be deprecated, there are much better alternatives like https://github.com/coreyryanhanson/comfy-qr"
|
||||
)
|
||||
if error_correct == "L" or error_correct not in ["M", "Q", "H"]:
|
||||
error_correct = qrcode.constants.ERROR_CORRECT_L
|
||||
elif error_correct == "M":
|
||||
error_correct = qrcode.constants.ERROR_CORRECT_M
|
||||
elif error_correct == "Q":
|
||||
error_correct = qrcode.constants.ERROR_CORRECT_Q
|
||||
else:
|
||||
error_correct = qrcode.constants.ERROR_CORRECT_H
|
||||
|
||||
qr = qrcode.QRCode(
|
||||
version=1,
|
||||
error_correction=error_correct,
|
||||
box_size=box_size,
|
||||
border=border,
|
||||
)
|
||||
qr.add_data(url)
|
||||
qr.make(fit=True)
|
||||
|
||||
back_color = (255, 255, 255) if invert else (0, 0, 0)
|
||||
fill_color = (0, 0, 0) if invert else (255, 255, 255)
|
||||
|
||||
code = qr.make_image(back_color=back_color, fill_color=fill_color)
|
||||
|
||||
# that we now resize without filtering
|
||||
code = code.resize((width, height), Image.NEAREST)
|
||||
|
||||
return (pil2tensor(code),)
|
||||
|
||||
|
||||
__nodes__ = [MTB_QrCode]
|
||||
+15
-42
@@ -1,16 +1,15 @@
|
||||
from math import ceil, sqrt
|
||||
from typing import cast
|
||||
|
||||
import torch
|
||||
import torchvision.transforms.functional as TF
|
||||
from ..utils import log, hex_to_rgb, tensor2pil, pil2tensor
|
||||
from math import sqrt, ceil
|
||||
from typing import cast
|
||||
from PIL import Image
|
||||
|
||||
from ..utils import hex_to_rgb, log, pil2tensor, tensor2pil
|
||||
|
||||
|
||||
class MTB_TransformImage:
|
||||
class TransformImage:
|
||||
"""Save torch tensors (image, mask or latent) to disk, useful to debug things outside comfy
|
||||
|
||||
|
||||
it return a tensor representing the transformed images with the same shape as the input tensor
|
||||
"""
|
||||
|
||||
@@ -19,22 +18,10 @@ class MTB_TransformImage:
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"x": (
|
||||
"FLOAT",
|
||||
{"default": 0, "step": 1, "min": -4096, "max": 4096},
|
||||
),
|
||||
"y": (
|
||||
"FLOAT",
|
||||
{"default": 0, "step": 1, "min": -4096, "max": 4096},
|
||||
),
|
||||
"zoom": (
|
||||
"FLOAT",
|
||||
{"default": 1.0, "min": 0.001, "step": 0.01},
|
||||
),
|
||||
"angle": (
|
||||
"FLOAT",
|
||||
{"default": 0, "step": 1, "min": -360, "max": 360},
|
||||
),
|
||||
"x": ("FLOAT", {"default": 0, "step": 1, "min": -4096, "max": 4096}),
|
||||
"y": ("FLOAT", {"default": 0, "step": 1, "min": -4096, "max": 4096}),
|
||||
"zoom": ("FLOAT", {"default": 1.0, "min": 0.001, "step": 0.01}),
|
||||
"angle": ("FLOAT", {"default": 0, "step": 1, "min": -360, "max": 360}),
|
||||
"shear": (
|
||||
"FLOAT",
|
||||
{"default": 0, "step": 1, "min": -4096, "max": 4096},
|
||||
@@ -66,21 +53,14 @@ class MTB_TransformImage:
|
||||
y = int(y)
|
||||
angle = int(angle)
|
||||
|
||||
log.debug(
|
||||
f"Zoom: {zoom} | x: {x}, y: {y}, angle: {angle}, shear: {shear}"
|
||||
)
|
||||
log.debug(f"Zoom: {zoom} | x: {x}, y: {y}, angle: {angle}, shear: {shear}")
|
||||
|
||||
if image.size(0) == 0:
|
||||
return (torch.zeros(0),)
|
||||
transformed_images = []
|
||||
frames_count, frame_height, frame_width, frame_channel_count = (
|
||||
image.size()
|
||||
)
|
||||
frames_count, frame_height, frame_width, frame_channel_count = image.size()
|
||||
|
||||
new_height, new_width = (
|
||||
int(frame_height * zoom),
|
||||
int(frame_width * zoom),
|
||||
)
|
||||
new_height, new_width = int(frame_height * zoom), int(frame_width * zoom)
|
||||
|
||||
log.debug(f"New height: {new_height}, New width: {new_width}")
|
||||
|
||||
@@ -94,12 +74,7 @@ class MTB_TransformImage:
|
||||
pw += abs(max_padding)
|
||||
ph += abs(max_padding)
|
||||
|
||||
padding = [
|
||||
max(0, pw + x),
|
||||
max(0, ph + y),
|
||||
max(0, pw - x),
|
||||
max(0, ph - y),
|
||||
]
|
||||
padding = [max(0, pw + x), max(0, ph + y), max(0, pw - x), max(0, ph - y)]
|
||||
|
||||
constant_color = hex_to_rgb(constant_color)
|
||||
log.debug(f"Fill Tuple: {constant_color}")
|
||||
@@ -114,9 +89,7 @@ class MTB_TransformImage:
|
||||
|
||||
img = cast(
|
||||
Image.Image,
|
||||
TF.affine(
|
||||
img, angle=angle, scale=zoom, translate=[x, y], shear=shear
|
||||
),
|
||||
TF.affine(img, angle=angle, scale=zoom, translate=[x, y], shear=shear),
|
||||
)
|
||||
|
||||
left = abs(padding[0])
|
||||
@@ -134,4 +107,4 @@ class MTB_TransformImage:
|
||||
return (pil2tensor(transformed_images),)
|
||||
|
||||
|
||||
__nodes__ = [MTB_TransformImage]
|
||||
__nodes__ = [TransformImage]
|
||||
|
||||
@@ -1,445 +0,0 @@
|
||||
import torch
|
||||
|
||||
from ..utils import create_uv_map_tensor, log
|
||||
|
||||
|
||||
class oldDistortImageWithUv:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"uv_map": ("UV_MAP",),
|
||||
"strength": ("FLOAT", {"default": 1.0, "step": 0.05}),
|
||||
},
|
||||
"optional": {
|
||||
"base_uv_map": ("UV_MAP",),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("image",)
|
||||
FUNCTION = "distort_image_with_uv"
|
||||
CATEGORY = "mtb/uv"
|
||||
|
||||
def distort_image_with_uv(
|
||||
self, image, uv_map, strength=1.0, base_uv_map=None
|
||||
):
|
||||
assert (
|
||||
image.shape[1:3] == uv_map.shape[1:3]
|
||||
), "Spatial dimensions of image and uv_map must match!"
|
||||
|
||||
if base_uv_map is None:
|
||||
base_uv_map = create_uv_map_tensor(image.shape[2], image.shape[1])
|
||||
|
||||
# Interpolate (or extrapolate) between base UV map and the distorted UV map based on strength
|
||||
uv_map = strength * uv_map + (1.0 - strength) * base_uv_map
|
||||
# Ensure the image and uv_map have the same spatial dimensions
|
||||
|
||||
# Extract U and V coordinates
|
||||
U = uv_map[:, :, :, 0]
|
||||
V = uv_map[:, :, :, 1]
|
||||
|
||||
# Convert U and V to pixel coordinates
|
||||
b, h, w, _ = image.shape
|
||||
U = U * (w - 1)
|
||||
V = V * (h - 1)
|
||||
|
||||
# Calculate the four corner indices for each UV coordinate
|
||||
U0 = torch.floor(U).long()
|
||||
V0 = torch.floor(V).long()
|
||||
U1 = U0 + 1
|
||||
V1 = V0 + 1
|
||||
|
||||
# Clip the indices to be within the image dimensions
|
||||
U0 = torch.clamp(U0, 0, w - 1)
|
||||
U1 = torch.clamp(U1, 0, w - 1)
|
||||
V0 = torch.clamp(V0, 0, h - 1)
|
||||
V1 = torch.clamp(V1, 0, h - 1)
|
||||
|
||||
# Bilinear interpolation weights
|
||||
w_U0 = (U1.float() - U).unsqueeze(-1)
|
||||
w_U1 = (U - U0.float()).unsqueeze(-1)
|
||||
w_V0 = (V1.float() - V).unsqueeze(-1)
|
||||
w_V1 = (V - V0.float()).unsqueeze(-1)
|
||||
|
||||
# Sample image using bilinear interpolation
|
||||
distorted = (
|
||||
(w_U0 * w_V0) * image[:, V0, U0]
|
||||
+ (w_U0 * w_V1) * image[:, V1, U0]
|
||||
+ (w_U1 * w_V0) * image[:, V0, U1]
|
||||
+ (w_U1 * w_V1) * image[:, V1, U1]
|
||||
)
|
||||
|
||||
return (distorted.squeeze(0),)
|
||||
|
||||
|
||||
class ImageDistortWithUv:
|
||||
"""Distorts an image based on a UV map."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"uv_map": ("UV_MAP",),
|
||||
"boundary_mode": (
|
||||
["clamp", "wrap", "reflect", "replicate"],
|
||||
{"default": "wrap"},
|
||||
),
|
||||
"strength": ("FLOAT", {"default": 1.0, "step": 0.05}),
|
||||
},
|
||||
"optional": {
|
||||
"base_uv_map": ("UV_MAP",),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("image",)
|
||||
FUNCTION = "distort_image_with_uv"
|
||||
CATEGORY = "mtb/uv"
|
||||
|
||||
def distort_image_with_uv(
|
||||
self,
|
||||
image,
|
||||
uv_map,
|
||||
boundary_mode="wrap",
|
||||
strength=1.0,
|
||||
base_uv_map=None,
|
||||
):
|
||||
log.debug(f"[UV Distort] Input image shape {image.shape}")
|
||||
if image.size(0) == 0:
|
||||
log.debug("Input image is empty, returning empty image")
|
||||
return (torch.zeros(0),)
|
||||
b, h, w, _ = image.shape
|
||||
|
||||
x = w - 1
|
||||
y = h - 1
|
||||
|
||||
# If no base UV map provided, create a default one
|
||||
if base_uv_map is None:
|
||||
base_uv_map = create_uv_map_tensor(w, h).to(image.device)
|
||||
|
||||
# Extract U and V coordinates from the base UV map
|
||||
base_U = base_uv_map[..., 0] * x
|
||||
base_V = base_uv_map[..., 1] * y
|
||||
|
||||
# Extract U and V coordinates from the distortion UV map and apply strength
|
||||
U = strength * uv_map[..., 0] * x + (1 - strength) * base_U
|
||||
V = strength * uv_map[..., 1] * y + (1 - strength) * base_V
|
||||
|
||||
# Handle boundary conditions
|
||||
if boundary_mode == "wrap":
|
||||
U = U % w
|
||||
V = V % h
|
||||
elif boundary_mode == "reflect":
|
||||
U = U % (2 * x)
|
||||
V = V % (2 * y)
|
||||
U = torch.where(w < U, 2 * x - U, U)
|
||||
V = torch.where(h < V, 2 * y - V, V)
|
||||
elif boundary_mode == "replicate":
|
||||
U = torch.clamp(U, 0, x)
|
||||
V = torch.clamp(V, 0, y)
|
||||
elif boundary_mode == "clamp":
|
||||
U = torch.clamp(U, 0, w)
|
||||
V = torch.clamp(V, 0, h)
|
||||
else:
|
||||
raise ValueError("Invalid boundary_mode")
|
||||
|
||||
# Check if any UV coordinates are out of bounds and log
|
||||
if torch.any(w <= U) or torch.any(h <= V):
|
||||
log.info("Input UVs out of bounds, clipping")
|
||||
|
||||
# Calculate the four corner indices for each UV coordinate
|
||||
U0, V0 = torch.floor(U).long(), torch.floor(V).long()
|
||||
# For replicate mode, if U0/V0 is at the last pixel, we replicate that pixel for U1/V1
|
||||
if boundary_mode == "replicate":
|
||||
U1 = torch.where(x > U0, U0 + 1, U0)
|
||||
V1 = torch.where(y > V0, V0 + 1, V0)
|
||||
else:
|
||||
U1, V1 = U0 + 1, V0 + 1
|
||||
|
||||
# Ensure U1, V1 do not go out of bounds
|
||||
U1 = torch.clamp(U1, 0, x)
|
||||
V1 = torch.clamp(V1, 0, y)
|
||||
|
||||
# Adjust the bilinear coordinates based on the boundary mode
|
||||
if boundary_mode == "wrap":
|
||||
U1 = U1 % w
|
||||
V1 = V1 % h
|
||||
elif boundary_mode == "reflect":
|
||||
# This remains unchanged as the coordinates are already reflected above
|
||||
pass
|
||||
elif boundary_mode == "replicate":
|
||||
U1 = torch.clamp(U1, 0, x)
|
||||
V1 = torch.clamp(V1, 0, y)
|
||||
|
||||
# Bilinear interpolation weights
|
||||
w_U0, w_U1 = (
|
||||
(U1.float() - U).unsqueeze(-1),
|
||||
(U - U0.float()).unsqueeze(-1),
|
||||
)
|
||||
w_V0, w_V1 = (
|
||||
(V1.float() - V).unsqueeze(-1),
|
||||
(V - V0.float()).unsqueeze(-1),
|
||||
)
|
||||
|
||||
# Sample image using bilinear interpolation
|
||||
distorted = (
|
||||
(w_U0 * w_V0) * image[:, V0, U0]
|
||||
+ (w_U0 * w_V1) * image[:, V1, U0]
|
||||
+ (w_U1 * w_V0) * image[:, V0, U1]
|
||||
+ (w_U1 * w_V1) * image[:, V1, U1]
|
||||
)
|
||||
|
||||
return (distorted.squeeze(0),)
|
||||
|
||||
|
||||
class UvToImage:
|
||||
"""Converts the UV map to an image. (Shallow converter)"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"uv_map": ("UV_MAP",),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("image",)
|
||||
FUNCTION = "uv_to_image"
|
||||
CATEGORY = "mtb/uv"
|
||||
|
||||
def uv_to_image(self, uv_map):
|
||||
return (uv_map,)
|
||||
|
||||
|
||||
class UvRemoveSeams:
|
||||
"""Blends values near the UV borders to mitigate visible seams."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"uv_map": ("UV_MAP",),
|
||||
"radius": ("FLOAT", {"default": 0.01, "step": 0.01}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("UV_MAP",)
|
||||
RETURN_NAMES = ("uv_map",)
|
||||
FUNCTION = "remove_uv_seams"
|
||||
CATEGORY = "mtb/uv"
|
||||
|
||||
def remove_uv_seams(self, uv_map, radius):
|
||||
# Create masks for U and V coordinates close to 0 or 1
|
||||
u_border_mask = (uv_map[..., 0] < radius) | (
|
||||
uv_map[..., 0] > 1 - radius
|
||||
)
|
||||
v_border_mask = (uv_map[..., 1] < radius) | (
|
||||
uv_map[..., 1] > 1 - radius
|
||||
)
|
||||
|
||||
# Soften the UV coordinates near the borders
|
||||
uv_map[..., 0] = torch.where(
|
||||
u_border_mask, uv_map[..., 0] * 0.5, uv_map[..., 0]
|
||||
)
|
||||
uv_map[..., 1] = torch.where(
|
||||
v_border_mask, uv_map[..., 1] * 0.5, uv_map[..., 1]
|
||||
)
|
||||
|
||||
return (uv_map,)
|
||||
|
||||
|
||||
class UvTile:
|
||||
"""Tiles the UV map based on the specified number of tiles."""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"uv_map": ("UV_MAP",),
|
||||
"tiles_u": ("INT", {"default": 1}),
|
||||
"tiles_v": ("INT", {"default": 1}),
|
||||
"alt_method": ("BOOLEAN", {"default": False}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("UV_MAP",)
|
||||
RETURN_NAMES = ("uv_map",)
|
||||
FUNCTION = "tile"
|
||||
CATEGORY = "mtb/uv"
|
||||
|
||||
def tile(self, uv_map, tiles_u, tiles_v, alt_method=False):
|
||||
tiled_uv = uv_map.clone()
|
||||
|
||||
if alt_method:
|
||||
tiled_uv[..., 0] = (
|
||||
uv_map[..., 0] * tiles_u
|
||||
).floor() / tiles_u + uv_map[..., 0] % (1.0 / tiles_u)
|
||||
tiled_uv[..., 1] = (
|
||||
uv_map[..., 1] * tiles_v
|
||||
).floor() / tiles_v + uv_map[..., 1] % (1.0 / tiles_v)
|
||||
|
||||
else:
|
||||
tiled_uv[..., 0] = (
|
||||
uv_map[..., 0] * tiles_u % 1.0
|
||||
) # tile and wrap U coordinates
|
||||
tiled_uv[..., 1] = (
|
||||
uv_map[..., 1] * tiles_v % 1.0
|
||||
) # tile and wrap V coordinates
|
||||
|
||||
return (tiled_uv,)
|
||||
|
||||
|
||||
class ImageToUv:
|
||||
"""Turn an image back into a UV map. (Shallow converter)"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"image_uv": ("IMAGE",),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("UV_MAP",)
|
||||
RETURN_NAMES = ("uv_map",)
|
||||
FUNCTION = "image_to_uv"
|
||||
CATEGORY = "mtb/uv"
|
||||
|
||||
def image_to_uv(self, image_uv):
|
||||
return (image_uv,)
|
||||
|
||||
|
||||
class UvDistort:
|
||||
"""Applies a polar coordinates or wave distortion to the UV map"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"uv_map": ("UV_MAP",),
|
||||
"mode": (["polar", "wave"], {"default": "polar"}),
|
||||
"polar_strength": (
|
||||
"FLOAT",
|
||||
{"default": 1.0, "step": 0.05, "min": -1.0, "max": 1.0},
|
||||
),
|
||||
"wave_frequency": ("FLOAT", {"default": 10.0}),
|
||||
"wave_amplitude": (
|
||||
"FLOAT",
|
||||
{"default": 0.05, "step": 0.05, "min": -1.0, "max": 1.0},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("UV_MAP",)
|
||||
RETURN_NAMES = ("uv_map",)
|
||||
FUNCTION = "distort_uvs"
|
||||
CATEGORY = "mtb/uv"
|
||||
|
||||
def distort_uvs(
|
||||
self,
|
||||
uv_map: torch.Tensor,
|
||||
mode,
|
||||
polar_strength,
|
||||
wave_frequency,
|
||||
wave_amplitude,
|
||||
):
|
||||
if mode == "polar":
|
||||
return (self.apply_polar_distortion(uv_map, polar_strength),)
|
||||
elif mode == "wave":
|
||||
return (
|
||||
self.apply_wave_distortion(
|
||||
uv_map, wave_frequency, wave_amplitude
|
||||
),
|
||||
)
|
||||
else:
|
||||
raise ValueError(f"Unknown mode {mode}")
|
||||
|
||||
@classmethod
|
||||
def apply_wave_distortion(cls, uv_map, frequency=10.0, amplitude=0.05):
|
||||
"""
|
||||
Applies a wave distortion to the UV map and returns an RGB representation.
|
||||
|
||||
Args:
|
||||
- uv_map (torch.Tensor): The UV map tensor.
|
||||
- frequency (float): Frequency of the wave.
|
||||
- amplitude (float): Amplitude of the wave.
|
||||
|
||||
Returns
|
||||
-------
|
||||
- torch.Tensor: Distorted UV map in RGB format.
|
||||
"""
|
||||
U = uv_map[:, :, :, 0]
|
||||
V = uv_map[:, :, :, 1]
|
||||
|
||||
# Apply wave distortion
|
||||
V_distorted = V + amplitude * torch.sin(U * frequency * 2 * 3.14159)
|
||||
|
||||
# Clip V values to [0, 1]
|
||||
V_distorted = torch.clamp(V_distorted, 0, 1)
|
||||
|
||||
R = U
|
||||
G = V_distorted
|
||||
B = torch.zeros_like(R)
|
||||
|
||||
return torch.stack([R, G, B], dim=-1)
|
||||
|
||||
@classmethod
|
||||
def apply_polar_distortion(cls, uv_map: torch.Tensor, strength=1.0):
|
||||
"""
|
||||
Applies a polar coordinates distortion to the UV map and returns an RGB representation.
|
||||
|
||||
Args:
|
||||
- uv_map (torch.Tensor): The UV map tensor.
|
||||
- strength (float): The strength of the distortion.
|
||||
|
||||
Returns
|
||||
-------
|
||||
- torch.Tensor: Distorted UV map in RGB format.
|
||||
"""
|
||||
U = uv_map[:, :, :, 0]
|
||||
V = uv_map[:, :, :, 1]
|
||||
|
||||
# Convert U and V to centered coordinates [-0.5, 0.5]
|
||||
U = U * 2 - 1
|
||||
V = V * 2 - 1
|
||||
|
||||
# Convert to polar coordinates
|
||||
R = torch.sqrt(U * U + V * V)
|
||||
Theta = torch.atan2(V, U)
|
||||
|
||||
# Distort the radius
|
||||
R_distorted = (
|
||||
R + (1.0 - R) * strength
|
||||
) # Changing this line for intuitive strength
|
||||
|
||||
# Convert back to Cartesian
|
||||
U_distorted = R_distorted * torch.cos(Theta)
|
||||
V_distorted = R_distorted * torch.sin(Theta)
|
||||
|
||||
# Normalize to [0, 1]
|
||||
U_distorted = (U_distorted + 1) / 2
|
||||
V_distorted = (V_distorted + 1) / 2
|
||||
|
||||
# Clip to ensure values are in [0, 1]
|
||||
U_distorted = torch.clamp(U_distorted, 0, 1)
|
||||
V_distorted = torch.clamp(V_distorted, 0, 1)
|
||||
|
||||
R = U_distorted
|
||||
G = V_distorted
|
||||
B = torch.zeros_like(R)
|
||||
|
||||
return torch.stack([R, G, B], dim=-1)
|
||||
|
||||
|
||||
__nodes__ = [
|
||||
UvDistort,
|
||||
UvToImage,
|
||||
ImageToUv,
|
||||
ImageDistortWithUv,
|
||||
UvTile,
|
||||
UvRemoveSeams,
|
||||
]
|
||||
+33
-259
@@ -1,171 +1,22 @@
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import comfy.utils
|
||||
import folder_paths
|
||||
import imageio.v3 as iio
|
||||
import numpy as np
|
||||
import torch
|
||||
from comfy.model_management import get_torch_device
|
||||
import numpy as np
|
||||
import hashlib
|
||||
from PIL import Image, ImageOps
|
||||
from PIL.PngImagePlugin import PngInfo
|
||||
import folder_paths
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
from ..log import log
|
||||
from ..utils import np2tensor
|
||||
|
||||
SUPPORTED_FORMATS = ["avi", "mov", "webm", "mp4", "mkv", "gif"]
|
||||
|
||||
|
||||
class MTBLiveVideo:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
input_dir = Path(folder_paths.get_input_directory())
|
||||
files = [
|
||||
f.name
|
||||
for f in input_dir.iterdir()
|
||||
if f.is_file() and f.suffix[1:] in SUPPORTED_FORMATS
|
||||
]
|
||||
return {
|
||||
"required": {
|
||||
"video": (["custom"] + sorted(files), {"default": "custom"}),
|
||||
"video_path": ("STRING", {"default": ""}),
|
||||
"frame_in": (
|
||||
"INT",
|
||||
{"default": 0, "min": 0, "step": 1},
|
||||
),
|
||||
"frame_out": (
|
||||
"INT",
|
||||
{"default": -1, "min": -1, "step": 1},
|
||||
),
|
||||
"frame_steps": (
|
||||
"INT",
|
||||
{"default": 1, "min": 1, "step": 1},
|
||||
),
|
||||
"device": (["auto", "cpu"], {"default": "auto"}),
|
||||
},
|
||||
}
|
||||
|
||||
CATEGORY = "mtb/video"
|
||||
FUNCTION = "video"
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("video frames",)
|
||||
|
||||
def video(
|
||||
self,
|
||||
video: str,
|
||||
video_path: str,
|
||||
frame_in=0,
|
||||
frame_out=-1,
|
||||
frame_steps=1,
|
||||
device="auto",
|
||||
):
|
||||
device = get_torch_device() if device == "auto" else device
|
||||
|
||||
if video == "custom":
|
||||
pth = Path(video_path)
|
||||
if not pth.exists():
|
||||
raise FileNotFoundError(
|
||||
"The video {pth} doesn't seem to exist"
|
||||
)
|
||||
video = pth.as_posix()
|
||||
else:
|
||||
video = folder_paths.get_annotated_filepath(video.strip('"'))
|
||||
|
||||
frames = []
|
||||
# total = 5
|
||||
# pbar = comfy.utils.ProgressBar(total)
|
||||
for i, frame in enumerate(iio.imiter(video, plugin="FFMPEG")):
|
||||
if (
|
||||
i >= frame_in # first frame
|
||||
and (i <= frame_out or frame_out == -1) # in range
|
||||
and i % frame_steps == 0 # stepping
|
||||
):
|
||||
frames.append(frame)
|
||||
|
||||
return (np2tensor(frames).to(device),)
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, video, **parms):
|
||||
image_path = folder_paths.get_annotated_filepath(video)
|
||||
m = hashlib.sha256()
|
||||
with open(image_path, "rb") as f:
|
||||
m.update(f.read())
|
||||
return m.digest().hex()
|
||||
|
||||
@classmethod
|
||||
def VALIDATE_INPUTS(cls, video, **parms):
|
||||
if not folder_paths.exists_annotated_filepath(video):
|
||||
return f"Invalid video file: {video}"
|
||||
return True
|
||||
|
||||
|
||||
class MTBCotracker2:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"grid_size": (
|
||||
"INT",
|
||||
{"default": 10, "min": 1, "max": 100},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
CATEGORY = "mtb/video"
|
||||
FUNCTION = "track"
|
||||
RETURN_TYPES = ("COTRACK_DATA",)
|
||||
RETURN_NAMES = ("tracking data",)
|
||||
|
||||
def track(self, image: torch.Tensor, grid_size=10):
|
||||
device = get_torch_device()
|
||||
cotracker = torch.hub.load(
|
||||
"facebookresearch/co-tracker", "cotracker2"
|
||||
).to(device)
|
||||
|
||||
video = (
|
||||
image.permute(0, 3, 1, 2).unsqueeze(0).float().to(device)
|
||||
) # B T C H W
|
||||
pred_tracks, pred_visibility = cotracker(
|
||||
video, grid_size=grid_size
|
||||
).to(device) # B T N 2, B T N 1
|
||||
|
||||
return (
|
||||
{"pred_tracks": pred_tracks, "pred_visibility": pred_visibility},
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def IS_CHANGED(path="", current_frame=0):
|
||||
print(f"Checking if changed: {path}, {current_frame}")
|
||||
# resolved_path = resolve_path(path, current_frame)
|
||||
# image_path = folder_paths.get_annotated_filepath(resolved_path)
|
||||
# if os.path.exists(image_path):
|
||||
# m = hashlib.sha256()
|
||||
# with open(image_path, "rb") as f:
|
||||
# m.update(f.read())
|
||||
# return m.digest().hex()
|
||||
# return "NONE"
|
||||
|
||||
# @staticmethod
|
||||
# def VALIDATE_INPUTS(path="", current_frame=0):
|
||||
|
||||
# print(f"Validating inputs: {path}, {current_frame}")
|
||||
# resolved_path = resolve_path(path, current_frame)
|
||||
# if not folder_paths.exists_annotated_filepath(resolved_path):
|
||||
# return f"Invalid image file: {resolved_path}"
|
||||
# return True
|
||||
|
||||
|
||||
class MTB_LoadImageSequence:
|
||||
class LoadImageSequence:
|
||||
"""Load an image sequence from a folder. The current frame is used to determine which image to load.
|
||||
|
||||
The current_frame property is used to determine which image to load.
|
||||
Usually used in conjunction with the `Primitive` node set to increment
|
||||
Usually used in conjunction with the `Primitive` node set to increment to load a sequence of images from a folder.
|
||||
Use -1 to load all matching frames as a batch.
|
||||
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
@@ -177,10 +28,7 @@ class MTB_LoadImageSequence:
|
||||
"INT",
|
||||
{"default": 0, "min": -1, "max": 9999999},
|
||||
),
|
||||
},
|
||||
"optional": {
|
||||
"range": ("STRING", {"default": ""}),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
CATEGORY = "mtb/IO"
|
||||
@@ -189,28 +37,17 @@ class MTB_LoadImageSequence:
|
||||
"IMAGE",
|
||||
"MASK",
|
||||
"INT",
|
||||
"INT",
|
||||
)
|
||||
RETURN_NAMES = (
|
||||
"image",
|
||||
"mask",
|
||||
"current_frame",
|
||||
"total_frames",
|
||||
)
|
||||
|
||||
def load_image(self, path=None, current_frame=0, range=""):
|
||||
def load_image(self, path=None, current_frame=0):
|
||||
load_all = current_frame == -1
|
||||
total_frames = 1
|
||||
|
||||
if range:
|
||||
frames = self.get_frames_from_range(path, range)
|
||||
imgs, masks = zip(*(img_from_path(frame) for frame in frames))
|
||||
out_img = torch.cat(imgs, dim=0)
|
||||
out_mask = torch.cat(masks, dim=0)
|
||||
total_frames = len(imgs)
|
||||
return (out_img, out_mask, -1, total_frames)
|
||||
|
||||
elif load_all:
|
||||
if load_all:
|
||||
log.debug(f"Loading all frames from {path}")
|
||||
frames = resolve_all_frames(path)
|
||||
log.debug(f"Found {len(frames)} frames")
|
||||
@@ -218,72 +55,33 @@ class MTB_LoadImageSequence:
|
||||
imgs = []
|
||||
masks = []
|
||||
|
||||
imgs, masks = zip(*(img_from_path(frame) for frame in frames))
|
||||
for frame in frames:
|
||||
img, mask = img_from_path(frame)
|
||||
imgs.append(img)
|
||||
masks.append(mask)
|
||||
|
||||
out_img = torch.cat(imgs, dim=0)
|
||||
out_mask = torch.cat(masks, dim=0)
|
||||
total_frames = len(imgs)
|
||||
|
||||
return (out_img, out_mask, -1, total_frames)
|
||||
return (
|
||||
out_img,
|
||||
out_mask,
|
||||
)
|
||||
|
||||
log.debug(f"Loading image: {path}, {current_frame}")
|
||||
print(f"Loading image: {path}, {current_frame}")
|
||||
resolved_path = resolve_path(path, current_frame)
|
||||
image_path = folder_paths.get_annotated_filepath(resolved_path)
|
||||
image, mask = img_from_path(image_path)
|
||||
return (image, mask, current_frame, total_frames)
|
||||
|
||||
def get_frames_from_range(self, path, range_str):
|
||||
try:
|
||||
start, end = map(int, range_str.split("-"))
|
||||
except ValueError:
|
||||
raise ValueError(
|
||||
f"Invalid range format: {range_str}. Expected format is 'start-end'."
|
||||
)
|
||||
|
||||
frames = resolve_all_frames(path)
|
||||
total_frames = len(frames)
|
||||
|
||||
if start < 0 or end >= total_frames:
|
||||
raise ValueError(
|
||||
f"Range {range_str} is out of bounds. Total frames available: {total_frames}"
|
||||
)
|
||||
|
||||
if "#" in path:
|
||||
frame_regex = re.escape(path).replace(r"\#", r"(\d+)")
|
||||
frame_number_regex = re.compile(frame_regex)
|
||||
|
||||
matching_frames = []
|
||||
for frame in frames:
|
||||
match = frame_number_regex.search(frame)
|
||||
|
||||
if match:
|
||||
frame_number = int(match.group(1))
|
||||
if start <= frame_number <= end:
|
||||
matching_frames.append(frame)
|
||||
|
||||
return matching_frames
|
||||
else:
|
||||
log.warning(
|
||||
f"Wildcard pattern or directory will use indexes instead of frame numbers for : {path}"
|
||||
)
|
||||
|
||||
selected_frames = frames[start : end + 1]
|
||||
|
||||
return selected_frames
|
||||
return (
|
||||
image,
|
||||
mask,
|
||||
current_frame,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def IS_CHANGED(path="", current_frame=0, range=""):
|
||||
def IS_CHANGED(path="", current_frame=0):
|
||||
print(f"Checking if changed: {path}, {current_frame}")
|
||||
if range or current_frame == -1:
|
||||
resolved_paths = resolve_all_frames(path)
|
||||
timestamps = [
|
||||
os.path.getmtime(folder_paths.get_annotated_filepath(p))
|
||||
for p in resolved_paths
|
||||
]
|
||||
combined_hash = hashlib.sha256(
|
||||
"".join(map(str, timestamps)).encode()
|
||||
)
|
||||
return combined_hash.hexdigest()
|
||||
resolved_path = resolve_path(path, current_frame)
|
||||
image_path = folder_paths.get_annotated_filepath(resolved_path)
|
||||
if os.path.exists(image_path):
|
||||
@@ -323,28 +121,11 @@ def img_from_path(path):
|
||||
)
|
||||
|
||||
|
||||
def resolve_all_frames(path: str):
|
||||
frames: list[str] = []
|
||||
if "#" not in path:
|
||||
pth = Path(path)
|
||||
if pth.is_dir():
|
||||
for f in pth.iterdir():
|
||||
if f.suffix in [".jpg", ".png"]:
|
||||
frames.append(f.as_posix())
|
||||
elif "*" in path:
|
||||
frames = glob.glob(path)
|
||||
else:
|
||||
raise ValueError(
|
||||
"The path doesn't contain a # or a * or is not a directory"
|
||||
)
|
||||
frames.sort()
|
||||
|
||||
return frames
|
||||
|
||||
pattern = path
|
||||
def resolve_all_frames(pattern):
|
||||
folder_path, file_pattern = os.path.split(pattern)
|
||||
|
||||
log.debug(f"Resolving all frames in {folder_path}")
|
||||
frames = []
|
||||
hash_count = file_pattern.count("#")
|
||||
frame_pattern = re.sub(r"#+", "*", file_pattern)
|
||||
|
||||
@@ -376,7 +157,7 @@ def resolve_path(path, frame):
|
||||
return re.sub("#+", padded_number, path)
|
||||
|
||||
|
||||
class MTB_SaveImageSequence:
|
||||
class SaveImageSequence:
|
||||
"""Save an image sequence to a folder. The current frame is used to determine which image to save.
|
||||
|
||||
This is merely a wrapper around the `save_images` function with formatting for the output folder and filename.
|
||||
@@ -392,10 +173,7 @@ class MTB_SaveImageSequence:
|
||||
"required": {
|
||||
"images": ("IMAGE",),
|
||||
"filename_prefix": ("STRING", {"default": "Sequence"}),
|
||||
"current_frame": (
|
||||
"INT",
|
||||
{"default": 0, "min": 0, "max": 9999999},
|
||||
),
|
||||
"current_frame": ("INT", {"default": 0, "min": 0, "max": 9999999}),
|
||||
},
|
||||
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
|
||||
}
|
||||
@@ -442,14 +220,10 @@ class MTB_SaveImageSequence:
|
||||
resolved_path = Path(self.output_dir) / filename_prefix
|
||||
resolved_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
resolved_img = (
|
||||
resolved_path / f"{filename_prefix}_{current_frame:05}.png"
|
||||
)
|
||||
resolved_img = resolved_path / f"{filename_prefix}_{current_frame:05}.png"
|
||||
|
||||
output_image = images[0].cpu().numpy()
|
||||
img = Image.fromarray(
|
||||
np.clip(output_image * 255.0, 0, 255).astype(np.uint8)
|
||||
)
|
||||
img = Image.fromarray(np.clip(output_image * 255.0, 0, 255).astype(np.uint8))
|
||||
metadata = PngInfo()
|
||||
if prompt is not None:
|
||||
metadata.add_text("prompt", json.dumps(prompt))
|
||||
@@ -472,6 +246,6 @@ class MTB_SaveImageSequence:
|
||||
|
||||
|
||||
__nodes__ = [
|
||||
MTB_LoadImageSequence,
|
||||
MTB_SaveImageSequence,
|
||||
LoadImageSequence,
|
||||
SaveImageSequence,
|
||||
]
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
import torch
|
||||
from huggingface_hub import hf_hub_download
|
||||
|
||||
from ..utils import models_dir, np2tensor
|
||||
|
||||
# TODO: check if I can make a torch script device independant
|
||||
# for now I forced it to use cuda.
|
||||
|
||||
|
||||
class MTB_LoadVitMatteModel:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"kind": (("Composition-1K", "Distinctions-646"),),
|
||||
"autodownload": ("BOOLEAN", {"default": True}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("VITMATTE_MODEL",)
|
||||
RETURN_NAMES = ("torch_script",)
|
||||
CATEGORY = "mtb/vitmatte"
|
||||
FUNCTION = "execute"
|
||||
|
||||
def execute(self, *, kind: str, autodownload: bool):
|
||||
dest = models_dir / "vitmatte"
|
||||
dest.mkdir(exist_ok=True)
|
||||
name = "dist" if kind == "Distinctions-646" else "com"
|
||||
|
||||
file = hf_hub_download(
|
||||
repo_id="melmass/pytorch-scripts",
|
||||
filename=f"vitmatte_b_{name}.pt",
|
||||
local_dir=dest.as_posix(),
|
||||
local_files_only=not autodownload,
|
||||
)
|
||||
model = torch.jit.load(file).to("cuda")
|
||||
|
||||
return (model,)
|
||||
|
||||
|
||||
class MTB_GenerateTrimap:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
# "image": ("IMAGE",),
|
||||
"mask": ("MASK",),
|
||||
"erode": ("INT", {"default": 10}),
|
||||
"dilate": ("INT", {"default": 10}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
RETURN_NAMES = ("trimap",)
|
||||
|
||||
CATEGORY = "mtb/vitmatte"
|
||||
FUNCTION = "execute"
|
||||
|
||||
def execute(
|
||||
self,
|
||||
# image:torch.Tensor,
|
||||
mask: torch.Tensor,
|
||||
erode: int = 10,
|
||||
dilate: int = 10,
|
||||
):
|
||||
# TODO: not sure what's the most practical between IMAGE or MASK
|
||||
|
||||
# image = image.to("cuda").half()
|
||||
mask = mask.to("cuda").half()
|
||||
|
||||
trimaps = []
|
||||
for m in mask:
|
||||
mask_arr = m.squeeze(0).to(torch.uint8).cpu().numpy() * 255
|
||||
erode_kernel = np.ones((erode, erode), np.uint8)
|
||||
dilate_kernel = np.ones((dilate, dilate), np.uint8)
|
||||
eroded = cv2.erode(mask_arr, erode_kernel, iterations=5)
|
||||
dilated = cv2.dilate(mask_arr, dilate_kernel, iterations=5)
|
||||
trimap = np.zeros_like(mask_arr)
|
||||
trimap[dilated == 255] = 128
|
||||
trimap[eroded == 255] = 255
|
||||
trimaps.append(trimap)
|
||||
|
||||
return (np2tensor(trimaps),)
|
||||
|
||||
|
||||
class MTB_ApplyVitMatte:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"model": ("VITMATTE_MODEL",),
|
||||
"image": ("IMAGE",),
|
||||
"trimap": ("IMAGE",),
|
||||
"returns": (("RGB", "RGBA"),),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE", "MASK")
|
||||
RETURN_NAMES = ("image (rgba)", "mask")
|
||||
CATEGORY = "mtb/utils"
|
||||
FUNCTION = "execute"
|
||||
|
||||
def execute(
|
||||
self, model, image: torch.Tensor, trimap: torch.Tensor, returns: str
|
||||
):
|
||||
im_count = image.shape[0]
|
||||
tm_count = trimap.shape[0]
|
||||
|
||||
if im_count != tm_count:
|
||||
raise ValueError("image and trimap must have the same batch size")
|
||||
|
||||
outputs_m: list[torch.Tensor] = []
|
||||
outputs_i: list[torch.Tensor] = []
|
||||
for i, im in enumerate(image):
|
||||
tm = trimap[i].half().unsqueeze(2).permute(2, 0, 1).to("cuda")
|
||||
im = im.half().permute(2, 0, 1).to("cuda")
|
||||
|
||||
inputs = {"image": im.unsqueeze(0), "trimap": tm.unsqueeze(0)}
|
||||
|
||||
fine_mask = model(inputs)
|
||||
foreground = im * fine_mask + (1 - fine_mask)
|
||||
|
||||
if returns == "RGBA":
|
||||
rgba_image = torch.cat(
|
||||
(foreground, fine_mask.unsqueeze(0)), dim=0
|
||||
)
|
||||
outputs_i.append(rgba_image.unsqueeze(0))
|
||||
else:
|
||||
outputs_i.append(foreground.unsqueeze(0))
|
||||
|
||||
outputs_m.append(fine_mask.unsqueeze(0))
|
||||
|
||||
result_m = torch.cat(outputs_m, dim=0)
|
||||
result_i = torch.cat(outputs_i, dim=0)
|
||||
|
||||
return (result_i.permute(0, 2, 3, 1), result_m)
|
||||
|
||||
|
||||
__nodes__ = [MTB_LoadVitMatteModel, MTB_GenerateTrimap, MTB_ApplyVitMatte]
|
||||
-185
@@ -1,185 +0,0 @@
|
||||
[build-system]
|
||||
requires = ["setuptools", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "comfy-mtb"
|
||||
version = "0.2.0"
|
||||
description = "Animation oriented nodes pack for ComfyUI."
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
# repository = ""
|
||||
# url = "https://github.com/melMass/comfy_mtb"
|
||||
authors = [{ name = "Mel Massadian", email = "mel@melmassadian.com" }]
|
||||
classifiers = [
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Intended Audience :: Developers",
|
||||
]
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
"qrcode",
|
||||
"cachetools",
|
||||
"onnxruntime-gpu",
|
||||
"requirements-parserx",
|
||||
"rembg",
|
||||
"imageio_ffmpeg",
|
||||
"rich",
|
||||
"rich_argparse",
|
||||
"matplotlib",
|
||||
"pillow",
|
||||
]
|
||||
optional-dependencies = { mel = [
|
||||
"jupyterlab==4.1.6",
|
||||
], dev = [
|
||||
"black[jupyter]",
|
||||
"codespell",
|
||||
"mypy",
|
||||
"pre-commit",
|
||||
"pytest",
|
||||
"pytest-cov",
|
||||
"pytest-random-order",
|
||||
"ruff",
|
||||
], doc = [
|
||||
"docutils==0.17.1",
|
||||
"jupyter-book>=0.15",
|
||||
"sphinx-autobuild",
|
||||
] }
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/melMass/comfy_mtb"
|
||||
Documentation = "https://github.com/melMass/comfy_mtb/wiki"
|
||||
Repository = "https://github.com/melMass/comfy_mtb"
|
||||
Issues = "https://github.com/melMass/comfy_mtb/issues"
|
||||
|
||||
[tool.comfy]
|
||||
PublisherId = "mel"
|
||||
DisplayName = "comfy-mtb"
|
||||
Icon = "https://avatars.githubusercontent.com/u/7041726?v=4"
|
||||
|
||||
[tool.bumpversion]
|
||||
current_version = "0.2.0"
|
||||
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
||||
serialize = ["{major}.{minor}.{patch}"]
|
||||
search = "{current_version}"
|
||||
replace = "{new_version}"
|
||||
regex = false
|
||||
ignore_missing_version = false
|
||||
ignore_missing_files = false
|
||||
tag = true
|
||||
sign_tags = true
|
||||
tag_name = "v{new_version}"
|
||||
tag_message = "⬆️ Bump version: {current_version} → {new_version}"
|
||||
allow_dirty = true
|
||||
commit = true
|
||||
message = "⬆️ Bump version: {current_version} → {new_version}"
|
||||
commit_args = ""
|
||||
|
||||
[[tool.bumpversion.files]]
|
||||
filename = "__init__.py"
|
||||
search = "__version__ = \"{current_version}\""
|
||||
replace = "__version__ = \"{new_version}\""
|
||||
|
||||
[[tool.bumpversion.files]]
|
||||
filename = "pyproject.toml"
|
||||
search = "version = \"{current_version}\""
|
||||
replace = "version = \"{new_version}\""
|
||||
|
||||
# [[tool.bumpversion.files]]
|
||||
# filename = "your_package/__init__.py"
|
||||
# search = "__version__ = '{current_version}'"
|
||||
# replace = "__version__ = '{new_version}'"
|
||||
|
||||
# INFO: All those remaining keys are meant for local dev
|
||||
[tool.pyright]
|
||||
include = ["."]
|
||||
exclude = [
|
||||
"**/node_modules",
|
||||
"**/__pycache__",
|
||||
"src/experimental",
|
||||
"src/typestubs",
|
||||
]
|
||||
ignore = ["src/oldstuff"]
|
||||
defineConstant = { DEBUG = true }
|
||||
extraPaths = ["python", "../.."]
|
||||
stubPath = "src/stubs"
|
||||
|
||||
reportMissingImports = true
|
||||
reportMissingTypeStubs = false
|
||||
typeCheckingMode = "basic"
|
||||
|
||||
pythonVersion = "3.10"
|
||||
pythonPlatform = "Windows"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
log_level = "DEBUG"
|
||||
log_cli = true
|
||||
markers = [
|
||||
"wip: tests that aren't fully finished yet",
|
||||
"heavy: marks tests as heavy (deselect with '-m \"not heavy\"')",
|
||||
|
||||
]
|
||||
filterwarnings = ["ignore::UserWarning", 'ignore::DeprecationWarning']
|
||||
|
||||
[tool.isort]
|
||||
profile = "black"
|
||||
line_length = 88
|
||||
auto_identify_namespace_packages = false
|
||||
# NOTE:
|
||||
# pyright doesn't like implicit namespace + single line (related to https://github.com/microsoft/pyright/issues/2882?) but it's horible so I'll live with it
|
||||
force_single_line = false
|
||||
known_first_party = ["mtb"]
|
||||
extend_skip = ["archives"]
|
||||
combine_straight_imports = true
|
||||
|
||||
[tool.coverage.run]
|
||||
parallel = true
|
||||
source = ["docs", "tests", "comfy-mtb"]
|
||||
|
||||
[tool.coverage.report]
|
||||
fail_under = 90
|
||||
show_missing = true
|
||||
|
||||
[tool.coverage.html]
|
||||
show_contexts = true
|
||||
|
||||
# for now ignoring
|
||||
# D100 - document public modules
|
||||
# D102 - document public methods of a class
|
||||
[tool.ruff]
|
||||
line-length = 79
|
||||
select = ["A", "B", "C", "D", "E", "F", "FBT", "I", "N", "S", "SIM", "UP", "W"]
|
||||
# NOTE:
|
||||
# D102 - undocumented-public-method (noisy)
|
||||
# D103 - undocumented-public-function (noisy)
|
||||
# D100 - undocumented-public-module (noisy)
|
||||
ignore = ["D103", "D102", "D100"]
|
||||
# exclude auto generated file
|
||||
extend-exclude = ["./docs/conf.py"]
|
||||
|
||||
[tool.ruff.lint.pep8-naming]
|
||||
extend-ignore-names = ["INPUT_TYPES", "_DEFAULT_INTERPOLANT"]
|
||||
|
||||
[tool.ruff.per-file-ignores]
|
||||
# imported but unused
|
||||
"__init__.py" = ["F401"]
|
||||
# use of assert detected
|
||||
"tests/*" = ["S101"]
|
||||
|
||||
[tool.ruff.pydocstyle]
|
||||
convention = "numpy"
|
||||
|
||||
[tool.mypy]
|
||||
pretty = true
|
||||
ignore_missing_imports = true
|
||||
# exclude auto generated file
|
||||
exclude = ["docs/conf.py"]
|
||||
|
||||
[tool.codespell]
|
||||
# exclude auto generated file
|
||||
skip = "./docs/conf.py,poetry.lock"
|
||||
check-filenames = true
|
||||
@@ -0,0 +1,8 @@
|
||||
onnxruntime-gpu==1.15.1
|
||||
qrcode[pil]
|
||||
rembg==2.0.50
|
||||
tensorflow
|
||||
facexlib==0.3.0
|
||||
insightface==0.7.3
|
||||
basicsr==1.4.2
|
||||
pytoshop
|
||||
@@ -0,0 +1,19 @@
|
||||
https://github.com/melMass/comfy_mtb/releases/download/v0.1.3/pycocotools-2.0.6-cp310-cp310-win_amd64.whl
|
||||
https://github.com/melMass/comfy_mtb/releases/download/v0.1.3/future-0.18.3-py3-none-any.whl
|
||||
https://github.com/melMass/comfy_mtb/releases/download/v0.1.3/filterpy-1.4.5-py3-none-any.whl
|
||||
https://github.com/melMass/comfy_mtb/releases/download/v0.1.3/easydict-1.10-py3-none-any.whl
|
||||
https://github.com/melMass/comfy_mtb/releases/download/v0.1.3/gdown-4.7.1-py3-none-any.whl
|
||||
https://github.com/melMass/comfy_mtb/releases/download/v0.1.3/basicsr-1.4.2-py3-none-any.whl
|
||||
https://github.com/melMass/comfy_mtb/releases/download/v0.1.3/mmcv-2.0.0-py2.py3-none-any.whl
|
||||
https://github.com/melMass/comfy_mtb/releases/download/v0.1.3/insightface-0.7.3-cp310-cp310-win_amd64.whl
|
||||
|
||||
onnxruntime-gpu==1.15.1
|
||||
qrcode[pil]
|
||||
rembg==2.0.50
|
||||
# on windows non WSL 2.10 is the last version with GPU support
|
||||
tensorflow==2.10.1;
|
||||
tb-nightly==2.12.0a20230126; platform_system == "Windows"
|
||||
facexlib==0.3.0
|
||||
# the old tf version on windows comes with a breaking protobuf version
|
||||
protobuf==3.19.6
|
||||
pytoshop
|
||||
@@ -1,16 +0,0 @@
|
||||
qrcode[pil]
|
||||
onnxruntime-gpu
|
||||
requirements-parser
|
||||
# opencv-contrib
|
||||
rembg
|
||||
imageio_ffmpeg
|
||||
rich
|
||||
rich_argparse
|
||||
matplotlib
|
||||
pillow
|
||||
|
||||
imageio
|
||||
imageio-ffmpeg
|
||||
aiohttp-cors
|
||||
open3d==0.17.0
|
||||
cachetools
|
||||
@@ -1,2 +0,0 @@
|
||||
$env.GITHUB_TOKEN = (gh auth token)
|
||||
git cliff --tag main | save -f CHANGELOG.md
|
||||
+3
-870
@@ -1,870 +1,3 @@
|
||||
name,prompt,negative_prompt
|
||||
>>>>>> Generic Styles
|
||||
Style: Enhance,"breathtaking {prompt} . award-winning, professional, highly detailed","ugly, deformed, noisy, blurry, distorted, grainy"
|
||||
Style: Anime,"anime artwork {prompt} . anime style, key visual, vibrant, studio anime, highly detailed","photo, deformed, black and white, realism, disfigured, low contrast"
|
||||
Style: Photographic,"cinematic photo {prompt} . 35mm photograph, film, bokeh, professional, 4k, highly detailed","drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly"
|
||||
Style: Digital art,"concept art {prompt} . digital artwork, illustrative, painterly, matte painting, highly detailed","photo, photorealistic, realism, ugly"
|
||||
Style: Comic book,"comic {prompt} . graphic illustration, comic art, graphic novel art, vibrant, highly detailed","photograph, deformed, glitch, noisy, realistic, stock photo"
|
||||
Style: Fantasy art,"ethereal fantasy concept art of {prompt} . magnificent, celestial, ethereal, painterly, epic, majestic, magical, fantasy art, cover art, dreamy","photographic, realistic, realism, 35mm film, dslr, cropped, frame, text, deformed, glitch, noise, noisy, off-center, deformed, cross-eyed, closed eyes, bad anatomy, ugly, disfigured, sloppy, duplicate, mutated, black and white"
|
||||
Style: Analog film,"analog film photo {prompt} . faded film, desaturated, 35mm photo, grainy, vignette, vintage, Kodachrome, Lomography, stained, highly detailed, found footage","painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured"
|
||||
Style: Neonpunk,"neonpunk style {prompt} . cyberpunk, vaporwave, neon, vibes, vibrant, stunningly beautiful, crisp, detailed, sleek, ultramodern, magenta highlights, dark purple shadows, high contrast, cinematic, ultra detailed, intricate, professional","painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured"
|
||||
Style: Isometric,"isometric style {prompt} . vibrant, beautiful, crisp, detailed, ultra detailed, intricate","deformed, mutated, ugly, disfigured, blur, blurry, noise, noisy, realistic, photographic"
|
||||
Style: Lowpoly,"low-poly style {prompt} . low-poly game art, polygon mesh, jagged, blocky, wireframe edges, centered composition","noisy, sloppy, messy, grainy, highly detailed, ultra textured, photo"
|
||||
Style: Origami,"origami style {prompt} . paper art, pleated paper, folded, origami art, pleats, cut and fold, centered composition","noisy, sloppy, messy, grainy, highly detailed, ultra textured, photo"
|
||||
Style: Line art,"line art drawing {prompt} . professional, sleek, modern, minimalist, graphic, line art, vector graphics","anime, photorealistic, 35mm film, deformed, glitch, blurry, noisy, off-center, deformed, cross-eyed, closed eyes, bad anatomy, ugly, disfigured, mutated, realism, realistic, impressionism, expressionism, oil, acrylic"
|
||||
Style: Craft clay,"play-doh style {prompt} . sculpture, clay art, centered composition, Claymation","sloppy, messy, grainy, highly detailed, ultra textured, photo"
|
||||
Style: Cinematic,"cinematic film still {prompt} . shallow depth of field, vignette, highly detailed, high budget Hollywood movie, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy","anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured"
|
||||
Style: 3d-model,"professional 3d model {prompt} . octane render, highly detailed, volumetric, dramatic lighting","ugly, deformed, noisy, low poly, blurry, painting"
|
||||
Style: pixel art,"pixel-art {prompt} . low-res, blocky, pixel art style, 8-bit graphics","sloppy, messy, blurry, noisy, highly detailed, ultra textured, photo, realistic"
|
||||
Style: Texture,"texture {prompt} top down close-up","ugly, deformed, noisy, blurry"
|
||||
>>>>>> SDXL COMFYUI PORT
|
||||
Style: Enhance,"breathtaking {prompt} . award-winning, professional, highly detailed","ugly, deformed, noisy, blurry, distorted, grainy"
|
||||
Style: sai-3d-model,"professional 3d model {prompt} . octane render, highly detailed, volumetric, dramatic lighting","ugly, deformed, noisy, low poly, blurry, painting"
|
||||
Style: sai-analog film,"analog film photo {prompt} . faded film, desaturated, 35mm photo, grainy, vignette, vintage, Kodachrome, Lomography, stained, highly detailed, found footage","painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured"
|
||||
Style: sai-anime,"anime artwork {prompt} . anime style, key visual, vibrant, studio anime, highly detailed","photo, deformed, black and white, realism, disfigured, low contrast"
|
||||
Style: sai-cinematic,"cinematic film still {prompt} . shallow depth of field, vignette, highly detailed, high budget, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy","anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured"
|
||||
Style: sai-comic book,"comic {prompt} . graphic illustration, comic art, graphic novel art, vibrant, highly detailed","photograph, deformed, glitch, noisy, realistic, stock photo"
|
||||
Style: sai-craft clay,"play-doh style {prompt} . sculpture, clay art, centered composition, Claymation","sloppy, messy, grainy, highly detailed, ultra textured, photo"
|
||||
Style: sai-digital art,"concept art {prompt} . digital artwork, illustrative, painterly, matte painting, highly detailed","photo, photorealistic, realism, ugly"
|
||||
Style: sai-enhance,"breathtaking {prompt} . award-winning, professional, highly detailed","ugly, deformed, noisy, blurry, distorted, grainy"
|
||||
Style: sai-fantasy art,"ethereal fantasy concept art of {prompt} . magnificent, celestial, ethereal, painterly, epic, majestic, magical, fantasy art, cover art, dreamy","photographic, realistic, realism, 35mm film, dslr, cropped, frame, text, deformed, glitch, noise, noisy, off-center, deformed, cross-eyed, closed eyes, bad anatomy, ugly, disfigured, sloppy, duplicate, mutated, black and white"
|
||||
Style: sai-isometric,"isometric style {prompt} . vibrant, beautiful, crisp, detailed, ultra detailed, intricate","deformed, mutated, ugly, disfigured, blur, blurry, noise, noisy, realistic, photographic"
|
||||
Style: sai-line art,"line art drawing {prompt} . professional, sleek, modern, minimalist, graphic, line art, vector graphics","anime, photorealistic, 35mm film, deformed, glitch, blurry, noisy, off-center, deformed, cross-eyed, closed eyes, bad anatomy, ugly, disfigured, mutated, realism, realistic, impressionism, expressionism, oil, acrylic"
|
||||
Style: sai-lowpoly,"low-poly style {prompt} . low-poly game art, polygon mesh, jagged, blocky, wireframe edges, centered composition","noisy, sloppy, messy, grainy, highly detailed, ultra textured, photo"
|
||||
Style: sai-neonpunk,"neonpunk style {prompt} . cyberpunk, vaporwave, neon, vibes, vibrant, stunningly beautiful, crisp, detailed, sleek, ultramodern, magenta highlights, dark purple shadows, high contrast, cinematic, ultra detailed, intricate, professional","painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured"
|
||||
Style: sai-origami,"origami style {prompt} . paper art, pleated paper, folded, origami art, pleats, cut and fold, centered composition","noisy, sloppy, messy, grainy, highly detailed, ultra textured, photo"
|
||||
Style: sai-photographic,"cinematic photo {prompt} . 35mm photograph, film, bokeh, professional, 4k, highly detailed","drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly"
|
||||
Style: sai-pixel art,"pixel-art {prompt} . low-res, blocky, pixel art style, 8-bit graphics","sloppy, messy, blurry, noisy, highly detailed, ultra textured, photo, realistic"
|
||||
Style: sai-texture,"texture {prompt} top down close-up","ugly, deformed, noisy, blurry"
|
||||
Style: ads-advertising,"Advertising poster style {prompt} . Professional, modern, product-focused, commercial, eye-catching, highly detailed","noisy, blurry, amateurish, sloppy, unattractive"
|
||||
Style: ads-automotive,"Automotive advertisement style {prompt} . Sleek, dynamic, professional, commercial, vehicle-focused, high-resolution, highly detailed","noisy, blurry, unattractive, sloppy, unprofessional"
|
||||
Style: ads-corporate,"Corporate branding style {prompt} . Professional, clean, modern, sleek, minimalist, business-oriented, highly detailed","noisy, blurry, grungy, sloppy, cluttered, disorganized"
|
||||
Style: ads-fashion editorial,"Fashion editorial style {prompt} . High fashion, trendy, stylish, editorial, magazine style, professional, highly detailed","outdated, blurry, noisy, unattractive, sloppy"
|
||||
Style: ads-food photography,"Food photography style {prompt} . Appetizing, professional, culinary, high-resolution, commercial, highly detailed","unappetizing, sloppy, unprofessional, noisy, blurry"
|
||||
Style: ads-luxury,"Luxury product style {prompt} . Elegant, sophisticated, high-end, luxurious, professional, highly detailed","cheap, noisy, blurry, unattractive, amateurish"
|
||||
Style: ads-real estate,"Real estate photography style {prompt} . Professional, inviting, well-lit, high-resolution, property-focused, commercial, highly detailed","dark, blurry, unappealing, noisy, unprofessional"
|
||||
Style: ads-retail,"Retail packaging style {prompt} . Vibrant, enticing, commercial, product-focused, eye-catching, professional, highly detailed","noisy, blurry, amateurish, sloppy, unattractive"
|
||||
Style: artstyle-abstract,"abstract style {prompt} . non-representational, colors and shapes, expression of feelings, imaginative, highly detailed","realistic, photographic, figurative, concrete"
|
||||
Style: artstyle-abstract expressionism,"abstract expressionist painting {prompt} . energetic brushwork, bold colors, abstract forms, expressive, emotional","realistic, photorealistic, low contrast, plain, simple, monochrome"
|
||||
Style: artstyle-art deco,"Art Deco style {prompt} . geometric shapes, bold colors, luxurious, elegant, decorative, symmetrical, ornate, detailed","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, modernist, minimalist"
|
||||
Style: artstyle-art nouveau,"Art Nouveau style {prompt} . elegant, decorative, curvilinear forms, nature-inspired, ornate, detailed","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, modernist, minimalist"
|
||||
Style: artstyle-constructivist,"constructivist style {prompt} . geometric shapes, bold colors, dynamic composition, propaganda art style","realistic, photorealistic, low contrast, plain, simple, abstract expressionism"
|
||||
Style: artstyle-cubist,"cubist artwork {prompt} . geometric shapes, abstract, innovative, revolutionary","anime, photorealistic, 35mm film, deformed, glitch, low contrast, noisy"
|
||||
Style: artstyle-expressionist,"expressionist {prompt} . raw, emotional, dynamic, distortion for emotional effect, vibrant, use of unusual colors, detailed","realism, symmetry, quiet, calm, photo"
|
||||
Style: artstyle-graffiti,"graffiti style {prompt} . street art, vibrant, urban, detailed, tag, mural","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic"
|
||||
Style: artstyle-hyperrealism,"hyperrealistic art {prompt} . extremely high-resolution details, photographic, realism pushed to extreme, fine texture, incredibly lifelike","simplified, abstract, unrealistic, impressionistic, low resolution"
|
||||
Style: artstyle-impressionist,"impressionist painting {prompt} . loose brushwork, vibrant color, light and shadow play, captures feeling over form","anime, photorealistic, 35mm film, deformed, glitch, low contrast, noisy"
|
||||
Style: artstyle-pointillism,"pointillism style {prompt} . composed entirely of small, distinct dots of color, vibrant, highly detailed","line drawing, smooth shading, large color fields, simplistic"
|
||||
Style: artstyle-pop art,"Pop Art style {prompt} . bright colors, bold outlines, popular culture themes, ironic or kitsch","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, minimalist"
|
||||
Style: artstyle-psychedelic,"psychedelic style {prompt} . vibrant colors, swirling patterns, abstract forms, surreal, trippy","monochrome, black and white, low contrast, realistic, photorealistic, plain, simple"
|
||||
Style: artstyle-renaissance,"Renaissance style {prompt} . realistic, perspective, light and shadow, religious or mythological themes, highly detailed","ugly, deformed, noisy, blurry, low contrast, modernist, minimalist, abstract"
|
||||
Style: artstyle-steampunk,"steampunk style {prompt} . antique, mechanical, brass and copper tones, gears, intricate, detailed","deformed, glitch, noisy, low contrast, anime, photorealistic"
|
||||
Style: artstyle-surrealist,"surrealist art {prompt} . dreamlike, mysterious, provocative, symbolic, intricate, detailed","anime, photorealistic, realistic, deformed, glitch, noisy, low contrast"
|
||||
Style: artstyle-typography,"typographic art {prompt} . stylized, intricate, detailed, artistic, text-based","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic"
|
||||
Style: artstyle-watercolor,"watercolor painting {prompt} . vibrant, beautiful, painterly, detailed, textural, artistic","anime, photorealistic, 35mm film, deformed, glitch, low contrast, noisy"
|
||||
Style: futuristic-biomechanical,"biomechanical style {prompt} . blend of organic and mechanical elements, futuristic, cybernetic, detailed, intricate","natural, rustic, primitive, organic, simplistic"
|
||||
Style: futuristic-biomechanical cyberpunk,"biomechanical cyberpunk {prompt} . cybernetics, human-machine fusion, dystopian, organic meets artificial, dark, intricate, highly detailed","natural, colorful, deformed, sketch, low contrast, watercolor"
|
||||
Style: futuristic-cybernetic,"cybernetic style {prompt} . futuristic, technological, cybernetic enhancements, robotics, artificial intelligence themes","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, historical, medieval"
|
||||
Style: futuristic-cybernetic robot,"cybernetic robot {prompt} . android, AI, machine, metal, wires, tech, futuristic, highly detailed","organic, natural, human, sketch, watercolor, low contrast"
|
||||
Style: futuristic-cyberpunk cityscape,"cyberpunk cityscape {prompt} . neon lights, dark alleys, skyscrapers, futuristic, vibrant colors, high contrast, highly detailed","natural, rural, deformed, low contrast, black and white, sketch, watercolor"
|
||||
Style: futuristic-futuristic,"futuristic style {prompt} . sleek, modern, ultramodern, high tech, detailed","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, vintage, antique"
|
||||
Style: futuristic-retro cyberpunk,"retro cyberpunk {prompt} . 80's inspired, synthwave, neon, vibrant, detailed, retro futurism","modern, desaturated, black and white, realism, low contrast"
|
||||
Style: futuristic-retro futurism,"retro-futuristic {prompt} . vintage sci-fi, 50s and 60s style, atomic age, vibrant, highly detailed","contemporary, realistic, rustic, primitive"
|
||||
Style: futuristic-sci-fi,"sci-fi style {prompt} . futuristic, technological, alien worlds, space themes, advanced civilizations","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, historical, medieval"
|
||||
Style: futuristic-vaporwave,"vaporwave style {prompt} . retro aesthetic, cyberpunk, vibrant, neon colors, vintage 80s and 90s style, highly detailed","monochrome, muted colors, realism, rustic, minimalist, dark"
|
||||
Style: game-bubble bobble,"Bubble Bobble style {prompt} . 8-bit, cute, pixelated, fantasy, vibrant, reminiscent of Bubble Bobble game","realistic, modern, photorealistic, violent, horror"
|
||||
Style: game-cyberpunk game,"cyberpunk game style {prompt} . neon, dystopian, futuristic, digital, vibrant, detailed, high contrast, reminiscent of cyberpunk genre video games","historical, natural, rustic, low detailed"
|
||||
Style: game-fighting game,"fighting game style {prompt} . dynamic, vibrant, action-packed, detailed character design, reminiscent of fighting video games","peaceful, calm, minimalist, photorealistic"
|
||||
Style: game-gta,"GTA-style artwork {prompt} . satirical, exaggerated, pop art style, vibrant colors, iconic characters, action-packed","realistic, black and white, low contrast, impressionist, cubist, noisy, blurry, deformed"
|
||||
Style: game-mario,"Super Mario style {prompt} . vibrant, cute, cartoony, fantasy, playful, reminiscent of Super Mario series","realistic, modern, horror, dystopian, violent"
|
||||
Style: game-minecraft,"Minecraft style {prompt} . blocky, pixelated, vibrant colors, recognizable characters and objects, game assets","smooth, realistic, detailed, photorealistic, noise, blurry, deformed"
|
||||
Style: game-pokemon,"Pokémon style {prompt} . vibrant, cute, anime, fantasy, reminiscent of Pokémon series","realistic, modern, horror, dystopian, violent"
|
||||
Style: game-retro arcade,"retro arcade style {prompt} . 8-bit, pixelated, vibrant, classic video game, old school gaming, reminiscent of 80s and 90s arcade games","modern, ultra-high resolution, photorealistic, 3D"
|
||||
Style: game-retro game,"retro game art {prompt} . 16-bit, vibrant colors, pixelated, nostalgic, charming, fun","realistic, photorealistic, 35mm film, deformed, glitch, low contrast, noisy"
|
||||
Style: game-rpg fantasy game,"role-playing game (RPG) style fantasy {prompt} . detailed, vibrant, immersive, reminiscent of high fantasy RPG games","sci-fi, modern, urban, futuristic, low detailed"
|
||||
Style: game-strategy game,"strategy game style {prompt} . overhead view, detailed map, units, reminiscent of real-time strategy video games","first-person view, modern, photorealistic"
|
||||
Style: game-streetfighter,"Street Fighter style {prompt} . vibrant, dynamic, arcade, 2D fighting game, highly detailed, reminiscent of Street Fighter series","3D, realistic, modern, photorealistic, turn-based strategy"
|
||||
Style: game-zelda,"Legend of Zelda style {prompt} . vibrant, fantasy, detailed, epic, heroic, reminiscent of The Legend of Zelda series","sci-fi, modern, realistic, horror"
|
||||
Style: misc-architectural,"architectural style {prompt} . clean lines, geometric shapes, minimalist, modern, architectural drawing, highly detailed","curved lines, ornate, baroque, abstract, grunge"
|
||||
Style: misc-disco,"disco-themed {prompt} . vibrant, groovy, retro 70s style, shiny disco balls, neon lights, dance floor, highly detailed","minimalist, rustic, monochrome, contemporary, simplistic"
|
||||
Style: misc-dreamscape,"dreamscape {prompt} . surreal, ethereal, dreamy, mysterious, fantasy, highly detailed","realistic, concrete, ordinary, mundane"
|
||||
Style: misc-dystopian,"dystopian style {prompt} . bleak, post-apocalyptic, somber, dramatic, highly detailed","ugly, deformed, noisy, blurry, low contrast, cheerful, optimistic, vibrant, colorful"
|
||||
Style: misc-fairy tale,"fairy tale {prompt} . magical, fantastical, enchanting, storybook style, highly detailed","realistic, modern, ordinary, mundane"
|
||||
Style: misc-gothic,"gothic style {prompt} . dark, mysterious, haunting, dramatic, ornate, detailed","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, cheerful, optimistic"
|
||||
Style: misc-grunge,"grunge style {prompt} . textured, distressed, vintage, edgy, punk rock vibe, dirty, noisy","smooth, clean, minimalist, sleek, modern, photorealistic"
|
||||
Style: misc-horror,"horror-themed {prompt} . eerie, unsettling, dark, spooky, suspenseful, grim, highly detailed","cheerful, bright, vibrant, light-hearted, cute"
|
||||
Style: misc-kawaii,"kawaii style {prompt} . cute, adorable, brightly colored, cheerful, anime influence, highly detailed","dark, scary, realistic, monochrome, abstract"
|
||||
Style: misc-lovecraftian,"lovecraftian horror {prompt} . eldritch, cosmic horror, unknown, mysterious, surreal, highly detailed","light-hearted, mundane, familiar, simplistic, realistic"
|
||||
Style: misc-macabre,"macabre style {prompt} . dark, gothic, grim, haunting, highly detailed","bright, cheerful, light-hearted, cartoonish, cute"
|
||||
Style: misc-manga,"manga style {prompt} . vibrant, high-energy, detailed, iconic, Japanese comic style","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, Western comic style"
|
||||
Style: misc-metropolis,"metropolis-themed {prompt} . urban, cityscape, skyscrapers, modern, futuristic, highly detailed","rural, natural, rustic, historical, simple"
|
||||
Style: misc-minimalist,"minimalist style {prompt} . simple, clean, uncluttered, modern, elegant","ornate, complicated, highly detailed, cluttered, disordered, messy, noisy"
|
||||
Style: misc-monochrome,"monochrome {prompt} . black and white, contrast, tone, texture, detailed","colorful, vibrant, noisy, blurry, deformed"
|
||||
Style: misc-nautical,"nautical-themed {prompt} . sea, ocean, ships, maritime, beach, marine life, highly detailed","landlocked, desert, mountains, urban, rustic"
|
||||
Style: misc-space,"space-themed {prompt} . cosmic, celestial, stars, galaxies, nebulas, planets, science fiction, highly detailed","earthly, mundane, ground-based, realism"
|
||||
Style: misc-stained glass,"stained glass style {prompt} . vibrant, beautiful, translucent, intricate, detailed","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic"
|
||||
Style: misc-techwear fashion,"techwear fashion {prompt} . futuristic, cyberpunk, urban, tactical, sleek, dark, highly detailed","vintage, rural, colorful, low contrast, realism, sketch, watercolor"
|
||||
Style: misc-tribal,"tribal style {prompt} . indigenous, ethnic, traditional patterns, bold, natural colors, highly detailed","modern, futuristic, minimalist, pastel"
|
||||
Style: misc-zentangle,"zentangle {prompt} . intricate, abstract, monochrome, patterns, meditative, highly detailed","colorful, representative, simplistic, large fields of color"
|
||||
Style: papercraft-collage,"collage style {prompt} . mixed media, layered, textural, detailed, artistic","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic"
|
||||
Style: papercraft-flat papercut,"flat papercut style {prompt} . silhouette, clean cuts, paper, sharp edges, minimalist, color block","3D, high detail, noise, grainy, blurry, painting, drawing, photo, disfigured"
|
||||
Style: papercraft-kirigami,"kirigami representation of {prompt} . 3D, paper folding, paper cutting, Japanese, intricate, symmetrical, precision, clean lines","painting, drawing, 2D, noisy, blurry, deformed"
|
||||
Style: papercraft-paper mache,"paper mache representation of {prompt} . 3D, sculptural, textured, handmade, vibrant, fun","2D, flat, photo, sketch, digital art, deformed, noisy, blurry"
|
||||
Style: papercraft-paper quilling,"paper quilling art of {prompt} . intricate, delicate, curling, rolling, shaping, coiling, loops, 3D, dimensional, ornamental","photo, painting, drawing, 2D, flat, deformed, noisy, blurry"
|
||||
Style: papercraft-papercut collage,"papercut collage of {prompt} . mixed media, textured paper, overlapping, asymmetrical, abstract, vibrant","photo, 3D, realistic, drawing, painting, high detail, disfigured"
|
||||
Style: papercraft-papercut shadow box,"3D papercut shadow box of {prompt} . layered, dimensional, depth, silhouette, shadow, papercut, handmade, high contrast","painting, drawing, photo, 2D, flat, high detail, blurry, noisy, disfigured"
|
||||
Style: papercraft-stacked papercut,"stacked papercut art of {prompt} . 3D, layered, dimensional, depth, precision cut, stacked layers, papercut, high contrast","2D, flat, noisy, blurry, painting, drawing, photo, deformed"
|
||||
Style: papercraft-thick layered papercut,"thick layered papercut art of {prompt} . deep 3D, volumetric, dimensional, depth, thick paper, high stack, heavy texture, tangible layers","2D, flat, thin paper, low stack, smooth texture, painting, drawing, photo, deformed"
|
||||
Style: photo-alien,"alien-themed {prompt} . extraterrestrial, cosmic, otherworldly, mysterious, sci-fi, highly detailed","earthly, mundane, common, realistic, simple"
|
||||
Style: photo-film noir,"film noir style {prompt} . monochrome, high contrast, dramatic shadows, 1940s style, mysterious, cinematic","ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, vibrant, colorful"
|
||||
Style: photo-hdr,"HDR photo of {prompt} . High dynamic range, vivid, rich details, clear shadows and highlights, realistic, intense, enhanced contrast, highly detailed","flat, low contrast, oversaturated, underexposed, overexposed, blurred, noisy"
|
||||
Style: photo-long exposure,"long exposure photo of {prompt} . Blurred motion, streaks of light, surreal, dreamy, ghosting effect, highly detailed","static, noisy, deformed, shaky, abrupt, flat, low contrast"
|
||||
Style: photo-neon noir,"neon noir {prompt} . cyberpunk, dark, rainy streets, neon signs, high contrast, low light, vibrant, highly detailed","bright, sunny, daytime, low contrast, black and white, sketch, watercolor"
|
||||
Style: photo-silhouette,"silhouette style {prompt} . high contrast, minimalistic, black and white, stark, dramatic","ugly, deformed, noisy, blurry, low contrast, color, realism, photorealistic"
|
||||
Style: photo-tilt-shift,"tilt-shift photo of {prompt} . Selective focus, miniature effect, blurred background, highly detailed, vibrant, perspective control","blurry, noisy, deformed, flat, low contrast, unrealistic, oversaturated, underexposed"
|
||||
>>>>>> Advanced GPT Styles
|
||||
Style: Space art,"galactic style {prompt} . nebula, constellation, cosmic, celestial, highly detailed, starry","blurry, grainy, deformed, photo-realistic, low-contrast, terrestrial"
|
||||
Style: Street art,"urban graffiti style {prompt} . vibrant, edgy, street art, underground, spray paint effect","clean, minimalistic, soft, gentle, blurry, off-center"
|
||||
Style: Baroque,"Baroque art {prompt} . ornate, richly detailed, dramatic, high contrast, complex composition","minimalistic, low-contrast, blurry, deformed, modern, abstract"
|
||||
Style: Abstract,"abstract {prompt} . imaginative, surreal, non-representational, dream-like","realistic, photo, literal, symmetrical, rigid"
|
||||
Style: Pointillism,"pointillism art {prompt} . dots, dappled, stipples, highly detailed","smooth, blurry, photo-realistic, non-dotted"
|
||||
Style: Impressionist,"impressionist painting {prompt} . soft edges, vibrant, loose brushwork, atmospheric, highly detailed","hard edges, muted colors, tight brushwork, non-atmospheric"
|
||||
Style: Pop art,"pop art {prompt} . vibrant, mass culture, comic style, bold lines, ironic","soft, elegant, high culture, realistic, subtle lines"
|
||||
Style: Minimalist,"minimalist design {prompt} . clean, simple, restrained, elegant","busy, complex, flamboyant, disfigured"
|
||||
Style: Art Deco,"art deco {prompt} . opulent, lavish, ornate, symmetrical, geometric","minimalistic, simple, asymmetrical, organic"
|
||||
Style: Cubist,"cubist {prompt} . abstract, geometric, fragmented, multiple perspectives","realistic, smooth, unbroken, single perspective"
|
||||
Style: Dada,"dada style {prompt} . absurd, satirical, avant-garde, abstract","serious, traditional, conventional, realistic"
|
||||
Style: Victorian,"Victorian style {prompt} . elegant, ornate, highly detailed, historical","modern, minimalist, low detail, contemporary"
|
||||
Style: Art Nouveau,"art nouveau {prompt} . organic, curvilinear, decorative, highly detailed","geometric, straight lines, functional, low detail"
|
||||
Style: Futuristic,"futuristic {prompt} . advanced, high-tech, sleek, modern","old, low-tech, chunky, historical"
|
||||
Style: Medieval,"medieval style {prompt} . historical, ornate, religious, gothic","modern, simple, secular, minimalist"
|
||||
Style: Industrial,"industrial style {prompt} . mechanical, robust, urban, gritty","natural, fragile, rural, clean"
|
||||
Style: Vaporwave,"vaporwave style {prompt} . retro, neon, pixelated, nostalgic","modern, monochrome, high-resolution, forward-looking"
|
||||
Style: Horror,"horror style {prompt} . dark, eerie, gothic, macabre","light, cheerful, minimalist, happy"
|
||||
Style: Gothic,"gothic style {prompt} . dark, mysterious, intricate, moody","light, cheerful, simple, vibrant"
|
||||
Style: Steampunk,"steampunk style {prompt} . retro, mechanical, detailed, Victorian","modern, digital, minimalist, contemporary"
|
||||
Style: Retro,"retro style {prompt} . vintage, nostalgic, old-fashioned, highly detailed","modern, futuristic, forward-looking, low detail"
|
||||
Style: Surrealist,"surrealist {prompt} . dream-like, bizarre, irrational, highly detailed","realistic, mundane, rational, low detail"
|
||||
Style: Realism,"realism style {prompt} . lifelike, detailed, accurate, representational","abstract, simplistic, inaccurate, non-representational"
|
||||
Style: Silhouette,"silhouette style {prompt} . minimalist, monochrome, stark, high contrast","detailed, multicolored, soft, low contrast"
|
||||
Style: Collage,"collage style {prompt} . mixed media, assembled, eclectic, highly detailed","uniform, unvarying, minimalist, low detail"
|
||||
Style: Watercolor,"watercolor {prompt} . soft, blended, transparent, fluid","hard, unblended, opaque, rigid"
|
||||
Style: Calligraphy,"calligraphy {prompt} . elegant, flowing, ornate, highly detailed","plain, rigid, simple, low detail"
|
||||
Style: Expressionist,"expressionist style {prompt} . emotional, intense, vibrant, highly detailed","emotionless, calm, muted, low detail"
|
||||
Style: Fauvist,"fauvist style {prompt} . bold color, exaggerated, expressive, highly detailed","neutral color, realistic, restrained, low detail"
|
||||
Style: Renaissance,"Renaissance style {prompt} . classical, humanistic, realistic, highly detailed","modern, abstract, unrealistic, low detail"
|
||||
Style: Photorealistic,"photorealistic {prompt} . highly detailed, lifelike, precise, accurate","abstract, low detail, unrealistic, inaccurate"
|
||||
Style: Symbolic,"symbolic style {prompt} . conceptual, representative, allegorical, highly detailed","literal, non-representative, factual, low detail"
|
||||
Style: Avant-garde,"avant-garde style {prompt} . experimental, innovative, non-traditional","traditional, conventional, classic"
|
||||
Style: Mosaic,"mosaic style {prompt} . fragmented, assembled, colorful, highly detailed","whole, unbroken, monochrome, low detail"
|
||||
Style: Trompe l'oeil,"trompe l'oeil style {prompt} . deceptive, 3D effect, realistic, highly detailed","honest, 2D effect, unrealistic, low detail"
|
||||
Style: Rococo,"rococo style {prompt} . ornate, playful, romantic, pastel, highly detailed","minimalistic, serious, unromantic, dark, low detail"
|
||||
Style: Macabre,"macabre style {prompt} . dark, eerie, grotesque, highly detailed","light, cheerful, beautiful, low detail"
|
||||
Style: Satirical,"satirical style {prompt} . humorous, ironic, exaggerated, critical","serious, literal, realistic, complimentary"
|
||||
Style: Pixelated,"pixelated style {prompt} . retro, low-res, digital, blocky","modern, high-res, organic, smooth"
|
||||
Style: Futurist,"futurist style {prompt} . dynamic, modern, mechanized, highly detailed","static, historical, organic, low detail"
|
||||
Style: Primitive,"primitive style {prompt} . raw, simple, naive, highly detailed","refined, complex, sophisticated, low detail"
|
||||
Style: Byzantine,"Byzantine style {prompt} . rich, ornate, religious, iconic, highly detailed","poor, simple, secular, non-iconic, low detail"
|
||||
Style: Psychedelic,"psychedelic style {prompt} . vibrant, abstract, distorted, highly detailed","muted, realistic, undistorted, low detail"
|
||||
Style: Suprematist,"suprematist style {prompt} . geometric, abstract, non-objective, simple","organic, realistic, objective, complex"
|
||||
Style: Constructivist,"constructivist style {prompt} . industrial, geometric, political, highly detailed","organic, curvilinear, apolitical, low detail"
|
||||
Style: De Stijl,"de Stijl style {prompt} . abstract, geometric, primary colors,"organic, curvilinear, muted colors, black and white"
|
||||
Style: Ukiyo-e,"ukiyo-e style {prompt} . woodblock print, vibrant, historical Japanese art, detailed","digital, muted, modern, Western"
|
||||
Style: Dystopian,"dystopian style {prompt} . bleak, oppressive, futuristic, detailed","utopian, cheerful, historical, low detail"
|
||||
Style: Biomechanical,"biomechanical style {prompt} . organic meets mechanical, alien, detailed, H.R. Giger-inspired","geometric, earthy, low detail, not H.R. Giger-inspired"
|
||||
Style: Hyperrealism,"hyperrealistic style {prompt} . ultra-detailed, lifelike, precision, crisp","abstract, low detail, unrealistic, blurry"
|
||||
Style: Glitch,"glitch style {prompt} . digital error, distorted, cyber, detailed","analog, undistorted, organic, low detail"
|
||||
Style: Trompe-l'oeil,"trompe-l'oeil style {prompt} . optical illusion, lifelike, 3D effect, detailed","flat, 2D effect, unrealistic, low detail"
|
||||
Style: Arabesque,"arabesque style {prompt} . geometric patterns, floral, Islamic art, detailed","chaotic, animalistic, non-Islamic art, low detail"
|
||||
Style: Brutalist,"brutalist style {prompt} . raw, rugged, geometric, concrete, detailed","smooth, delicate, curvilinear, abstract, low detail"
|
||||
Style: Chiaroscuro,"chiaroscuro style {prompt} . high contrast, dramatic lighting, detailed","low contrast, flat lighting, low detail"
|
||||
Style: Tenebrism,"tenebrism style {prompt} . dark, dramatic illumination, high contrast, detailed","light, flat lighting, low contrast, low detail"
|
||||
Style: Romantic,"romantic style {prompt} . emotional, dramatic, nature-focused, detailed","unemotional, flat, city-focused, low detail"
|
||||
Style: Bauhaus,"bauhaus style {prompt} . functional, geometric, minimal, detailed","ornamental, curvilinear, maximal, low detail"
|
||||
Style: Art brut,"art brut style {prompt} . raw, outsider art, naïve, detailed","refined, mainstream art, sophisticated, low detail"
|
||||
Style: Metaphysical,"metaphysical style {prompt} . surreal, eerie, uncanny, detailed","realistic, comfortable, familiar, low detail"
|
||||
Style: Neoplasticism,"neoplasticism style {prompt} . geometric, primary colors, black and white, abstract","organic, muted colors, colorful, realistic"
|
||||
Style: Hard-edge,"hard-edge style {prompt} . geometric, flat colors, precision, detailed","organic, gradient colors, imprecise, low detail"
|
||||
Style: Automatism,"automatism style {prompt} . unconscious, spontaneous, abstract, detailed","conscious, planned, realistic, low detail"
|
||||
Style: Tachisme,"tachisme style {prompt} . gestural, abstract, spontaneous, detailed","controlled, realistic, planned, low detail"
|
||||
Style: Lyrical abstraction,"lyrical abstraction style {prompt} . emotional, non-figurative, expressive, detailed","unemotional, figurative, restrained, low detail"
|
||||
Style: Color field,"color field style {prompt} . flat, large fields of color, minimal, detailed","textured, small patches of color, maximal, low detail"
|
||||
Style: Synthetism,"synthetism style {prompt} . simplified, symbolic, bright colors, detailed","complex, literal, muted colors, low detail"
|
||||
Style: Cloisonnism,"cloisonnism style {prompt} . bold outlines, flat colors, decorative, detailed","soft outlines, gradient colors, functional, low detail"
|
||||
Style: Assemblage,"assemblage style {prompt} . three-dimensional, found objects, eclectic, detailed","two-dimensional, traditional materials, uniform, low detail"
|
||||
Style: Vorticism,"vorticism style {prompt} . geometric, abstract, dynamic, detailed","organic, realistic, static, low detail"
|
||||
Style: Op art,"op art style {prompt} . optical illusions, geometric, black and white, detailed","no illusions, organic, colorful, low detail"
|
||||
Style: Divisionism,"divisionism style {prompt} . color theory, dot technique, vibrant, detailed","black and white, smooth technique, muted, low detail"
|
||||
Style: Kinetic art,"kinetic art style {prompt} . movement, dynamic, interactive, detailed","static, static, non-interactive, low detail"
|
||||
Style: Orphism,"orphism style {prompt} . pure color, abstract, musical, detailed","mixed color, realistic, non-musical, low detail"
|
||||
Style: Suprematism,"suprematism style {prompt} . geometric, abstract, limited color palette, detailed","organic, realistic, broad color palette, low detail"
|
||||
Style: Letterism,"letterism style {prompt} . letters, typographic, abstract, detailed","images, non-typographic, realistic, low detail"
|
||||
Style: Situationalist,"situationalist style {prompt} . political, collage, detournement, detailed","apolitical, single medium, straightforward, low detail"
|
||||
Style: Sound art,"sound art style {prompt} . auditory, abstract, non-visual, detailed","visual, realistic, silent, low detail"
|
||||
Style: Land art,"land art style {prompt} . natural materials, outdoor, environmental, detailed","synthetic materials, indoor, non-environmental, low detail"
|
||||
Style: Photorealistic graffiti,"photorealistic graffiti style {prompt} . urban, street art, lifelike, detailed","rural, gallery art, abstract, low detail"
|
||||
Style: Hypermodern,"hypermodern style {prompt} . postmodern, technology focused, sleek, detailed","premodern, nature focused, rustic, low detail"
|
||||
Style: Virtual realism,"virtual realism style {prompt} . digital, lifelike, immersive, detailed","analog, abstract, non-immersive, low detail"
|
||||
Style: Structural film,"structural film style {prompt} . experimental, non-narrative, texture, detailed","traditional, narrative, smooth, low detail"
|
||||
Style: Process art,"process art style {prompt} . creation focused, ephemeral, documentation, detailed","result focused, permanent, no documentation, low detail"
|
||||
Style: Light and space,"light and space style {prompt} . perceptual phenomena, immersive, minimal, detailed","solid objects, non-immersive, maximal, low detail"
|
||||
Style: Post-internet,"post-internet style {prompt} . digital culture, technology, online, detailed","pre-internet, nature, offline, low detail"
|
||||
Style: Bio-art,"bio-art style {prompt} . living organisms, ethical, natural, detailed","inorganic, unethical, synthetic, low detail"
|
||||
>>>>>> GPT Cultural Styles
|
||||
Style: Byzantine,"Byzantine style {prompt} . religious, iconography, gold, highly detailed, mosaics","secular, simple, bronze, minimalist, paintings"
|
||||
Style: Celtic,"Celtic style {prompt} . geometric patterns, intricate knots, medieval, highly detailed","random, simplistic, modern, undetailed"
|
||||
Style: Native American,"Native American style {prompt} . traditional patterns, tribal, cultural symbols, highly detailed","modern, non-tribal, abstract, undetailed"
|
||||
Style: Aboriginal,"Aboriginal style {prompt} . dot painting, Dreamtime stories, Australian culture, highly detailed","non-Australian, line drawing, abstract, undetailed"
|
||||
Style: Egyptian,"Egyptian style {prompt} . hieroglyphs, gods and goddesses, Pharaohs, highly detailed","non-Egyptian, text-free, secular, undetailed"
|
||||
Style: Mayan,"Mayan style {prompt} . glyphs, ancient civilization, detailed carvings, highly detailed","modern, non-Mayan, simplistic, undetailed"
|
||||
Style: Renaissance,"Renaissance style {prompt} . humanism, realism, perspective, highly detailed","abstract, surreal, flat, undetailed"
|
||||
Style: Mughal,"Mughal style {prompt} . Indian and Persian influence, miniature paintings, highly detailed","non-Indian, non-Persian, large-scale, undetailed"
|
||||
Style: Romanesque,"Romanesque style {prompt} . medieval, religious, thick walls, highly detailed","modern, secular, transparent, undetailed"
|
||||
Style: Gothic,"Gothic style {prompt} . medieval, pointed arches, stained glass, highly detailed","modern, round arches, clear glass, undetailed"
|
||||
Style: Baroque,"Baroque style {prompt} . grandeur, drama, chiaroscuro, highly detailed","minimalist, calm, flat, undetailed"
|
||||
Style: Rococo,"Rococo style {prompt} . ornate, pastel, love and nature themes, highly detailed","simple, dark, abstract, undetailed"
|
||||
Style: Pre-Raphaelite,"Pre-Raphaelite style {prompt} . romantic, vivid color, medieval subjects, highly detailed","realistic, muted color, modern subjects, undetailed"
|
||||
Style: Impressionist,"Impressionist style {prompt} . loose brushwork, light and color, ordinary subjects, highly detailed","tight brushwork, black and white, extraordinary subjects, undetailed"
|
||||
Style: Cubist,"Cubist style {prompt} . geometric, multi-perspective, fragmented, highly detailed","organic, single perspective, whole, undetailed"
|
||||
Style: Surrealist,"Surrealist style {prompt} . dreamlike, irrational, unexpected juxtapositions, highly detailed","realistic, rational, expected combinations, undetailed"
|
||||
Style: Futurist,"Futurist style {prompt} . dynamic, technology, speed, highly detailed","static, nature, slow, undetailed"
|
||||
Style: Dada,"Dada style {prompt} . absurd, anti-art, randomness, highly detailed","rational, pro-art, order, undetailed"
|
||||
Style: Expressionist,"Expressionist style {prompt} . emotional, distorted, individual perspective, highly detailed","unemotional, realistic, collective perspective, undetailed"
|
||||
Style: Fauvist,"Fauvist style {prompt} . bold color, wild brushwork, simplification, highly detailed","muted color, careful brushwork, detail, undetailed"
|
||||
Style: Socialist Realist,"Socialist Realist style {prompt} . idealized, political, proletarian, highly detailed","realistic, apolitical, bourgeois, undetailed"
|
||||
Style: Pop Art,"Pop Art style {prompt} . popular culture, advertising, bold, highly detailed","high art, non-commercial, muted, undetailed"
|
||||
Style: Suprematism,"Suprematism style {prompt} . geometric, non-objective, primary colors, highly detailed","organic, objective, pastel colors, undetailed"
|
||||
Style: Symbolist,"Symbolist style {prompt} . mythical, dreamy, spiritual, highly detailed","realistic, practical, secular, undetailed"
|
||||
Style: Pre-Columbian,"Pre-Columbian style {prompt} . ancient Americas, native, cultural, highly detailed","modern, non-American, abstract, undetailed"
|
||||
Style: Constructivist,"Constructivist style {prompt} . industrial, geometric, socialist, highly detailed","organic, round, capitalist, undetailed"
|
||||
Style: Art Nouveau,"Art Nouveau style {prompt} . decorative, nature-inspired, curved lines, highly detailed","functional, geometric, straight lines, undetailed"
|
||||
Style: Precisionist,"Precisionist style {prompt} . industrial, crisp, geometric, highly detailed","organic, blurry, round, undetailed"
|
||||
Style: Neoclassical,"Neoclassical style {prompt} . ancient Rome and Greece, rational, heroic, highly detailed","modern, emotional, ordinary, undetailed"
|
||||
Style: Persian Miniature,"Persian Miniature style {prompt} . Middle Eastern, intricate, storytelling, highly detailed","Western, simple, non-narrative, undetailed"
|
||||
Style: Edo,"Edo style {prompt} . Japanese, woodblock prints, floating world, highly detailed","non-Japanese, oil painting, real world, undetailed"
|
||||
Style: Tribal,"Tribal style {prompt} . African, indigenous, symbolic, highly detailed","non-African, mainstream, abstract, undetailed"
|
||||
Style: Tibetan Thangka,"Tibetan Thangka style {prompt} . spiritual, Buddhist, meditation, highly detailed","secular, non-Buddhist, disturbing, undetailed"
|
||||
Style: Art Deco,"Art Deco style {prompt} . modern, geometric, luxury, highly detailed","vintage, organic, minimalism, undetailed"
|
||||
Style: Minimalist,"Minimalist style {prompt} . simple, functional, unadorned, highly detailed","complex, decorative, adorned, undetailed"
|
||||
Style: Greek Classical,"Greek Classical style {prompt} . ancient, mythology, balanced, highly detailed","modern, everyday life, unbalanced, undetailed"
|
||||
Style: African,"African style {prompt} . tribal, symbolic, cultural, highly detailed","non-African, abstract, non-cultural, undetailed"
|
||||
Style: Russian Iconography,"Russian Iconography style {prompt} . religious, orthodox, gold, highly detailed","secular, non-orthodox, silver, undetailed"
|
||||
Style: Nordic,"Nordic style {prompt} . Scandinavian, minimal, nature, highly detailed","non-Scandinavian, maximal, urban, undetailed"
|
||||
Style: Inuit,"Inuit style {prompt} . Arctic, native, animal themes, highly detailed","tropical, non-native, human themes, undetailed"
|
||||
Style: Maori,"Maori style {prompt} . New Zealand, tribal, spiritual, highly detailed","non-New Zealand, non-tribal, secular, undetailed"
|
||||
Style: Iznik,"Iznik style {prompt} . Turkish, ceramic, floral, highly detailed","non-Turkish, canvas, geometric, undetailed"
|
||||
Style: Ottoman,"Ottoman style {prompt} . Islamic, calligraphy, miniatures, highly detailed","non-Islamic, typography, large-scale, undetailed"
|
||||
Style: Hanami,"Hanami style {prompt} . Japanese, cherry blossoms,spring, highly detailed","non-Japanese, winter, abstract, undetailed"
|
||||
Style: Mandala,"Mandala style {prompt} . spiritual, geometric, symmetrical, highly detailed","secular, organic, asymmetrical, undetailed"
|
||||
Style: Aztec,"Aztec style {prompt} . ancient Mexico, symbolic, cultural, highly detailed","modern, abstract, non-cultural, undetailed"
|
||||
Style: Sumi-e,"Sumi-e style {prompt} . Japanese ink painting, minimal, nature, highly detailed","non-Japanese, colorful, urban, undetailed"
|
||||
Style: Ukiyo-e,"Ukiyo-e style {prompt} . Japanese, woodblock prints, floating world, highly detailed","non-Japanese, digital art, real world, undetailed"
|
||||
Style: Haida,"Haida style {prompt} . Native American, form line, nature, highly detailed","non-Native American, abstract, urban, undetailed"
|
||||
Style: Moorish,"Moorish style {prompt} . Islamic, geometric, Andalusian, highly detailed","non-Islamic, organic, non-Andalusian, undetailed"
|
||||
Style: Victorian,"Victorian style {prompt} . 19th century, ornate, romantic, highly detailed","21st century, minimal, unemotional, undetailed"
|
||||
Style: Pueblo,"Pueblo style {prompt} . Native American, traditional, pottery, highly detailed","non-Native American, modern, photography, undetailed"
|
||||
Style: Cloisonné,"Cloisonné style {prompt} . metalwork, enamel, intricate, highly detailed","woodwork, paint, simple, undetailed"
|
||||
Style: Khokhloma,"Khokhloma style {prompt} . Russian, folk art, floral, highly detailed","non-Russian, fine art, geometric, undetailed"
|
||||
Style: Biedermeier,"Biedermeier style {prompt} . 19th century, domestic, unpretentious, highly detailed","21st century, public, pretentious, undetailed"
|
||||
Style: Goryeo,"Goryeo style {prompt} . Korean, celadon, inlay, highly detailed","non-Korean, terra cotta, relief, undetailed"
|
||||
Style: Han,"Han style {prompt} . Chinese, ancient, stone relief, highly detailed","non-Chinese, modern, oil painting, undetailed"
|
||||
Style: Hellenistic,"Hellenistic style {prompt} . ancient Greek, dynamic, emotional, highly detailed","modern, static, unemotional, undetailed"
|
||||
Style: Tang,"Tang style {prompt} . Chinese, ancient, sculpture, highly detailed","non-Chinese, modern, photography, undetailed"
|
||||
Style: Ming,"Ming style {prompt} . Chinese, elegant, pottery, highly detailed","non-Chinese, rustic, painting, undetailed"
|
||||
Style: Joseon,"Joseon style {prompt} . Korean, Confucian, painting, highly detailed","non-Korean, Taoist, sculpture, undetailed"
|
||||
Style: Gupta,"Gupta style {prompt} . Indian, ancient, sculpture, highly detailed","non-Indian, modern, painting, undetailed"
|
||||
Style: Pallava,"Pallava style {prompt} . Indian, Dravidian architecture, sculpture, highly detailed","non-Indian, Mughal architecture, painting, undetailed"
|
||||
Style: Chola,"Chola style {prompt} . Indian, bronze, dancing Shiva, highly detailed","non-Indian, marble, sitting Buddha, undetailed"
|
||||
Style: Minoan,"Minoan style {prompt} . ancient Crete, frescoes, sea life, highly detailed","modern, oil painting, land animals, undetailed"
|
||||
Style: Mycenaean,"Mycenaean style {prompt} . ancient Greece, gold, death mask, highly detailed","modern, bronze, life mask, undetailed"
|
||||
Style: Ndebele,"Ndebele style {prompt} . African, geometric, house painting, highly detailed","non-African, organic, canvas painting, undetailed"
|
||||
Style: San,"San style {prompt} . African, rock art, animal figures, highly detailed","non-African, digital art, human figures, undetailed"
|
||||
Style: Batik,"Batik style {prompt} . Indonesian, resist dyeing, floral, highly detailed","non-Indonesian, direct dyeing, geometric, undetailed"
|
||||
Style: Assyrian,"Assyrian style {prompt} . ancient Mesopotamia, relief, war scenes, highly detailed","modern, oil painting, peaceful scenes, undetailed"
|
||||
Style: Thracian,"Thracian style {prompt} . ancient Balkans, gold, ritual objects, highly detailed","modern, wood, everyday objects, undetailed"
|
||||
Style: Etruscan,"Etruscan style {prompt} . ancient Italy, bronze, mythological scenes, highly detailed","modern, steel, realistic scenes, undetailed"
|
||||
Style: Sumerian,"Sumerian style {prompt} . ancient Mesopotamia, cuneiform, clay tablets, highly detailed","modern, Latin script, parchment scrolls, undetailed"
|
||||
Style: Babylonian,"Babylonian style {prompt} . ancient Mesopotamia, law codes, stone steles, highly detailed","modern, lawless, paper books, undetailed"
|
||||
Style: Norse,"Norse style {prompt} . Viking, runic, wood carving, highly detailed","non-Viking, Latin script, metalwork, undetailed"
|
||||
Style: Olmec,"Olmec style {prompt} . ancient Mexico, colossal heads, basalt, highly detailed","modern, miniature hands, marble, undetailed"
|
||||
Style: Toltec,"Toltec style {prompt} . ancient Mexico, monumental architecture, relief, highly detailed","modern, small-scale models, oil painting, undetailed"
|
||||
Style: Sicán,"Sicán style {prompt} . ancient Peru, gold masks, funerary objects, highly detailed","modern, wood masks, everyday objects, undetailed"
|
||||
Style: Nazca,"Nazca style {prompt} . ancient Peru, geoglyphs, desert, highly detailed","modern, graffiti, urban, undetailed"
|
||||
Style: Inca,"Inca style {prompt} . ancient Peru, stonework, terraces, highly detailed","modern, woodwork, flat plains, undetailed"
|
||||
Style: Zapotec,"Zapotec style {prompt} . ancient Mexico, urns, jaguars, highly detailed","modern, vases, dogs, undetailed"
|
||||
Style: Mixtec,"Mixtec style {prompt} . ancient Mexico, codices, turquoise, highly detailed","modern, novels, gold, undetailed"
|
||||
Style: Ottonian,"Ottonian style {prompt} . medieval Germany, religious art, manuscripts, highly detailed","modern, secular art, newspapers, undetailed"
|
||||
Style: Merovingian,"Merovingian style {prompt} . medieval France, jewelry, garnet cloisonné, highly detailed","modern, clothing, sapphire pavé, undetailed"
|
||||
Style: Carolingian,"Carolingian style {prompt} . medieval Europe, illuminatedmanuscripts, luxury, highly detailed","modern, paperback books, simplicity, undetailed"
|
||||
Style: Otomi,"Otomi style {prompt} . Mexican, textile, embroidery, highly detailed","non-Mexican, metalwork, hammering, undetailed"
|
||||
Style: Huichol,"Huichol style {prompt} . Mexican, yarn painting, spiritual, highly detailed","non-Mexican, oil painting, secular, undetailed"
|
||||
Style: Ainu,"Ainu style {prompt} . Japanese indigenous, wood carving, bear worship, highly detailed","non-Japanese, stone carving, dragon worship, undetailed"
|
||||
Style: Maori,"Maori style {prompt} . New Zealand, tattoo, spiritual, highly detailed","non-New Zealand, body paint, secular, undetailed"
|
||||
Style: Aboriginal,"Aboriginal style {prompt} . Australian indigenous, dot painting, storytelling, highly detailed","non-Australian, line drawing, non-narrative, undetailed"
|
||||
Style: Inuit,"Inuit style {prompt} . Arctic, stone carving, animal figures, highly detailed","tropical, wood carving, human figures, undetailed"
|
||||
Style: Saami,"Saami style {prompt} . Nordic indigenous, duodji (craft), reindeer, highly detailed","non-Nordic, factory-made, cow, undetailed"
|
||||
Style: Ojibwe,"Ojibwe style {prompt} . Native American, birch bark, canoes, highly detailed","non-Native American, pine bark, rafts, undetailed"
|
||||
Style: Tlingit,"Tlingit style {prompt} . Native American, totem poles, spiritual, highly detailed","non-Native American, street signs, secular, undetailed"
|
||||
Style: Navajo,"Navajo style {prompt} . Native American, textile, rug weaving, highly detailed","non-Native American, metalwork, jewelry making, undetailed"
|
||||
Style: Apache,"Apache style {prompt} . Native American, basketry, coiled, highly detailed","non-Native American, pottery, thrown, undetailed"
|
||||
Style: Zuni,"Zuni style {prompt} . Native American, jewelry, silver, highly detailed","non-Native American, clothing, cotton, undetailed"
|
||||
Style: Hopi,"Hopi style {prompt} . Native American, kachina dolls, spiritual, highly detailed","non-Native American, action figures, secular, undetailed"
|
||||
Style: Sioux,"Sioux style {prompt} . Native American, quillwork, porcupine, highly detailed","non-Native American, embroidery, silk, undetailed"
|
||||
Style: Lakota,"Lakota style {prompt} . Native American, beadwork, clothing, highly detailed","non-Native American, sequin work, banners, undetailed"
|
||||
Style: Yupik,"Yupik style {prompt} . Native American, mask, ceremonial, highly detailed","non-Native American, mask, recreational, undetailed"
|
||||
Style: Cherokee,"Cherokee style {prompt} . Native American, pottery, stamped, highly detailed","non-Native American, pottery, painted, undetailed"
|
||||
Style: Mohawk,"Mohawk style {prompt} . Native American, sweetgrass, basketry, highly detailed","non-Native American, bamboo, basketry, undetailed"
|
||||
Style: Cree,"Cree style {prompt} . Native American, hide, clothing, highly detailed","non-Native American, synthetic material, clothing, undetailed"
|
||||
Style: Acoma,"Acoma style {prompt} . Native American, pottery, sky city, highly detailed","non-Native American, pottery, earth city, undetailed"
|
||||
Style: Laguna,"Laguna style {prompt} . Native American, pottery, polychrome, highly detailed","non-Native American, pottery, monochrome, undetailed"
|
||||
Style: Seminole,"Seminole style {prompt} . Native American, patchwork, clothing, highly detailed","non-Native American, knitting, clothing, undetailed"
|
||||
Style: Osage,"Osage style {prompt} . Native American, ribbon work, floral, highly detailed","non-Native American, beadwork, geometric, undetailed"
|
||||
Style: Anasazi,"Anasazi style {prompt} . Native American, pottery, black-on-white, highly detailed","non-Native American, pottery, color-on-color, undetailed"
|
||||
Style: Mimbres,"Mimbres style {prompt} . Native American, pottery, figurative, highly detailed","non-Native American, pottery, abstract, undetailed"
|
||||
Style: Pomo,"Pomo style {prompt} . Native American, basketry, feathers, highly detailed","non-Native American, basketry, beads, undetailed"
|
||||
Style: Hohokam,"Hohokam style {prompt} . Native American, pottery, red-on-buff, highly detailed","non-Native American, pottery, blue-on-cream, undetailed"
|
||||
Style: Mississippian,"Mississippian style {prompt} . Native American, stone carving, ceremonial, highly detailed","non-Native American, wood carving, everyday, undetailed"
|
||||
Style: Fremont,"Fremont style {prompt} . Native American, petroglyphs, rock art, highly detailed","non-Native American, graffiti, wall art, undetailed"
|
||||
Style: Mogollon,"Mogollon style {prompt} . Native American, pottery, geometric, highly detailed","non-Native American, pottery, organic, undetailed"
|
||||
Style: Salado,"Salado style {prompt} . Native American, pottery, polychrome, highly detailed","non-Native American, pottery, duochrome, undetailed"
|
||||
Style: Zulu,"Zulu style {prompt} . African, basketry, coiled, highly detailed","non-African, pottery, thrown, undetailed"
|
||||
Style: Maasai,"Maasai style {prompt} . African, beadwork, jewelry, highly detailed","non-African, macramé, wall hanging, undetailed"
|
||||
Style: Ndebele,"Ndebele style {prompt} . African, mural art, homes, highly detailed","non-African, canvas art, studios, undetailed"
|
||||
Style: Kuba,"Kuba style {prompt} . African, textile, raffia, highly detailed","non-African, metalwork, steel, undetailed"
|
||||
Style: Yoruba,"Yoruba style {prompt} . African, sculpture, spiritual, highly detailed","non-African, photography, secular, undetailed"
|
||||
Style: Akan,"Akan style {prompt} . African, gold weights, symbolic, highly detailed","non-African, silver weights, literal, undetailed"
|
||||
Style: Berber,"Berber style {prompt} . North African, jewelry, silver, highly detailed","non-North African, clothing, cotton, undetailed"
|
||||
Style: Dogon,"Dogon style {prompt} . African, wood carving, spiritual, highly detailed","non-African, stone carving, secular, undetailed"
|
||||
Style: Fang,"Fang style {prompt} . African, mask, ceremonial, highly detailed","non-African, mask, recreational, undetailed"
|
||||
Style: Baga,"Baga style {prompt} . African, mask, spiritual, highly detailed","non-African, mask, secular, undetailed"
|
||||
>>>>>> GPT Culture Movies Prompts
|
||||
Style: Blade Runner,"Blade Runner {prompt} . Cyberpunk, neon-lit, rainy, dystopian, noir, cinematic, highly detailed","bright, sunny, utopian, cheerful, undetailed"
|
||||
Style: Star Wars,"Star Wars {prompt} . Space opera, galaxy far, far away, epic, iconic, cinematic, highly detailed","earthly, small scale, uniconic, undetailed"
|
||||
Style: Lord of the Rings,"Lord of the Rings {prompt} . Epic fantasy, Middle-earth, vast landscapes, highly detailed","science fiction, cityscape, undetailed"
|
||||
Style: Matrix,"Matrix {prompt} . Cyberpunk, green tint, reality-bending, cinematic, highly detailed","rustic, brown tint, reality-based, undetailed"
|
||||
Style: Indiana Jones,"Indiana Jones {prompt} . Adventure, archaeology, exotic locations, cinematic, highly detailed","domestic, library, unadventurous, undetailed"
|
||||
Style: Mad Max,"Mad Max {prompt} . Post-apocalyptic, desert landscapes, dystopian, cinematic, highly detailed","utopian, lush landscapes, pre-apocalyptic, undetailed"
|
||||
Style: 2001: A Space Odyssey,"2001: A Space Odyssey {prompt} . Sci-fi, space exploration, monolith, cinematic, highly detailed","fantasy, earth exploration, monochrome, undetailed"
|
||||
Style: Alien,"Alien {prompt} . Sci-fi horror, space, xenomorphs, dark, highly detailed","comedy, bright, undetailed"
|
||||
Style: Avatar,"Avatar {prompt} . Sci-fi, Pandora, bioluminescent, 3D, highly detailed","earthly, non-bioluminescent, 2D, undetailed"
|
||||
Style: Pulp Fiction,"Pulp Fiction {prompt} . Crime, non-linear narrative, 90s, highly detailed","linear narrative, 2000s, undetailed"
|
||||
Style: Kill Bill,"Kill Bill {prompt} . Martial arts, vengeance, yellow jumpsuit, cinematic, highly detailed","peaceful, pink jumpsuit, undetailed"
|
||||
Style: Inception,"Inception {prompt} . Sci-fi, dream within a dream, mind-bending, cinematic, highly detailed","reality-based, straightforward, undetailed"
|
||||
Style: Fight Club,"Fight Club {prompt} . Dark, gritty, psychological drama, highly detailed","light, glossy, undramatic, undetailed"
|
||||
Style: Harry Potter,"Harry Potter {prompt} . Fantasy, Hogwarts, wizardry, highly detailed","science fiction, non-magical, undetailed"
|
||||
Style: Marvel Cinematic Universe,"Marvel Cinematic Universe {prompt} . Superheroes, epic battles, colorful, highly detailed","ordinary people, small conflicts, monochrome, undetailed"
|
||||
Style: DC Extended Universe,"DC Extended Universe {prompt} . Superheroes, grim, darker tones, highly detailed","ordinary people, cheerful, brighter tones, undetailed"
|
||||
Style: Game of Thrones,"Game of Thrones {prompt} . Fantasy, Westeros, dragons, highly detailed","science fiction, no dragons, undetailed"
|
||||
Style: Twilight,"Twilight {prompt} . Romantic fantasy, vampires, Pacific Northwest, highly detailed","non-romantic, zombies, desert, undetailed"
|
||||
Style: Transformers,"Transformers {prompt} . Sci-fi, giant robots, explosions, highly detailed","fantasy, small creatures, calm, undetailed"
|
||||
Style: The Hunger Games,"The Hunger Games {prompt} . Dystopian, survival, rebellion, highly detailed","utopian, abundance, conformity, undetailed"
|
||||
Style: Pirates of the Caribbean,"Pirates of the Caribbean {prompt} . Adventure, pirates, supernatural, highly detailed","domestic, non-pirates, realistic, undetailed"
|
||||
Style: Jurassic Park,"Jurassic Park {prompt} . Adventure, dinosaurs, Isla Nublar, highly detailed","undramatic, no dinosaurs, mainland, undetailed"
|
||||
Style: The Shining,"The Shining {prompt} . Horror, haunted hotel, psychological thriller, highly detailed","comedy, non-haunted hotel, undetailed"
|
||||
Style: The Godfather,"The Godfather {prompt} . Crime, mafia, 1940s-1950s, highly detailed","law-abiding, 2000s, undetailed"
|
||||
Style: The Dark Knight,"The Dark Knight {prompt} . Superhero, gritty, Batman, Joker, highly detailed","light-hearted, Superman, undetailed"
|
||||
Style: Casablanca,"Casablanca {prompt} . Drama, romance, WWII, highly detailed","action, non-romantic, modern day, undetailed"
|
||||
Style: Jaws,"Jaws {prompt} . Thriller, shark, Amity Island, highly detailed","comedy, no shark, mainland, undetailed"
|
||||
Style: The Wizard of Oz,"The Wizard of Oz {prompt} . Fantasy, musical, Technicolor, Oz, highly detailed","realistic, non-musical, monochrome, Kansas, undetailed"
|
||||
Style: E.T.,"E.T. {prompt} . Sci-fi, family, suburban, highly detailed","fantasy, non-family, urban, undetailed"
|
||||
Style: Ghostbusters,"Ghostbusters {prompt} . Comedy, supernatural, New York City, highly detailed","horror, natural, rural, undetailed"
|
||||
Style: Back to the Future,"Back to the Future {prompt} . Sci-fi, time travel, DeLorean, highly detailed","fantasy, time stationary, non-vehicle, undetailed"
|
||||
Style: Toy Story,"Toy Story {prompt} . Animated, toys come to life, friendship, highly detailed","live-action, inanimate toys, rivalry, undetailed"
|
||||
Style: The Lion King,"The Lion King {prompt} . Animated, animal kingdom, African savannah, highly detailed","live-action, human kingdom, urban, undetailed"
|
||||
Style: Finding Nemo,"Finding Nemo {prompt} . Animated, ocean adventure, Great Barrier Reef, highly detailed","live-action, land adventure, desert, undetailed"
|
||||
Style: Shrek,"Shrek {prompt} . Animated, fairytale, swamp, highly detailed","live-action, realistic, city, undetailed"
|
||||
Style: The Little Mermaid,"The Little Mermaid {prompt} . Animated, undersea, mermaids, highly detailed","live-action, land, humans, undetailed"
|
||||
Style: Aladdin,"Aladdin {prompt} . Animated, Arabian Nights, magic carpet, highly detailed","live-action, modern day, ordinary carpet, undetailed"
|
||||
Style: Beauty and the Beast,"Beauty and the Beast {prompt} . Animated, fairytale, enchanted castle, highly detailed","live-action, realistic, ordinary house, undetailed"
|
||||
Style: Cinderella,"Cinderella {prompt} . Animated, fairytale, magical transformation, highly detailed","live-action, realistic, ordinary transformation, undetailed"
|
||||
Style: Sleeping Beauty,"Sleeping Beauty {prompt} . Animated, fairytale, spinning wheel, highly detailed",""live-action, realistic, sewing machine, undetailed"
|
||||
Style: Snow White,"Snow White {prompt} . Animated, fairytale, seven dwarfs, highly detailed","live-action, realistic, seven giants, undetailed"
|
||||
Style: Mulan,"Mulan {prompt} . Animated, historical, Chinese warfare, highly detailed","live-action, futuristic, space warfare, undetailed"
|
||||
Style: Pocahontas,"Pocahontas {prompt} . Animated, historical, Native American, highly detailed","live-action, modern, urban American, undetailed"
|
||||
Style: The Nightmare Before Christmas,"The Nightmare Before Christmas {prompt} . Stop-motion, Halloween Town, Christmas Town, highly detailed","live-action, Easter Town, undetailed"
|
||||
Style: Frozen,"Frozen {prompt} . Animated, fairytale, ice magic, highly detailed","live-action, realistic, fire magic, undetailed"
|
||||
Style: Moana,"Moana {prompt} . Animated, Polynesian, ocean adventure, highly detailed","live-action, Nordic, mountain adventure, undetailed"
|
||||
Style: Tangled,"Tangled {prompt} . Animated, fairytale, magic hair, highly detailed","live-action, realistic, ordinary hair, undetailed"
|
||||
Style: Zootopia,"Zootopia {prompt} . Animated, anthropomorphic animals, urban, highly detailed","live-action, humans, rural, undetailed"
|
||||
Style: Coco,"Coco {prompt} . Animated, Dia de los Muertos, Mexican culture, highly detailed","live-action, Halloween, American culture, undetailed"
|
||||
Style: Brave,"Brave {prompt} . Animated, Scottish highlands, archery, highly detailed","live-action, tropical island, surfing, undetailed"
|
||||
Style: Inside Out,"Inside Out {prompt} . Animated, emotions, abstract, highly detailed","live-action, logical thinking, realistic, undetailed"
|
||||
Style: The Incredibles,"The Incredibles {prompt} . Animated, superhero, family, highly detailed","live-action, villain, solitary, undetailed"
|
||||
Style: Up,"Up {prompt} . Animated, adventure, flying house, highly detailed","live-action, everyday life, stationary house, undetailed"
|
||||
Style: Wall-E,"Wall-E {prompt} . Animated, post-apocalyptic, robots, highly detailed","live-action, pre-apocalyptic, humans, undetailed"
|
||||
Style: Ratatouille,"Ratatouille {prompt} . Animated, culinary, Paris, highly detailed","live-action, non-culinary, New York, undetailed"
|
||||
Style: Monsters Inc.,"Monsters Inc. {prompt} . Animated, monsters, scare factory, highly detailed","live-action, humans, laughter factory, undetailed"
|
||||
Style: Cars,"Cars {prompt} . Animated, anthropomorphic cars, racing, highly detailed","live-action, humans, walking, undetailed"
|
||||
Style: A Bug's Life,"A Bug's Life {prompt} . Animated, insects, ant colony, highly detailed","live-action, mammals, human society, undetailed"
|
||||
Style: James Bond,"James Bond {prompt} . Spy, action, globe-trotting, highly detailed","romantic comedy, peace, domestic, undetailed"
|
||||
Style: Fast and Furious,"Fast and Furious {prompt} . Action, car chases, family, highly detailed","romantic comedy, pedestrian chases, solitary, undetailed"
|
||||
Style: Mission Impossible,"Mission Impossible {prompt} . Action, spy, impossible stunts, highly detailed","romantic comedy, everyday person, possible stunts, undetailed"
|
||||
Style: Jurassic World,"Jurassic World {prompt} . Adventure, dinosaurs, theme park, highly detailed","romantic comedy, no dinosaurs, city park, undetailed"
|
||||
Style: Minions,"Minions {prompt} . Animated, comedy, minions, highly detailed","live-action, drama, no minions, undetailed"
|
||||
Style: Interstellar,"Interstellar {prompt} . Sci-fi, space travel, wormholes, highly detailed","romantic comedy, earth travel, roads, undetailed"
|
||||
Style: The Grinch,"The Grinch {prompt} . Animated, Christmas, Whoville, highly detailed","live-action, summer, city, undetailed"
|
||||
Style: Avengers: Endgame,"Avengers: Endgame {prompt} . Superhero, epic battle, time travel, highly detailed","romantic comedy, small conflict, present time, undetailed"
|
||||
Style: Wonder Woman,"Wonder Woman {prompt} . Superhero, Amazonian, World War I, highly detailed","romantic comedy, non-Amazonian, modern day, undetailed"
|
||||
Style: The Iron Giant,"The Iron Giant {prompt} . Animated, robot, 1950s, highly detailed","live-action, human, modern day, undetailed"
|
||||
Style: Godzilla,"Godzilla {prompt} . Monster, destruction, cityscape, highly detailed","romantic comedy, creation, countryside, undetailed"
|
||||
Style: King Kong,"King Kong {prompt} . Monster, island, skyscraper, highly detailed","romantic comedy, mainland, low-rise, undetailed"
|
||||
Style: The Grand Budapest Hotel,"The Grand Budapest Hotel {prompt} . Comedy, hotel, pastel colors, highly detailed","action, wilderness, dark colors, undetailed"
|
||||
Style: Inside Llewyn Davis,"Inside Llewyn Davis {prompt} . Drama, folk music, 1960s, highly detailed","action, pop music, modern day, undetailed"
|
||||
Style: Drive,"Drive {prompt} . Action, neon, 1980s aesthetic, highly detailed","romantic comedy, daylight, modern aesthetic, undetailed"
|
||||
Style: The Neon Demon,"The Neon Demon {prompt} . Horror, fashion, Los Angeles, highly detailed","romantic comedy, construction, New York, undetailed"
|
||||
Style: It Follows,"It Follows {prompt} . Horror, supernatural, suburbia, highly detailed","romantic comedy, natural, city, undetailed"
|
||||
Style: Dunkirk,"Dunkirk {prompt} . War, World War II, beach, highly detailed","romantic comedy, peace, city, undetailed"
|
||||
Style: Her,"Her {prompt} . Romance, sci-fi, artificial intelligence, highly detailed","action, reality, human intelligence, undetailed"
|
||||
Style: The Revenant,"The Revenant {prompt} . Drama, survival, wilderness, highly detailed","romantic comedy, luxury, city, undetailed"
|
||||
Style: Whiplash,"Whiplash {prompt} . Drama, music, drumming, highly detailed","action, silence, no music, undetailed"
|
||||
Style: The Shape of Water,"The Shape of Water {prompt} . Fantasy, romance, aquatic creature, highly detailed","action, hatred, terrestrial creature, undetailed"
|
||||
Style: A Ghost Story,"A Ghost Story {prompt} . Drama, supernatural, ghost, highly detailed","romantic comedy, natural, human, undetailed"
|
||||
Style: The Florida Project,"The Florida Project {prompt} . Drama, childhood, motel, highly detailed","action, adulthood, skyscraper, undetailed"
|
||||
Style: La La Land,"La La Land {prompt} . Musical, romance, Los Angeles, highly detailed","action, hatred, New York, undetailed"
|
||||
Style: The Lobster,"The Lobster {prompt}". Dark comedy, dystopian, relationship rules, highly detailed","romantic comedy, utopian, no relationship rules, undetailed"
|
||||
Style: Ex Machina,"Ex Machina {prompt} . Sci-fi, artificial intelligence, secluded mansion, highly detailed","romantic comedy, human intelligence, bustling city, undetailed"
|
||||
Style: Birdman,"Birdman {prompt} . Drama, Broadway, magical realism, highly detailed","action, Hollywood, realism, undetailed"
|
||||
Style: Gravity,"Gravity {prompt} . Sci-fi, space, survival, highly detailed","romantic comedy, earth, abundance, undetailed"
|
||||
Style: The Tree of Life,"The Tree of Life {prompt} . Drama, philosophical, nonlinear narrative, highly detailed","action, practical, linear narrative, undetailed"
|
||||
Style: Inception,"Inception {prompt} . Sci-fi, dream manipulation, heist, highly detailed","romantic comedy, reality, gift-giving, undetailed"
|
||||
Style: The Social Network,"The Social Network {prompt} . Drama, Facebook, entrepreneurship, highly detailed","action, Myspace, employment, undetailed"
|
||||
Style: Moonlight,"Moonlight {prompt} . Drama, coming-of-age, Miami, highly detailed","action, aging, Los Angeles, undetailed"
|
||||
Style: Roma,"Roma {prompt} . Drama, Mexico City, 1970s, highly detailed","action, New York City, modern day, undetailed"
|
||||
Style: Parasite,"Parasite {prompt} . Thriller, class disparity, South Korea, highly detailed","romantic comedy, class equality, United States, undetailed"
|
||||
Style: 1917,"1917 {prompt} . War, World War I, single shot, highly detailed","romantic comedy, peace, multiple shots, undetailed"
|
||||
Style: Jojo Rabbit,"Jojo Rabbit {prompt} . Comedy, World War II, imaginary friend, highly detailed","drama, modern day, real friend, undetailed"
|
||||
Style: Joker,"Joker {prompt} . Drama, psychological, Gotham City, highly detailed","romantic comedy, psychological well-being, Metropolis, undetailed"
|
||||
Style: The Lighthouse,"The Lighthouse {prompt} . Drama, isolation, lighthouse, highly detailed","romantic comedy, community, city, undetailed"
|
||||
Style: Once Upon a Time in Hollywood,"Once Upon a Time in Hollywood {prompt} . Comedy-drama, 1960s Hollywood, film industry, highly detailed","action, modern Hollywood, tech industry, undetailed"
|
||||
Style: The Irishman,"The Irishman {prompt} . Crime, mafia, aging, highly detailed","romantic comedy, law-abiding citizens, youth, undetailed"
|
||||
Style: Uncut Gems,"Uncut Gems {prompt} . Crime, debt, gambling, highly detailed","romantic comedy, abundance, saving, undetailed"
|
||||
Style: Little Women,"Little Women {prompt} . Drama, coming-of-age, Civil War era, highly detailed","action, aging, modern day, undetailed"
|
||||
Style: Knives Out,"Knives Out {prompt} . Mystery, whodunit, wealthy family, highly detailed","romantic comedy, clear culprit, poor family, undetailed"
|
||||
Style: Marriage Story,"Marriage Story {prompt} . Drama, divorce, bi-coastal, highly detailed","romantic comedy, marriage, same city, undetailed"
|
||||
Style: Midsommar,"Midsommar {prompt} . Horror, cult, Sweden, highly detailed","romantic comedy, mainstream religion, United States, undetailed"
|
||||
Style: Booksmart,"Booksmart {prompt} . Comedy, high school, overachievers, highly detailed","drama, college, underachievers, undetailed"
|
||||
Style: Ford v Ferrari,"Ford v Ferrari {prompt} . Drama, racing, 1960s, highly detailed","romantic comedy, walking, modern day, undetailed"
|
||||
Style: Rocketman,"Rocketman {prompt} . Musical, biographical, Elton John, highly detailed","action, fictional, ordinary person, undetailed"
|
||||
Style: Ad Astra,"Ad Astra {prompt} . Sci-fi, space travel, father-son relationship, highly detailed","romantic comedy, earth travel, romantic relationship, undetailed"
|
||||
Style: Waves,"Waves {prompt} . Drama, family tragedy, forgiveness, highly detailed","romantic comedy, family comedy, grudge, undetailed"
|
||||
Style: The Farewell,"The Farewell {prompt} . Drama, family, cultural conflict, highly detailed","romantic comedy, strangers, cultural harmony, undetailed"
|
||||
Style: Hustlers,"Hustlers {prompt} . Drama, strippers, financial crime, highly detailed","romantic comedy, office workers, financial responsibility, undetailed"
|
||||
Style: Portrait of a Lady on Fire,"Portrait of a Lady on Fire {prompt} . Romance, art, 18th century France, highly detailed","action, science, modern day United States, undetailed"
|
||||
Style: Pain and Glory,"Painand Glory {prompt} . Drama, filmmaking, memory, highly detailed","romantic comedy, accounting, forgetfulness, undetailed"
|
||||
Style: The Two Popes,"The Two Popes {prompt} . Drama, Vatican, philosophical discussions, highly detailed","action, a small town, physical challenges, undetailed"
|
||||
Style: A Beautiful Day in the Neighborhood,"A Beautiful Day in the Neighborhood {prompt} . Drama, Fred Rogers, kindness, highly detailed","action, a villainous character, ruthlessness, undetailed"
|
||||
Style: The Peanut Butter Falcon,"The Peanut Butter Falcon {prompt} . Adventure, friendship, wrestling, highly detailed","romantic comedy, rivalry, chess, undetailed"
|
||||
Style: The Goldfinch,"The Goldfinch {prompt} . Drama, art, trauma, highly detailed","action, science, joy, undetailed"
|
||||
Style: High Life,"High Life {prompt} . Sci-fi, space travel, isolation, highly detailed","romantic comedy, road trip, companionship, undetailed"
|
||||
Style: The Nightingale,"The Nightingale {prompt} . Drama, revenge, colonial Tasmania, highly detailed","romantic comedy, forgiveness, modern California, undetailed"
|
||||
Style: Yesterday,"Yesterday {prompt} . Comedy, music, The Beatles, highly detailed","drama, silence, unknown band, undetailed"
|
||||
Style: Doctor Sleep,"Doctor Sleep {prompt} . Horror, supernatural, The Shining sequel, highly detailed","romantic comedy, natural, standalone story, undetailed"
|
||||
Style: The Farewell,"The Farewell {prompt} . Drama, family, terminal illness, highly detailed","romantic comedy, friends, good health, undetailed"
|
||||
Style: John Wick 3,"John Wick 3 {prompt} . Action, assassin, relentless pursuit, highly detailed","romantic comedy, pacifist, peaceful life, undetailed"
|
||||
Style: Us,"Us {prompt} . Horror, doppelgängers, underground, highly detailed","romantic comedy, identical twins, above ground, undetailed"
|
||||
Style: The Irishman,"The Irishman {prompt} . Crime, mobster, union, highly detailed","romantic comedy, law-abiding citizen, small business, undetailed"
|
||||
Style: Honey Boy,"Honey Boy {prompt} . Drama, father-son relationship, Hollywood, highly detailed","romantic comedy, mother-daughter relationship, a small town, undetailed"
|
||||
Style: Joker,"Joker {prompt} . Drama, mental health, Gotham City, highly detailed","romantic comedy, mental well-being, Metropolis, undetailed"
|
||||
Style: Uncut Gems,"Uncut Gems {prompt} . Crime, gambling, New York City's Diamond District, highly detailed","romantic comedy, savings, rural town, undetailed"
|
||||
Style: 1917,"1917 {prompt} . War, World War I, real-time, highly detailed","romantic comedy, peacetime, timeless, undetailed"
|
||||
Style: Ford v Ferrari,"Ford v Ferrari {prompt} . Drama, racing, corporate politics, highly detailed","romantic comedy, walking, friendship, undetailed"
|
||||
Style: Cats,"Cats {prompt} . Musical, anthropomorphic cats, surreal, highly detailed","action, ordinary humans, realism, undetailed"
|
||||
Style: Jojo Rabbit,"Jojo Rabbit {prompt} . Comedy-drama, World War II, Hitler Youth, highly detailed","romantic comedy, modern day, ordinary youth, undetailed"
|
||||
Style: Parasite,"Parasite {prompt} . Drama, social class, deception, highly detailed","romantic comedy, equality, honesty, undetailed"
|
||||
Style: The Lion King,"The Lion King {prompt} . Animated, animal kingdom, Shakespearean, highly detailed","live-action, human kingdom, modern, undetailed"
|
||||
Style: Aladdin,"Aladdin {prompt} . Animated, Middle Eastern, magic, highly detailed","live-action, Western, science, undetailed"
|
||||
Style: Toy Story 4,"Toy Story 4 {prompt} . Animated, toys, adventure, highly detailed","live-action, non-living objects, ordinary life, undetailed"
|
||||
Style: Avengers: Endgame,"Avengers: Endgame {prompt} . Superhero, epic, time travel, highly detailed","romantic comedy, small-scale, present day, undetailed"
|
||||
Style: Star Wars: The Rise of Skywalker,"Star Wars: The Rise of Skywalker {prompt} . Sci-fi, space opera, Jedi, highly detailed","romantic comedy, earthbound, everyday person, undetailed"
|
||||
Style: Downton Abbey,"Downton Abbey {prompt} . Drama, British aristocracy, period piece, highly detailed","romantic comedy, modern middle class, present day, undetailed"
|
||||
Style: Frozen 2,"Frozen 2 {prompt} . Animated, fairytale, sisterhood, highly detailed","live-action, realism, rivalry, undetailed"
|
||||
Style: Little Women,"Little Women {prompt} . Drama, sisters, Civil War era, highly detailed","action, brothers, modern day, undetailed"
|
||||
>>>>>> GPT Anime Cartoon Mangas
|
||||
Style: 2D Traditional Animation,"traditional 2D animation {prompt} . hand-drawn, frames, expressive, vibrant colors, highly detailed","3D, CG, stop-motion, photo-realistic, black and white"
|
||||
Style: CGI Animation,"CGI animation {prompt} . 3D, photorealistic, high-quality textures and lighting, highly detailed","2D, stop-motion, anime, manga, black and white"
|
||||
Style: Stop-Motion Animation,"stop-motion animation {prompt} . physical models, frame-by-frame, quirky, distinctive, highly detailed","2D, 3D, CG, anime, manga, black and white"
|
||||
Style: Claymation,"claymation {prompt} . clay models, stop-motion, handcrafted, tactile, highly detailed","2D, 3D, CG, anime, manga, black and white"
|
||||
Style: Vector Animation,"vector animation {prompt} . digital, clean lines, geometric shapes, bold colors, highly detailed","stop-motion, claymation, 3D, CG, black and white"
|
||||
Style: Flash Animation,"flash animation {prompt} . digital, vector graphics, tweening, simple shapes, highly detailed","stop-motion, claymation, 3D, CG, black and white"
|
||||
Style: Rotoscope Animation,"rotoscope animation {prompt} . traced over live-action, realistic movement, highly detailed","stop-motion, claymation, 3D, CG, black and white"
|
||||
Style: Cut-Out Animation,"cut-out animation {prompt} . paper or fabric cut-outs, stop-motion, handcrafted, highly detailed","2D, 3D, CG, anime, manga, black and white"
|
||||
Style: Sand Animation,"sand animation {prompt} . sand manipulated on light box, fluid movement, highly detailed","2D, 3D, CG, anime, manga, black and white"
|
||||
Style: Pixel Art Animation,"pixel art animation {prompt} . low-res, blocky, digital, 8-bit, highly detailed","stop-motion, claymation, 3D, CG, black and white"
|
||||
Style: Anime Style Animation,"anime style animation {prompt} . Japanese style, hand-drawn or digital, vibrant, unique character designs, highly detailed","western cartoons, 3D, CG, black and white"
|
||||
Style: Manga Style Art,"manga style {prompt} . Japanese comics, black and white, unique character designs, detailed backgrounds, highly detailed","western comics, 3D, CG, vibrant colors"
|
||||
Style: Chibi Style Art,"chibi style {prompt} . Japanese, super-deformed, cute, exaggerated features, vibrant colors, highly detailed","realistic, 3D, CG, western comics, black and white"
|
||||
Style: Superflat,"superflat {prompt} . Japanese, postmodern art, flat planes of color, manga and anime influences, highly detailed","3D, CG, western art styles, black and white"
|
||||
Style: Ukiyo-e,"ukiyo-e style {prompt} . Japanese woodblock prints, flat areas of color, detailed patterns, subjects from history and mythology, highly detailed","modern, 3D, CG, western art styles, black and white"
|
||||
Style: Western Comics Art,"western comics art {prompt} . bold lines, dynamic poses, vibrant colors, dramatic lighting, highly detailed","anime, manga, 3D, CG, black and white"
|
||||
Style: Graphic Novel Art,"graphic novel art {prompt} . detailed, expressive, ranges from black and white to full color, often more realistic than traditional comics, highly detailed","anime, manga, 3D, CG, western comics"
|
||||
Style: Cartoon Modern,"cartoon modern {prompt} . mid-century modern aesthetic, stylized, geometric shapes, flat colors, highly detailed","realistic, 3D, CG, anime, manga, black and white"
|
||||
Style: Abstract Animation,"abstract animation {prompt} . nonrepresentational, uses movement and color to create mood or emotion, highly detailed","realistic, 3D, CG, anime, manga, black and white"
|
||||
Style: Silhouette Animation,"silhouette animation {prompt} . black figures against light background, dramatic, based on shadow puppetry, highly detailed","colorful, 3D, CG, anime, manga, black and white"
|
||||
Style: Looney Tunes,"Looney Tunes {prompt} . Cartoon, slapstick humor, dynamic and exaggerated character designs, colorful, vibrant, whimsical","3D, realism, manga, black and white, subdued, serious"
|
||||
Style: Disney Classic,"Disney Classic {prompt} . Animation, fairy tales, musical numbers, expressive characters, bright colors, detailed, professional","manga, anime, black and white, sketchy, rough"
|
||||
Style: Studio Ghibli,"Studio Ghibli {prompt} . Anime, magical realism, environmental themes, unique characters, breathtaking landscapes, highly detailed","cartoon, slapstick, black and white, photo-realistic, barren"
|
||||
Style: Pixar,"Pixar {prompt} . 3D animation, heartwarming stories, photorealistic environments, appealing character designs, emotional depth, detailed, professional","2D, anime, manga, black and white, sketchy"
|
||||
Style: Shōnen,"Shōnen {prompt} . Manga, action-packed, youthful characters, dynamic battles, inspiring themes, highly detailed","Disney, Pixar, black and white, realism, romantic comedy"
|
||||
Style: Mecha,"Mecha {prompt} . Anime, robots, futuristic technologies, dynamic battles, detailed mechanical designs, highly detailed","Disney, Pixar, cartoon, Looney Tunes, realism, fairy tales"
|
||||
Style: Shojo,"Shojo {prompt} . Manga, romantic themes, delicate art style, emotional narratives, highly detailed","action, mecha, 3D, Pixar, black and white, barren"
|
||||
Style: Nickelodeon,"Nickelodeon {prompt} . Cartoon, humor, dynamic characters, wacky and colorful designs, highly detailed","anime, manga, black and white, sketchy, serious"
|
||||
Style: Cartoon Network,"Cartoon Network {prompt} . Cartoon, humor, dynamic characters, unique and abstract designs, highly detailed","anime, manga, black and white, sketchy, serious"
|
||||
Style: Adult Swim,"Adult Swim {prompt} . Animation, adult humor, surreal themes, unique and abstract designs, highly detailed","children's cartoons, Disney, fairy tales, bright colors, traditional"
|
||||
Style: Adventure Time,"Adventure Time {prompt} . Cartoon, fantasy themes, quirky characters, vibrant colors, highly detailed","anime, manga, black and white, sketchy, serious"
|
||||
Style: Rick and Morty,"Rick and Morty {prompt} . Cartoon, science fiction, adult humor, unique and abstract designs, highly detailed","children's cartoons, Disney, fairy tales, bright colors, traditional"
|
||||
Style: South Park,"South Park {prompt} . Animation, satire, crude humor, simplistic designs, highly detailed","anime, manga, Disney, Pixar, detailed, professional"
|
||||
Style: The Simpsons,"The Simpsons {prompt} . Animation, satire, family themes, recognizable yellow characters, highly detailed","anime, manga, Disney, Pixar, black and white"
|
||||
Style: Family Guy,"Family Guy {prompt} . Animation, adult humor, satirical themes, cartoonish designs, highly detailed","anime, manga, Disney, Pixar, black and white"
|
||||
Style: Bob's Burgers,"Bob's Burgers {prompt} . Animation, family themes, humor, quirky characters, highly detailed","anime, manga, Disney, Pixar, black and white"
|
||||
Style: Gravity Falls,"Gravity Falls {prompt} . Cartoon, mystery, fantasy themes, unique character designs, highly detailed","anime, manga, Disney, Pixar, black and white"
|
||||
Style: Steven Universe,"Steven Universe {prompt} . Cartoon, LGBTQ+ themes, fantasy, vibrant colors, unique character designs, highly detailed","anime, manga, Disney, Pixar, black and white"
|
||||
Style: One Piece,"One Piece {prompt} . Manga, adventure, pirates, dynamic battles, unique character designs, highly detailed","cartoon, realism, Disney, Pixar, black and white"
|
||||
Style: Attack on Titan,"Attack on Titan {prompt} . Anime, dystopian, giants, dynamic battles, highly detailed","cartoon, realism, Disney, Pixar, black and white"
|
||||
Style: My Hero Academia,"My Hero Academia {prompt} . Anime, superhero, high school, dynamic battles, unique character designs, highly detailed","cartoon, realism, Disney, Pixar, black and white"
|
||||
Style: Naruto,"Naruto {prompt} . Anime, ninjas, coming-of-age, dynamic battles, unique character designs, highly detailed","cartoon, realism, Disney, Pixar, black and white"
|
||||
Style: Dragon Ball Z,"Dragon Ball Z {prompt} . Anime, martial arts, aliens, dynamic battles, unique character designs, highly detailed","cartoon, realism, Disney, Pixar, black and white"
|
||||
Style: Sailor Moon,"Sailor Moon {prompt} . Anime, magical girls, romance, unique character designs, highly detailed","cartoon, realism, Disney, Pixar, black and white"
|
||||
Style: Cowboy Bebop,"Cowboy Bebop {prompt} . Anime, space western, bounty hunters, noir themes, highly detailed","cartoon, realism, Disney, Pixar, black and white"
|
||||
>>>>>> GPT Famous Artists
|
||||
Style: Van Gogh, "Van Gogh style {prompt} . Expressive, impasto, swirling brushwork, vibrant," "realistic, photorealistic, calm, straight lines"
|
||||
Style: Warhol, "Warhol style {prompt} . Pop art, bold colors, mass production, repetitive," "subdued colors, traditional, unique, serious"
|
||||
Style: Picasso, "Picasso style {prompt} . Cubist, geometric, abstract, innovative," "realistic, detailed, smooth, fluid, single perspective"
|
||||
Style: Da Vinci, "Da Vinci style {prompt} . Realistic, sfumato, detailed, chiaroscuro," "abstract, vibrant colors, bold, loose brushwork"
|
||||
Style: Monet, "Monet style {prompt} . Impressionist, light-filled, loose brushwork, en plein air," "defined, detailed, subdued, studio work"
|
||||
Style: Dali, "Dali style {prompt} . Surrealist, dreamlike, bizarre, symbolic," "realistic, ordinary, rational, clear, obvious"
|
||||
Style: Pollock, "Pollock style {prompt} . Abstract expressionist, gestural, dripping, layered," "sharp, precise, realistic, calm"
|
||||
Style: Rothko, "Rothko style {prompt} . Color field, abstract, simple, large-scale," "detailed, small, complex, figurative"
|
||||
Style: Matisse, "Matisse style {prompt} . Fauvist, bold colors, loose, decorative," "realistic, subdued colors, detailed, serious"
|
||||
Style: Banksy, "Banksy style {prompt} . Street art, satirical, stenciled, urban," "classic, traditional, indoor, realism"
|
||||
Style: Michelangelo, "Michelinagelo style {prompt} . High Renaissance, sculptural, detailed, humanistic," "abstract, loose, simplistic, impersonal"
|
||||
Style: Kusama, "Kusama style {prompt} . Pop Art, abstract, polka dots, immersive," "plain, monotone, realistic, sparse"
|
||||
Style: Hokusai, "Hokusai style {prompt} . Ukiyo-e, woodblock print, detailed, narrative," "abstract, free-form, modern, minimal"
|
||||
Style: O'Keeffe, "O'Keeffe style {prompt} . Modernist, floral, bold, abstract," "small scale, detailed, muted colors, complex"
|
||||
Style: Cézanne, "Cézanne style {prompt} . Post-impressionist, geometric, detailed, brushstrokes," "smooth, flat, loose, fluid"
|
||||
Style: Hopper, "Hopper style {prompt} . Realistic, light and shadow, loneliness, American urban," "busy, crowded, vibrant, abstract"
|
||||
Style: Klimt, "Klimt style {prompt} . Symbolist, decorative, ornamental, sensual," "simple, bare, abstract, rough"
|
||||
Style: Chagall, "Chagall style {prompt} . Surrealist, dreamy, vibrant, narrative," "realistic, dull, serious, minimal"
|
||||
Style: Lichtenstein, "Lichtenstein style {prompt} . Pop art, comic strip, bold, ironic," "realistic, traditional, serious, detailed"
|
||||
Style: Basquiat, "Basquiat style {prompt} . Neo-expressionist, primitive, graffiti, social commentary," "polished, elegant, subdued, subtle"
|
||||
Style: Frida Kahlo, "Frida Kahlo style {prompt} . Symbolic, surrealistic, emotional, vibrant," "realistic, subdued, impersonal, monochromatic"
|
||||
Style: Georgia O'Keeffe, "Georgia O'Keeffe style {prompt} . Modernist, abstract, large scale, organic," "small, detailed, geometric, muted colors"
|
||||
Style: Jackson Pollock, "Jackson Pollock style {prompt} . Abstract expressionist, action painting, drip technique, energetic," "controlled, figurative, calm, small scale"
|
||||
Style: Rembrandt, "Rembrandt style {prompt} . Baroque, chiaroscuro, realistic, emotional," "flat lighting, abstract, impersonal, clean"
|
||||
Style: Renoir, "Renoir style {prompt} . Impressionist, vibrant, lively, warm," "dull, calm, detailed, cool colors"
|
||||
Style: Magritte, "Magritte style {prompt} . Surrealist, thought-provoking, mysterious, realistic," "abstract, obvious, open, unrefined"
|
||||
Style: Manet, "Manet style {prompt} . Realistic, impressionistic, bold, contemporary," "abstract, traditional, timid, historical"
|
||||
Style: Vermeer, "Vermeer style {prompt} . Baroque, detailed, light, tranquil," "abstract, rough, dark, chaotic"
|
||||
Style: Caravaggio, "Caravaggio style {prompt} . Baroque, chiaroscuro, dramatic, realistic," "soft lighting, calm, abstract, idealized"
|
||||
Style: Rodin, "Rodin style {prompt} . Realistic, expressive, textured, bronze," "smooth, emotionless, polished, painted"
|
||||
Style: Botticelli, "Botticelli style {prompt} . Early Renaissance, allegorical, graceful, detailed," "abstract, harsh, simplified, rough"
|
||||
Style: Edward Hopper, "Edward Hopper style {prompt} . Realistic, isolation, architectural, strong contrast," "crowded, organic, soft lighting, abstract"
|
||||
Style: Keith Haring, "Keith Haring style {prompt} . Pop art, bold lines, vibrant colors, social messages," "subtle, realistic, muted colors, personal"
|
||||
Style: Damien Hirst, "Damien Hirst style {prompt} . Contemporary, shocking, conceptual, large scale," "traditional, calming, handcrafted, small scale"
|
||||
Style: Yayoi Kusama, "Yayoi Kusama style {prompt} . Contemporary, polka dots, immersive, psychedelic," "traditional, plain, minimalist, calm"
|
||||
Style: Francis Bacon, "Francis Bacon style {prompt} . Existential, distorted, unsettling, expressive," "comforting, realistic, calm, subdued"
|
||||
Style: Ai Weiwei, "Ai Weiwei style {prompt} . Conceptual, political, traditional Chinese materials, large-scale," "apolitical, contemporary, small-scale, western materials"
|
||||
Style: Cindy Sherman, "Cindy Sherman style {prompt} . Conceptual, self-portrait, character study, cinematic," "landscape, group portraits, candid, documentary"
|
||||
Style: Frank Stella, "Frank Stella style {prompt} . Minimalist, geometric, large scale, non-representational," "maximalist, organic, small scale, representational"
|
||||
Style: Lucian Freud, "Lucian Freud style {prompt} . Realistic, impasto, psychological, intimate," "abstract, smooth, impersonal, public"
|
||||
Style: Marc Chagall, "Marc Chagall style {prompt} . Dreamlike, vibrant, symbolic, folklore-inspired," "realistic, subdued, literal, modern"
|
||||
Style: Roy Lichtenstein, "Roy Lichtenstein style {prompt} . Pop art, comic strip influence, bold outlines, primary colors," "abstract, realistic, pastel colors, complex"
|
||||
Style: Thomas Kinkade, "Thomas Kinkade style {prompt} . Romantic, idealized, warm light, detailed," "abstract, harsh, cool light, minimalist"
|
||||
Style: Joan Miró, "Joan Miró style {prompt} . Surrealist, abstract, biomorphic forms, primary colors," "realistic, figurative, complex, muted colors"
|
||||
Style: Gerhard Richter, "Gerhard Richter style {prompt} . Abstract, textured, layered, scraped," "realistic, smooth, single-layer, detailed"
|
||||
Style: Wassily Kandinsky, "Wassily Kandinsky style {prompt} . Abstract, geometric, vibrant, musical," "realistic, organic, muted, silent"
|
||||
Style: Norman Rockwell, "Norman Rockwell style {prompt} . Realistic, narrative, Americana, detailed," "abstract, non-narrative, foreign, minimalist"
|
||||
Style: Bridget Riley, "Bridget Riley style {prompt} . Op art, geometric, black and white, optical illusion," "organic, color, realistic, straightforward"
|
||||
Style: Piet Mondrian, "Piet Mondrian style {prompt} . De Stijl, geometric, primary colors, black grid," "organic, multiple colors, no grid, curved lines"
|
||||
Style: Salvador Dalí, "Salvador Dalí style {prompt} . Surrealist, dreamlike, symbolic, detailed," "realistic, ordinary, literal, sketchy"
|
||||
Style: Mary Cassatt, "Mary Cassatt style {prompt} . Impressionist, domestic life, soft colors, loose brushwork," "abstract, public life, vibrant colors, precise"
|
||||
Style: Diego Rivera, "Diego Rivera style {prompt} . Muralist, social realist, Mexican culture, narrative," "miniature, abstract, foreign, non-narrative"
|
||||
Style: Jean-Michel Basquiat, "Jean-Michel Basquiat style {prompt} . Neo-expressionist, graffiti influence, raw, socially critical," "classical, polished, refined, apolitical"
|
||||
Style: Henry Moore, "Henry Moore style {prompt} . Abstract, organic, bronze, monumental," "realistic, geometric, miniature, pastel"
|
||||
Style: Frida Kahlo, "Frida Kahlo style {prompt} . Surrealist, symbolic, vibrant, autobiographical," "realistic, abstract, dull, impersonal"
|
||||
Style: Grant Wood, "Grant Wood style {prompt} . Regionalist, rural, detailed, Americana," "urban, abstract, vague, non-American"
|
||||
Style: Edward Hopper, "Edward Hopper style {prompt} . Realistic, isolation, strong light, urban," "impressionistic, crowded, soft light, rural"
|
||||
Style: Andy Goldsworthy, "Andy Goldsworthy style {prompt} . Environmental art, natural materials, temporary, site-specific," "urban art, man-made materials, permanent, unspecific site"
|
||||
Style: Louise Bourgeois, "Louise Bourgeois style {prompt} . Abstract, psychological, large-scale, organic," "realistic, impersonal, small-scale, geometric"
|
||||
Style: Ansel Adams, "Ansel Adams style {prompt} . Black and white, nature, high contrast, detailed," "color, urban, low contrast, vague"
|
||||
Style: Yoko Ono, "Yoko Ono style {prompt} . Conceptual, minimalist, performance, participatory," "decorative, maximalist, static, non-interactive"
|
||||
Style: Gustav Klimt, "Gustav Klimt style {prompt} . Symbolist, decorative, golden, intricate," "realistic, functional, monochrome, simplified"
|
||||
Style: Jeff Koons, "Jeff Koons style {prompt} . Contemporary, kitsch, glossy, large-scale," "traditional, serious, matte, small-scale"
|
||||
Style: John Singer Sargent, "John Singer Sargent style {prompt} . Realistic, elegant, portrait, expressive," "abstract, casual, landscape, subdued"
|
||||
Style: Marcel Duchamp, "Marcel Duchamp style {prompt} . Dada, readymade, conceptual, controversial," "traditional, handmade, decorative, safe"
|
||||
Style: Claude Monet, "Claude Monet style {prompt} . Impressionist, outdoor, light, loose brushwork," "neoclassical, indoor, dark, tight brushwork"
|
||||
Style: Anish Kapoor, "Anish Kapoor style {prompt} . Abstract, large-scale, reflective, curved," "figurative, small-scale, matte, straight lines"
|
||||
Style: Hieronymus Bosch, "Hieronymus Bosch style {prompt} . Surrealist, detailed, religious, narrative," "realistic, abstract, secular, non-narrative"
|
||||
Style: Paul Gauguin, "Paul Gauguin style {prompt} . Post-Impressionist, exotic, bold colors, flat," "Impressionist, familiar, muted colors, volumetric"
|
||||
Style: Katsushika Hokusai, "Katsushika Hokusai style {prompt} . Ukiyo-e, nature, woodblock print, detailed," "western style, urban, oil painting, abstract"
|
||||
Style: Pierre-Auguste Renoir, "Pierre-Auguste Renoir style {prompt} . Impressionist, joyful, light, loose brushwork," "neoclassical, somber, dark, tight brushwork"
|
||||
Style: Antony Gormley, "Antony Gormley style {prompt} . Sculpture, human form, rusted, site-specific," "painting, abstract, polished, gallery-based"
|
||||
Style: Kazimir Malevich, "Kazimir Malevich style {prompt} . Suprematist, abstract, geometric, minimal," "realistic, organic, decorative, complex"
|
||||
Style: Jean-Antoine Watteau, "Jean-Antoine Watteau style {prompt} . Rococo, outdoor, elegant, lively," "Baroque, indoor, serious, static"
|
||||
Style: Constantin Brâncuși, "Constantin Brâncuși style {prompt} . Modernist, abstract, bronze, streamlined," "traditional, figurative, wood, complex"
|
||||
Style: Egon Schiele, "Egon Schiele style {prompt} . Expressionist, figure, distorted, emotional," "Impressionist, landscape, proportional, detached"
|
||||
Style: Nam June Paik, "Nam June Paik style {prompt} . Video art, technological, interactive, large-scale," "painting, traditional, static, small-scale"
|
||||
Style: James Whistler, "James Whistler style {prompt} . Tonalism, atmospheric, subdued, abstract," "Fauvism, vibrant, bold, detailed"
|
||||
Style: Wassily Kandinsky, "Wassily Kandinsky style {prompt} . Abstract, musical, geometric, vibrant," "realistic, silent, organic, subdued"
|
||||
Style: Lucio Fontana, "Lucio Fontana style {prompt} . Spatialism, monochrome, slashed, minimal," "Futurism, colorful, whole, detailed"
|
||||
Style: Artemisia Gentileschi, "Artemisia Gentileschi style {prompt} . Baroque, dramatic, biblical, female-centric," "Rococo, calm, mythological, male-centric"
|
||||
Style: Jean Dubuffet, "Jean Dubuffet style {prompt} . Art Brut, textured, primal, abstract," "Academic art, smooth, refined, realistic"
|
||||
Style: Sandro Botticelli, "Sandro Botticelli style {prompt} . Early Renaissance, mythological, linear, vibrant," "Baroque, historical, painterly, subdued"
|
||||
Style: Carl Andre, "Carl Andre style {prompt} . Minimalist, geometric, industrial, ground-level," "Baroque, organic, handcrafted, elevated"
|
||||
Style: David Hockney, "David Hockney style {prompt} . Pop art, landscape, vibrant, digital," "Abstract Expressionism, figure, subdued, traditional"
|
||||
Style: Cindy Sherman, "Cindy Sherman style {prompt} . Conceptual, self-portrait, character study, cinematic," "landscape, group portraits, candid, documentary"
|
||||
Style: Jenny Holzer, "Jenny Holzer style {prompt} . Conceptual, text-based, public, LED," "painting, image-based, private, canvas"
|
||||
Style: Dante Gabriel Rossetti, "Dante Gabriel Rossetti style {prompt} . Pre-Raphaelite, medieval, literary, romantic," "Futurist, modern, abstract, stark"
|
||||
Style: Zaha Hadid, "Zaha Hadid style {prompt} . Modernist, organic, futuristic, curved," "Classical, geometric, traditional, straight lines"
|
||||
Style: Takashi Murakami, "Takashi Murakami style {prompt} . Superflat, pop culture, colorful, cartoonish," "Cubist, high culture, monochrome, realistic"
|
||||
Style: Edward Weston, "Edward Weston style {prompt} . Photography, black and white, still life, detailed," "Painting, color, action, abstract"
|
||||
Style: Edvard Munch, "Edvard Munch style {prompt} . Expressionist, psychological, bold colors, distorted," "Impressionist, physical, muted colors, proportional"
|
||||
Style: Ai Weiwei, "Ai Weiwei style {prompt} . Contemporary, political, traditional Chinese materials, large-scale," "Classical, apolitical, modern materials, small-scale"
|
||||
Style: Georges Braque, "Georges Braque style {prompt} . Cubist, abstract, collage, muted colors," "Romantic, realistic, oil painting, vibrant colors"
|
||||
Style: Sol LeWitt, "Sol LeWitt style {prompt} . Conceptual, geometric, minimal, instructional," "Expressionist, organic, complex, spontaneous"
|
||||
Style: Mary Cassatt, "Mary Cassatt style {prompt} . Impressionist, domestic, pastel, feminine," "Realist, urban, oil, masculine"
|
||||
Style: Damien Hirst, "Damien Hirst style {prompt} . Contemporary, controversial, installation, medical," "Classical, traditional, canvas, floral"
|
||||
Style: Giuseppe Arcimboldo, "Giuseppe Arcimboldo style {prompt} . Mannerist, portrait, food, symbolic," "Cubist, landscape, abstract, literal"
|
||||
Style: Yves Klein, "Yves Klein style {prompt} . Nouveau réalisme, monochrome, blue, performance," "Pop Art, colorful, red, static"
|
||||
Style: Frida Kahlo, "Frida Kahlo style {prompt} . Surrealist, autobiographical, vibrant, symbolic," "Realist, historical, muted, literal"
|
||||
Style: Piet Mondrian, "Piet Mondrian style {prompt} . De Stijl, geometric, primary colors, balanced," "Surrealist, organic, pastel colors, chaotic"
|
||||
Style: Bridget Riley, "Bridget Riley style {prompt} . Op Art, geometric, black and white, optical," "Impressionist, organic, colorful, static"
|
||||
Style: Mark Rothko, "Mark Rothko style {prompt} . Abstract Expressionist, color field, large-scale, emotional," "Pop Art, pattern, small-scale, detached"
|
||||
Style: Joseph Beuys, "Joseph Beuys style {prompt} . Fluxus, performance, social sculpture, felt," "Minimalism, painting, object, metal"
|
||||
Style: Berthe Morisot, "Berthe Morisot style {prompt} . Impressionist, feminine, domestic, light," "Surrealist, masculine, public, dark"
|
||||
Style: Agnes Martin, "Agnes Martin style {prompt} . Minimalist, geometric, grid, subtle," "Baroque, organic, floral, bold"
|
||||
Style: Yayoi Kusama, "Yayoi Kusama style {prompt} . Contemporary, polka dots, infinity rooms, red," "Classical, plain, single room, blue"
|
||||
Style: Andy Goldsworthy, "Andy Goldsworthy style {prompt} . Environmental, temporary, nature, outdoors," "Industrial, permanent, man-made, indoors"
|
||||
Style: Henri Cartier-Bresson, "Henri Cartier-Bresson style {prompt} . Photography, decisive moment, black and white, candid," "Painting, posed, color, staged"
|
||||
Style: Marina Abramović, "Marina Abramović style {prompt} . Performance, endurance, audience participation, minimal," "Sculpture, instant, observer, complex"
|
||||
Style: Man Ray, "Man Ray style {prompt} . Dada, photography, rayograph, experimental," "Realism, painting, traditional, conventional"
|
||||
Style: Käthe Kollwitz, "Käthe Kollwitz style {prompt} . Expressionist, social realism, black and white, human suffering," "Impressionist, aestheticism, color, human joy"
|
||||
Style: Robert Rauschenberg, "Robert Rauschenberg style {prompt} . Neo-Dada, combine, mixed-media, assemblage," "Minimalism, singular material, oil painting, separated"
|
||||
Style: Lyonel Feininger, "Lyonel Feininger style {prompt} . Expressionist, Cubist, architecture, transparent," "Impressionist, organic, landscape, opaque"
|
||||
Style: Tracey Emin, "Tracey Emin style {prompt} . YBA, confessional, neon, textile," "Old Masters, universal, oil, marble"
|
||||
Style: René Magritte, "René Magritte style {prompt} . Surrealist, object, juxtaposition, mystery," "Realist, figure, relation, clarity"
|
||||
Style: Henry Moore, "Henry Moore style {prompt} . Modernist, sculpture, organic, monumental," "Classical, painting, geometric, small"
|
||||
Style: Rachel Whiteread, "Rachel Whiteread style {prompt} . Contemporary, sculpture, negative space, cast," "Traditional, drawing, positive space, sketch"
|
||||
Style: Tomma Abts, "Tomma Abts style {prompt} . Abstract, geometric, small-scale, acrylic and oil," "Figurative, organic, large-scale, watercolor"
|
||||
Style: Max Ernst, "Max Ernst style {prompt} . Surrealist, collage, frottage, dreamlike," "Realist, oil painting, brushwork, day-to-day"
|
||||
Style: Richard Serra, "Richard Serra style {prompt} . Minimalist, sculpture, corten steel, site-specific," "Baroque, painting, canvas, gallery-specific"
|
||||
Style: Ernst Ludwig Kirchner, "Ernst Ludwig Kirchner style {prompt} . Expressionist, urban, woodcut, vibrant," "Impressionist, rural, oil painting, subdued"
|
||||
Style: Eva Hesse, "Eva Hesse style {prompt} . Postminimalist, sculpture, organic, fiberglass," "Minimalist, painting, geometric, canvas"
|
||||
Style: Paul Cézanne, "Paul Cézanne style {prompt} . Post-Impressionist, still life, geometric, brushwork," "Impressionist, action, organic, smooth"
|
||||
Style: Francis Bacon, "Francis Bacon style {prompt} . Expressionist, distorted, triptych, anguish," "Classical, proportional, single panel, contentment"
|
||||
Style: Louise Bourgeois, "Louise Bourgeois style {prompt} . Contemporary, sculpture, feminist, fabric," "Classical, painting, patriarchal, oil"
|
||||
Style: Chuck Close, "Chuck Close style {prompt} . Photorealism, portrait, large-scale, gridded," "Impressionism, landscape, small-scale, loose"
|
||||
Style: Thomas Gainsborough, "Thomas Gainsborough style {prompt} . Rococo, landscape, elegant, oil," "Baroque, portrait, casual, pastel"
|
||||
Style: Gerhard Richter, "Gerhard Richter style {prompt} . Abstract, squeegee, photo-based, blurred," "Realistic, brushwork, imagination-based, detailed"
|
||||
Style: Jean-Michel Basquiat, "Jean-Michel Basquiat style {prompt} . Neo-expressionist, graffiti, crown, vibrant," "Photorealism, calligraphy, mundane, subdued"
|
||||
Style: Alexander Calder, "Alexander Calder style {prompt} . Kinetic, mobile, primary colors, balanced," "Static, statue, pastel colors, unbalanced"
|
||||
Style: Jackson Pollock, "Jackson Pollock style {prompt} . Abstract Expressionist, drip, large-scale, spontaneous," "Cubist, precise, small-scale, planned"
|
||||
Style: Anselm Kiefer, "Anselm Kiefer style {prompt} . Neo-expressionist, monumental, textured, historical," "Minimalist, small-scale, smooth, futuristic"
|
||||
Style: Amedeo Modigliani, "Amedeo Modigliani style {prompt} . Modernist, portrait, elongated, nude," "Cubist, landscape, proportional, clothed"
|
||||
Style: Gilbert & George, "Gilbert & George style {prompt} . Contemporary, photographic, duo, confrontational," "Traditional, painted, individual, pleasant"
|
||||
Style: El Greco, "El Greco style {prompt} . Mannerist, religious, elongated, dramatic," "Renaissance, secular, proportional, calm"
|
||||
Style: Salvador Dalí, "Salvador Dalí style {prompt} . Surrealist, dreamlike, precise, melting," "Realist, day-to-day, loose, solid"
|
||||
Style: Rembrandt van Rijn, "Rembrandt van Rijn style {prompt} . Baroque, self-portrait, chiaroscuro, etching," "Rococo, group portrait, bright, oil painting"
|
||||
Style: Keith Haring, "Keith Haring style {prompt} . Pop art, street art, bold lines, active figures," "Impressionism, studio art, fine brushwork, passive landscape"
|
||||
Style: Georgia O'Keeffe, "Georgia O'Keeffe style {prompt} . Modernist, flowers, close-up, sensual," "Cubist, objects, far-off, detached"
|
||||
Style: Caravaggio, "Caravaggio style {prompt} . Baroque, tenebrism, dramatic, religious," "Renaissance, bright, calm, secular"
|
||||
Style: Louise Nevelson, "Louise Nevelson style {prompt} . Abstract expressionist, sculpture, monochrome, found objects," "Realist, painting, colorful, new materials"
|
||||
Style: James Turrell, "James Turrell style {prompt} . Land art, light, immersive, perceptual," "Street art, dark, observational, intellectual"
|
||||
Style: Édouard Manet, "Édouard Manet style {prompt} . Realist, modern life, loose brushwork, controversial," "Romantic, history, fine brushwork, conventional"
|
||||
Style: Marc Chagall, "Marc Chagall style {prompt} . Surrealist, dreamlike, colorful, narrative," "Realist, day-to-day, monochrome, non-narrative"
|
||||
Style: Dan Flavin, "Dan Flavin style {prompt} . Minimalist, light, fluorescent, site-specific," "Baroque, dark, oil, gallery-specific"
|
||||
Style: Sarah Lucas, "Sarah Lucas style {prompt} . YBA, feminist, readymade, provocative," "Old Masters, masculine, handmade, conservative"
|
||||
Style: Johannes Vermeer, "Johannes Vermeer style {prompt} . Baroque, domestic, light, detailed," "Cubist, public, dark, abstract"
|
||||
Style: Tadao Ando, "Tadao Ando style {prompt} . Minimalist, concrete, light, water," "Baroque, brick, dark, dry"
|
||||
Style: Roy Lichtenstein, "Roy Lichtenstein style {prompt} . Pop art, comic strip, benday dots, primary colors," "Abstract expressionism, serious subject, brushwork, secondary colors"
|
||||
Style: Joseph Cornell, "Joseph Cornell style {prompt} . Surrealist, box, found objects, nostalgic," "Minimalist, open space, new materials, contemporary"
|
||||
Style: Gustave Courbet, "Gustave Courbet style {prompt} . Realist, rural life, coarse brushwork, controversial," "Neoclassical, noble life, fine brushwork, conventional"
|
||||
Style: Richard Long, "Richard Long style {prompt} . Land art, circle, natural materials, ephemeral," "Street art, square, synthetic materials, permanent"
|
||||
Style: Otto Dix, "Otto Dix style {prompt} . New Objectivity, war, grotesque, social critique," "Impressionism, peace, beautiful, aesthetic enjoyment"
|
||||
Style: Barnett Newman, "Barnett Newman style {prompt} . Abstract expressionism, zip, large-scale, color field," "Pop art, pattern, small-scale, comic strip"
|
||||
Style: Sophie Calle, "Sophie Calle style {prompt} . Conceptual, photography, text, personal," "Abstract, painting, brushwork, universal"
|
||||
Style: KAWS, "KAWS style {prompt} . Pop art, vinyl toy, X eyes, cartoonish," "Conceptual, bronze statue, normal eyes, realistic"
|
||||
Style: Francis Picabia, "Francis Picabia style {prompt} . Dada, machine, painting, provocative," "Impressionism, nature, sketch, pleasant"
|
||||
Style: H.R. Giger, "H.R. Giger style {prompt} . Surrealist, biomechanical, airbrush, dark," "Impressionist, human, brush, light"
|
||||
Style: Jean Arp, "Jean Arp style {prompt} . Dada, abstract, biomorphic, sculpture," "Realism, figurative, geometric, painting"
|
||||
Style: Ai Weiwei, "Ai Weiwei style {prompt} . Contemporary, political, installation, ceramics," "Renaissance, neutral, oil painting, metals"
|
||||
Style: Fernand Léger, "Fernand Léger style {prompt} . Cubist, mechanical, mural, bold colors," "Surrealist, organic, small-scale, muted colors"
|
||||
Style: Yoko Ono, "Yoko Ono style {prompt} . Conceptual, performance, instruction, peace," "Realist, still life, detailed, war"
|
||||
Style: Cindy Sherman, "Cindy Sherman style {prompt} . Contemporary, self-portrait, photography, identity," "Traditional, landscape, painting, anonymity"
|
||||
Style: Nam June Paik, "Nam June Paik style {prompt} . Video art, television, interactive, futuristic," "Traditional art, canvas, passive, historical"
|
||||
Style: Barbara Kruger, "Barbara Kruger style {prompt} . Conceptual, text, black and white, feminist," "Impressionist, image, color, patriarchal"
|
||||
Style: Piero della Francesca, "Piero della Francesca style {prompt} . Renaissance, fresco, mathematical, religious," "Contemporary, installation, random, secular"
|
||||
Style: Georgia O'Keeffe, "Georgia O'Keeffe style {prompt} . Modernist, flowers, close-up, sensual," "Cubist, objects, far-off, detached"
|
||||
Style: Richard Hamilton, "Richard Hamilton style {prompt} . Pop Art, collage, consumer culture, mixed media," "Impressionism, oil painting, rural life, single medium"
|
||||
Style: Kazimir Malevich, "Kazimir Malevich style {prompt} . Suprematism, abstract, geometric, minimal," "Realism, figurative, detailed, maximal"
|
||||
Style: Grayson Perry, "Grayson Perry style {prompt} . Contemporary, ceramics, tapestry, narrative," "Old Masters, oil painting, canvas, non-narrative"
|
||||
Style: Faith Ringgold, "Faith Ringgold style {prompt} . Contemporary, quilt, narrative, feminist," "Abstract, sculpture, non-narrative, masculine"
|
||||
Style: Banksy, "Banksy style {prompt} . Street Art, stencil, satirical, black and white," "Studio Art, oil painting, serious, color"
|
||||
Style: Tracey Emin, "Tracey Emin style {prompt} . YBA, confessional, neon, textile," "Old Masters, universal, oil, marble"
|
||||
Style: Olafur Eliasson, "Olafur Eliasson style {prompt} . Installation, light, environment, perceptual," "Painting, dark, indoors, cognitive"
|
||||
Style: Kiki Smith, "Kiki Smith style {prompt} . Feminist, body, sculpture, mythological," "Patriarchal, landscape, painting, historical"
|
||||
Style: David Hockney, "David Hockney style {prompt} . Pop Art, vibrant colors, collage, landscapes," "Abstract Expressionism, muted colors, single panel, figures"
|
||||
Style: Chris Ofili, "Chris Ofili style {prompt} . YBA, mixed-media, elephant dung, decorative," "Minimalism, single-media, clean, austere"
|
||||
Style: Ellsworth Kelly, "Ellsworth Kelly style {prompt} . Hard-edge painting, color field, minimalist, geometric," "Impressionism, detailed, ornate, organic"
|
||||
Style: Christo and Jeanne-Claude, "Christo and Jeanne-Claude style {prompt} . Installation, environmental, fabric, temporal," "Still Life, indoor, metal, permanent"
|
||||
Style: Wayne Thiebaud, "Wayne Thiebaud style {prompt} . Pop Art, still life, pastel, thick paint," "Cubism, dynamic scenes, vibrant, thin paint"
|
||||
Style: Jenny Holzer, "Jenny Holzer style {prompt} . Conceptual, text, LED, public spaces," "Realism, image, oil painting, private spaces"
|
||||
Style: Antony Gormley, "Antony Gormley style {prompt} . Sculpture, human form, rusted metal, public art," "Painting, abstract, bright colors, gallery art"
|
||||
Style: Maurice Sendak, "Maurice Sendak style {prompt} . Children's illustration, fantasy, detailed, narrative," "Abstract, adult, minimalist, non-narrative"
|
||||
>>>>>> Advanced GPT Photography
|
||||
Portrait Photography Style: Charismatic,"{prompt} with charisma. 50mm lens, f/2.8, focused on eyes, natural lighting","overexposed, underexposed, blurry, distorted, overprocessed"
|
||||
Portrait Photography Style: Cinematic,"cinematic portrait of {prompt}. 85mm lens, f/1.8, dramatic side lighting, moody atmosphere","overblown highlights, noisy, grainy, oversaturated, wide-angle distortion"
|
||||
Portrait Photography Style: Environmental,"environmental portrait of {prompt}. 35mm lens, f/4, wider context, natural surroundings","cluttered background, poor lighting, overexposed, underexposed, unsharp"
|
||||
Photojournalism Style: Reportage,"gripping reportage of {prompt}. Wide-angle lens, f/8, focus on action, capture the moment","blurred action, low light noise, unsteady shot, out of focus, distorted perspective"
|
||||
Photojournalism Style: Candid,"candid shot of {prompt}. 50mm lens, f/2.8, spontaneous, unposed","poor lighting, motion blur, out of focus, distracting background, overprocessed"
|
||||
Photojournalism Style: Documentary,"documentary style of {prompt}. 35mm lens, f/5.6, truthful representation, neutral perspective","overexposed, underexposed, oversaturated, motion blur, unsteady shot"
|
||||
Fashion Photography Style: Haute Couture,"haute couture display of {prompt}. 85mm lens, f/2.2, vibrant colors, dramatic lighting","flat lighting, out of focus, distracting background, overprocessed, oversaturated"
|
||||
Fashion Photography Style: Editorial,"editorial fashion shot of {prompt}. 50mm lens, f/2.5, storytelling, focused on outfit","unflattering pose, poor lighting, blurry, distracting elements, overexposed"
|
||||
Fashion Photography Style: Catalog,"catalog shot of {prompt}. 70mm lens, f/5.6, neutral background, clear focus on attire","poor lighting, unflattering angles, distorted perspective, underexposed, oversaturated"
|
||||
Sports Photography Style: Action-packed,"action-packed shot of {prompt}. 200mm lens, f/2.8, high shutter speed, capture the peak moment","motion blur, underexposed, out of focus, distracting background, unsteady shot"
|
||||
Sports Photography Style: Emotional,"emotional moment in {prompt}. 135mm lens, f/4, capture expressions, ambient lighting","poor focus, high ISO noise, unsteady shot, underexposed, distorted colors"
|
||||
Sports Photography Style: Narrative,"narrative image of {prompt}. 50mm lens, f/3.5, storytelling, context setting","unfocused, poor lighting, cluttered composition, overexposed, distorted perspective"
|
||||
Still Life Photography Style: Minimalistic,"minimalistic composition of {prompt}. 50mm lens, f/5.6, simplistic design, neutral colors","cluttered, oversaturated, unbalanced composition, poor lighting, overexposed"
|
||||
Still Life Photography Style: Dramatic,"dramatic still life of {prompt}. 85mm lens, f/2.2, dramatic lighting, intense colors","flat lighting, blurry, underexposed, distracting elements, oversaturated"
|
||||
Still Life Photography Style: Rustic,"rustic presentation of {prompt}. 35mm lens, f/4, natural elements, warm tones","poor focus, overexposed, cluttered, cold colors, unbalanced composition"
|
||||
Editorial Photography Style: Investigative,"investigative shot of {prompt}. 24mm lens, f/4, informative, intriguing","blurry, underexposed, distorted perspective, high ISO noise, distracting elements"
|
||||
Editorial Photography Style: Lifestyle,"lifestyle capture of {prompt}. 50mm lens, f/2.8, candid, vibrant colors","poor lighting, overprocessed, distracting background, motion blur, unsteady shot"
|
||||
Editorial Photography Style: Opinion,"opinion image of {prompt}. 35mm lens, f/5.6, emotive, storytelling","poor focus, underexposed, cluttered composition, overexposed highlights, distorted colors"
|
||||
Architectural Photography Style: Historical,"historical capture of {prompt}. 24mm lens, f/8, capture architectural details, natural lighting","distorted perspective, underexposed, overprocessed, unsharp, oversaturated"
|
||||
Architectural Photography Style: Modernist,"modernist view of {prompt}. 18mm lens, f/4, minimalistic, strong lines","barrel distortion, overexposed, blurry, poor composition, flat colors"
|
||||
Architectural Photography Style: Surreal,"surreal perspective of {prompt}. Fisheye lens, f/2.8, abstract interpretation, vibrant colors","unfocused, poor lighting, underexposed, overprocessed, distracting elements"
|
||||
>>>>>> GPT Painting Styles
|
||||
Style: Steampunk,"steampunk-inspired {prompt} . gears, brass, rivets, old-world technology, intricate, highly detailed, Victorian,"ugly, deformed, noisy, blurry, minimalistic, sleek"
|
||||
Style: Futuristic,"futuristic interpretation of {prompt} . sleek, high-tech, metallic, smooth surfaces, neon, sharp edges, crystal clear, professional, ultra detailed,"ugly, deformed, noisy, blurry, rustic, vintage, antique"
|
||||
Style: Abstract Expressionism,"Abstract Expressionist style of {prompt} . bold colors, vigorous brushwork, non-representational, spontaneous, expressive, emotional,"boring, monotone, plain, still, unemotional, realistic, photographic"
|
||||
Style: Surrealism,"surrealistic {prompt} . dreamlike, subconscious, bizarre, highly detailed, intricate, imaginative, illogical juxtaposition,"clear, realistic, boring, typical, straightforward, concrete, photographic"
|
||||
Style: Watercolor,"watercolor painting of {prompt} . fluid, soft edges, light colors, translucent, delicate, dreamy,"hard, geometric, precise, opaque, harsh, dark, sharp, digital, pixelated"
|
||||
Style: Pointillism,"pointillist technique on {prompt} . tiny dots of color, optical blend, detailed, vibrant, rich,"solid, monochromatic, bland, minimalist, soft, blurry"
|
||||
Style: Cubism,"cubist interpretation of {prompt} . geometric forms, multi-perspective, abstract, fragmented, complex,"rounded, realistic, photographic, simple, straightforward, traditional"
|
||||
Style: Gothic,"gothic style {prompt} . dark, mysterious, medieval, ornate, intricate, detailed, haunting,"bright, modern, simple, minimalist, cheerful, photorealistic"
|
||||
Style: Pop Art,"pop art style {prompt} . bold colors, mass culture, comic style, ironical, vibrant, detailed,"neutral, realistic, serious, dull, monochromatic, photographic"
|
||||
Style: Impressionism,"impressionist take on {prompt} . loose brushwork, light color, emphasis on light and movement, emotive, painterly,"tight, photographic, dark, stationary, unemotional, sharp, digital"
|
||||
Style: Street Art,"street art version of {prompt} . urban, graffiti, spray paint, vibrant, bold, rough, rebellious,"elegant, refined, traditional, delicate, soft, photorealistic"
|
||||
Style: Art Nouveau,"art nouveau style {prompt} . elegant, ornate, flowing lines, detailed, decorative,"simple, modern, sharp, minimalistic, geometric, unadorned"
|
||||
Style: Charcoal,"charcoal sketch of {prompt} . dark, grainy, high contrast, loose, dramatic,"light, smooth, precise, colorful, clean, photographic"
|
||||
Style: Collage,"collage of {prompt} . mixed media, eclectic, detailed, layered, creative,"uniform, minimalistic, simple, clean, digital, monochromatic"
|
||||
Style: Minimalist,"minimalist {prompt} . clean lines, simple shapes, limited color palette, modern, sleek,"detailed, ornate, decorative, colorful, chaotic, complex"
|
||||
Style: Graffiti,"graffiti style {prompt} . street art, bold, colorful, vibrant, dynamic, urban, rebellious, intricate,"refined, subtle, soft, elegant, traditional, photorealistic"
|
||||
Style: Trompe L'oeil,"trompe l'oeil of {prompt} . hyperrealistic, 3d illusion, detailed, deceptive, intricate,"abstract, flat, simple, symbolic, unrealistic, distorted"
|
||||
Style: Fauvism,"fauvist interpretation of {prompt} . wild brushwork, vibrant color, expressive, bold, emotive, painterly,"neutral, precise, calm, realistic, photographic, subdued"
|
||||
Style: Hyperrealism,"hyperrealistic {prompt} . photorealistic, extreme detail, lifelike, crisp, precise,"blurry, abstract, loose, impressionistic, simple, symbolic"
|
||||
Style: Dada,"dadaist version of {prompt} . anti-art, absurd, random, satirical, mixed media, collage,"traditional, sensible, serious, realistic, photorealistic"
|
||||
Style: Calligraphy,"calligraphy style {prompt} . elegant, flowing, precise, detailed, intricate, hand-drawn,"bold, blocky, geometric, rough, digital, simple"
|
||||
Style: Baroque,"baroque rendition of {prompt} . opulent, grand, ornate, dramatic, detailed, decorative,"minimalist, modern, simple, clean, unadorned, geometric"
|
||||
Style: Op Art,"op art style {prompt} . optical illusion, geometric, vibrant, dynamic, detailed, bold,"soft, organic, loose, subdued, simple, unpatterned"
|
||||
Style: Psychedelic,"psychedelic version of {prompt} . vibrant color, distorted visuals, swirling patterns, trippy, detailed, intricate,"neutral, realistic, orderly, simple, clear, photorealistic"
|
||||
Style: Scratchboard,"scratchboard technique on {prompt} . contrast, engraved, black and white, detailed, dramatic,"colorful, soft, loose, blended, photorealistic"
|
||||
Style: Botanical Illustration,"botanical illustration of {prompt} . detailed, accurate, precise, delicate, naturalistic,"abstract, loose, imprecise, bold, exaggerated, symbolic"
|
||||
Style: Lithography,"lithograph of {prompt} . printmaking, smooth, detailed, bold, graphic,"rough, textured, loose, brushy, three dimensional"
|
||||
Style: Mosaic,"mosaic of {prompt} . tiled, geometric, vibrant, intricate, decorative,"soft, organic, loose, simple, smooth, unpatterned"
|
||||
Style: Woodcut,"woodcut style {prompt} . carved, bold lines, high contrast, rustic, handmade,"smooth, soft, delicate, digital, photorealistic"
|
||||
Style: Stencil Art,"stencil art of {prompt} . sharp edges, bold, graphic, street art style, vibrant,"soft, loose, organic, brushy, traditional"
|
||||
Style: Rotoscoping,"rotoscoped {prompt} . traced, animation style, smooth, realistic, detailed,"abstract, symbolic, rough, loose, blocky"
|
||||
Style: Glass Painting,"glass painting of {prompt} . translucent, vibrant, decorative, intricate, glossy,"matte, dull, loose, rough, opaque"
|
||||
Style: Art Deco,"art deco interpretation of {prompt} . geometric, bold, symmetrical, ornate, detailed, decorative,"soft, organic, asymmetrical, minimalist, simple"
|
||||
Style: Hard Edge Painting,"hard edge painting of {prompt} . geometric, sharp edges, flat color, modern, bold,"soft, organic, loose, textured, detailed, photorealistic"
|
||||
Style: Drybrush,"drybrush technique on {prompt} . rough texture, loose brushwork, subtle detail, expressive, painterly,"smooth, precise, clean, detailed, photorealistic"
|
||||
Style: Silhouette,"silhouette of {prompt} . high contrast, dramatic, simple, bold, graphic,"detailed, textured, colorful, light, photorealistic"
|
||||
Style: Plein Air,"plein air painting of {prompt} . outdoor, natural light, vibrant, loose, expressive,"studio, artificial, precise, tight, clean, photorealistic"
|
||||
Style: Ink Wash,"ink wash painting of {prompt} . monochromatic, loose, fluid, expressive, delicate,"colorful, tight, dry, bold, detailed, photorealistic"
|
||||
Style: Body Painting,"body painting of {prompt} . human canvas, vibrant, detailed, transformative, expressive,"traditional canvas, subtle, clean, realistic, monochromatic"
|
||||
Style: Spray Paint,"spray paint art of {prompt} . street style, vibrant, spontaneous, bold, rough,"refined, soft, delicate, precise, clean, photorealistic"
|
||||
Style: Grisaille,"grisaille painting of {prompt} . monochromatic, detailed, realistic, refined, tonal,"colorful, abstract, loose, impressionistic, simple"
|
||||
Style: Stippling,"stippled technique on {prompt} . dotted, texture, detailed, graphic, intricate,"smooth, solid, loose, brushy, blended"
|
||||
Style: Pastel,"pastel drawing of {prompt} . soft, colorful, delicate, expressive, textured,"sharp, bold, clean, precise, digital"
|
||||
Style: Encaustic,"encaustic painting of {prompt} . wax, textured, layered, luminous, rich,"flat, smooth, simple, clean, dry, photorealistic"
|
||||
Style: Macrame,"macrame style {prompt} . knotted, textile, intricate, handmade, decorative,"smooth, flat, hard, precise, digital"
|
||||
Style: Graffiti Stencil,"graffiti stencil art of {prompt} . urban, bold, vibrant, street style, graphic,"elegant, refined, soft, traditional, photorealistic"
|
||||
Style: Action Painting,"action painting of {prompt} . spontaneous, energetic, abstract, expressive, bold,"precise, slow, realistic, photographic, unemotional"
|
||||
Style: Batik,"batik style {prompt} . dyed, vibrant, patterned, textile, decorative,"plain, unpatterned, hard, smooth, clean, digital"
|
||||
Style: Folk Art,"folk art depiction of {prompt} . traditional, handmade, decorative, vibrant, detailed,"modern, digital, simple, clean, minimalistic"
|
||||
Style: Glitch Art,"glitch art of {prompt} . distorted, digital, vibrant, abstract, modern,"refined, traditional, realistic, photographic, unaltered"
|
||||
Style: Chiaroscuro,"chiaroscuro technique on {prompt} . high contrast, dramatic, realistic, refined, tonal,"flat, dull, abstract, impressionistic, simple"
|
||||
Style: Gouache,"gouache painting of {prompt} . vibrant, opaque, smooth, rich, detailed,"transparent, loose, rough, dull, photorealistic"
|
||||
>>>>>> GPT Instagram Styles
|
||||
Style: High-Fashion, "{prompt} in haute couture. Luxury, designer brands, runway-ready, tailored, chic", "casual, sporty, laid-back, street style, loose"
|
||||
Style: Casual-Chic, "{prompt} in a casual chic outfit. Comfortable, stylish, modern, accessible", "formal, high fashion, flamboyant, extravagant"
|
||||
Style: Streetwear, "{prompt} rocking the streetwear trend. Urban, hip-hop influence, sneakers, caps, oversized", "preppy, conservative, formal, traditional"
|
||||
Style: Athletic, "{prompt} in athletic wear. Sporty, gym-ready, functional, sneakers, activewear", "evening wear, formal, business, relaxed"
|
||||
Style: Vintage, "{prompt} in a vintage ensemble. Retro, nostalgia, classic styles, second-hand", "modern, futuristic, minimalist, new"
|
||||
Style: Bohemian, "{prompt} in boho fashion. Free-spirited, layered, patterns, ethnic-inspired, fringe", "minimalist, structured, monochromatic, sleek"
|
||||
Style: Minimalist, "{prompt} sporting minimalist fashion. Simple, clean lines, neutral colors, unfussy", "vintage, boho, flamboyant, colorful"
|
||||
Style: Preppy, "{prompt} dressed in preppy style. Collegiate, clean-cut, conservative, layered", "gothic, punk, casual, relaxed"
|
||||
Style: Gothic, "{prompt} in a gothic getup. Dark, leather, lace, Victorian influence", "preppy, pastel, boho, bright"
|
||||
Style: Punk, "{prompt} with a punk look. Rebellious, grungy, band tees, ripped denim", "preppy, classic, conservative, formal"
|
||||
Style: Grunge, "{prompt} sporting a grunge look. '90s influence, flannel, band tees, distressed", "preppy, glamorous, feminine, tailored"
|
||||
Style: Glamorous, "{prompt} looking glamorous. Luxury, sequins, fur, red carpet ready", "casual, relaxed, sporty, minimalist"
|
||||
Style: Rocker, "{prompt} rocking the rock style. Leather, band tees, edgy, black", "preppy, pastel, boho, cute"
|
||||
Style: Hipster, "{prompt} in a hipster outfit. Eclectic, indie, non-mainstream, vintage", "mainstream, sporty, glamorous, preppy"
|
||||
Style: Ethical, "{prompt} wearing ethical fashion. Sustainable, fair trade, organic materials, eco-friendly", "fast fashion, synthetic, mass-produced, cheap"
|
||||
Style: Business Casual, "{prompt} dressed in business casual. Semi-formal, tailored, smart, professional", "sporty, casual, grunge, punk"
|
||||
Style: Beachwear, "{prompt} in beachwear. Bikinis, cover-ups, sandals, straw hats, light fabrics", "winter wear, formal, business, structured"
|
||||
Style: Activewear, "{prompt} in stylish activewear. Sporty, comfortable, functional, athleisure", "evening wear, formal, preppy, boho"
|
||||
Style: Country, "{prompt} sporting country style. Western, cowboy boots, plaid, denim", "gothic, punk, high fashion, glamorous"
|
||||
Style: Military, "{prompt} wearing military-inspired fashion. Camouflage, khaki, structured, badges", "boho, glamorous, preppy, beachwear"
|
||||
Style: Kawaii, "{prompt} in Kawaii style. Cute, pastel, girly, anime-inspired, frilly", "gothic, punk, grunge, minimalist"
|
||||
Style: Lolita, "{prompt} in a Lolita ensemble. Victorian-inspired, frilly, bows, lace, layered", "minimalist, sporty, casual, business"
|
||||
Style: Formal, "{prompt} dressed in formal wear. Black tie, tuxedo, evening gown, polished", "casual, sporty, grunge, beachwear"
|
||||
Style: Tomboy, "{prompt} rocking a tomboy look. Androgynous, loose, sneakers, caps", "glamorous, feminine, boho, preppy"
|
||||
Style: Normcore, "{prompt} dressed in normcore. Unpretentious, casual, basics, comfortable", "high fashion, glamorous, punk, gothic"
|
||||
Style: Artistic, "{prompt} in an artistic outfit. Creative, unique, expressive, handmade", "preppy, conservative, business, traditional"
|
||||
Style: Genderless, "{prompt} in genderless fashion. Androgynous, neutral, modern, unisex", "feminine, masculine, glam, preppy"
|
||||
Style: Monochromatic, "{prompt} in a monochromatic look. Single color, sleek, modern, minimalist", "colorful, vibrant, patterned, boho"
|
||||
Style: Mod, "{prompt} dressed in Mod style. '60s influence, A-line, geometric patterns, bold", "boho, grunge, minimalist, normcore"
|
||||
Style: Harajuku, "{prompt} in Harajuku style. Japanese street fashion, eclectic, colorful, anime", "conservative, preppy, minimalist, business"
|
||||
Style: Cyberpunk, "{prompt} in a cyberpunk outfit. Futuristic, dystopian, metallic, neon", "vintage, retro, classic, boho"
|
||||
Style: Rave, "{prompt} in rave wear. Bright colors, neon, sequins, fur", "business casual, preppy, conservative, minimalist"
|
||||
Style: Hippy, "{prompt} in hippy style. '70s influence, tie-dye, bell-bottoms, fringe", "preppy, conservative, formal, modern"
|
||||
Style: Skater, "{prompt} rocking skater style. Casual, sneakers, baggy, sporty, laid-back", "formal, glamorous, high fashion, preppy"
|
||||
Style: Pin-Up, "{prompt} in a pin-up style. Retro, '50s influence, feminine, curves", "gothic, grunge, sporty, tomboy"
|
||||
Style: Nautical, "{prompt} in a nautical outfit. Sailor-inspired, stripes, navy, white, red", "gothic, punk, grunge, boho"
|
||||
Style: Futuristic, "{prompt} in futuristic fashion. Metallic, geometric, avant-garde, high-tech", "vintage, classic, traditional, retro"
|
||||
Style: Eccentric, "{prompt} in an eccentric ensemble. Unique, quirky, stand-out, individualistic", "traditional, classic, conservative, minimalist"
|
||||
Style: Tailored, "{prompt} in a tailored suit. Formal, professional, sleek, well-fitted", "casual, relaxed, oversized, loose"
|
||||
Style: Sustainable, "{prompt} in sustainable fashion. Eco-friendly, organic, recycled materials, fair trade", "fast fashion, synthetic, cheap, disposable"
|
||||
Style: Traditional, "{prompt} in a traditional outfit. Ethnic, regional, cultural, heritage", "modern, futuristic, western, mainstream"
|
||||
Style: Candid, "{prompt} captured in a candid moment. Unposed, natural, spontaneous, real-life situation", "posed, artificial, studio shot, planned"
|
||||
Style: Portrait, "portrait shot of {prompt}. Close-up, eyes on camera, clear, sharp", "wide shot, landscape, blurred, candid"
|
||||
Style: Lifestyle, "lifestyle photo of {prompt}. Everyday activities, real-life situations, relatable", "fantasy, staged, surreal, unrealistic"
|
||||
Style: Editorial, "editorial shot of {prompt}. Fashion-forward, styled, professional, magazine-ready", "casual, candid, unstyled, amateur"
|
||||
Style: Glamour, "glamour shot of {prompt}. Beauty focused, make-up, lighting, seductive", "natural, minimal, candid, unglamorous"
|
||||
Style: Fitness, "fitness photo of {prompt}. Athletic, workout gear, active, strong", "laid back, casual, non-athletic, inactive"
|
||||
Style: Boudoir, "boudoir shot of {prompt}. Intimate, sensual, classy, tasteful", "public, conservative, modest, non-intimate"
|
||||
Style: Silhouette, "silhouette photo of {prompt}. Dramatic, backlighting, mysterious, creative", "frontlit, clear, detailed, revealing"
|
||||
Style: Maternity, "maternity shot of {prompt}. Pregnancy, baby bump, motherhood, glowing", "non-pregnant, childless, pre-pregnancy, post-pregnancy"
|
||||
Style: Black and White, "black and white photo of {prompt}. Monochrome, timeless, artistic, dramatic", "color, vibrant, modern, digital"
|
||||
Style: Pin-Up, "pin-up style photo of {prompt}. Retro, feminine, seductive, fun", "modern, conservative, modest, non-vintage"
|
||||
Style: Headshot, "headshot of {prompt}. Professional, clear, neutral background, focused", "full body, casual, distracting background, unfocused"
|
||||
Style: Full Body, "full body shot of {prompt}. Whole outfit, clear, sharp, balanced", "close up, cropped, blurry, unbalanced"
|
||||
Style: High Fashion, "high fashion photo of {prompt}. Designer clothes, dramatic poses, avant-garde", "casual, candid, natural, mainstream fashion"
|
||||
Style: Business, "business photo of {prompt}. Professional attire, workplace setting, confident", "casual, relaxed, non-work, insecure"
|
||||
Style: Beach, "beach photo of {prompt}. Swimwear, sand, ocean, relaxed", "urban, winter, formal, stressed"
|
||||
Style: Lingerie, "lingerie shot of {prompt}. Intimate apparel, sensual, feminine, seductive", "outerwear, modest, masculine, non-sensual"
|
||||
Style: Athletic, "athletic shot of {prompt}. Sportswear, action, energy, strength", "leisure, inactive, weak, non-sporty"
|
||||
Style: Close-up, "close-up photo of {prompt}. Detailed, intimate, clear, personal", "wide shot, distant, blurry, impersonal"
|
||||
Style: Nature, "nature shot with {prompt}. Outdoors, greenery, natural light, fresh", "indoor, city, artificial light, stale"
|
||||
Style: Studio, "studio shot of {prompt}. Controlled lighting, plain background, clear", "outdoor, natural light, busy background, unclear"
|
||||
Style: Street, "street shot of {prompt}. Urban, casual, candid, trendy", "rural, formal, posed, traditional"
|
||||
Style: Dance, "dance photo of {prompt}. Movement, grace, energy, rhythm", "static, clumsy, lethargic, off-beat"
|
||||
Style: Vintage, "vintage style photo of {prompt}. Retro, nostalgic, old-fashioned, timeless", "modern, futuristic, trendy, transient"
|
||||
Style: Low Light, "low light photo of {prompt}. Ambient, moody, dramatic, shadowy", "bright, cheerful, flat, clear"
|
||||
Style: Underwater, "underwater photo of {prompt}. Aquatic, serene, dreamlike, floaty", "land, hectic, realistic, heavy"
|
||||
Style: Action, "action shot of {prompt}. Movement, energy, dynamic, intense", "still, calm, static, gentle"
|
||||
Style: Fashion, "fashion shot of {prompt}. Trendy outfit, styled, runway-ready, chic", "plain, unstyled, out of style, ordinary"
|
||||
Style: Aerial, "aerial shot of {prompt}. Birds-eye view, grand, adventurous, stunning", "ground level, confined, cautious, underwhelming"
|
||||
Style: Music, "music-related shot of {prompt}. Playing an instrument, singing, energetic, passionate", "quiet, uninterested, uninvolved, lackluster"
|
||||
Style: Abstract, "abstract photo of {prompt}. Artistic, unique, creative, unconventional", "concrete, literal, conventional, uncreative"
|
||||
Style: Fine Art, "fine art photo of {prompt}. Conceptual, creative, artistic, aesthetic", "commercial, literal, uncreative, unaesthetic"
|
||||
Style: Cityscape, "cityscape shot with {prompt}. Urban, skyline, architectural, dynamic", "rural, landscape, natural, static"
|
||||
Style: Landscape, "landscape shot with {prompt}. Scenic, outdoors, grand, beautiful", "indoor, close-up, confined, unattractive"
|
||||
Style: Macro, "macro shot of {prompt}. Extremely close-up, detailed, intricate, revealing", "wide shot, undetailed, simple, concealing"
|
||||
Style: Golden Hour, "golden hour shot of {prompt}. Warm light, sunset/sunrise, magical, serene", "midday, harsh light, mundane, agitated"
|
||||
Style: Blue Hour, "blue hour shot of {prompt}. Cool light, twilight, peaceful, moody", "midday, harsh light, chaotic, flat"
|
||||
Style: Night, "night shot of {prompt}. Dark, lit, moody, mysterious", "daytime, bright, cheerful, clear"
|
||||
Style: Reflection, "reflection shot of {prompt}. Mirror image, symmetry, creative, thoughtful", "direct, asymmetrical, uncreative, thoughtless"
|
||||
Style: Backlit, "backlit photo of {prompt}. Silhouette, dramatic, artistic, shadowy", "frontlit, flat, unartistic, clear"
|
||||
Style: Overhead, "overhead shot of {prompt}. Top-down view, unique perspective, revealing", "low angle, ordinary perspective, concealing"
|
||||
name,prompt,negative_prompt
|
||||
❌Low Token,,"embedding:EasyNegative, NSFW, Cleavage, Pubic Hair, Nudity, Naked, censored"
|
||||
✅Line Art / Manga,"(Anime Scene, Toonshading, Satoshi Kon, Ken Sugimori, Hiromu Arakawa:1.2), (Anime Style, Manga Style:1.3), Low detail, sketch, concept art, line art, webtoon, manhua, hand drawn, defined lines, simple shades, minimalistic, High contrast, Linear compositions, Scalable artwork, Digital art, High Contrast Shadows, glow effects, humorous illustration, big depth of field, Masterpiece, colors, concept art, trending on artstation, Vivid colors, dramatic",
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 171 and column 80.
|
Vendored
-126
@@ -1,126 +0,0 @@
|
||||
// Some manual types I use to facilitate developing on top of
|
||||
// Comfy's Litegraph implementation.
|
||||
|
||||
import type {
|
||||
ContextMenuItem,
|
||||
LGraphNode,
|
||||
IWidget,
|
||||
LGraph,
|
||||
} from '../../../web/types/litegraph'
|
||||
|
||||
export type {
|
||||
ComfyExtension,
|
||||
ComfyObjectInfo,
|
||||
ComfyObjectInfoConfig,
|
||||
} from '../../../web/types/comfy'
|
||||
|
||||
export type {
|
||||
ContextMenuItem,
|
||||
IWidget,
|
||||
LLink,
|
||||
INodeInputSlot,
|
||||
INodeOutputSlot,
|
||||
} from '../../../web/types/litegraph'
|
||||
|
||||
export type VectorWidget = IWidget<number[], { default: number[] }>
|
||||
export interface NodeData {
|
||||
category: str
|
||||
description: str
|
||||
display_name: str
|
||||
input: NodeInput
|
||||
name: str
|
||||
output: [str]
|
||||
output_is_list: [boolean]
|
||||
output_name: [str]
|
||||
output_node: boolean
|
||||
}
|
||||
|
||||
export interface ComfyDialog {
|
||||
element: Element
|
||||
close: () => void
|
||||
show: (html: str) => void
|
||||
}
|
||||
|
||||
export interface ComfySettingsDialog {
|
||||
app: ComfyApp
|
||||
element: Element
|
||||
settingsValues: Record<string, unknown>
|
||||
settingsLookup: Record<string, unknown>
|
||||
load: () => Promise<void>
|
||||
setSettingValueAsync: (id: string, value: unknown) => Promise<void>
|
||||
}
|
||||
|
||||
export interface ComfyUI {
|
||||
app: ComfyApp
|
||||
dialog: ComfyDialog
|
||||
settings: ComfySettingsDialog
|
||||
autoQueueMode: 'instant' | 'change'
|
||||
batchCount: number
|
||||
lastQueueSize: number
|
||||
graphHasChanged: boolean
|
||||
queue: ComfyList
|
||||
history: ComfyList
|
||||
}
|
||||
|
||||
/**Very incomplete Comfy App definition*/
|
||||
interface ComfyApp {
|
||||
graph: LGraph
|
||||
queueItems: { number: number; batchCount: number }[]
|
||||
processingQueue: boolean
|
||||
ui: ComfyUI
|
||||
extensions: ComfyExtension[]
|
||||
nodeOutputs: Record<string, unknown>
|
||||
nodePreviewImages: Record<string, Image>
|
||||
shiftDown: boolean
|
||||
isImageNode: (node: LGraphNodeExtended) => boolean
|
||||
queuePrompt: (number: number, batchCount: number) => Promise<void>
|
||||
/** Loads workflow data from the specified file*/
|
||||
handleFile: (file: File) => Promise<void>
|
||||
}
|
||||
|
||||
export type { ComfyApp as App }
|
||||
|
||||
export interface LGraphNodeExtension {
|
||||
addDOMWidget: (
|
||||
name: string,
|
||||
type: string,
|
||||
element: Element,
|
||||
options: Record<string, unknown>,
|
||||
) => IWidget
|
||||
onNodeCreated: () => void
|
||||
getExtraMenuOptions: () => ContextMenuItem[]
|
||||
prototype: LGraphNodeExtended
|
||||
}
|
||||
|
||||
export type LGraphNodeExtended = LGraphNode & LGraphNodeExtension
|
||||
|
||||
export interface NodeType /*extends LGraphNode*/ {
|
||||
category: str
|
||||
comfyClass: str
|
||||
length: 0
|
||||
name: str
|
||||
nodeData: NodeData
|
||||
prototype: LGraphNodeExtended
|
||||
title: str
|
||||
type: str
|
||||
}
|
||||
|
||||
export interface NodeInput {
|
||||
required: object
|
||||
}
|
||||
|
||||
// NOTE: for prototype overriding
|
||||
export type OnDrawWidgetParams = Parameters<IWidget['draw']>
|
||||
export type OnDrawForegroundParams = Parameters<LGraphNode['onDrawForeground']>
|
||||
export type OnMouseDownParams = Parameters<LGraphNode['onMouseDown']>
|
||||
export type OnConnectionsChangeParams = Parameters<
|
||||
LGraphNode['onConnectionsChange']
|
||||
>
|
||||
export type OnNodeCreatedParams = Parameters<
|
||||
LGraphNodeExtension['onNodeCreated']
|
||||
>
|
||||
|
||||
export interface DocumentationOptions {
|
||||
icon_size?: number
|
||||
icon_margin?: number
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/**
|
||||
* @typedef {import("./shared.d.ts").NodeData} NodeData
|
||||
* @typedef {import("./shared.d.ts").NodeType} NodeType
|
||||
* @typedef {import("./shared.d.ts").DocumentationOptions} DocumentationOptions
|
||||
* @typedef {import("./shared.d.ts").OnDrawForegroundParams} OnDrawForegroundParams
|
||||
* @typedef {import("./shared.d.ts").OnMouseDownParams} OnMouseDownParams
|
||||
* @typedef {import("./shared.d.ts").OnConnectionsChangeParams} OnConnectionsChangeParams
|
||||
* @typedef {import("./shared.d.ts").ContextMenuItem} ContextMenuItem
|
||||
* @typedef {import("./shared.d.ts").IWidget} IWidget
|
||||
* @typedef {import("./shared.d.ts").VectorWidget} VectorWidget
|
||||
* @typedef {import("./shared.d.ts").LGraphNodeExtended} LGraphNode
|
||||
* @typedef {import("./shared.d.ts").LLink} LLink
|
||||
* @typedef {import("./shared.d.ts").App} App
|
||||
* @typedef {import("./shared.d.ts").OnDrawWidgetParams} OnDrawWidgetParams
|
||||
* @typedef {import("./shared.d.ts").INodeInputSlot} INodeInputSlot
|
||||
* @typedef {import("./shared.d.ts").INodeOutputSlot} INodeOutputSlot
|
||||
*/
|
||||
|
||||
@@ -13,10 +13,6 @@ data otherwise:
|
||||

|
||||
|
||||
|
||||
**note +**
|
||||
A basic HTML note mainly to add better looking notes/instructions for workflow makers:
|
||||

|
||||
|
||||
|
||||
## Standalone
|
||||
These scripts can be taken and placed independently of `comfy_mtb` or any other files, mimicking what pythongosss did for their
|
||||
|
||||
+142
-974
File diff suppressed because it is too large
Load Diff
-496
@@ -1,496 +0,0 @@
|
||||
import { app } from '../../scripts/app.js'
|
||||
import * as shared from './comfy_shared.js'
|
||||
import { infoLogger } from './comfy_shared.js'
|
||||
import { MtbWidgets } from './mtb_widgets.js'
|
||||
import { ComfyWidgets } from '../../scripts/widgets.js'
|
||||
import * as mtb_widgets from './mtb_widgets.js'
|
||||
|
||||
/**
|
||||
* @typedef {'number'|'string'|'vector2'|'vector3'|'vector4'|'color'} ConstantType
|
||||
* @typedef {import ("../../../web/types/litegraph.d.ts").LGraphNode} Node
|
||||
* @typedef {{x:number,y:number,z?:number,w?:number}} VectorValue
|
||||
* @typedef {}
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {number} size - The number of axis of the vector (2,3 or 4)
|
||||
* @param {number} val - The default scalar value to fill the vector with
|
||||
* @returns {VectorValue} vector
|
||||
* */
|
||||
const initVector = (size, val = 0.0) => {
|
||||
const res = {}
|
||||
for (let i = 0; i < size; i++) {
|
||||
const axis = mtb_widgets.VECTOR_AXIS[i]
|
||||
res[axis] = val
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @extends {Node}
|
||||
* @classdesc Wrapper for the python node
|
||||
*/
|
||||
export class ConstantJs {
|
||||
constructor(python_node) {
|
||||
// this.uuid = shared.makeUUID()
|
||||
const wrapper = this
|
||||
|
||||
python_node.shape = LiteGraph.BOX_SHAPE
|
||||
python_node.serialize_widgets = true
|
||||
|
||||
const onNodeCreated = python_node.prototype.onNodeCreated
|
||||
python_node.prototype.onNodeCreated = function () {
|
||||
const r = onNodeCreated ? onNodeCreated.apply(this) : undefined
|
||||
|
||||
this.addProperty('type', 'number')
|
||||
this.addProperty('value', 0)
|
||||
|
||||
this.removeInput(0)
|
||||
this.removeOutput(0)
|
||||
|
||||
this.addOutput('Output', '*')
|
||||
|
||||
// bind our wrapper
|
||||
this.configure = wrapper.configure.bind(this)
|
||||
// this.applyToGraph = wrapper.applyToGraph.bind(this)
|
||||
this.updateWidgets = wrapper.updateWidgets.bind(this)
|
||||
this.convertValue = wrapper.convertValue.bind(this)
|
||||
// this.updateOutput = wrapper.updateOutput.bind(this)
|
||||
this.updateOutputType = wrapper.updateOutputType.bind(this)
|
||||
// this.updateTargetWidgets = wrapper.updateTargetWidgets.bind(this)
|
||||
|
||||
this.addWidget(
|
||||
'combo',
|
||||
'Type',
|
||||
this.properties.type,
|
||||
(value) => {
|
||||
this.properties.type = value
|
||||
this.updateWidgets()
|
||||
this.updateOutputType()
|
||||
},
|
||||
{
|
||||
values: [
|
||||
// 'number',
|
||||
'float',
|
||||
'int',
|
||||
'string',
|
||||
'vector2',
|
||||
'vector3',
|
||||
'vector4',
|
||||
'color',
|
||||
],
|
||||
},
|
||||
)
|
||||
this.updateWidgets()
|
||||
this.updateOutputType()
|
||||
|
||||
for (let n = 0; n < this.inputs.length; n++) {
|
||||
this.removeInput(n)
|
||||
}
|
||||
this.inputs = []
|
||||
return r
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// NOTE: this is called onPrompt
|
||||
// applyToGraph() {
|
||||
// infoLogger('Updating values for backend')
|
||||
// this.updateTargetWidgets()
|
||||
// }
|
||||
|
||||
// NOTE: deserialization happens here
|
||||
configure(info) {
|
||||
// super.configure(info)
|
||||
infoLogger('Configure Constant', { info, node: this })
|
||||
|
||||
this.properties.type = info.properties.type
|
||||
this.properties.value = info.properties.value
|
||||
|
||||
this.pos = info.pos
|
||||
this.order = info.order
|
||||
|
||||
this.updateWidgets()
|
||||
this.updateOutputType()
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the old value type to the new one, falling back to some default
|
||||
* @param {ConstantType} propType - The target type
|
||||
*/
|
||||
convertValue(propType) {
|
||||
switch (propType) {
|
||||
case 'color': {
|
||||
if (typeof this.properties.value !== 'string') {
|
||||
this.properties.value = '#ffffff'
|
||||
} else if (this.properties.value[0] !== '#') {
|
||||
this.properties.value = '#ff0000'
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'int': {
|
||||
if (typeof this.properties.value === 'object') {
|
||||
this.properties.value = Number.parseInt(this.properties.value.x)
|
||||
} else {
|
||||
this.properties.value = Number.parseInt(this.properties.value) || 0
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'float': {
|
||||
if (typeof this.properties.value === 'object') {
|
||||
this.properties.value = Number.parseFloat(this.properties.value.x)
|
||||
} else {
|
||||
this.properties.value =
|
||||
Number.parseFloat(this.properties.value) || 0.0
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'string': {
|
||||
if (typeof this.properties.value !== 'string') {
|
||||
this.properties.value = JSON.stringify(this.properties.value)
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'vector2':
|
||||
case 'vector3':
|
||||
case 'vector4': {
|
||||
const numInputs = Number.parseInt(propType.charAt(6))
|
||||
if (!this.properties.value) {
|
||||
this.properties.value = initVector(numInputs) // Array.from({ length: numInputs }, () => 0.0)
|
||||
} else if (typeof this.properties.value === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(this.properties.value)
|
||||
const newVec = {}
|
||||
for (
|
||||
let i = 0;
|
||||
i < Object.keys(mtb_widgets.VECTOR_AXIS).length;
|
||||
i++
|
||||
) {
|
||||
const axis = mtb_widgets.VECTOR_AXIS[i]
|
||||
if (Object.keys(parsed).includes(axis)) {
|
||||
newVec[axis] = parsed[axis]
|
||||
}
|
||||
}
|
||||
this.properties.value = newVec
|
||||
} catch (e) {
|
||||
shared.errorLogger(e)
|
||||
infoLogger(
|
||||
`Couldn't parse string to vec (${this.properties.value})`,
|
||||
)
|
||||
this.properties.value = initVector(numInputs)
|
||||
}
|
||||
} else if (typeof this.properties.value === 'number') {
|
||||
const newVec = initVector(numInputs)
|
||||
newVec.x = Number.parseFloat(this.properties.value)
|
||||
this.properties.value = newVec
|
||||
}
|
||||
|
||||
if (
|
||||
typeof this.properties.value === 'object' &&
|
||||
Object.keys(this.properties.value).length !== numInputs
|
||||
) {
|
||||
const current = Object.keys(this.properties.value)
|
||||
if (current.length < numInputs) {
|
||||
infoLogger('current value smaller than target, adjusting')
|
||||
for (let index = current.length; index < numInputs; index++) {
|
||||
this.properties.value[mtb_widgets.VECTOR_AXIS[index]] = 0.0
|
||||
}
|
||||
} else {
|
||||
infoLogger('current value greater than target, adjusting')
|
||||
const newVal = {}
|
||||
for (let index = 0; index < numInputs; index++) {
|
||||
newVal[mtb_widgets.VECTOR_AXIS[index]] =
|
||||
this.properties.value[mtb_widgets.VECTOR_AXIS[index]]
|
||||
}
|
||||
this.properties.value = newVal
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all widgets but the comboBox for selecting the type
|
||||
* then recreate the appropriate widget from scratch
|
||||
*/
|
||||
updateWidgets() {
|
||||
// NOTE: Remove existing widgets
|
||||
for (let i = 1; i < this.widgets.length; i++) {
|
||||
const element = this.widgets[i]
|
||||
if (element.onRemove) {
|
||||
element.onRemove()
|
||||
}
|
||||
// element?.onRemove()
|
||||
}
|
||||
|
||||
this.widgets.splice(1)
|
||||
this.widgets[0].value = this.properties.type
|
||||
|
||||
this.convertValue(this.properties.type)
|
||||
|
||||
switch (this.properties.type) {
|
||||
case 'color': {
|
||||
const col_widget = this.addCustomWidget(
|
||||
MtbWidgets.COLOR('Value', this.properties.value),
|
||||
)
|
||||
col_widget.callback = (col) => {
|
||||
this.properties.value = col
|
||||
// this.updateOutput()
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'int': {
|
||||
const f_widget = this.addCustomWidget(
|
||||
ComfyWidgets.INT(
|
||||
this,
|
||||
'Value',
|
||||
[
|
||||
'',
|
||||
{
|
||||
default: this.properties.value,
|
||||
callback: (val) => console.log('VALUE', val),
|
||||
},
|
||||
],
|
||||
app,
|
||||
),
|
||||
)
|
||||
|
||||
f_widget.widget.callback = (val) => {
|
||||
this.properties.value = val
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
case 'float': {
|
||||
this.addWidget('number', 'Value', this.properties.value, (val) => {
|
||||
this.properties.value = val
|
||||
})
|
||||
break
|
||||
}
|
||||
case 'string': {
|
||||
mtb_widgets.addMultilineWidget(
|
||||
this,
|
||||
'Value',
|
||||
{
|
||||
defaultVal: this.properties.value,
|
||||
},
|
||||
(v) => {
|
||||
this.properties.value = v
|
||||
// this.updateOutput()
|
||||
},
|
||||
)
|
||||
break
|
||||
}
|
||||
case 'vector2':
|
||||
case 'vector3':
|
||||
case 'vector4': {
|
||||
const numInputs = Number.parseInt(this.properties.type.charAt(6))
|
||||
const node = this
|
||||
const v_widget = mtb_widgets.addVectorWidget(
|
||||
this,
|
||||
'Value',
|
||||
this.properties.value, // value
|
||||
numInputs, // vector_size
|
||||
function (v) {
|
||||
node.properties.value = v
|
||||
// this.updateOutput()
|
||||
},
|
||||
)
|
||||
break
|
||||
}
|
||||
|
||||
// NOTE: this is not reached anymore, kept for reference
|
||||
case 'number': {
|
||||
if (typeof this.properties.value !== 'number') {
|
||||
this.properties.value = 0.0
|
||||
}
|
||||
const n_widget = this.addWidget(
|
||||
'number',
|
||||
'Value',
|
||||
this.properties.force_int
|
||||
? Number.parseInt(this.properties.value)
|
||||
: this.properties.value,
|
||||
(value) => {
|
||||
this.properties.value = this.properties.force_int
|
||||
? Number.parseInt(value)
|
||||
: value
|
||||
// this.updateOutput()
|
||||
},
|
||||
)
|
||||
//override the callback
|
||||
const origCallback = n_widget.callback
|
||||
const node = this
|
||||
n_widget.callback = function (val) {
|
||||
const r = origCallback ? origCallback.apply(this, [val]) : undefined
|
||||
if (node.properties.force_int) {
|
||||
// TODO: rework this, a it makes it harder to manipulate
|
||||
this.value = Number.parseInt(this.value)
|
||||
node.properties.value = Number.parseInt(this.value)
|
||||
}
|
||||
infoLogger('NEW NUMBER', this.value)
|
||||
return r
|
||||
}
|
||||
|
||||
this.addWidget(
|
||||
'toggle',
|
||||
'Convert to Integer',
|
||||
this.properties.force_int,
|
||||
(value) => {
|
||||
this.properties.force_int = value
|
||||
this.updateOutputType()
|
||||
},
|
||||
)
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
onConnectionsChange(type, slotIndex, isConnected, link, ioSlot) {
|
||||
// super.onConnectionsChange(type, slotIndex, isConnected, link, ioSlot)
|
||||
if (isConnected) {
|
||||
this.updateTargetWidgets([link.id])
|
||||
}
|
||||
}
|
||||
|
||||
updateOutputType() {
|
||||
infoLogger('Updating output type')
|
||||
const rm_if_mismatch = (type) => {
|
||||
if (this.outputs[0].type !== type) {
|
||||
for (let i = 0; i < this.outputs.length; i++) {
|
||||
this.removeOutput(i)
|
||||
}
|
||||
this.addOutput('output', type)
|
||||
// this.setOutputDataType(0, type)
|
||||
}
|
||||
}
|
||||
switch (this.properties.type) {
|
||||
case 'color':
|
||||
rm_if_mismatch('COLOR')
|
||||
break
|
||||
case 'float':
|
||||
rm_if_mismatch('FLOAT')
|
||||
break
|
||||
case 'int':
|
||||
rm_if_mismatch('INT')
|
||||
break
|
||||
case 'number':
|
||||
if (this.properties.force_int) {
|
||||
rm_if_mismatch('INT')
|
||||
} else {
|
||||
rm_if_mismatch('FLOAT')
|
||||
}
|
||||
break
|
||||
case 'string':
|
||||
rm_if_mismatch('STRING')
|
||||
break
|
||||
// case 'vector2':
|
||||
// case 'vector3':
|
||||
// case 'vector4':
|
||||
// rm_if_mismatch('FLOAT')
|
||||
// break
|
||||
case 'vector2':
|
||||
rm_if_mismatch('VECTOR2')
|
||||
break
|
||||
case 'vector3':
|
||||
rm_if_mismatch('VECTOR3')
|
||||
break
|
||||
case 'vector4':
|
||||
rm_if_mismatch('VECTOR4')
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
// this.updateOutput()
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE: This feels hacky but seems to work fine
|
||||
* since Constant is a virtual node.
|
||||
*/
|
||||
updateTargetWidgets(u_links) {
|
||||
infoLogger('Updating target widgets')
|
||||
if (!app.graph.links) return
|
||||
const links = u_links || this.outputs[0].links
|
||||
if (!links) return
|
||||
for (let i = 0; i < links.length; i++) {
|
||||
const link = app.graph.links[links[i]]
|
||||
const tgt_node = app.graph.getNodeById(link.target_id)
|
||||
if (!tgt_node || !tgt_node.inputs) return
|
||||
const tgt_input = tgt_node.inputs[link.target_slot]
|
||||
if (!tgt_input) return
|
||||
const tgt_widget = tgt_node.widgets.filter(
|
||||
(w) => w.name === tgt_input.name,
|
||||
)
|
||||
// infoLogger('Constant Target Node', tgt_node)
|
||||
// infoLogger('Constant Target Input', tgt_input)
|
||||
if (!tgt_widget || tgt_widget.length === 0) return
|
||||
|
||||
tgt_widget[0].value = this.properties.value
|
||||
}
|
||||
}
|
||||
|
||||
updateOutput() {
|
||||
infoLogger('Updating output value')
|
||||
const value = this.properties.value
|
||||
|
||||
switch (this.properties.type) {
|
||||
case 'color':
|
||||
this.setOutputData(0, value)
|
||||
break
|
||||
case 'number':
|
||||
if (this.properties.force_int) {
|
||||
this.setOutputData(0, Number.parseInt(value))
|
||||
} else {
|
||||
this.setOutputData(0, Number.parseFloat(value))
|
||||
}
|
||||
break
|
||||
case 'string':
|
||||
this.setOutputData(0, value.toString())
|
||||
break
|
||||
case 'vector2':
|
||||
case 'vector3':
|
||||
case 'vector4':
|
||||
this.setOutputData(0, value)
|
||||
break
|
||||
|
||||
// case 'vector2':
|
||||
// this.setOutputData(0, value.slice(0, 2))
|
||||
// break
|
||||
// case 'vector3':
|
||||
// this.setOutputData(0, value.slice(0, 3))
|
||||
// break
|
||||
// case 'vector4':
|
||||
// this.setOutputData(0, value.slice(0, 4))
|
||||
// break
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
infoLogger('New Value', this.value)
|
||||
|
||||
this.updateTargetWidgets()
|
||||
}
|
||||
}
|
||||
app.registerExtension({
|
||||
name: 'mtb.constant',
|
||||
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, _app) {
|
||||
if (nodeData.name === 'Constant (mtb)') {
|
||||
new ConstantJs(nodeType)
|
||||
}
|
||||
},
|
||||
// NOTE: old js only registration
|
||||
//
|
||||
// registerCustomNodes() {
|
||||
// LiteGraph.registerNodeType('Constant (mtb)', Constant)
|
||||
//
|
||||
// Constant.category = 'mtb/utils'
|
||||
// Constant.title = 'Constant (mtb)'
|
||||
// },
|
||||
})
|
||||
@@ -1,221 +0,0 @@
|
||||
// Reference the shared typedefs file
|
||||
/// <reference path="../types/typedefs.js" />
|
||||
import { app } from '../../scripts/app.js'
|
||||
import { infoLogger } from './comfy_shared.js'
|
||||
|
||||
function B0(t) {
|
||||
return (1 - t) ** 3 / 6
|
||||
}
|
||||
function B1(t) {
|
||||
return (3 * t ** 3 - 6 * t ** 2 + 4) / 6
|
||||
}
|
||||
function B2(t) {
|
||||
return (-3 * t ** 3 + 3 * t ** 2 + 3 * t + 1) / 6
|
||||
}
|
||||
function B3(t) {
|
||||
return t ** 3 / 6
|
||||
}
|
||||
class CurveWidget {
|
||||
constructor(...args) {
|
||||
const [inputName, opts] = args
|
||||
|
||||
this.name = inputName || 'Curve'
|
||||
|
||||
this.type = 'FLOAT_CURVE'
|
||||
this.selectedPointIndex = null
|
||||
this.options = opts
|
||||
this.value = this.value || { 0: { x: 0, y: 0 }, 1: { x: 1, y: 1 } }
|
||||
}
|
||||
|
||||
drawBSpline(ctx, width, height, posY) {
|
||||
const n = this.value.length - 1
|
||||
const numSegments = n - 2
|
||||
const numPoints = this.value.length
|
||||
if (numPoints < 4) {
|
||||
this.drawLinear(ctx, width, height, posY)
|
||||
} else {
|
||||
for (let j = 0; j <= numSegments; j++) {
|
||||
for (let t = 0; t <= 1; t += 0.01) {
|
||||
let pt = this.getBSplinePoint(j, t)
|
||||
let x = pt.x * width
|
||||
let y = posY + height - pt.y * height
|
||||
|
||||
if (t === 0) ctx.moveTo(x, y)
|
||||
else ctx.lineTo(x, y)
|
||||
}
|
||||
}
|
||||
ctx.stroke()
|
||||
}
|
||||
}
|
||||
|
||||
drawLinear(ctx, width, height, posY) {
|
||||
for (let i = 0; i < Object.keys(this.value).length - 1; i++) {
|
||||
let p1 = this.value[i]
|
||||
let p2 = this.value[i + 1]
|
||||
ctx.moveTo(p1.x * width, posY + height - p1.y * height)
|
||||
ctx.lineTo(p2.x * width, posY + height - p2.y * height)
|
||||
}
|
||||
ctx.stroke()
|
||||
}
|
||||
getBSplinePoint(i, t) {
|
||||
// Control points for this segment
|
||||
const p0 = this.value[i]
|
||||
const p1 = this.value[i + 1]
|
||||
const p2 = this.value[i + 2]
|
||||
const p3 = this.value[i + 3]
|
||||
|
||||
const x = B0(t) * p0.x + B1(t) * p1.x + B2(t) * p2.x + B3(t) * p3.x
|
||||
const y = B0(t) * p0.y + B1(t) * p1.y + B2(t) * p2.y + B3(t) * p3.y
|
||||
|
||||
return { x, y }
|
||||
}
|
||||
/**
|
||||
* @param {OnDrawWidgetParams} args
|
||||
*/
|
||||
draw(...args) {
|
||||
const hide = this.type !== 'FLOAT_CURVE'
|
||||
if (hide) {
|
||||
return
|
||||
}
|
||||
|
||||
const [ctx, node, width, posY, height] = args
|
||||
const [cw, ch] = this.computeSize(width)
|
||||
|
||||
ctx.beginPath()
|
||||
ctx.fillStyle = '#000'
|
||||
ctx.strokeStyle = '#fff'
|
||||
ctx.lineWidth = 2
|
||||
|
||||
// normalized coordinates -> canvas coordinates
|
||||
for (let i = 0; i < Object.keys(this.value || {}).length - 1; i++) {
|
||||
let p1 = this.value[i]
|
||||
let p2 = this.value[i + 1]
|
||||
ctx.moveTo(p1.x * cw, posY + ch - p1.y * ch)
|
||||
ctx.lineTo(p2.x * cw, posY + ch - p2.y * ch)
|
||||
}
|
||||
ctx.stroke()
|
||||
|
||||
// points
|
||||
Object.values(this.value || {}).forEach((point) => {
|
||||
ctx.beginPath()
|
||||
ctx.arc(point.x * cw, posY + ch - point.y * ch, 5, 0, 2 * Math.PI)
|
||||
ctx.fill()
|
||||
})
|
||||
}
|
||||
|
||||
mouse(event, pos, node) {
|
||||
let x = pos[0] - node.pos[0]
|
||||
let y = pos[1] - node.pos[1]
|
||||
const width = node.size[0]
|
||||
const height = 300 // TODO: compute
|
||||
const posY = node.pos[1]
|
||||
const localPos = { x: pos[0], y: pos[1] - LiteGraph.NODE_WIDGET_HEIGHT }
|
||||
|
||||
if (event.type === LiteGraph.pointerevents_method + 'down') {
|
||||
console.debug('Checking if a point was clicked')
|
||||
const clickedPointIndex = this.detectPoint(localPos, width, height)
|
||||
if (clickedPointIndex !== null) {
|
||||
this.selectedPointIndex = clickedPointIndex
|
||||
} else {
|
||||
this.addPoint(localPos, width, height)
|
||||
}
|
||||
return true
|
||||
} else if (
|
||||
event.type === LiteGraph.pointerevents_method + 'move' &&
|
||||
this.selectedPointIndex !== null
|
||||
) {
|
||||
this.movePoint(this.selectedPointIndex, localPos, width, height)
|
||||
return true
|
||||
} else if (
|
||||
event.type === LiteGraph.pointerevents_method + 'up' &&
|
||||
this.selectedPointIndex !== null
|
||||
) {
|
||||
this.selectedPointIndex = null
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
callback(...args) {
|
||||
//value, that, node, pos, event) {
|
||||
|
||||
}
|
||||
|
||||
detectPoint(localPos, width, height) {
|
||||
const threshold = 20 // TODO: extract
|
||||
const keys = Object.keys(this.value)
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i]
|
||||
const p = this.value[key]
|
||||
const px = p.x * width
|
||||
const py = height - p.y * height
|
||||
if (
|
||||
Math.abs(localPos.x - px) < threshold &&
|
||||
Math.abs(localPos.y - py) < threshold
|
||||
) {
|
||||
return key
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
addPoint(localPos, width, height) {
|
||||
// add a new point based on click position
|
||||
const normalizedPoint = {
|
||||
x: localPos.x / width,
|
||||
y: 1 - localPos.y / height,
|
||||
}
|
||||
|
||||
const keys = Object.keys(this.value)
|
||||
let insertIndex = keys.length
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
if (normalizedPoint.x < this.value[keys[i]].x) {
|
||||
insertIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
// shift
|
||||
for (let i = keys.length; i > insertIndex; i--) {
|
||||
this.value[i] = this.value[i - 1]
|
||||
}
|
||||
|
||||
this.value[insertIndex] = normalizedPoint
|
||||
}
|
||||
|
||||
movePoint(index, localPos, width, height) {
|
||||
const point = this.value[index]
|
||||
point.x = Math.max(0, Math.min(1, localPos.x / width))
|
||||
point.y = Math.max(0, Math.min(1, 1 - localPos.y / height))
|
||||
|
||||
this.value[index] = point
|
||||
}
|
||||
computeSize(width) {
|
||||
return [width, 300]
|
||||
}
|
||||
|
||||
configure(data) {
|
||||
}
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: 'mtb.curves',
|
||||
getCustomWidgets: () => {
|
||||
return {
|
||||
/**
|
||||
* @param {LGraphNode} node
|
||||
* @param {str} inputName
|
||||
* @param {[str,*]} inputData
|
||||
* @param {*} app
|
||||
*
|
||||
*/
|
||||
FLOAT_CURVE: (node, inputName, inputData, app) => {
|
||||
// const c = node.widgets.find((w) => w.type === "FLOAT_CURVE")
|
||||
const wid = node.addCustomWidget(new CurveWidget(inputName, inputData))
|
||||
|
||||
return {
|
||||
widget: wid,
|
||||
minWidth: 150,
|
||||
minHeight: 30,
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
+31
-75
@@ -7,68 +7,36 @@
|
||||
*
|
||||
*/
|
||||
|
||||
// Reference the shared typedefs file
|
||||
/// <reference path="../types/typedefs.js" />
|
||||
|
||||
import { app } from '../../scripts/app.js'
|
||||
|
||||
import * as shared from './comfy_shared.js'
|
||||
import { MtbWidgets } from './mtb_widgets.js'
|
||||
import { app } from '/scripts/app.js'
|
||||
import * as shared from '/extensions/mtb/comfy_shared.js'
|
||||
import { log } from '/extensions/mtb/comfy_shared.js'
|
||||
import { MtbWidgets } from '/extensions/mtb/mtb_widgets.js'
|
||||
|
||||
// TODO: respect inputs order...
|
||||
|
||||
function escapeHtml(unsafe) {
|
||||
return unsafe
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
}
|
||||
app.registerExtension({
|
||||
name: 'mtb.Debug',
|
||||
|
||||
/**
|
||||
* @param {NodeType} nodeType
|
||||
* @param {NodeData} nodeData
|
||||
* @param {*} app
|
||||
*/
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
if (nodeData.name === 'Debug (mtb)') {
|
||||
const onNodeCreated = nodeType.prototype.onNodeCreated
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
this.options = {}
|
||||
const r = onNodeCreated
|
||||
? onNodeCreated.apply(this, arguments)
|
||||
: undefined
|
||||
this.addInput(`anything_1`, '*')
|
||||
return r
|
||||
}
|
||||
|
||||
const onConnectionsChange = nodeType.prototype.onConnectionsChange
|
||||
/**
|
||||
* @param {OnConnectionsChangeParams} args
|
||||
*/
|
||||
nodeType.prototype.onConnectionsChange = function (...args) {
|
||||
const [_type, index, connected, link_info, ioSlot] = args
|
||||
nodeType.prototype.onConnectionsChange = function (
|
||||
type,
|
||||
index,
|
||||
connected,
|
||||
link_info
|
||||
) {
|
||||
const r = onConnectionsChange
|
||||
? onConnectionsChange.apply(this, args)
|
||||
? onConnectionsChange.apply(this, arguments)
|
||||
: undefined
|
||||
// TODO: remove all widgets on disconnect once computed
|
||||
shared.dynamic_connection(this, index, connected, 'anything_', '*', {
|
||||
link: link_info,
|
||||
ioSlot: ioSlot,
|
||||
})
|
||||
shared.dynamic_connection(this, index, connected, 'anything_', '*')
|
||||
|
||||
//- infer type
|
||||
if (link_info) {
|
||||
// const fromNode = this.graph._nodes.find(
|
||||
// (otherNode) => otherNode.id === link_info.origin_id,
|
||||
// )
|
||||
// const fromNode = app.graph.getNodeById(link_info.origin_id)
|
||||
const { from } = shared.nodesFromLink(this, link_info)
|
||||
if (!from || this.inputs.length === 0) return
|
||||
const type = from.outputs[link_info.origin_slot].type
|
||||
const fromNode = this.graph._nodes.find(
|
||||
(otherNode) => otherNode.id == link_info.origin_id
|
||||
)
|
||||
const type = fromNode.outputs[link_info.origin_slot].type
|
||||
this.inputs[index].type = type
|
||||
// this.inputs[index].label = type.toLowerCase()
|
||||
}
|
||||
@@ -77,63 +45,51 @@ app.registerExtension({
|
||||
this.inputs[index].type = '*'
|
||||
this.inputs[index].label = `anything_${index + 1}`
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
const onExecuted = nodeType.prototype.onExecuted
|
||||
nodeType.prototype.onExecuted = async function (data) {
|
||||
nodeType.prototype.onExecuted = function (message) {
|
||||
onExecuted?.apply(this, arguments)
|
||||
|
||||
const prefix = 'anything_'
|
||||
|
||||
if (this.widgets) {
|
||||
// const pos = this.widgets.findIndex((w) => w.name === "anything_1");
|
||||
// if (pos !== -1) {
|
||||
for (let i = 0; i < this.widgets.length; i++) {
|
||||
if (this.widgets[i].name !== 'output_to_console') {
|
||||
this.widgets[i].onRemoved?.()
|
||||
}
|
||||
this.widgets[i].onRemoved?.()
|
||||
}
|
||||
this.widgets.length = 1
|
||||
this.widgets.length = 0
|
||||
}
|
||||
let widgetI = 1
|
||||
if (data.text) {
|
||||
for (const txt of data.text) {
|
||||
if (message.text) {
|
||||
for (const txt of message.text) {
|
||||
const w = this.addCustomWidget(
|
||||
MtbWidgets.DEBUG_STRING(`${prefix}_${widgetI}`, escapeHtml(txt)),
|
||||
MtbWidgets.DEBUG_STRING(`${prefix}_${widgetI}`, txt)
|
||||
)
|
||||
w.parent = this
|
||||
widgetI++
|
||||
}
|
||||
}
|
||||
if (data.b64_images) {
|
||||
for (const img of data.b64_images) {
|
||||
if (message.b64_images) {
|
||||
for (const img of message.b64_images) {
|
||||
const w = this.addCustomWidget(
|
||||
MtbWidgets.DEBUG_IMG(`${prefix}_${widgetI}`, img),
|
||||
MtbWidgets.DEBUG_IMG(`${prefix}_${widgetI}`, img)
|
||||
)
|
||||
w.parent = this
|
||||
widgetI++
|
||||
}
|
||||
// this.onResize?.(this.size);
|
||||
// this.resize?.(this.size)
|
||||
this.setSize(this.computeSize())
|
||||
}
|
||||
|
||||
if (data.geometry) {
|
||||
for (const geom of data.geometry) {
|
||||
console.log('Adding geom', geom, typeof geom)
|
||||
const w = this.addCustomWidget(
|
||||
await MtbWidgets.DEBUG_GEOM(this, `${prefix}_${widgetI}`, geom),
|
||||
)
|
||||
w.parent = this
|
||||
widgetI++
|
||||
}
|
||||
}
|
||||
|
||||
// this.setSize(this.computeSize())
|
||||
|
||||
this.onRemoved = function () {
|
||||
// When removing this node we need to remove the input from the DOM
|
||||
for (const y in this.widgets) {
|
||||
for (let y in this.widgets) {
|
||||
if (this.widgets[y].canvas) {
|
||||
this.widgets[y].canvas.remove()
|
||||
}
|
||||
shared.cleanupNode(this)
|
||||
this.widgets[y].onRemoved?.()
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
-3
File diff suppressed because one or more lines are too long
@@ -1,29 +0,0 @@
|
||||
/**
|
||||
* File: geometry_nodes.js
|
||||
* Project: comfy_mtb
|
||||
* Author: Mel Massadian
|
||||
*
|
||||
* Copyright (c) 2023 Mel Massadian
|
||||
*
|
||||
*/
|
||||
|
||||
import { app } from '../../scripts/app.js'
|
||||
|
||||
app.registerExtension({
|
||||
name: 'mtb.geometry_nodes',
|
||||
init: () => {},
|
||||
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, ...args) {
|
||||
switch (nodeData.name) {
|
||||
case 'Geometry Load (mtb)': {
|
||||
const onExecuted = nodeType.prototype.onExecuted
|
||||
nodeType.prototype.onExecuted = function (message) {
|
||||
onExecuted?.apply(this, nodeType, nodeData, ...args)
|
||||
console.log('Executed Load Geometry', ...args)
|
||||
console.log('Message:', message)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
+279
-302
@@ -9,348 +9,325 @@
|
||||
|
||||
// forked from pysssss's imageFeed.js
|
||||
|
||||
import { api } from '../../scripts/api.js'
|
||||
import { app } from '../../scripts/app.js'
|
||||
import { LocalStorageManager } from './comfy_shared.js'
|
||||
import { api } from '/scripts/api.js'
|
||||
import { app } from '/scripts/app.js'
|
||||
|
||||
const styles = {
|
||||
lighbox: {
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: '100vw',
|
||||
height: '100vh',
|
||||
background: 'rgba(0,0,0,0.5)',
|
||||
display: 'none',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
zIndex: 999,
|
||||
},
|
||||
lightboxBtn: (extra) => ({
|
||||
position: 'absolute',
|
||||
top: '50%',
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
color: '#fff',
|
||||
zIndex: 1000,
|
||||
fontSize: '30px',
|
||||
cursor: 'pointer',
|
||||
pointerEvents: 'auto',
|
||||
...extra,
|
||||
}),
|
||||
img_list: {
|
||||
minHeight: '30px',
|
||||
maxHeight: '300px',
|
||||
width: '100vw',
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
zIndex: 10,
|
||||
background: '#333',
|
||||
overflow: 'auto',
|
||||
},
|
||||
lighbox: {
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: '100vw',
|
||||
height: '100vh',
|
||||
background: 'rgba(0,0,0,0.5)',
|
||||
display: 'none',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
zIndex: 999,
|
||||
},
|
||||
lightboxBtn: (extra) => ({
|
||||
position: 'absolute',
|
||||
top: '50%',
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
color: '#fff',
|
||||
zIndex: 1000,
|
||||
fontSize: '30px',
|
||||
cursor: 'pointer',
|
||||
pointerEvents: 'auto',
|
||||
...extra,
|
||||
}),
|
||||
img_list: {
|
||||
minHeight: '30px',
|
||||
maxHeight: '300px',
|
||||
width: '100vw',
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
zIndex: 10,
|
||||
background: '#333',
|
||||
overflow: 'auto',
|
||||
},
|
||||
}
|
||||
|
||||
let currentImageIndex = 0
|
||||
const imageUrls = []
|
||||
|
||||
let image_menu = null
|
||||
const storage = new LocalStorageManager('mtb')
|
||||
|
||||
let activated = storage.get('image_feed', false)
|
||||
let activated = true
|
||||
|
||||
app.registerExtension({
|
||||
name: 'mtb.ImageFeed',
|
||||
setup: () => {
|
||||
app.ui.settings.addSetting({
|
||||
id: 'mtb.Main.image-feed-enabled',
|
||||
category: ['mtb', 'Main', 'image-feed-enabled'],
|
||||
name: 'Enable Image Feed',
|
||||
type: 'boolean',
|
||||
defaultValue: false,
|
||||
attrs: {
|
||||
style: {
|
||||
fontFamily: 'monospace',
|
||||
},
|
||||
},
|
||||
async onChange(value) {
|
||||
storage.set('image_feed', value)
|
||||
activated = value
|
||||
},
|
||||
})
|
||||
},
|
||||
init: async () => {
|
||||
if (!activated) {
|
||||
return
|
||||
}
|
||||
const pythongossFeed = app.extensions.find(
|
||||
(e) => e.name === 'pysssss.ImageFeed',
|
||||
)
|
||||
if (pythongossFeed) {
|
||||
console.warn(
|
||||
"[mtb] - Aborting the loading of mtb's imageFeed in favor of pysssss.ImageFeed",
|
||||
)
|
||||
activated = false // just in case other methods are added later on
|
||||
return
|
||||
}
|
||||
// - HTML & CSS
|
||||
//- lightbox
|
||||
const lightboxContainer = document.createElement('div')
|
||||
Object.assign(lightboxContainer.style, styles.lighbox)
|
||||
name: 'mtb.ImageFeed',
|
||||
init: async () => {
|
||||
const pythongossFeed = app.extensions.find(
|
||||
(e) => e.name == 'pysssss.ImageFeed'
|
||||
)
|
||||
if (pythongossFeed) {
|
||||
console.warn(
|
||||
"[mtb] - Aborting the loading of mtb's imageFeed in favor of pysssss.ImageFeed"
|
||||
)
|
||||
activated = false // just in case other methods are added later on
|
||||
return
|
||||
}
|
||||
// - HTML & CSS
|
||||
//- lightbox
|
||||
const lightboxContainer = document.createElement('div')
|
||||
Object.assign(lightboxContainer.style, styles.lighbox)
|
||||
|
||||
const lightboxImage = document.createElement('img')
|
||||
Object.assign(lightboxImage.style, {
|
||||
maxHeight: '100%',
|
||||
maxWidth: '100%',
|
||||
borderRadius: '5px',
|
||||
})
|
||||
const lightboxImage = document.createElement('img')
|
||||
Object.assign(lightboxImage.style, {
|
||||
maxHeight: '100%',
|
||||
maxWidth: '100%',
|
||||
borderRadius: '5px',
|
||||
})
|
||||
|
||||
// previous and next buttons
|
||||
const lightboxPrevBtn = document.createElement('button')
|
||||
const lightboxNextBtn = document.createElement('button')
|
||||
// previous and next buttons
|
||||
const lightboxPrevBtn = document.createElement('button')
|
||||
const lightboxNextBtn = document.createElement('button')
|
||||
|
||||
lightboxPrevBtn.textContent = '❮'
|
||||
lightboxNextBtn.textContent = '❯'
|
||||
lightboxPrevBtn.textContent = '❮'
|
||||
lightboxNextBtn.textContent = '❯'
|
||||
|
||||
Object.assign(lightboxPrevBtn.style, styles.lightboxBtn({ left: '0%' }))
|
||||
Object.assign(lightboxNextBtn.style, styles.lightboxBtn({ right: '0%' }))
|
||||
Object.assign(lightboxPrevBtn.style, styles.lightboxBtn({ left: '0%' }))
|
||||
Object.assign(lightboxNextBtn.style, styles.lightboxBtn({ right: '0%' }))
|
||||
|
||||
// close button
|
||||
const lightboxCloseBtn = document.createElement('button')
|
||||
Object.assign(
|
||||
lightboxCloseBtn.style,
|
||||
styles.lightboxBtn({ right: '0', top: '0' }),
|
||||
)
|
||||
lightboxCloseBtn.textContent = '❌'
|
||||
// close button
|
||||
const lightboxCloseBtn = document.createElement('button')
|
||||
Object.assign(
|
||||
lightboxCloseBtn.style,
|
||||
styles.lightboxBtn({ right: '0', top: '0' })
|
||||
)
|
||||
lightboxCloseBtn.textContent = '❌'
|
||||
|
||||
const lightboxButtons = document.createElement('div')
|
||||
Object.assign(lightboxButtons.style, {
|
||||
position: 'absolute',
|
||||
top: '0%',
|
||||
right: '0%',
|
||||
// transform: "translate(50%, -50%)",
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
color: '#fff',
|
||||
fontSize: '30px',
|
||||
cursor: 'pointer',
|
||||
pointerEvents: 'none',
|
||||
})
|
||||
const lightboxButtons = document.createElement('div')
|
||||
Object.assign(lightboxButtons.style, {
|
||||
position: 'absolute',
|
||||
top: '0%',
|
||||
right: '0%',
|
||||
// transform: "translate(50%, -50%)",
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
color: '#fff',
|
||||
fontSize: '30px',
|
||||
cursor: 'pointer',
|
||||
pointerEvents: 'none',
|
||||
})
|
||||
|
||||
lightboxButtons.append(lightboxPrevBtn, lightboxNextBtn, lightboxCloseBtn)
|
||||
lightboxContainer.append(lightboxButtons, lightboxImage)
|
||||
lightboxButtons.append(lightboxPrevBtn, lightboxNextBtn, lightboxCloseBtn)
|
||||
lightboxContainer.append(lightboxButtons, lightboxImage)
|
||||
|
||||
//- image list
|
||||
const imageListContainer = document.createElement('div')
|
||||
Object.assign(imageListContainer.style, styles.img_list)
|
||||
//- image list
|
||||
const imageListContainer = document.createElement('div')
|
||||
Object.assign(imageListContainer.style, styles.img_list)
|
||||
|
||||
const createImgListBtn = (text, style) => {
|
||||
const btn = document.createElement('button')
|
||||
btn.type = 'button'
|
||||
btn.textContent = text
|
||||
Object.assign(btn.style, {
|
||||
...style,
|
||||
border: 'none',
|
||||
color: '#fff',
|
||||
background: 'none',
|
||||
height: '20px',
|
||||
cursor: 'pointer',
|
||||
position: 'absolute',
|
||||
top: '5px',
|
||||
fontSize: '12px',
|
||||
lineHeight: '12px',
|
||||
})
|
||||
imageListContainer.append(btn)
|
||||
return btn
|
||||
}
|
||||
const showBtn = document.createElement('button')
|
||||
const closeBtn = createImgListBtn('❌', {
|
||||
width: '20px',
|
||||
textIndent: '-4px',
|
||||
right: '5px',
|
||||
})
|
||||
const loadButton = createImgListBtn('Load Session History', {
|
||||
right: '90px',
|
||||
})
|
||||
const clearButton = createImgListBtn('Clear', {
|
||||
right: '30px',
|
||||
})
|
||||
const createImgListBtn = (text, style) => {
|
||||
const btn = document.createElement('button')
|
||||
btn.type = 'button'
|
||||
btn.textContent = text
|
||||
Object.assign(btn.style, {
|
||||
...style,
|
||||
border: 'none',
|
||||
color: '#fff',
|
||||
background: 'none',
|
||||
height: '20px',
|
||||
cursor: 'pointer',
|
||||
position: 'absolute',
|
||||
top: '5px',
|
||||
fontSize: '12px',
|
||||
lineHeight: '12px',
|
||||
})
|
||||
imageListContainer.append(btn)
|
||||
return btn
|
||||
}
|
||||
const showBtn = document.createElement('button')
|
||||
const closeBtn = createImgListBtn('❌', {
|
||||
width: '20px',
|
||||
textIndent: '-4px',
|
||||
right: '5px',
|
||||
})
|
||||
const loadButton = createImgListBtn('Load Session History', {
|
||||
right: '90px',
|
||||
})
|
||||
const clearButton = createImgListBtn('Clear', {
|
||||
right: '30px',
|
||||
})
|
||||
|
||||
//- tools popup button
|
||||
showBtn.classList.add('comfy-settings-btn')
|
||||
Object.assign(showBtn.style, {
|
||||
right: '16px',
|
||||
cursor: 'pointer',
|
||||
display: 'none',
|
||||
})
|
||||
//- tools popup button
|
||||
showBtn.classList.add('comfy-settings-btn')
|
||||
Object.assign(showBtn.style, {
|
||||
right: '16px',
|
||||
cursor: 'pointer',
|
||||
display: 'none',
|
||||
})
|
||||
|
||||
//- append to DOM
|
||||
document.body.append(imageListContainer)
|
||||
//- append to DOM
|
||||
document.body.append(imageListContainer)
|
||||
|
||||
showBtn.textContent = '🖼'
|
||||
showBtn.onclick = () => {
|
||||
imageListContainer.style.display = 'block'
|
||||
showBtn.style.display = 'none'
|
||||
}
|
||||
document.querySelector('.comfy-settings-btn').after(showBtn)
|
||||
document.querySelector('.comfy-settings-btn').after(lightboxContainer)
|
||||
showBtn.textContent = '🖼️'
|
||||
showBtn.onclick = () => {
|
||||
imageListContainer.style.display = 'block'
|
||||
showBtn.style.display = 'none'
|
||||
}
|
||||
document.querySelector('.comfy-settings-btn').after(showBtn)
|
||||
document.querySelector('.comfy-settings-btn').after(lightboxContainer)
|
||||
|
||||
// for (const { output } of history) {
|
||||
// if (output?.images) {
|
||||
// for (const src of output.images) {
|
||||
// const img = document.createElement("img");
|
||||
// const but = document.createElement("button");
|
||||
// for (const { output } of history) {
|
||||
// if (output?.images) {
|
||||
// for (const src of output.images) {
|
||||
// const img = document.createElement("img");
|
||||
// const but = document.createElement("button");
|
||||
|
||||
//- callbacks
|
||||
closeBtn.onclick = () => {
|
||||
imageListContainer.style.display = 'none'
|
||||
showBtn.style.display = 'unset'
|
||||
}
|
||||
//- callbacks
|
||||
closeBtn.onclick = () => {
|
||||
imageListContainer.style.display = 'none'
|
||||
showBtn.style.display = 'unset'
|
||||
}
|
||||
|
||||
clearButton.onclick = () => {
|
||||
imageListContainer.replaceChildren(closeBtn, clearButton, loadButton)
|
||||
}
|
||||
clearButton.onclick = () => {
|
||||
imageListContainer.replaceChildren(closeBtn, clearButton, loadButton)
|
||||
}
|
||||
|
||||
lightboxNextBtn.onclick = () => {
|
||||
currentImageIndex = (currentImageIndex + 1) % imageUrls.length
|
||||
const imageUrl = imageUrls[currentImageIndex]
|
||||
lightboxImage.src = imageUrl
|
||||
}
|
||||
lightboxNextBtn.onclick = () => {
|
||||
currentImageIndex = (currentImageIndex + 1) % imageUrls.length
|
||||
const imageUrl = imageUrls[currentImageIndex]
|
||||
lightboxImage.src = imageUrl
|
||||
}
|
||||
|
||||
// Modify the lightboxPrevBtn onclick callback
|
||||
lightboxPrevBtn.onclick = () => {
|
||||
currentImageIndex =
|
||||
(currentImageIndex - 1 + imageUrls.length) % imageUrls.length
|
||||
const imageUrl = imageUrls[currentImageIndex]
|
||||
lightboxImage.src = imageUrl
|
||||
}
|
||||
// Modify the lightboxPrevBtn onclick callback
|
||||
lightboxPrevBtn.onclick = () => {
|
||||
currentImageIndex =
|
||||
(currentImageIndex - 1 + imageUrls.length) % imageUrls.length
|
||||
const imageUrl = imageUrls[currentImageIndex]
|
||||
lightboxImage.src = imageUrl
|
||||
}
|
||||
|
||||
lightboxCloseBtn.onclick = () => {
|
||||
lightboxContainer.style.display = 'none'
|
||||
}
|
||||
lightboxImage.onclick = lightboxNextBtn.onclick
|
||||
/**
|
||||
* This is the function that creates the image buttons for the image list
|
||||
* They are wrapped in a button so that they can be clicked and open
|
||||
* the image in the lightbox.
|
||||
* @param {*} src
|
||||
*/
|
||||
const createImageBtn = (src) => {
|
||||
console.debug(`making image ${src.filename}`)
|
||||
const img = document.createElement('img')
|
||||
const but = document.createElement('button')
|
||||
lightboxCloseBtn.onclick = () => {
|
||||
lightboxContainer.style.display = 'none'
|
||||
}
|
||||
lightboxImage.onclick = lightboxNextBtn.onclick
|
||||
/**
|
||||
* This is the function that creates the image buttons for the image list
|
||||
* They are wrapped in a button so that they can be clicked and open
|
||||
* the image in the lightbox.
|
||||
* @param {*} src
|
||||
*/
|
||||
const createImageBtn = (src) => {
|
||||
console.debug(`making image ${src.filename}`)
|
||||
const img = document.createElement('img')
|
||||
const but = document.createElement('button')
|
||||
|
||||
Object.assign(but.style, {
|
||||
height: '120px',
|
||||
width: '120px',
|
||||
border: 'none',
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
})
|
||||
Object.assign(img.style, {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
objectFit: 'cover',
|
||||
})
|
||||
Object.assign(but.style, {
|
||||
height: '120px',
|
||||
width: '120px',
|
||||
border: 'none',
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
})
|
||||
Object.assign(img.style, {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
objectFit: 'cover',
|
||||
})
|
||||
|
||||
img.src = `/view?filename=${encodeURIComponent(src.filename)}&type=${
|
||||
src.type
|
||||
}&subfolder=${encodeURIComponent(src.subfolder)}`
|
||||
img.src = `/view?filename=${encodeURIComponent(src.filename)}&type=${
|
||||
src.type
|
||||
}&subfolder=${encodeURIComponent(src.subfolder)}`
|
||||
|
||||
imageUrls.push(img.src)
|
||||
imageUrls.push(img.src)
|
||||
|
||||
console.debug(img.src)
|
||||
console.debug(img.src)
|
||||
|
||||
img.onload = () => {
|
||||
but.style.width = `${120 * (img.naturalWidth / img.naturalHeight)}px`
|
||||
}
|
||||
img.onload = () => {
|
||||
but.style.width = `${120 * (img.naturalWidth / img.naturalHeight)}px`
|
||||
}
|
||||
|
||||
but.onclick = () => {
|
||||
lightboxContainer.style.display = 'flex'
|
||||
// add the same image to the lightbox
|
||||
lightboxImage.src = img.src
|
||||
// lighboxContainer.replaceChildren(lightboxButtons, img);
|
||||
}
|
||||
but.onclick = () => {
|
||||
lightboxContainer.style.display = 'flex'
|
||||
// add the same image to the lightbox
|
||||
lightboxImage.src = img.src
|
||||
// lighboxContainer.replaceChildren(lightboxButtons, img);
|
||||
}
|
||||
|
||||
// add right click menu
|
||||
but.addEventListener('contextmenu', (e) => {
|
||||
e.preventDefault()
|
||||
// add right click menu
|
||||
but.addEventListener('contextmenu', (e) => {
|
||||
e.preventDefault()
|
||||
|
||||
if (image_menu) {
|
||||
image_menu.remove()
|
||||
}
|
||||
if (image_menu) {
|
||||
image_menu.remove()
|
||||
}
|
||||
|
||||
image_menu = document.createElement('div')
|
||||
Object.assign(image_menu.style, {
|
||||
position: 'absolute',
|
||||
top: `${e.clientY}px`,
|
||||
left: `${e.clientX}px`,
|
||||
background: '#333',
|
||||
color: '#fff',
|
||||
padding: '5px',
|
||||
borderRadius: '5px',
|
||||
zIndex: 999,
|
||||
})
|
||||
const load_img = document.createElement('button')
|
||||
load_img.textContent = 'Load'
|
||||
load_img.onclick = () => {
|
||||
app.handleFile(img.src)
|
||||
}
|
||||
image_menu = document.createElement('div')
|
||||
Object.assign(image_menu.style, {
|
||||
position: 'absolute',
|
||||
top: `${e.clientY}px`,
|
||||
left: `${e.clientX}px`,
|
||||
background: '#333',
|
||||
color: '#fff',
|
||||
padding: '5px',
|
||||
borderRadius: '5px',
|
||||
zIndex: 999,
|
||||
})
|
||||
const load_img = document.createElement('button')
|
||||
load_img.textContent = 'Load'
|
||||
load_img.onclick = () => {
|
||||
app.handleFile(img.src)
|
||||
}
|
||||
|
||||
image_menu.appendChild(load_img)
|
||||
document.body.appendChild(image_menu)
|
||||
})
|
||||
image_menu.appendChild(load_img)
|
||||
document.body.appendChild(image_menu)
|
||||
})
|
||||
|
||||
but.append(img)
|
||||
imageListContainer.prepend(but)
|
||||
}
|
||||
but.append(img)
|
||||
imageListContainer.prepend(but)
|
||||
}
|
||||
|
||||
loadButton.onclick = async () => {
|
||||
const all_history = await api.getHistory()
|
||||
for (const history of all_history.History) {
|
||||
if (history.outputs) {
|
||||
for (const key of Object.keys(history.outputs)) {
|
||||
console.debug(key)
|
||||
if (history.outputs[key].images) {
|
||||
for (const im of history.outputs[key].images) {
|
||||
console.debug(im)
|
||||
createImageBtn(im)
|
||||
}
|
||||
}
|
||||
}
|
||||
// for (const src of outputs.outputs.images) {
|
||||
// console.debug(src)
|
||||
// makeImage(`${src.subfolder}/${src.filename}`)
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
loadButton.onclick = async () => {
|
||||
const all_history = await api.getHistory()
|
||||
for (const history of all_history.History) {
|
||||
if (history.outputs) {
|
||||
for (const key of Object.keys(history.outputs)) {
|
||||
console.debug(key)
|
||||
if (history.outputs[key].images) {
|
||||
for (const im of history.outputs[key].images) {
|
||||
console.debug(im)
|
||||
createImageBtn(im)
|
||||
}
|
||||
}
|
||||
}
|
||||
// for (const src of outputs.outputs.images) {
|
||||
// console.debug(src)
|
||||
// makeImage(`${src.subfolder}/${src.filename}`)
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////-------
|
||||
///////-------
|
||||
|
||||
// const all_history = await api.getHistory()
|
||||
// for (const history of all_history.History) {
|
||||
// if (history.outputs) {
|
||||
// for (const key of Object.keys(history.outputs)) {
|
||||
// for (const im of history.outputs[key].images) {
|
||||
// makeImage(im)
|
||||
// }
|
||||
// }
|
||||
// // for (const src of outputs.outputs.images) {
|
||||
// // console.debug(src)
|
||||
// // makeImage(`${src.subfolder}/${src.filename}`)
|
||||
// // }
|
||||
// }
|
||||
// }
|
||||
// const all_history = await api.getHistory()
|
||||
// for (const history of all_history.History) {
|
||||
// if (history.outputs) {
|
||||
// for (const key of Object.keys(history.outputs)) {
|
||||
// for (const im of history.outputs[key].images) {
|
||||
// makeImage(im)
|
||||
// }
|
||||
// }
|
||||
// // for (const src of outputs.outputs.images) {
|
||||
// // console.debug(src)
|
||||
// // makeImage(`${src.subfolder}/${src.filename}`)
|
||||
// // }
|
||||
// }
|
||||
// }
|
||||
|
||||
//- Hook into the API
|
||||
api.addEventListener('executed', ({ detail }) => {
|
||||
if (detail?.output?.images) {
|
||||
for (const src of detail.output.images) {
|
||||
console.debug(`Adding ${src} to image feed`)
|
||||
createImageBtn(src)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//- Hook into the API
|
||||
api.addEventListener('executed', ({ detail }) => {
|
||||
if (detail?.output?.images) {
|
||||
for (const src of detail.output.images) {
|
||||
console.debug(`Adding ${src} to image feed`)
|
||||
createImageBtn(src)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
import { app } from '../../scripts/app.js'
|
||||
import { api } from '../../scripts/api.js'
|
||||
|
||||
// import * as shared from './comfy_shared.js'
|
||||
|
||||
import {
|
||||
// defineCSSClass,
|
||||
ensureMTBStyles,
|
||||
makeElement,
|
||||
makeSelect,
|
||||
makeSlider,
|
||||
renderSidebar,
|
||||
} from './mtb_ui.js'
|
||||
|
||||
const offset = 0
|
||||
let currentWidth = 200
|
||||
let currentMode = 'input'
|
||||
let currentSort = 'None'
|
||||
|
||||
const IMAGE_NODES = ['LoadImage']
|
||||
|
||||
const updateImage = (node, image) => {
|
||||
if (IMAGE_NODES.includes(node.type)) {
|
||||
const w = node.widgets?.find((w) => w.name === 'image')
|
||||
if (w) {
|
||||
w.value = image
|
||||
w.callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getImgsFromUrls = (urls, target) => {
|
||||
const imgs = []
|
||||
if (urls === undefined) {
|
||||
return imgs
|
||||
}
|
||||
|
||||
for (const [key, url] of Object.entries(urls)) {
|
||||
const a = makeElement('img')
|
||||
a.src = url
|
||||
a.width = currentWidth
|
||||
if (currentMode === 'input') {
|
||||
a.onclick = (_e) => {
|
||||
const selected = app.canvas.selected_nodes
|
||||
if (selected && Object.keys(selected).length === 0) {
|
||||
app.extensionManager.toast.add({
|
||||
severity: 'warn',
|
||||
summary: 'No LoadImage node selected!',
|
||||
detail:
|
||||
'For now the only action when clicking images in the sidebar is to set the image on all selected LoadImage nodes.',
|
||||
life: 5000,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
for (const [_id, node] of Object.entries(app.canvas.selected_nodes)) {
|
||||
updateImage(node, key)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
a.onclick = (_e) =>
|
||||
// window.MTB?.notify?.("Output import isn't supported yet...", 5000)
|
||||
app.extensionManager.toast.add({
|
||||
severity: 'warn',
|
||||
summary: 'Outputs not supported',
|
||||
detail:
|
||||
'For now only inputs can be clicked to load the image on the active LoadImage node.',
|
||||
life: 5000,
|
||||
})
|
||||
}
|
||||
imgs.push(a)
|
||||
}
|
||||
if (target !== undefined) {
|
||||
target.append(...imgs)
|
||||
}
|
||||
return imgs
|
||||
}
|
||||
|
||||
const getUrls = async () => {
|
||||
const count = await api.getSetting('mtb.io-sidebar.count')
|
||||
console.log('Sidebar count', count)
|
||||
const inputs = await api.fetchApi('/mtb/actions', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
name: 'getUserImages',
|
||||
// mode, count, offset
|
||||
args: [currentMode, count, offset, currentSort],
|
||||
}),
|
||||
})
|
||||
const output = await inputs.json()
|
||||
return output?.result || {}
|
||||
}
|
||||
|
||||
//NOTE: do not load if using the old ui
|
||||
if (window?.__COMFYUI_FRONTEND_VERSION__) {
|
||||
// NOTE: removed this for now since I'm not actually exposing anything a client
|
||||
// cannot already access from "/view"...
|
||||
// let exposed = false
|
||||
|
||||
const sidebar_extension = {
|
||||
name: 'mtb.io-sidebar',
|
||||
// init: async () => {
|
||||
// try {
|
||||
// const res = await api.fetchApi('/mtb/server-info')
|
||||
// const msg = await res.json()
|
||||
// exposed = msg.exposed
|
||||
// } catch (e) {
|
||||
// console.error('Error:', e)
|
||||
// }
|
||||
// },
|
||||
init: () => {
|
||||
let handle
|
||||
const version = window?.__COMFYUI_FRONTEND_VERSION__
|
||||
console.log(`%c ${version}`, 'background: orange; color: white;')
|
||||
|
||||
ensureMTBStyles()
|
||||
|
||||
app.ui.settings.addSetting({
|
||||
id: 'mtb.io-sidebar.count',
|
||||
category: ['mtb', 'Input & Output Sidebar', 'count'],
|
||||
|
||||
name: 'Number of images to fetch',
|
||||
type: 'number',
|
||||
defaultValue: 1000,
|
||||
|
||||
tooltip:
|
||||
"This setting affects the input/output sidebar to determine how many images to fetch per pagination (pagination is not yet supported so for now it's the static total)",
|
||||
attrs: {
|
||||
style: {
|
||||
// fontFamily: 'monospace',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
app.ui.settings.addSetting({
|
||||
id: 'mtb.io-sidebar.img-size',
|
||||
category: ['mtb', 'Input & Output Sidebar', 'img-size'],
|
||||
|
||||
name: 'Resolution of the images',
|
||||
type: 'number',
|
||||
defaultValue: 512,
|
||||
|
||||
tooltip: "It's recommended to keep it at 512px",
|
||||
attrs: {
|
||||
style: {
|
||||
// fontFamily: 'monospace',
|
||||
},
|
||||
},
|
||||
})
|
||||
app.ui.settings.addSetting({
|
||||
id: 'mtb.io-sidebar.sort',
|
||||
category: ['mtb', 'Input & Output Sidebar', 'sort'],
|
||||
name: 'Default sort mode',
|
||||
type: 'combo',
|
||||
|
||||
onChange: (v) => {
|
||||
// alert(`Sort is now ${v}`)
|
||||
currentSort = v
|
||||
},
|
||||
|
||||
defaultValue: 'Modified',
|
||||
// tooltip: "It's recommended to keep it at 512px",
|
||||
options: [
|
||||
'None',
|
||||
'Modified',
|
||||
'Modified-Reverse',
|
||||
'Name',
|
||||
'Name-Reverse',
|
||||
],
|
||||
})
|
||||
|
||||
app.extensionManager.registerSidebarTab({
|
||||
id: 'mtb-inputs-outputs',
|
||||
icon: 'pi pi-images',
|
||||
title: 'Input & Outputs',
|
||||
tooltip: 'MTB: Browse inputs and outputs directories.',
|
||||
type: 'custom',
|
||||
|
||||
// this is run everytime the tab's diplay is toggled on.
|
||||
render: async (el) => {
|
||||
if (handle) {
|
||||
handle.unregister()
|
||||
handle = undefined
|
||||
}
|
||||
|
||||
if (el.parentNode) {
|
||||
el.parentNode.style.overflowY = 'clip'
|
||||
}
|
||||
|
||||
const urls = await getUrls(currentMode)
|
||||
let imgs = {}
|
||||
|
||||
const cont = makeElement('div.mtb_sidebar')
|
||||
|
||||
const imgGrid = makeElement('div.mtb_img_grid')
|
||||
const selector = makeSelect(['input', 'output'], currentMode)
|
||||
|
||||
selector.addEventListener('change', async (e) => {
|
||||
const newMode = e.target.value
|
||||
const changed = newMode !== currentMode
|
||||
currentMode = newMode
|
||||
if (changed) {
|
||||
imgGrid.innerHTML = ''
|
||||
const urls = await getUrls()
|
||||
if (urls) {
|
||||
imgs = getImgsFromUrls(urls, imgGrid)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const imgTools = makeElement('div.mtb_tools')
|
||||
const orderSelect = makeSelect(
|
||||
['None', 'Modified', 'Modified-Reverse', 'Name', 'Name-Reverse'],
|
||||
currentSort,
|
||||
)
|
||||
|
||||
orderSelect.addEventListener('change', async (e) => {
|
||||
const newSort = e.target.value
|
||||
const changed = newSort !== currentSort
|
||||
currentSort = newSort
|
||||
if (changed) {
|
||||
imgGrid.innerHTML = ''
|
||||
const urls = await getUrls()
|
||||
if (urls) {
|
||||
imgs = getImgsFromUrls(urls, imgGrid)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const sizeSlider = makeSlider(64, 1024, currentWidth, 1)
|
||||
imgTools.appendChild(orderSelect)
|
||||
|
||||
imgTools.appendChild(sizeSlider)
|
||||
|
||||
imgs = getImgsFromUrls(urls, imgGrid)
|
||||
|
||||
sizeSlider.addEventListener('input', (e) => {
|
||||
currentWidth = e.target.value
|
||||
for (const img of imgs) {
|
||||
img.style.width = `${e.target.value}px`
|
||||
}
|
||||
})
|
||||
handle = renderSidebar(el, cont, [selector, imgGrid, imgTools])
|
||||
},
|
||||
destroy: () => {
|
||||
if (handle) {
|
||||
handle.unregister()
|
||||
handle = undefined
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
app.registerExtension(sidebar_extension)
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
// NOTE: this will be the LT part of mtb API system
|
||||
// I need to properly publish the source and fix a few things before
|
||||
|
||||
// import { app } from '../../scripts/app.js'
|
||||
// // import { api } from '../../scripts/api.js'
|
||||
//
|
||||
// import * as shared from './comfy_shared.js'
|
||||
// import { createOutliner } from './dist/mtb_inspector.js'
|
||||
//
|
||||
// if (window?.__COMFYUI_FRONTEND_VERSION__) {
|
||||
// const version = window?.__COMFYUI_FRONTEND_VERSION__
|
||||
// console.log(`%c ${version}`, 'background: orange; color: white;')
|
||||
//
|
||||
// const panel = app.extensionManager.registerSidebarTab({
|
||||
// id: 'mtb-nodes',
|
||||
// icon: 'pi pi-bolt',
|
||||
// title: 'MTB',
|
||||
// tooltip: 'MTB: API outliner',
|
||||
// type: 'custom',
|
||||
// // this is run everytime the tab's diplay is toggled on.
|
||||
// render: (el) => {
|
||||
// const outliner = createOutliner(el)
|
||||
// const inputs = shared.getAPIInputs()
|
||||
// console.log('INPUTS', inputs)
|
||||
// outliner.$$set({ inputs })
|
||||
// },
|
||||
// })
|
||||
// }
|
||||
-504
@@ -1,504 +0,0 @@
|
||||
/**
|
||||
* Adds a named stylesheet to the document with an optional ability to replace an existing one.
|
||||
*
|
||||
* @param {string} name - The unique name (ID) of the stylesheet.
|
||||
* @param {string} css - The CSS rules as a string.
|
||||
* @param {boolean} [force=false] - Whether to replace the existing stylesheet if it exists.
|
||||
* @returns {void}
|
||||
*/
|
||||
export function addNamedStyleSheet(name, css, force = false) {
|
||||
const existingStyleSheet = document.getElementById(name)
|
||||
|
||||
if (existingStyleSheet && !force) {
|
||||
console.debug(
|
||||
`Stylesheet with name "${name}" already exists. Skipping addition.`,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (existingStyleSheet && force) {
|
||||
console.debug(`Stylesheet with name "${name}" exists. Replacing...`)
|
||||
existingStyleSheet.remove()
|
||||
}
|
||||
|
||||
const styleElement = document.createElement('style')
|
||||
styleElement.id = name
|
||||
styleElement.type = 'text/css'
|
||||
|
||||
styleElement.appendChild(document.createTextNode(css))
|
||||
document.head.appendChild(styleElement)
|
||||
|
||||
console.debug(`Stylesheet with name "${name}" added.`)
|
||||
}
|
||||
|
||||
export const ensureMTBStyles = () => {
|
||||
const S = {
|
||||
fg: 'var(--fg-color)',
|
||||
bgi: 'var(--comfy-input-bg)',
|
||||
bgm: 'var(--comfy-menu-bg)',
|
||||
border: 'var(--comfy-border)',
|
||||
borderHover: 'var(--comfy-border-hover)',
|
||||
box: 'var(--comfy-box)',
|
||||
accent: 'var(--p-button-text-primary-color)',
|
||||
}
|
||||
const common = `
|
||||
.mtb_sidebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: ${S.bgm};
|
||||
}
|
||||
.mtb_img_grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
overflow: scroll;
|
||||
gap: 1em;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.mtb_tools {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
`
|
||||
const inputs = `
|
||||
/* SELECT */
|
||||
.mtb_select {
|
||||
appearance: none;
|
||||
display: grid;
|
||||
grid-template-areas: "select";
|
||||
padding: 10px;
|
||||
background-color: ${S.bgi};
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
font-size: 14px;
|
||||
color: ${S.fg};
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@supports (-moz-appearance:none) {
|
||||
.mtb_select{
|
||||
grid-area: select;
|
||||
background: ${S.bgi} url('data:image/gif;base64,R0lGODlhBgAGAKEDAFVVVX9/f9TU1CgmNyH5BAEKAAMALAAAAAAGAAYAAAIODA4hCDKWxlhNvmCnGwUAOw==') right center no-repeat !important;
|
||||
background-position: calc(100% - 5px) center !important;
|
||||
-moz-appearance:none !important;
|
||||
}
|
||||
|
||||
/* styling the dropdown arrow for browsers that support it */
|
||||
.mtb_select:after {
|
||||
content: "";
|
||||
width: 0.8em;
|
||||
height: 0.5em;
|
||||
background-color: ${S.fg};
|
||||
clip-path: polygon(100% 0%, 0 0%, 50% 100%);
|
||||
}
|
||||
|
||||
.mtb_select:focus {
|
||||
outline: none;
|
||||
border-color: #0056b3;
|
||||
}
|
||||
|
||||
.mtb_select > option {
|
||||
padding: 10px;
|
||||
background-color: ${S.bgi};
|
||||
border:none;
|
||||
color: ${S.fg};
|
||||
}
|
||||
|
||||
.mtb_select > option:hover {
|
||||
background-color: red;
|
||||
color: ${S.fg};
|
||||
}
|
||||
|
||||
/* SLIDER */
|
||||
.mtb_slider[type="range"] {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 100%;
|
||||
height: 10px;
|
||||
background: ${S.bgm};
|
||||
border-radius: 5px;
|
||||
outline: none;
|
||||
opacity: 0.7;
|
||||
transition: opacity .2s;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
/* slider track */
|
||||
.mtb_slider[type="range"]::-webkit-slider-runnable-track,
|
||||
.mtb_slider[type="range"]::-moz-range-track {
|
||||
width: 100%;
|
||||
height: 10px;
|
||||
background: ${S.bgi};
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
|
||||
/* progress */
|
||||
.mtb_slider[type="range"]::-moz-range-progress {
|
||||
background-color: ${S.accent};
|
||||
height:10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
/* slider thumb (the handle) */
|
||||
.mtb_slider[type="range"]::-webkit-slider-thumb,
|
||||
.mtb_slider[type="range"]::-moz-range-thumb
|
||||
{
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border-radius: 50%;
|
||||
background: ${S.fg};
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
filter: drop-shadow(1px 1px 4px black);
|
||||
}
|
||||
|
||||
.mtb_slider[type="range"]:focus {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.mtb_slider[type=range]:-moz-focusring{
|
||||
outline: 1px solid red;
|
||||
outline-offset: -1px;
|
||||
}
|
||||
|
||||
.mtb_slider[type="range"]:hover::-webkit-slider-thumb,
|
||||
.mtb_slider[type="range"]:active::-webkit-slider-thumb {
|
||||
background-color: ${S.accent};
|
||||
}
|
||||
`
|
||||
addNamedStyleSheet(
|
||||
'mtb_ui',
|
||||
`
|
||||
${common}
|
||||
${inputs}
|
||||
`,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DOM element with optional styles, class, and id.
|
||||
*
|
||||
* @param {string} kind - The tag name of the element. Supports class and id syntax (e.g. 'div.class#id').
|
||||
* @param {Object} [style] - CSS styles to apply to the element.
|
||||
* @returns {HTMLElement} - The created DOM element.
|
||||
*/
|
||||
export const makeElement = (kind, style) => {
|
||||
let [real_kind, className] = kind.split('.')
|
||||
let id
|
||||
|
||||
if (className?.includes('#')) {
|
||||
;[className, id] = className.split('#')
|
||||
}
|
||||
|
||||
const el = document.createElement(real_kind)
|
||||
|
||||
if (style) {
|
||||
Object.assign(el.style, style)
|
||||
}
|
||||
|
||||
if (className) {
|
||||
el.classList.add(...className.split(' ')) // Support multiple classes
|
||||
}
|
||||
|
||||
if (id) {
|
||||
el.id = id
|
||||
}
|
||||
|
||||
return el
|
||||
}
|
||||
/**
|
||||
* Clears all child elements of the given parent element.
|
||||
*
|
||||
* @param {HTMLElement} el - The parent element whose children should be removed.
|
||||
*/
|
||||
export const clearElement = (el) => {
|
||||
while (el.firstChild) {
|
||||
el.removeChild(el.firstChild)
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Creates a labeled element (input, select, etc.).
|
||||
*
|
||||
* @param {HTMLElement} el - The element to label.
|
||||
* @param {string} labelText - The label text.
|
||||
* @returns {HTMLDivElement} - A div containing the label and the element.
|
||||
*/
|
||||
export const makeLabeledElement = (el, labelText) => {
|
||||
const wrapper = makeElement('div.mtb_labeled_element', {
|
||||
marginBottom: '1em',
|
||||
})
|
||||
const label = makeElement('label', {
|
||||
display: 'block',
|
||||
marginBottom: '0.5em',
|
||||
})
|
||||
label.textContent = labelText
|
||||
wrapper.appendChild(label)
|
||||
wrapper.appendChild(el)
|
||||
return wrapper
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a camelCase CSS property to kebab-case.
|
||||
*
|
||||
* @param {string} prop - The camelCase CSS property.
|
||||
* @returns {string} - The kebab-case CSS property.
|
||||
*/
|
||||
const camelToKebab = (prop) =>
|
||||
prop.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)
|
||||
|
||||
/**
|
||||
* Parses the style string into an object of CSS property-value pairs.
|
||||
*
|
||||
* @param {string} styleString - The CSS rule text (e.g., "color: red; background-color: blue;").
|
||||
* @returns {Object} - An object with camelCase CSS properties.
|
||||
*/
|
||||
const parseStyleString = (styleString) => {
|
||||
const styleObj = {}
|
||||
for (const rule of styleString.split(';')) {
|
||||
const [property, value] = rule.split(':').map((item) => item.trim())
|
||||
if (property && value) {
|
||||
const camelProp = property.replace(/-([a-z])/g, (g) => g[1].toUpperCase())
|
||||
styleObj[camelProp] = value
|
||||
}
|
||||
}
|
||||
return styleObj
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a new CSS class with the provided styles, or skips if the class already exists.
|
||||
*
|
||||
* @param {string} className - The name of the CSS class to define.
|
||||
* @param {Object} classStyles - An object containing camelCase CSS property-value pairs.
|
||||
*/
|
||||
export function defineCSSClass(className, classStyles) {
|
||||
const styleSheets = document.styleSheets
|
||||
let classExists = false
|
||||
let existingStyleString = ''
|
||||
const classExistsInStyleSheet = (styleSheet) => {
|
||||
const rules = styleSheet.rules || styleSheet.cssRules
|
||||
for (const rule of rules) {
|
||||
if (rule.selectorText === `.${className}`) {
|
||||
classExists = true
|
||||
existingStyleString = rule.style.cssText // Capture existing styles
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
for (const styleSheet of styleSheets) {
|
||||
if (classExistsInStyleSheet(styleSheet)) {
|
||||
console.debug(`Class ${className} already exists, merging styles...`)
|
||||
break
|
||||
}
|
||||
}
|
||||
const existingStyles = classExists
|
||||
? parseStyleString(existingStyleString)
|
||||
: {}
|
||||
const mergedStyles = { ...existingStyles, ...classStyles }
|
||||
|
||||
const stylesString = Object.entries(mergedStyles)
|
||||
.map(([key, value]) => `${camelToKebab(key)}: ${value};`)
|
||||
.join(' ')
|
||||
|
||||
if (!classExists) {
|
||||
console.debug(`Defining new class ${className}...`)
|
||||
if (styleSheets[0].insertRule) {
|
||||
styleSheets[0].insertRule(`.${className} { ${stylesString} }`, 0)
|
||||
} else if (styleSheets[0].addRule) {
|
||||
styleSheets[0].addRule(`.${className}`, stylesString, 0)
|
||||
}
|
||||
} else {
|
||||
console.debug(`Updating existing class ${className} with merged styles...`)
|
||||
for (const styleSheet of styleSheets) {
|
||||
const rules = styleSheet.rules || styleSheet.cssRules
|
||||
for (const rule of rules) {
|
||||
if (rule.selectorText === `.${className}`) {
|
||||
rule.style.cssText = stylesString // Update the existing rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.debug(
|
||||
`Class ${className} has been defined/updated with styles:`,
|
||||
mergedStyles,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a sidebar and ensures it resizes correctly when the window is resized.
|
||||
*
|
||||
* @param {HTMLElement} el - The element where the sidebar is rendered.
|
||||
* @param {HTMLElement} cont - The content container of the sidebar.
|
||||
* @param {HTMLElement[]} elems - Array of elements to append to the sidebar.
|
||||
* @returns {Object} - A handle with a method to unregister the resize event.
|
||||
*/
|
||||
export const renderSidebar = (el, cont, elems) => {
|
||||
el.appendChild(cont)
|
||||
|
||||
if (!el.parentNode) {
|
||||
return
|
||||
}
|
||||
el.parentNode.style.overflowY = 'clip'
|
||||
cont.style.height = `${el.parentNode.offsetHeight}px`
|
||||
|
||||
const resizeHandler = () => {
|
||||
cont.style.height = `${el.parentNode.offsetHeight}px`
|
||||
}
|
||||
window.addEventListener('resize', resizeHandler)
|
||||
|
||||
for (const elem of elems) {
|
||||
cont.appendChild(elem)
|
||||
}
|
||||
|
||||
return {
|
||||
unregister: () => {
|
||||
window.removeEventListener('resize', resizeHandler)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <select> dropdown with given options.
|
||||
*
|
||||
* @param {string[]} options - The options for the select element.
|
||||
* @param {string} [current] - The currently selected option (optional).
|
||||
* @returns {HTMLSelectElement} - The created <select> element.
|
||||
*/
|
||||
export const makeSelect = (options, current = undefined) => {
|
||||
const selector = makeElement('select.mtb_select', {
|
||||
width: 'auto',
|
||||
margin: '1em',
|
||||
})
|
||||
|
||||
for (const option of options) {
|
||||
const opt = makeElement('option')
|
||||
opt.value = option
|
||||
opt.innerHTML = option
|
||||
selector.appendChild(opt)
|
||||
}
|
||||
|
||||
if (current !== undefined) {
|
||||
if (options.includes(current)) {
|
||||
selector.value = current
|
||||
} else {
|
||||
console.error(
|
||||
`You tried to select an option that doesn't exist (${current}). Options: ${options}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return selector
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an <input type="range"> slider element with given parameters.
|
||||
*
|
||||
* @param {number} min - Minimum value of the slider.
|
||||
* @param {number} max - Maximum value of the slider.
|
||||
* @param {number} [value] - Initial value of the slider.
|
||||
* @param {number} [step] - Step value for the slider.
|
||||
* @returns {HTMLInputElement} - The created slider element.
|
||||
*/
|
||||
export const makeSlider = (min, max, value = undefined, step = undefined) => {
|
||||
const slider = makeElement('input.mtb_slider', {
|
||||
width: '100%',
|
||||
})
|
||||
|
||||
slider.type = 'range'
|
||||
slider.min = min || 0
|
||||
slider.max = max || 100
|
||||
slider.value = value || slider.min
|
||||
slider.step = step || 1
|
||||
|
||||
return slider
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a button element.
|
||||
*
|
||||
* @param {string} label - The label for the button.
|
||||
* @param {Object} [style] - Optional styles to apply to the button.
|
||||
* @param {Function} [onClick] - Optional click handler.
|
||||
* @returns {HTMLButtonElement} - The created button element.
|
||||
*/
|
||||
export const makeButton = (label, style = {}, onClick = undefined) => {
|
||||
const button = makeElement('button.mtb_button', style)
|
||||
button.textContent = label
|
||||
|
||||
if (onClick) {
|
||||
button.addEventListener('click', onClick)
|
||||
}
|
||||
|
||||
return button
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a resizable splitter between two elements.
|
||||
*
|
||||
* @param {HTMLElement} el1 - The first element.
|
||||
* @param {HTMLElement} el2 - The second element.
|
||||
* @param {'vertical' | 'horizontal'} direction - Splitter direction (vertical or horizontal).
|
||||
* @param {'absolute' | 'normal'} mode - Splitter mode: 'absolute' for free resizing, 'normal' for layout-based resizing.
|
||||
* @returns {HTMLDivElement} - The container with resizable splitter.
|
||||
*/
|
||||
export const makeSplitter = (
|
||||
el1,
|
||||
el2,
|
||||
direction = 'vertical',
|
||||
mode = 'normal',
|
||||
) => {
|
||||
const container = makeElement('div.mtb_splitter_container', {
|
||||
display: mode === 'absolute' ? 'block' : 'flex',
|
||||
flexDirection: direction === 'vertical' ? 'row' : 'column',
|
||||
position: mode === 'absolute' ? 'relative' : 'static',
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
})
|
||||
|
||||
const handle = makeElement('div.mtb_splitter_handle', {
|
||||
backgroundColor: '#ccc',
|
||||
cursor: direction === 'vertical' ? 'col-resize' : 'row-resize',
|
||||
width: direction === 'vertical' ? '5px' : '100%',
|
||||
height: direction === 'horizontal' ? '5px' : '100%',
|
||||
})
|
||||
|
||||
let isResizing = false
|
||||
|
||||
handle.addEventListener('mousedown', () => {
|
||||
isResizing = true
|
||||
})
|
||||
|
||||
window.addEventListener('mouseup', () => {
|
||||
isResizing = false
|
||||
})
|
||||
|
||||
window.addEventListener('mousemove', (e) => {
|
||||
if (!isResizing) return
|
||||
if (direction === 'vertical') {
|
||||
const newWidth = e.clientX - container.offsetLeft
|
||||
el1.style.width = `${newWidth}px`
|
||||
el2.style.width = `${container.offsetWidth - newWidth}px`
|
||||
} else {
|
||||
const newHeight = e.clientY - container.offsetTop
|
||||
el1.style.height = `${newHeight}px`
|
||||
el2.style.height = `${container.offsetHeight - newHeight}px`
|
||||
}
|
||||
})
|
||||
|
||||
container.appendChild(el1)
|
||||
container.appendChild(handle)
|
||||
container.appendChild(el2)
|
||||
|
||||
return container
|
||||
}
|
||||
+228
-620
File diff suppressed because it is too large
Load Diff
@@ -1,246 +0,0 @@
|
||||
// web/note_plus.constants.js
|
||||
|
||||
export const DEFAULT_CSS = ''
|
||||
export const DEFAULT_HTML = `<p style='color:red;font-family:monospace'>
|
||||
Note+
|
||||
</p>`
|
||||
export const DEFAULT_MD = '## Note+'
|
||||
export const DEFAULT_MODE = 'markdown'
|
||||
export const DEFAULT_THEME = 'one_dark'
|
||||
|
||||
export const DEMO_CONTENT = `
|
||||
# @mtb/svelte-markdown.
|
||||
## This is a subheader
|
||||
|
||||
[](https://github.com/melMass/comfy_mtb/actions/workflows/test_embedded.yml)
|
||||

|
||||
|
||||
<details>
|
||||
<summary>More details about the inception of the project</summary>
|
||||
|
||||
\`\`\`js
|
||||
class YesMan{
|
||||
constructor(){
|
||||
this.started = false
|
||||
}
|
||||
}
|
||||
\`\`\`
|
||||
</details>
|
||||
|
||||
This is a paragraph. If it goes over the maximum width it will not automatically wrap unless it reaches the max-w of \`prose\` check [styles](/styles) for more info.
|
||||
|
||||
This component is useful for building some tools on top. Or even just a static system using svelte at its core. My personal blog is fully powered by **@mtb/svelte-markdown**
|
||||
|
||||
| And this is | A table |
|
||||
|-------------|---------|
|
||||
| With two | columns |
|
||||
|
||||
We also support github callout:
|
||||
|
||||
|
||||
> [!NOTE]
|
||||
> Highlights information that users should take into account, even when skimming.
|
||||
> [!TIP]
|
||||
> Optional information to help a user be more successful.
|
||||
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Crucial information necessary for users to succeed.
|
||||
|
||||
> [!WARNING]
|
||||
> Critical content demanding immediate user attention due to potential risks.
|
||||
|
||||
> [!CAUTION]
|
||||
> Negative potential consequences of an action.
|
||||
`
|
||||
|
||||
export const THEMES = [
|
||||
'ambiance',
|
||||
'chaos',
|
||||
'chrome',
|
||||
'cloud9_day',
|
||||
'cloud9_night',
|
||||
'cloud9_night_low_color',
|
||||
'cloud_editor',
|
||||
'cloud_editor_dark',
|
||||
'clouds',
|
||||
'clouds_midnight',
|
||||
'cobalt',
|
||||
'crimson_editor',
|
||||
'dawn',
|
||||
'dracula',
|
||||
'dreamweaver',
|
||||
'eclipse',
|
||||
'github',
|
||||
'github_dark',
|
||||
'gob',
|
||||
'gruvbox',
|
||||
'gruvbox_dark_hard',
|
||||
'gruvbox_light_hard',
|
||||
'idle_fingers',
|
||||
'iplastic',
|
||||
'katzenmilch',
|
||||
'kr_theme',
|
||||
'kuroir',
|
||||
'merbivore',
|
||||
'merbivore_soft',
|
||||
'mono_industrial',
|
||||
'monokai',
|
||||
'nord_dark',
|
||||
'one_dark',
|
||||
'pastel_on_dark',
|
||||
'solarized_dark',
|
||||
'solarized_light',
|
||||
'sqlserver',
|
||||
'terminal',
|
||||
'textmate',
|
||||
'tomorrow',
|
||||
'tomorrow_night',
|
||||
'tomorrow_night_blue',
|
||||
'tomorrow_night_bright',
|
||||
'tomorrow_night_eighties',
|
||||
'twilight',
|
||||
'vibrant_ink',
|
||||
'vscode',
|
||||
]
|
||||
|
||||
export const CSS_RESET = `
|
||||
* {
|
||||
font-family: monospace;
|
||||
line-height: 1.25em;
|
||||
}
|
||||
.shiki{
|
||||
padding: 1em;
|
||||
width: 100%;
|
||||
}
|
||||
.markdown-callout-title {
|
||||
.octicon{
|
||||
fill:white;
|
||||
}
|
||||
/* background: var(--current-color); */
|
||||
color: var(--current-color);
|
||||
font-weight: bold;
|
||||
/* border-start-end-radius: var(--radius); */
|
||||
/* border-start-start-radius: var(--radius); */
|
||||
padding: 0.5em;
|
||||
padding-inline-start: 1em;
|
||||
}
|
||||
.markdown-callout-content {
|
||||
padding: 1em;
|
||||
}
|
||||
.markdown-callout {
|
||||
--radius: 8px;
|
||||
--current-color: purple;
|
||||
/* border-start-end-radius: var(--radius); */
|
||||
/* border-start-start-radius: var(--radius); */
|
||||
border-left: 3px solid var(--current-color);
|
||||
margin-bottom: 1em;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.markdown-callout-tip {
|
||||
--text-color: whitesmoke;
|
||||
--current-color: #50e3c2;
|
||||
}
|
||||
|
||||
.markdown-callout-note {
|
||||
--text-color: whitesmoke;
|
||||
--current-color: #0070f3;
|
||||
}
|
||||
.markdown-callout-important {
|
||||
--text-color: whitesmoke;
|
||||
--current-color: #7928ca;
|
||||
}
|
||||
.markdown-callout-warning {
|
||||
--current-color: #f5a623;
|
||||
}
|
||||
.markdown-callout-caution {
|
||||
--current-color: #e60000;
|
||||
}
|
||||
|
||||
|
||||
.note-plus-preview {
|
||||
display:flex;
|
||||
flex-direction:column;
|
||||
align-items: flex-start;
|
||||
width:95%;
|
||||
margin-left: 20px;
|
||||
margin-top:20px;
|
||||
/*background-color: rgba(255,0,0,0.5)!important;*/
|
||||
}
|
||||
|
||||
/* allowed to be selected*/
|
||||
h1, h2, h3, h4, h5, h6,a, p, ul, ol, dl, blockquote,details,summary {
|
||||
pointer-events:auto;
|
||||
user-select:text;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
display:inline-block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
p, ul, ol, dl, blockquote {
|
||||
margin: 0.3em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
ul, ol {
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
pointer-events: all;
|
||||
color: cyan;
|
||||
}
|
||||
|
||||
img {
|
||||
padding: 1em 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
iframe {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border:none;
|
||||
pointer-events:all;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
border-left: 4px solid #ccc;
|
||||
padding-left: 1em;
|
||||
margin-left: 0;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
pre, code {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
border-bottom: 1px solid #000;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
th, td {
|
||||
border-left: 1px solid #000;
|
||||
border-right: 1px solid #000;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
th {
|
||||
border: 1px solid #000;
|
||||
background-color: rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
input[type="checkbox"] {
|
||||
margin-right: 10px;
|
||||
}
|
||||
`
|
||||
@@ -1,830 +0,0 @@
|
||||
/// <reference path="../types/typedefs.js" />
|
||||
|
||||
import { app } from '../../scripts/app.js'
|
||||
|
||||
import * as shared from './comfy_shared.js'
|
||||
import { infoLogger, successLogger, errorLogger } from './comfy_shared.js'
|
||||
import {
|
||||
DEFAULT_CSS,
|
||||
DEFAULT_HTML,
|
||||
DEFAULT_MD,
|
||||
DEFAULT_MODE,
|
||||
DEFAULT_THEME,
|
||||
THEMES,
|
||||
CSS_RESET,
|
||||
DEMO_CONTENT,
|
||||
} from './note_plus.constants.js'
|
||||
import { LocalStorageManager } from './comfy_shared.js'
|
||||
|
||||
const storage = new LocalStorageManager('mtb')
|
||||
|
||||
/**
|
||||
* Uses `@mtb/markdown-parser` (a fork of marked)
|
||||
* It is statically stored to avoid having
|
||||
* more than 1 instance ever.
|
||||
* The size difference between both libraries...
|
||||
* ╭───┬────────────────────────────────┬──────────╮
|
||||
* │ # │ name │ size │
|
||||
* ├───┼────────────────────────────────┼──────────┤
|
||||
* │ 0 │ web-dist/mtb_markdown_plus.mjs │ 1.2 MB │ <- with shiki
|
||||
* │ 1 │ web-dist/mtb_markdown.mjs │ 44.7 KB │
|
||||
* ╰───┴────────────────────────────────┴──────────╯
|
||||
*/
|
||||
let useShiki = storage.get('np-use-shiki', false)
|
||||
|
||||
const makeResizable = (dialog) => {
|
||||
dialog.style.resize = 'both'
|
||||
dialog.style.transformOrigin = 'top left'
|
||||
dialog.style.overflow = 'auto'
|
||||
}
|
||||
|
||||
const makeDraggable = (dialog, handle) => {
|
||||
let offsetX = 0
|
||||
let offsetY = 0
|
||||
let isDragging = false
|
||||
|
||||
const onMouseMove = (e) => {
|
||||
if (isDragging) {
|
||||
dialog.style.left = `${e.clientX - offsetX}px`
|
||||
dialog.style.top = `${e.clientY - offsetY}px`
|
||||
}
|
||||
}
|
||||
|
||||
const onMouseUp = () => {
|
||||
isDragging = false
|
||||
document.removeEventListener('mousemove', onMouseMove)
|
||||
document.removeEventListener('mouseup', onMouseUp)
|
||||
}
|
||||
|
||||
handle.addEventListener('mousedown', (e) => {
|
||||
isDragging = true
|
||||
offsetX = e.clientX - dialog.offsetLeft
|
||||
offsetY = e.clientY - dialog.offsetTop
|
||||
document.addEventListener('mousemove', onMouseMove)
|
||||
document.addEventListener('mouseup', onMouseUp)
|
||||
})
|
||||
}
|
||||
|
||||
/** @extends {LGraphNode} */
|
||||
class NotePlus extends LiteGraph.LGraphNode {
|
||||
// same values as the comfy note
|
||||
color = LGraphCanvas.node_colors.yellow.color
|
||||
bgcolor = LGraphCanvas.node_colors.yellow.bgcolor
|
||||
groupcolor = LGraphCanvas.node_colors.yellow.groupcolor
|
||||
|
||||
/* NOTE: this is not serialized and only there to make multiple
|
||||
* note+ nodes in the same graph unique.
|
||||
*/
|
||||
uuid
|
||||
|
||||
/** Stores the dialog observer*/
|
||||
resizeObserver
|
||||
|
||||
/** Live update the preview*/
|
||||
live = true
|
||||
/** DOM height by adding child size together*/
|
||||
calculated_height = 0
|
||||
|
||||
/** ????*/
|
||||
_raw_html
|
||||
|
||||
/** might not be needed anymore */
|
||||
inner
|
||||
|
||||
/** the dialog DOM widget*/
|
||||
dialog
|
||||
|
||||
/** widgets*/
|
||||
|
||||
/** used to store the raw value and display the parsed html at the same time*/
|
||||
html_widget
|
||||
|
||||
/** hidden widgets for serialization*/
|
||||
css_widget
|
||||
edit_mode_widget
|
||||
theme_widget
|
||||
|
||||
editorsContainer
|
||||
/** ACE editors instances*/
|
||||
html_editor
|
||||
css_editor
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
this.uuid = shared.makeUUID()
|
||||
|
||||
infoLogger('Constructing Note+ instance')
|
||||
shared.ensureMarkdownParser((_p) => {
|
||||
this.updateHTML()
|
||||
})
|
||||
// - litegraph settings
|
||||
this.collapsable = true
|
||||
this.isVirtualNode = true
|
||||
this.shape = LiteGraph.BOX_SHAPE
|
||||
this.serialize_widgets = true
|
||||
|
||||
// - default values, serialization is done through widgets
|
||||
this._raw_html = DEFAULT_MODE === 'html' ? DEFAULT_HTML : DEFAULT_MD
|
||||
|
||||
// - state
|
||||
this.live = true
|
||||
this.calculated_height = 0
|
||||
|
||||
// - add widgets
|
||||
const cinner = document.createElement('div')
|
||||
this.inner = document.createElement('div')
|
||||
|
||||
cinner.append(this.inner)
|
||||
this.inner.classList.add('note-plus-preview')
|
||||
cinner.style.margin = '0'
|
||||
cinner.style.padding = '0'
|
||||
this.html_widget = this.addDOMWidget('HTML', 'html', cinner, {
|
||||
setValue: (val) => {
|
||||
this._raw_html = val
|
||||
},
|
||||
getValue: () => this._raw_html,
|
||||
getMinHeight: () => this.calculated_height, // (the edit button),
|
||||
onDraw: () => {
|
||||
// HACK: dirty hack for now until it's addressed upstream...
|
||||
this.html_widget.element.style.pointerEvents = 'none'
|
||||
// NOTE: not sure about this, it avoid the visual "bugs" but scrolling over the wrong area will affect zoom...
|
||||
// this.html_widget.element.style.overflow = 'scroll'
|
||||
},
|
||||
hideOnZoom: false,
|
||||
})
|
||||
|
||||
this.setupSerializationWidgets()
|
||||
this.setupDialog()
|
||||
this.loadAceEditor()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {CanvasRenderingContext2D} ctx canvas context
|
||||
* @param {any} _graphcanvas
|
||||
*/
|
||||
onDrawForeground(ctx, _graphcanvas) {
|
||||
if (this.flags.collapsed) return
|
||||
this.drawEditIcon(ctx)
|
||||
this.drawSideHandle(ctx)
|
||||
|
||||
// DEBUG BACKGROUND
|
||||
// ctx.fillStyle = 'rgba(0, 255, 0, 0.3)'
|
||||
// const rect = this.rect
|
||||
// ctx.fillRect(rect.x, rect.y, rect.width, rect.height)
|
||||
}
|
||||
drawSideHandle(ctx) {
|
||||
const handleRect = this.sideHandleRect
|
||||
const chamfer = 20
|
||||
ctx.beginPath()
|
||||
|
||||
// top left
|
||||
ctx.moveTo(handleRect.x, handleRect.y + chamfer)
|
||||
// top right
|
||||
ctx.lineTo(handleRect.x + handleRect.width, handleRect.y)
|
||||
|
||||
// bottom right
|
||||
ctx.lineTo(
|
||||
handleRect.x + handleRect.width,
|
||||
handleRect.y + handleRect.height,
|
||||
)
|
||||
// bottom left
|
||||
ctx.lineTo(handleRect.x, handleRect.y + handleRect.height - chamfer)
|
||||
ctx.closePath()
|
||||
|
||||
ctx.fillStyle = 'rgba(255, 255, 255, 0.05)'
|
||||
ctx.fill()
|
||||
}
|
||||
|
||||
drawEditIcon(ctx) {
|
||||
const rect = this.iconRect
|
||||
// DEBUG ICON POSITION
|
||||
// ctx.fillStyle = 'rgba(0, 255, 0, 0.3)'
|
||||
// ctx.fillRect(rect.x, rect.y, rect.width, rect.height)
|
||||
|
||||
const pencilPath = new Path2D(
|
||||
'M21.28 6.4l-9.54 9.54c-.95.95-3.77 1.39-4.4.76-.63-.63-.2-3.45.75-4.4l9.55-9.55a2.58 2.58 0 1 1 3.64 3.65z',
|
||||
)
|
||||
const folderPath = new Path2D(
|
||||
'M11 4H6a4 4 0 0 0-4 4v10a4 4 0 0 0 4 4h11c2.21 0 3-1.8 3-4v-5',
|
||||
)
|
||||
|
||||
ctx.save()
|
||||
ctx.translate(rect.x, rect.y)
|
||||
ctx.scale(rect.width / 32, rect.height / 32)
|
||||
ctx.strokeStyle = 'rgba(255,255,255,0.4)'
|
||||
ctx.lineCap = 'round'
|
||||
ctx.lineJoin = 'round'
|
||||
ctx.lineWidth = 2.4
|
||||
ctx.stroke(pencilPath)
|
||||
ctx.stroke(folderPath)
|
||||
ctx.restore()
|
||||
}
|
||||
/**
|
||||
* @param {number} x
|
||||
* @param {number} y
|
||||
* @param {{x:number,y:number,width:number,height:number}} rect
|
||||
* @returns {}
|
||||
*/
|
||||
inRect(x, y, rect) {
|
||||
rect = rect || this.iconRect
|
||||
return (
|
||||
x >= rect.x &&
|
||||
x <= rect.x + rect.width &&
|
||||
y >= rect.y &&
|
||||
y <= rect.y + rect.height
|
||||
)
|
||||
}
|
||||
get rect() {
|
||||
return {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: this.size[0],
|
||||
height: this.size[1],
|
||||
}
|
||||
}
|
||||
get sideHandleRect() {
|
||||
const w = this.size[0]
|
||||
const h = this.size[1]
|
||||
|
||||
const bw = 32
|
||||
const bho = 64
|
||||
|
||||
return {
|
||||
x: w - bw,
|
||||
y: bho,
|
||||
width: bw,
|
||||
height: h - bho * 1.5,
|
||||
}
|
||||
}
|
||||
get iconRect() {
|
||||
const iconSize = 32
|
||||
const iconMargin = 16
|
||||
return {
|
||||
x: this.size[0] - iconSize - iconMargin,
|
||||
y: iconMargin * 1.5,
|
||||
width: iconSize,
|
||||
height: iconSize,
|
||||
}
|
||||
}
|
||||
onMouseDown(_e, localPos, _graphcanvas) {
|
||||
if (this.inRect(localPos[0], localPos[1])) {
|
||||
this.openEditorDialog()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/* Hidden widgets to store note+ settings in the workflow (stripped in API)*/
|
||||
setupSerializationWidgets() {
|
||||
infoLogger('Setup Serializing widgets')
|
||||
|
||||
this.edit_mode_widget = this.addWidget(
|
||||
'combo',
|
||||
'Mode',
|
||||
DEFAULT_MODE,
|
||||
(me) => successLogger('Updating edit_mode', me),
|
||||
{
|
||||
values: ['html', 'markdown', 'raw'],
|
||||
},
|
||||
)
|
||||
this.css_widget = this.addWidget('text', 'CSS', DEFAULT_CSS, (val) => {
|
||||
successLogger(`Updating css ${val}`)
|
||||
})
|
||||
this.theme_widget = this.addWidget(
|
||||
'text',
|
||||
'Theme',
|
||||
DEFAULT_THEME,
|
||||
(val) => {
|
||||
successLogger(`Setting theme ${val}`)
|
||||
},
|
||||
)
|
||||
|
||||
shared.hideWidgetForGood(this, this.edit_mode_widget)
|
||||
shared.hideWidgetForGood(this, this.css_widget)
|
||||
shared.hideWidgetForGood(this, this.theme_widget)
|
||||
}
|
||||
|
||||
setupDialog() {
|
||||
infoLogger('Setup dialog')
|
||||
|
||||
this.dialog = new app.ui.dialog.constructor()
|
||||
this.dialog.element.classList.add('comfy-settings')
|
||||
|
||||
Object.assign(this.dialog.element.style, {
|
||||
position: 'absolute',
|
||||
boxShadow: 'none',
|
||||
})
|
||||
|
||||
const subcontainer = this.dialog.textElement.parentElement
|
||||
|
||||
if (subcontainer) {
|
||||
Object.assign(subcontainer.style, {
|
||||
width: '100%',
|
||||
})
|
||||
}
|
||||
const closeButton = this.dialog.element.querySelector('button')
|
||||
closeButton.textContent = 'CANCEL'
|
||||
closeButton.id = 'cancel-editor-dialog'
|
||||
closeButton.title =
|
||||
"Cancel the changes since last opened (doesn't support live mode)"
|
||||
closeButton.disabled = this.live
|
||||
|
||||
closeButton.style.background = this.live
|
||||
? 'repeating-linear-gradient(45deg,#606dbc,#606dbc 10px,#465298 10px,#465298 20px)'
|
||||
: ''
|
||||
|
||||
const saveButton = document.createElement('button')
|
||||
saveButton.textContent = 'SAVE'
|
||||
saveButton.onclick = () => {
|
||||
this.closeEditorDialog(true)
|
||||
}
|
||||
closeButton.onclick = () => {
|
||||
this.closeEditorDialog(false)
|
||||
}
|
||||
closeButton.before(saveButton)
|
||||
}
|
||||
|
||||
teardownEditors() {
|
||||
this.css_editor.destroy()
|
||||
this.css_editor.container.remove()
|
||||
|
||||
this.html_editor.destroy()
|
||||
this.html_editor.container.remove()
|
||||
}
|
||||
|
||||
closeEditorDialog(accept) {
|
||||
infoLogger('Closing editor dialog', accept)
|
||||
if (accept && !this.live) {
|
||||
this.updateHTML(this.html_editor.getValue())
|
||||
this.updateCSS(this.css_editor.getValue())
|
||||
}
|
||||
if (this.resizeObserver) {
|
||||
this.resizeObserver.disconnect()
|
||||
this.resizeObserver = null
|
||||
}
|
||||
this.teardownEditors()
|
||||
this.dialog.close()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} elem
|
||||
*/
|
||||
hookResize(elem) {
|
||||
if (!this.resizeObserver) {
|
||||
const observer = () => {
|
||||
this.html_editor.resize()
|
||||
this.css_editor.resize()
|
||||
Object.assign(this.editorsContainer.style, {
|
||||
minHeight: `${(this.dialog.element.clientHeight / 100) * 50}px`, //'200px',
|
||||
})
|
||||
}
|
||||
this.resizeObserver = new ResizeObserver(observer).observe(elem)
|
||||
}
|
||||
}
|
||||
openEditorDialog() {
|
||||
infoLogger(`Current edit mode ${this.edit_mode_widget.value}`)
|
||||
this.hookResize(this.dialog.element)
|
||||
const container = document.createElement('div')
|
||||
Object.assign(container.style, {
|
||||
display: 'flex',
|
||||
gap: '10px',
|
||||
flexDirection: 'column',
|
||||
})
|
||||
|
||||
this.editorsContainer = document.createElement('div')
|
||||
|
||||
Object.assign(this.editorsContainer.style, {
|
||||
display: 'flex',
|
||||
gap: '10px',
|
||||
flexDirection: 'row',
|
||||
minHeight: this.dialog.element.offsetHeight, //'200px',
|
||||
width: '100%',
|
||||
})
|
||||
|
||||
container.append(this.editorsContainer)
|
||||
|
||||
this.dialog.show('')
|
||||
this.dialog.textElement.append(container)
|
||||
|
||||
const aceHTML = document.createElement('div')
|
||||
aceHTML.id = 'noteplus-html-editor'
|
||||
Object.assign(aceHTML.style, {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
|
||||
minWidth: '300px',
|
||||
minHeight: 'inherit',
|
||||
})
|
||||
|
||||
this.editorsContainer.append(aceHTML)
|
||||
|
||||
const aceCSS = document.createElement('div')
|
||||
aceCSS.id = 'noteplus-css-editor'
|
||||
Object.assign(aceCSS.style, {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
minHeight: 'inherit',
|
||||
})
|
||||
|
||||
this.editorsContainer.append(aceCSS)
|
||||
|
||||
const live_edit = document.createElement('input')
|
||||
live_edit.type = 'checkbox'
|
||||
live_edit.checked = this.live
|
||||
live_edit.onchange = () => {
|
||||
this.live = live_edit.checked
|
||||
const cancel_button = this.dialog.element.querySelector(
|
||||
'#cancel-editor-dialog',
|
||||
)
|
||||
if (cancel_button) {
|
||||
cancel_button.disabled = this.live
|
||||
cancel_button.style.background = this.live
|
||||
? 'repeating-linear-gradient(45deg,#606dbc,#606dbc 10px,#465298 10px,#465298 20px)'
|
||||
: ''
|
||||
}
|
||||
}
|
||||
|
||||
//- "Dynamic" elements
|
||||
const firstButton = this.dialog.element.querySelector('button')
|
||||
const syncUI = () => {
|
||||
let convert_to_html =
|
||||
this.dialog.element.querySelector('#convert-to-html')
|
||||
if (this.edit_mode_widget.value === 'markdown') {
|
||||
if (convert_to_html == null) {
|
||||
convert_to_html = document.createElement('button')
|
||||
convert_to_html.textContent = 'Convert to HTML (NO UNDO!)'
|
||||
convert_to_html.id = 'convert-to-html'
|
||||
convert_to_html.onclick = () => {
|
||||
const select_mode = this.dialog.element.querySelector('#edit_mode')
|
||||
|
||||
const md = this.html_editor.getValue()
|
||||
this.edit_mode_widget.value = 'html'
|
||||
select_mode.value = 'html'
|
||||
MTB.mdParser.parse(md).then((content) => {
|
||||
this.html_widget.value = content
|
||||
this.html_editor.setValue(content)
|
||||
this.html_editor.session.setMode('ace/mode/html')
|
||||
this.updateHTML(this.html_widget.value)
|
||||
convert_to_html.remove()
|
||||
})
|
||||
}
|
||||
firstButton.before(convert_to_html)
|
||||
}
|
||||
} else {
|
||||
if (convert_to_html != null) {
|
||||
convert_to_html.remove()
|
||||
convert_to_html = null
|
||||
}
|
||||
}
|
||||
select_mode.value = this.edit_mode_widget.value
|
||||
|
||||
// the header for dragging the dialog
|
||||
const header = document.createElement('div')
|
||||
header.style.padding = '8px'
|
||||
header.style.cursor = 'move'
|
||||
header.style.backgroundColor = 'rgba(0,0,0,0.5)'
|
||||
header.style.userSelect = 'none'
|
||||
|
||||
header.style.borderBottom = '1px solid #ddd'
|
||||
header.textContent = 'MTB Note+ Editor'
|
||||
container.prepend(header)
|
||||
makeDraggable(this.dialog.element, header)
|
||||
makeResizable(this.dialog.element)
|
||||
}
|
||||
//- combobox
|
||||
let theme_select = this.dialog.element.querySelector('#theme_select')
|
||||
if (!theme_select) {
|
||||
infoLogger('Creating combobox for select')
|
||||
theme_select = document.createElement('select')
|
||||
theme_select.name = 'theme'
|
||||
theme_select.id = 'theme_select'
|
||||
|
||||
const addOption = (label) => {
|
||||
const option = document.createElement('option')
|
||||
option.value = label
|
||||
option.textContent = label
|
||||
theme_select.append(option)
|
||||
}
|
||||
for (const t of THEMES) {
|
||||
addOption(t)
|
||||
}
|
||||
|
||||
theme_select.addEventListener('change', (event) => {
|
||||
const val = event.target.value
|
||||
this.setTheme(val)
|
||||
})
|
||||
|
||||
container.prepend(theme_select)
|
||||
}
|
||||
|
||||
theme_select.value = this.theme_widget.value
|
||||
|
||||
let select_mode = this.dialog.element.querySelector('#edit_mode')
|
||||
|
||||
if (!select_mode) {
|
||||
infoLogger('Creating combobox for select')
|
||||
select_mode = document.createElement('select')
|
||||
select_mode.name = 'mode'
|
||||
select_mode.id = 'edit_mode'
|
||||
|
||||
const addOption = (label) => {
|
||||
const option = document.createElement('option')
|
||||
option.value = label
|
||||
option.textContent = label
|
||||
select_mode.append(option)
|
||||
}
|
||||
addOption('markdown')
|
||||
addOption('html')
|
||||
|
||||
select_mode.addEventListener('change', (event) => {
|
||||
const val = event.target.value
|
||||
this.edit_mode_widget.value = val
|
||||
if (this.html_editor) {
|
||||
this.html_editor.session.setMode(`ace/mode/${val}`)
|
||||
this.updateHTML(this.html_editor.getValue())
|
||||
|
||||
syncUI()
|
||||
}
|
||||
})
|
||||
|
||||
container.append(select_mode)
|
||||
}
|
||||
select_mode.value = this.edit_mode_widget.value
|
||||
|
||||
syncUI()
|
||||
|
||||
const live_edit_label = document.createElement('label')
|
||||
live_edit_label.textContent = 'Live Edit'
|
||||
|
||||
// add a tooltip
|
||||
live_edit_label.title =
|
||||
'When this is on, the editor will update the note+ whenever you change the text.'
|
||||
|
||||
live_edit_label.append(live_edit)
|
||||
|
||||
// select_mode.before(live_edit_label)
|
||||
container.append(live_edit_label)
|
||||
|
||||
this.setupEditors()
|
||||
}
|
||||
loadAceEditor() {
|
||||
shared.loadScript('/mtb_async/ace/ace.js').catch((e) => {
|
||||
errorLogger(e)
|
||||
})
|
||||
}
|
||||
onCreate() {
|
||||
errorLogger('NotePlus onCreate')
|
||||
}
|
||||
restoreNodeState(info) {
|
||||
this.html_widget.element.id = `note-plus-${this.uuid}`
|
||||
this.setMode(this.edit_mode_widget.value)
|
||||
this.setTheme(this.theme_widget.value)
|
||||
this.updateHTML(this.html_widget.value)
|
||||
this.updateCSS(this.css_widget.value)
|
||||
if (info?.size) {
|
||||
this.setSize(info.size)
|
||||
}
|
||||
}
|
||||
configure(info) {
|
||||
super.configure(info)
|
||||
infoLogger('Restoring serialized values', info)
|
||||
this.restoreNodeState(info)
|
||||
// - update view from serialzed data
|
||||
}
|
||||
onNodeCreated() {
|
||||
infoLogger('Node created', this.uuid)
|
||||
this.restoreNodeState({})
|
||||
// this.html_widget.element.id = `note-plus-${this.uuid}`
|
||||
// this.setMode(this.edit_mode_widget.value)
|
||||
// this.setTheme(this.theme_widget.value)
|
||||
// this.updateHTML(this.html_widget.value) // widget is populated here since we called super
|
||||
// this.updateCSS(this.css_widget.value)
|
||||
}
|
||||
onRemoved() {
|
||||
infoLogger('Node removed', this.uuid)
|
||||
}
|
||||
getExtraMenuOptions() {
|
||||
const currentMode = this.edit_mode_widget.value
|
||||
const newMode = currentMode === 'html' ? 'markdown' : 'html'
|
||||
|
||||
const debugItems = window.MTB?.DEBUG
|
||||
? [
|
||||
{
|
||||
content: 'Replace with demo content (debug)',
|
||||
callback: () => {
|
||||
this.html_widget.value = DEMO_CONTENT
|
||||
},
|
||||
},
|
||||
]
|
||||
: []
|
||||
|
||||
return [
|
||||
...debugItems,
|
||||
{
|
||||
content: `Set to ${newMode}`,
|
||||
callback: () => {
|
||||
this.edit_mode_widget.value = newMode
|
||||
this.updateHTML(this.html_widget.value)
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
_setupEditor(editor) {
|
||||
this.setTheme(this.theme_widget.value)
|
||||
|
||||
editor.setShowPrintMargin(false)
|
||||
editor.session.setUseWrapMode(true)
|
||||
editor.renderer.setShowGutter(false)
|
||||
editor.session.setTabSize(4)
|
||||
editor.session.setUseSoftTabs(true)
|
||||
editor.setFontSize(14)
|
||||
editor.setReadOnly(false)
|
||||
editor.setHighlightActiveLine(false)
|
||||
editor.setShowFoldWidgets(true)
|
||||
return editor
|
||||
}
|
||||
|
||||
setTheme(theme) {
|
||||
this.theme_widget.value = theme
|
||||
if (this.html_editor) {
|
||||
this.html_editor.setTheme(`ace/theme/${theme}`)
|
||||
}
|
||||
if (this.css_editor) {
|
||||
this.css_editor.setTheme(`ace/theme/${theme}`)
|
||||
}
|
||||
}
|
||||
|
||||
setMode(mode) {
|
||||
this.edit_mode_widget.value = mode
|
||||
if (this.html_editor) {
|
||||
this.html_editor.session.setMode(`ace/mode/${mode}`)
|
||||
}
|
||||
|
||||
this.updateHTML(this.html_widget.value)
|
||||
}
|
||||
setupEditors() {
|
||||
infoLogger('NotePlus setupEditor')
|
||||
|
||||
this.html_editor = ace.edit('noteplus-html-editor')
|
||||
|
||||
this.css_editor = ace.edit('noteplus-css-editor')
|
||||
this.css_editor.session.setMode('ace/mode/css')
|
||||
|
||||
this.setMode(DEFAULT_MODE)
|
||||
|
||||
this._setupEditor(this.html_editor)
|
||||
this._setupEditor(this.css_editor)
|
||||
|
||||
this.css_editor.session.on('change', (_delta) => {
|
||||
// delta.start, delta.end, delta.lines, delta.action
|
||||
if (this.live) {
|
||||
this.updateCSS(this.css_editor.getValue())
|
||||
}
|
||||
})
|
||||
|
||||
this.html_editor.session.on('change', (_delta) => {
|
||||
// delta.start, delta.end, delta.lines, delta.action
|
||||
if (this.live) {
|
||||
this.updateHTML(this.html_editor.getValue())
|
||||
}
|
||||
})
|
||||
|
||||
this.html_editor.setValue(this.html_widget.value)
|
||||
this.css_editor.setValue(this.css_widget.value)
|
||||
}
|
||||
|
||||
scopeCss(css, scopeId) {
|
||||
return css
|
||||
.split('}')
|
||||
.map((rule) => {
|
||||
if (rule.trim() === '') {
|
||||
return ''
|
||||
}
|
||||
const scopedRule = rule
|
||||
.split('{')
|
||||
.map((segment, index) => {
|
||||
if (index === 0) {
|
||||
return `#${scopeId} ${segment.trim()}`
|
||||
}
|
||||
return `{${segment.trim()}`
|
||||
})
|
||||
.join(' ')
|
||||
return `${scopedRule}}`
|
||||
})
|
||||
.join('\n')
|
||||
}
|
||||
getCssDom() {
|
||||
const styleTagId = `note-plus-stylesheet-${this.uuid}`
|
||||
|
||||
let styleTag = document.head.querySelector(`#${styleTagId}`)
|
||||
|
||||
if (!styleTag) {
|
||||
styleTag = document.createElement('style')
|
||||
styleTag.type = 'text/css'
|
||||
styleTag.id = styleTagId
|
||||
document.head.appendChild(styleTag)
|
||||
infoLogger(`Creating note-plus-stylesheet-${this.uuid}`, styleTag)
|
||||
}
|
||||
|
||||
return styleTag
|
||||
}
|
||||
calculateHeight() {
|
||||
this.calculated_height = shared.calculateTotalChildrenHeight(
|
||||
this.html_widget.element,
|
||||
)
|
||||
this.setDirtyCanvas(true, true)
|
||||
}
|
||||
updateCSS(css) {
|
||||
infoLogger('NotePlus updateCSS')
|
||||
// this.html_widget.element.style = css
|
||||
const scopedCss = this.scopeCss(
|
||||
`${CSS_RESET}\n${css}`,
|
||||
`note-plus-${this.uuid}`,
|
||||
)
|
||||
|
||||
const cssDom = this.getCssDom()
|
||||
cssDom.innerHTML = scopedCss
|
||||
|
||||
this.css_widget.value = css
|
||||
this.calculateHeight()
|
||||
infoLogger('NotePlus updateCSS', this.calculated_height)
|
||||
// this.setSize(this.computeSize())
|
||||
}
|
||||
|
||||
parserInitiated() {
|
||||
if (window.MTB?.mdParser) return true
|
||||
return false
|
||||
}
|
||||
|
||||
/** to easilty swap purification methods*/
|
||||
purify(content) {
|
||||
return DOMPurify.sanitize(content, {
|
||||
ADD_TAGS: ['iframe', 'detail', 'summary'],
|
||||
})
|
||||
}
|
||||
|
||||
updateHTML(val) {
|
||||
if (!this.parserInitiated()) {
|
||||
return
|
||||
}
|
||||
val = val || this.html_widget.value
|
||||
const isHTML = this.edit_mode_widget.value === 'html'
|
||||
|
||||
const cleanHTML = this.purify(val)
|
||||
|
||||
const value = isHTML
|
||||
? cleanHTML
|
||||
: cleanHTML.replaceAll('>', '>').replaceAll('<', '<')
|
||||
// .replaceAll('&', '&')
|
||||
// .replaceAll('"', '"')
|
||||
// .replaceAll(''', "'")
|
||||
|
||||
this.html_widget.value = value
|
||||
|
||||
if (isHTML) {
|
||||
this.inner.innerHTML = value
|
||||
} else {
|
||||
MTB.mdParser.parse(value).then((e) => {
|
||||
this.inner.innerHTML = e
|
||||
})
|
||||
}
|
||||
// this.html_widget.element.innerHTML = `<div id="note-plus-spacer"></div>${value}`
|
||||
this.calculateHeight()
|
||||
// this.setSize(this.computeSize())
|
||||
}
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: 'mtb.noteplus',
|
||||
setup: () => {
|
||||
app.ui.settings.addSetting({
|
||||
id: 'mtb.noteplus.use-shiki',
|
||||
category: ['mtb', 'Note+', 'use-shiki'],
|
||||
name: 'Use shiki to highlight code',
|
||||
tooltip:
|
||||
'This will load a larger version of @mtb/markdown-parser that bundles shiki, it supports all shiki transformers (supported langs: html,css,python,markdown)',
|
||||
|
||||
type: 'boolean',
|
||||
defaultValue: false,
|
||||
attrs: {
|
||||
style: {
|
||||
// fontFamily: 'monospace',
|
||||
},
|
||||
},
|
||||
async onChange(value) {
|
||||
storage.set('np-use-shiki', value)
|
||||
useShiki = value
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
registerCustomNodes() {
|
||||
LiteGraph.registerNodeType('Note Plus (mtb)', NotePlus)
|
||||
|
||||
NotePlus.category = 'mtb/utils'
|
||||
NotePlus.title = 'Note+ (mtb)'
|
||||
|
||||
NotePlus.title_mode = LiteGraph.NO_TITLE
|
||||
},
|
||||
})
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import { app } from '../../scripts/app.js'
|
||||
import { app } from '/scripts/app.js'
|
||||
|
||||
const log = (...args) => {
|
||||
if (window.MTB?.TRACE) {
|
||||
|
||||
@@ -1,334 +0,0 @@
|
||||
// This is a vanillajs implementation of Houdini's number input widgets.
|
||||
// It basically popup a visual sensitivity slider of steps to use as incr/decr
|
||||
// TODO: Convert it to IWidget
|
||||
|
||||
// import styles from "./style.module.css";
|
||||
|
||||
function getValidNumber(numberInput) {
|
||||
let num =
|
||||
isNaN(numberInput.value) || numberInput.value === ''
|
||||
? 0
|
||||
: parseFloat(numberInput.value)
|
||||
return num
|
||||
}
|
||||
/**
|
||||
* Number input widgets
|
||||
*/
|
||||
export class NumberInputWidget {
|
||||
constructor(containerId, numberOfInputs = 1, isDebug = false) {
|
||||
this.container = document.getElementById(containerId)
|
||||
this.numberOfInputs = numberOfInputs
|
||||
this.currentInput = null // Store the currently active input
|
||||
|
||||
this.threshold = 30
|
||||
this.mouseSensitivityMultiplier = 0.05
|
||||
this.debug = isDebug
|
||||
|
||||
//- states
|
||||
this.initialMouseX
|
||||
this.lastMouseX
|
||||
this.activeStep = 1
|
||||
this.accumulatedDelta = 0
|
||||
this.stepLocked = false
|
||||
this.thresholdExceeded = false
|
||||
this.isDragging = false
|
||||
|
||||
const styleTagId = 'mtb-constant-style'
|
||||
|
||||
let styleTag = document.head.querySelector(`#${styleTagId}`)
|
||||
|
||||
if (!styleTag) {
|
||||
styleTag = document.createElement('style')
|
||||
styleTag.type = 'text/css'
|
||||
styleTag.id = styleTagId
|
||||
|
||||
styleTag.innerHTML = `
|
||||
|
||||
.${containerId}{
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.sensitivity-menu {
|
||||
display: none;
|
||||
position: absolute;
|
||||
/* Additional styling */
|
||||
}
|
||||
|
||||
.sensitivity-menu .step {
|
||||
cursor: pointer;
|
||||
padding: 0.5em;
|
||||
/* Add more styling as needed */
|
||||
}
|
||||
|
||||
.sensitivity-menu {
|
||||
font-family: monospace;
|
||||
|
||||
background: var(--bg-color);
|
||||
border: 1px solid var(--fg-color);
|
||||
/* Highlight for the active step */
|
||||
}
|
||||
.number-input {
|
||||
background: var(--bg-color);
|
||||
color: var(--fg-color)
|
||||
}
|
||||
|
||||
.sensitivity-menu .step.active {
|
||||
background-color:var(--drag-text);
|
||||
/* Highlight for the active step */
|
||||
}
|
||||
|
||||
.sensitivity-menu .step.locked {
|
||||
background-color: #f00;
|
||||
/* Change to your preferred color for the locked state */
|
||||
}
|
||||
#debug-container {
|
||||
transform: translateX(50%);
|
||||
width: 50%;
|
||||
text-align: center;
|
||||
font-family: monospace;
|
||||
}
|
||||
`
|
||||
document.head.appendChild(styleTag)
|
||||
}
|
||||
|
||||
this.createWidgetElements()
|
||||
this.initializeEventListeners()
|
||||
}
|
||||
|
||||
setLabel(str) {
|
||||
this.label.textContent = str
|
||||
}
|
||||
setValue(...values) {
|
||||
if (values.length !== this.numberInputs.length) {
|
||||
console.error('Number of values does not match the number of inputs.')
|
||||
console.error(
|
||||
`You provided ${values.length} but the input want ${this.numberInputs.length}`,
|
||||
{ values },
|
||||
)
|
||||
return
|
||||
}
|
||||
// Set each input value
|
||||
this.numberInputs.forEach((input, index) => {
|
||||
input.value = values[index]
|
||||
})
|
||||
}
|
||||
getValue() {
|
||||
const value = []
|
||||
this.numberInputs.forEach((input, index) => {
|
||||
value.push(Number.parseFloat(input.value) || 0.0)
|
||||
})
|
||||
return value
|
||||
}
|
||||
resetValues() {
|
||||
for (const input of numberInputs) {
|
||||
input.value = 0
|
||||
}
|
||||
this.onChange?.(this.getValue())
|
||||
}
|
||||
|
||||
createWidgetElements() {
|
||||
this.label = document.createElement('label')
|
||||
this.label.textContent = 'Control All:'
|
||||
this.label.className = 'widget-label'
|
||||
this.container.appendChild(this.label)
|
||||
|
||||
this.label.addEventListener('mousedown', (event) => {
|
||||
if (event.button === 1) {
|
||||
this.currentInput = null
|
||||
this.handleMouseDown(event)
|
||||
}
|
||||
})
|
||||
|
||||
this.label.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
this.resetValues()
|
||||
})
|
||||
|
||||
this.numberInputs = []
|
||||
|
||||
// create linked inputs
|
||||
for (let i = 0; i < this.numberOfInputs; i++) {
|
||||
const numberInput = document.createElement('input')
|
||||
numberInput.type = 'number'
|
||||
numberInput.className = 'number-input' //styles.numberInput; //"number-input";
|
||||
numberInput.step = 'any'
|
||||
this.container.appendChild(numberInput)
|
||||
this.numberInputs.push(numberInput)
|
||||
|
||||
numberInput.addEventListener('mousedown', (event) => {
|
||||
if (event.button === 1) {
|
||||
this.currentInput = numberInput
|
||||
this.handleMouseDown(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
this.sensitivityMenu = document.createElement('div')
|
||||
this.sensitivityMenu.className = 'sensitivity-menu' //styles.sensitivityMenu; //"sensitivity-menu";
|
||||
this.container.appendChild(this.sensitivityMenu)
|
||||
|
||||
// create steps
|
||||
const stepsValues = [0.001, 0.01, 0.1, 1, 10, 100]
|
||||
stepsValues.forEach((value) => {
|
||||
const step = document.createElement('div')
|
||||
step.className = 'step' //styles.step //"step";
|
||||
step.dataset.step = value
|
||||
step.textContent = value.toString()
|
||||
this.sensitivityMenu.appendChild(step)
|
||||
})
|
||||
|
||||
this.steps = this.sensitivityMenu.getElementsByClassName('step') //styles.step)
|
||||
|
||||
if (this.debug) {
|
||||
this.debugContainer = document.createElement('div')
|
||||
this.debugContainer.id = 'debug-container' //styles.debugContainer //"debugContainer";
|
||||
document.body.appendChild(this.debugContainer)
|
||||
}
|
||||
}
|
||||
showSensitivityMenu(pageX, pageY) {
|
||||
this.sensitivityMenu.style.display = 'block'
|
||||
this.sensitivityMenu.style.left = `${pageX}px`
|
||||
this.sensitivityMenu.style.top = `${pageY}px`
|
||||
this.initialMouseX = pageX
|
||||
this.lastMouseX = pageX
|
||||
this.isDragging = true
|
||||
this.thresholdExceeded = false
|
||||
this.stepLocked = false
|
||||
this.updateDebugInfo()
|
||||
}
|
||||
updateDebugInfo() {
|
||||
if (this.debug) {
|
||||
this.debugContainer.innerHTML = `
|
||||
<div>Active Step: ${this.activeStep}</div>
|
||||
<div>Initial Mouse X: ${this.initialMouseX}</div>
|
||||
<div>Last Mouse X: ${this.lastMouseX}</div>
|
||||
<div>Accumulated Delta: ${this.accumulatedDelta}</div>
|
||||
<div>Threshold Exceeded: ${this.thresholdExceeded}</div>
|
||||
<div>Step Locked: ${this.stepLocked}</div>
|
||||
<div>Number Input Value: ${this.currentInput?.value}</div>
|
||||
`
|
||||
}
|
||||
}
|
||||
handleMouseDown(event) {
|
||||
if (event.button === 1) {
|
||||
this.showSensitivityMenu(
|
||||
event.target.offsetWidth,
|
||||
event.target.offsetHeight,
|
||||
)
|
||||
event.preventDefault()
|
||||
}
|
||||
}
|
||||
handleMouseUp(event) {
|
||||
if (event.button === 1) {
|
||||
this.resetWidgetState()
|
||||
}
|
||||
}
|
||||
handleClickOutside(event) {
|
||||
if (event.target !== this.numberInput) {
|
||||
this.resetWidgetState()
|
||||
}
|
||||
}
|
||||
handleMouseMove(event) {
|
||||
if (this.sensitivityMenu.style.display === 'block') {
|
||||
const relativeY = event.pageY - 300 // this.sensitivityMenu.offsetTop
|
||||
|
||||
const horizontalDistanceFromInitial = Math.abs(
|
||||
event.target.offsetWidth - this.initialMouseX,
|
||||
)
|
||||
|
||||
// Unlock if the mouse moves back towards the initial position
|
||||
if (horizontalDistanceFromInitial < this.threshold) {
|
||||
this.thresholdExceeded = false
|
||||
this.stepLocked = false
|
||||
this.accumulatedDelta = 0
|
||||
}
|
||||
|
||||
// Update step only if it is not locked
|
||||
if (!this.stepLocked) {
|
||||
for (let step of this.steps) {
|
||||
step.classList.remove('active') //styles.active)
|
||||
step.classList.remove('locked') //styles.locked)
|
||||
if (
|
||||
relativeY >= step.offsetTop &&
|
||||
relativeY <= step.offsetTop + step.offsetHeight
|
||||
) {
|
||||
step.classList.add('active') //styles.active)
|
||||
this.setActiveStep(parseFloat(step.dataset.step))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.stepLocked) {
|
||||
this.sensitivityMenu
|
||||
.querySelector('.step.active')
|
||||
?.classList.add('locked')
|
||||
}
|
||||
|
||||
this.updateStepValue(event.pageX)
|
||||
}
|
||||
}
|
||||
|
||||
initializeEventListeners() {
|
||||
document.addEventListener('mousemove', (event) =>
|
||||
this.handleMouseMove(event),
|
||||
)
|
||||
document.addEventListener('mouseup', (event) => this.handleMouseUp(event))
|
||||
|
||||
document.addEventListener('click', (event) =>
|
||||
this.handleClickOutside(event),
|
||||
)
|
||||
}
|
||||
|
||||
setActiveStep(val) {
|
||||
if (this.activeStep !== val) {
|
||||
this.activeStep = val
|
||||
this.stepLocked = false
|
||||
this.accumulatedDelta = 0
|
||||
this.thresholdExceeded = false
|
||||
}
|
||||
}
|
||||
resetWidgetState() {
|
||||
this.sensitivityMenu.style.display = 'none'
|
||||
this.isDragging = false
|
||||
this.lastMouseX = undefined
|
||||
this.thresholdExceeded = false
|
||||
this.stepLocked = false
|
||||
this.updateDebugInfo()
|
||||
}
|
||||
updateStepValue(mouseX) {
|
||||
if (this.isDragging && this.lastMouseX !== undefined) {
|
||||
const deltaX = mouseX - this.lastMouseX
|
||||
this.accumulatedDelta += deltaX
|
||||
|
||||
if (
|
||||
!this.thresholdExceeded &&
|
||||
Math.abs(this.accumulatedDelta) > this.threshold
|
||||
) {
|
||||
this.thresholdExceeded = true
|
||||
this.stepLocked = true
|
||||
}
|
||||
|
||||
if (this.thresholdExceeded && this.stepLocked) {
|
||||
// frequency of value changes
|
||||
if (
|
||||
Math.abs(this.accumulatedDelta) * this.mouseSensitivityMultiplier >=
|
||||
1
|
||||
) {
|
||||
const valueChange = Math.sign(this.accumulatedDelta) * this.activeStep
|
||||
if (this.currentInput) {
|
||||
this.currentInput.value =
|
||||
getValidNumber(this.currentInput) + valueChange
|
||||
this.onChange?.(this.getValue())
|
||||
} else {
|
||||
this.numberInputs.forEach((input) => {
|
||||
input.value = getValidNumber(input) + valueChange
|
||||
})
|
||||
}
|
||||
this.accumulatedDelta = 0
|
||||
}
|
||||
}
|
||||
|
||||
this.lastMouseX = mouseX
|
||||
}
|
||||
this.updateDebugInfo()
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
||||
ace.define("ace/ext/beautify",["require","exports","module","ace/token_iterator"],function(e,t,n){"use strict";function i(e,t){return e.type.lastIndexOf(t+".xml")>-1}var r=e("../token_iterator").TokenIterator;t.singletonTags=["area","base","br","col","command","embed","hr","html","img","input","keygen","link","meta","param","source","track","wbr"],t.blockTags=["article","aside","blockquote","body","div","dl","fieldset","footer","form","head","header","html","nav","ol","p","script","section","style","table","tbody","tfoot","thead","ul"],t.formatOptions={lineBreaksAfterCommasInCurlyBlock:!0},t.beautify=function(e){var n=new r(e,0,0),s=n.getCurrentToken(),o=e.getTabString(),u=t.singletonTags,a=t.blockTags,f=t.formatOptions||{},l,c=!1,h=!1,p=!1,d="",v="",m="",g=0,y=0,b=0,w=0,E=0,S=0,x=0,T,N=0,C=0,k=[],L=!1,A,O=!1,M=!1,_=!1,D=!1,P={0:0},H=[],B=!1,j=function(){l&&l.value&&l.type!=="string.regexp"&&(l.value=l.value.replace(/^\s*/,""))},F=function(){var e=d.length-1;for(;;){if(e==0)break;if(d[e]!==" ")break;e-=1}d=d.slice(0,e+1)},I=function(){d=d.trimRight(),c=!1};while(s!==null){N=n.getCurrentTokenRow(),k=n.$rowTokens,l=n.stepForward();if(typeof s!="undefined"){v=s.value,E=0,_=m==="style"||e.$modeId==="ace/mode/css",i(s,"tag-open")?(M=!0,l&&(D=a.indexOf(l.value)!==-1),v==="</"&&(D&&!c&&C<1&&C++,_&&(C=1),E=1,D=!1)):i(s,"tag-close")?M=!1:i(s,"comment.start")?D=!0:i(s,"comment.end")&&(D=!1),!M&&!C&&s.type==="paren.rparen"&&s.value.substr(0,1)==="}"&&C++,N!==T&&(C=N,T&&(C-=T));if(C){I();for(;C>0;C--)d+="\n";c=!0,!i(s,"comment")&&!s.type.match(/^(comment|string)$/)&&(v=v.trimLeft())}if(v){s.type==="keyword"&&v.match(/^(if|else|elseif|for|foreach|while|switch)$/)?(H[g]=v,j(),p=!0,v.match(/^(else|elseif)$/)&&d.match(/\}[\s]*$/)&&(I(),h=!0)):s.type==="paren.lparen"?(j(),v.substr(-1)==="{"&&(p=!0,O=!1,M||(C=1)),v.substr(0,1)==="{"&&(h=!0,d.substr(-1)!=="["&&d.trimRight().substr(-1)==="["?(I(),h=!1):d.trimRight().substr(-1)===")"?I():F())):s.type==="paren.rparen"?(E=1,v.substr(0,1)==="}"&&(H[g-1]==="case"&&E++,d.trimRight().substr(-1)==="{"?I():(h=!0,_&&(C+=2))),v.substr(0,1)==="]"&&d.substr(-1)!=="}"&&d.trimRight().substr(-1)==="}"&&(h=!1,w++,I()),v.substr(0,1)===")"&&d.substr(-1)!=="("&&d.trimRight().substr(-1)==="("&&(h=!1,w++,I()),F()):s.type!=="keyword.operator"&&s.type!=="keyword"||!v.match(/^(=|==|===|!=|!==|&&|\|\||and|or|xor|\+=|.=|>|>=|<|<=|=>)$/)?s.type==="punctuation.operator"&&v===";"?(I(),j(),p=!0,_&&C++):s.type==="punctuation.operator"&&v.match(/^(:|,)$/)?(I(),j(),v.match(/^(,)$/)&&x>0&&S===0&&f.lineBreaksAfterCommasInCurlyBlock?C++:(p=!0,c=!1)):s.type==="support.php_tag"&&v==="?>"&&!c?(I(),h=!0):i(s,"attribute-name")&&d.substr(-1).match(/^\s$/)?h=!0:i(s,"attribute-equals")?(F(),j()):i(s,"tag-close")?(F(),v==="/>"&&(h=!0)):s.type==="keyword"&&v.match(/^(case|default)$/)&&B&&(E=1):(I(),j(),h=!0,p=!0);if(c&&(!s.type.match(/^(comment)$/)||!!v.substr(0,1).match(/^[/#]$/))&&(!s.type.match(/^(string)$/)||!!v.substr(0,1).match(/^['"@]$/))){w=b;if(g>y){w++;for(A=g;A>y;A--)P[A]=w}else g<y&&(w=P[g]);y=g,b=w,E&&(w-=E),O&&!S&&(w++,O=!1);for(A=0;A<w;A++)d+=o}s.type==="keyword"&&v.match(/^(case|default)$/)?B===!1&&(H[g]=v,g++,B=!0):s.type==="keyword"&&v.match(/^(break)$/)&&H[g-1]&&H[g-1].match(/^(case|default)$/)&&(g--,B=!1),s.type==="paren.lparen"&&(S+=(v.match(/\(/g)||[]).length,x+=(v.match(/\{/g)||[]).length,g+=v.length),s.type==="keyword"&&v.match(/^(if|else|elseif|for|while)$/)?(O=!0,S=0):!S&&v.trim()&&s.type!=="comment"&&(O=!1);if(s.type==="paren.rparen"){S-=(v.match(/\)/g)||[]).length,x-=(v.match(/\}/g)||[]).length;for(A=0;A<v.length;A++)g--,v.substr(A,1)==="}"&&H[g]==="case"&&g--}s.type=="text"&&(v=v.replace(/\s+$/," ")),h&&!c&&(F(),d.substr(-1)!=="\n"&&(d+=" ")),d+=v,p&&(d+=" "),c=!1,h=!1,p=!1;if(i(s,"tag-close")&&(D||a.indexOf(m)!==-1)||i(s,"doctype")&&v===">")D&&l&&l.value==="</"?C=-1:C=1;l&&u.indexOf(l.value)===-1&&(i(s,"tag-open")&&v==="</"?g--:i(s,"tag-open")&&v==="<"?g++:i(s,"tag-close")&&v==="/>"&&g--),i(s,"tag-name")&&(m=v),T=N}}s=l}d=d.trim(),e.doc.setValue(d)},t.commands=[{name:"beautify",description:"Format selection (Beautify)",exec:function(e){t.beautify(e.session)},bindKey:"Ctrl-Shift-B"}]}); (function() {
|
||||
ace.require(["ace/ext/beautify"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
ace.define("ace/ext/code_lens",["require","exports","module","ace/line_widgets","ace/lib/event","ace/lib/lang","ace/lib/dom","ace/editor","ace/config"],function(e,t,n){"use strict";function u(e){var t=e.$textLayer,n=t.$lenses;n&&n.forEach(function(e){e.remove()}),t.$lenses=null}function a(e,t){var n=e&t.CHANGE_LINES||e&t.CHANGE_FULL||e&t.CHANGE_SCROLL||e&t.CHANGE_TEXT;if(!n)return;var r=t.session,i=t.session.lineWidgets,s=t.$textLayer,a=s.$lenses;if(!i){a&&u(t);return}var f=t.$textLayer.$lines.cells,l=t.layerConfig,c=t.$padding;a||(a=s.$lenses=[]);var h=0;for(var p=0;p<f.length;p++){var d=f[p].row,v=i[d],m=v&&v.lenses;if(!m||!m.length)continue;var g=a[h];g||(g=a[h]=o.buildDom(["div",{"class":"ace_codeLens"}],t.container)),g.style.height=l.lineHeight+"px",h++;for(var y=0;y<m.length;y++){var b=g.childNodes[2*y];b||(y!=0&&g.appendChild(o.createTextNode("\u00a0|\u00a0")),b=o.buildDom(["a"],g)),b.textContent=m[y].title,b.lensCommand=m[y]}while(g.childNodes.length>2*y-1)g.lastChild.remove();var w=t.$cursorLayer.getPixelPosition({row:d,column:0},!0).top-l.lineHeight*v.rowsAbove-l.offset;g.style.top=w+"px";var E=t.gutterWidth,S=r.getLine(d).search(/\S|$/);S==-1&&(S=0),E+=S*l.characterWidth,g.style.paddingLeft=c+E+"px"}while(h<a.length)a.pop().remove()}function f(e){if(!e.lineWidgets)return;var t=e.widgetManager;e.lineWidgets.forEach(function(e){e&&e.lenses&&t.removeLineWidget(e)})}function l(e){e.codeLensProviders=[],e.renderer.on("afterRender",a),e.$codeLensClickHandler||(e.$codeLensClickHandler=function(t){var n=t.target.lensCommand;if(!n)return;e.execCommand(n.id,n.arguments),e._emit("codeLensClick",t)},i.addListener(e.container,"click",e.$codeLensClickHandler,e)),e.$updateLenses=function(){function o(){var r=n.selection.cursor,i=n.documentToScreenRow(r),o=n.getScrollTop(),u=t.setLenses(n,s),a=n.$undoManager&&n.$undoManager.$lastDelta;if(a&&a.action=="remove"&&a.lines.length>1)return;var f=n.documentToScreenRow(r),l=e.renderer.layerConfig.lineHeight,c=n.getScrollTop()+(f-i)*l;u==0&&o<l/4&&o>-l/4&&(c=-l),n.setScrollTop(c)}var n=e.session;if(!n)return;n.widgetManager||(n.widgetManager=new r(n),n.widgetManager.attach(e));var i=e.codeLensProviders.length,s=[];e.codeLensProviders.forEach(function(e){e.provideCodeLenses(n,function(e,t){if(e)return;t.forEach(function(e){s.push(e)}),i--,i==0&&o()})})};var n=s.delayedCall(e.$updateLenses);e.$updateLensesOnInput=function(){n.delay(250)},e.on("input",e.$updateLensesOnInput)}function c(e){e.off("input",e.$updateLensesOnInput),e.renderer.off("afterRender",a),e.$codeLensClickHandler&&e.container.removeEventListener("click",e.$codeLensClickHandler)}var r=e("../line_widgets").LineWidgets,i=e("../lib/event"),s=e("../lib/lang"),o=e("../lib/dom");t.setLenses=function(e,t){var n=Number.MAX_VALUE;return f(e),t&&t.forEach(function(t){var r=t.start.row,i=t.start.column,s=e.lineWidgets&&e.lineWidgets[r];if(!s||!s.lenses)s=e.widgetManager.$registerLineWidget({rowCount:1,rowsAbove:1,row:r,column:i,lenses:[]});s.lenses.push(t.command),r<n&&(n=r)}),e._emit("changeFold",{data:{start:{row:n}}}),n},t.registerCodeLensProvider=function(e,t){e.setOption("enableCodeLens",!0),e.codeLensProviders.push(t),e.$updateLensesOnInput()},t.clear=function(e){t.setLenses(e,null)};var h=e("../editor").Editor;e("../config").defineOptions(h.prototype,"editor",{enableCodeLens:{set:function(e){e?l(this):c(this)}}}),o.importCssString("\n.ace_codeLens {\n position: absolute;\n color: #aaa;\n font-size: 88%;\n background: inherit;\n width: 100%;\n display: flex;\n align-items: flex-end;\n pointer-events: none;\n}\n.ace_codeLens > a {\n cursor: pointer;\n pointer-events: auto;\n}\n.ace_codeLens > a:hover {\n color: #0000ff;\n text-decoration: underline;\n}\n.ace_dark > .ace_codeLens > a:hover {\n color: #4e94ce;\n}\n","codelense.css",!1)}); (function() {
|
||||
ace.require(["ace/ext/code_lens"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
||||
ace.define("ace/ext/elastic_tabstops_lite",["require","exports","module","ace/editor","ace/config"],function(e,t,n){"use strict";var r=function(){function e(e){this.$editor=e;var t=this,n=[],r=!1;this.onAfterExec=function(){r=!1,t.processRows(n),n=[]},this.onExec=function(){r=!0},this.onChange=function(e){r&&(n.indexOf(e.start.row)==-1&&n.push(e.start.row),e.end.row!=e.start.row&&n.push(e.end.row))}}return e.prototype.processRows=function(e){this.$inChange=!0;var t=[];for(var n=0,r=e.length;n<r;n++){var i=e[n];if(t.indexOf(i)>-1)continue;var s=this.$findCellWidthsForBlock(i),o=this.$setBlockCellWidthsToMax(s.cellWidths),u=s.firstRow;for(var a=0,f=o.length;a<f;a++){var l=o[a];t.push(u),this.$adjustRow(u,l),u++}}this.$inChange=!1},e.prototype.$findCellWidthsForBlock=function(e){var t=[],n,r=e;while(r>=0){n=this.$cellWidthsForRow(r);if(n.length==0)break;t.unshift(n),r--}var i=r+1;r=e;var s=this.$editor.session.getLength();while(r<s-1){r++,n=this.$cellWidthsForRow(r);if(n.length==0)break;t.push(n)}return{cellWidths:t,firstRow:i}},e.prototype.$cellWidthsForRow=function(e){var t=this.$selectionColumnsForRow(e),n=[-1].concat(this.$tabsForRow(e)),r=n.map(function(e){return 0}).slice(1),i=this.$editor.session.getLine(e);for(var s=0,o=n.length-1;s<o;s++){var u=n[s]+1,a=n[s+1],f=this.$rightmostSelectionInCell(t,a),l=i.substring(u,a);r[s]=Math.max(l.replace(/\s+$/g,"").length,f-u)}return r},e.prototype.$selectionColumnsForRow=function(e){var t=[],n=this.$editor.getCursorPosition();return this.$editor.session.getSelection().isEmpty()&&e==n.row&&t.push(n.column),t},e.prototype.$setBlockCellWidthsToMax=function(e){var t=!0,n,r,i,s=this.$izip_longest(e);for(var o=0,u=s.length;o<u;o++){var a=s[o];if(!a.push){console.error(a);continue}a.push(NaN);for(var f=0,l=a.length;f<l;f++){var c=a[f];t&&(n=f,i=0,t=!1);if(isNaN(c)){r=f;for(var h=n;h<r;h++)e[h][o]=i;t=!0}i=Math.max(i,c)}}return e},e.prototype.$rightmostSelectionInCell=function(e,t){var n=0;if(e.length){var r=[];for(var i=0,s=e.length;i<s;i++)e[i]<=t?r.push(i):r.push(0);n=Math.max.apply(Math,r)}return n},e.prototype.$tabsForRow=function(e){var t=[],n=this.$editor.session.getLine(e),r=/\t/g,i;while((i=r.exec(n))!=null)t.push(i.index);return t},e.prototype.$adjustRow=function(e,t){var n=this.$tabsForRow(e);if(n.length==0)return;var r=0,i=-1,s=this.$izip(t,n);for(var o=0,u=s.length;o<u;o++){var a=s[o][0],f=s[o][1];i+=1+a,f+=r;var l=i-f;if(l==0)continue;var c=this.$editor.session.getLine(e).substr(0,f),h=c.replace(/\s*$/g,""),p=c.length-h.length;l>0&&(this.$editor.session.getDocument().insertInLine({row:e,column:f+1},Array(l+1).join(" ")+" "),this.$editor.session.getDocument().removeInLine(e,f,f+1),r+=l),l<0&&p>=-l&&(this.$editor.session.getDocument().removeInLine(e,f+l,f),r+=l)}},e.prototype.$izip_longest=function(e){if(!e[0])return[];var t=e[0].length,n=e.length;for(var r=1;r<n;r++){var i=e[r].length;i>t&&(t=i)}var s=[];for(var o=0;o<t;o++){var u=[];for(var r=0;r<n;r++)e[r][o]===""?u.push(NaN):u.push(e[r][o]);s.push(u)}return s},e.prototype.$izip=function(e,t){var n=e.length>=t.length?t.length:e.length,r=[];for(var i=0;i<n;i++){var s=[e[i],t[i]];r.push(s)}return r},e}();t.ElasticTabstopsLite=r;var i=e("../editor").Editor;e("../config").defineOptions(i.prototype,"editor",{useElasticTabstops:{set:function(e){e?(this.elasticTabstops||(this.elasticTabstops=new r(this)),this.commands.on("afterExec",this.elasticTabstops.onAfterExec),this.commands.on("exec",this.elasticTabstops.onExec),this.on("change",this.elasticTabstops.onChange)):this.elasticTabstops&&(this.commands.removeListener("afterExec",this.elasticTabstops.onAfterExec),this.commands.removeListener("exec",this.elasticTabstops.onExec),this.removeListener("change",this.elasticTabstops.onChange))}}})}); (function() {
|
||||
ace.require(["ace/ext/elastic_tabstops_lite"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
||||
; (function() {
|
||||
ace.require(["ace/ext/error_marker"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
ace.define("ace/ext/hardwrap",["require","exports","module","ace/range","ace/editor","ace/config"],function(e,t,n){"use strict";function i(e,t){function m(e,t,n){if(e.length<t)return;var r=e.slice(0,t),i=e.slice(t),s=/^(?:(\s+)|(\S+)(\s+))/.exec(i),o=/(?:(\s+)|(\s+)(\S+))$/.exec(r),u=0,a=0;o&&!o[2]&&(u=t-o[1].length,a=t),s&&!s[2]&&(u||(u=t),a=t+s[1].length);if(u)return{start:u,end:a};if(o&&o[2]&&o.index>n)return{start:o.index,end:o.index+o[2].length};if(s&&s[2])return u=t+s[2].length,{start:u,end:u+s[3].length}}var n=t.column||e.getOption("printMarginColumn"),i=t.allowMerge!=0,s=Math.min(t.startRow,t.endRow),o=Math.max(t.startRow,t.endRow),u=e.session;while(s<=o){var a=u.getLine(s);if(a.length>n){var f=m(a,n,5);if(f){var l=/^\s*/.exec(a)[0];u.replace(new r(s,f.start,s,f.end),"\n"+l)}o++}else if(i&&/\S/.test(a)&&s!=o){var c=u.getLine(s+1);if(c&&/\S/.test(c)){var h=a.replace(/\s+$/,""),p=c.replace(/^\s+/,""),d=h+" "+p,f=m(d,n,5);if(f&&f.start>h.length||d.length<n){var v=new r(s,h.length,s+1,c.length-p.length);u.replace(v," "),s--,o--}else h.length<a.length&&u.remove(new r(s,h.length,s,a.length))}}s++}}function s(e){if(e.command.name=="insertstring"&&/\S/.test(e.args)){var t=e.editor,n=t.selection.cursor;if(n.column<=t.renderer.$printMarginColumn)return;var r=t.session.$undoManager.$lastDelta;i(t,{startRow:n.row,endRow:n.row,allowMerge:!1}),r!=t.session.$undoManager.$lastDelta&&t.session.markUndoGroup()}}var r=e("../range").Range,o=e("../editor").Editor;e("../config").defineOptions(o.prototype,"editor",{hardWrap:{set:function(e){e?this.commands.on("afterExec",s):this.commands.off("afterExec",s)},value:!1}}),t.hardWrap=i}); (function() {
|
||||
ace.require(["ace/ext/hardwrap"], function(m) {
|
||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
||||
module.exports = m;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user