Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78e0d6f096 |
@@ -1,2 +0,0 @@
|
|||||||
[*]
|
|
||||||
end_of_line = lf
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
name: 🐞 Bug Report
|
name: 🐞 Bug Report
|
||||||
title: '[bug] '
|
title: "[bug] "
|
||||||
description: Report a bug
|
description: Report a bug
|
||||||
labels: ['type: 🐛 bug', 'status: 🧹 needs triage']
|
labels: ["type: 🐛 bug", "status: 🧹 needs triage"]
|
||||||
assignees:
|
assignees:
|
||||||
- melMass
|
- melMass
|
||||||
|
|
||||||
@@ -12,8 +12,6 @@ body:
|
|||||||
## Before submiting an issue
|
## Before submiting an issue
|
||||||
- Make sure to read the README & INSTALL instructions.
|
- 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.
|
- 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
|
### Try using the debug mode to get more info
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,3 @@ __pycache__
|
|||||||
*.onnx
|
*.onnx
|
||||||
wheels/
|
wheels/
|
||||||
node_modules/
|
node_modules/
|
||||||
compose.yaml
|
|
||||||
comfy_mtb.wsb
|
|
||||||
Dockerfile
|
|
||||||
|
|||||||
@@ -7,6 +7,3 @@
|
|||||||
[submodule "extern/frame_interpolation"]
|
[submodule "extern/frame_interpolation"]
|
||||||
path = extern/frame_interpolation
|
path = extern/frame_interpolation
|
||||||
url = https://github.com/google-research/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
|
|
||||||
-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
|
|
||||||
|
|
||||||
@@ -15,11 +15,6 @@
|
|||||||
|
|
||||||
[**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)
|
||||||
|
|
||||||
There is now a dedicated `#mtb-nodes` channel on the Banodoco discord:
|
|
||||||
[](https://discord.gg/IAXhsabmDhn)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
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.
|
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).
|
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).
|
||||||
@@ -46,7 +41,6 @@ mtb add a few widgets like `COLOR`
|
|||||||
A few nodes have the concept of "dynamic" inputs:
|
A few nodes have the concept of "dynamic" inputs:
|
||||||
<img alt="dynamic inputs" width=450 src="https://github.com/melMass/comfy_mtb/assets/7041726/10b3976e-b212-4968-91eb-f34c02bb80c3" />
|
<img alt="dynamic inputs" width=450 src="https://github.com/melMass/comfy_mtb/assets/7041726/10b3976e-b212-4968-91eb-f34c02bb80c3" />
|
||||||
|
|
||||||
<!-- NOTE: Here it should just be some examples and warnings, move the rest to the wiki -->
|
|
||||||
|
|
||||||
# Node List
|
# Node List
|
||||||
|
|
||||||
|
|||||||
+13
-14
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding:utf-8 -*-
|
||||||
###
|
###
|
||||||
# File: __init__.py
|
# File: __init__.py
|
||||||
# Project: comfy_mtb
|
# Project: comfy_mtb
|
||||||
@@ -42,7 +43,7 @@ __version__ = "0.2.0"
|
|||||||
def extract_nodes_from_source(filename):
|
def extract_nodes_from_source(filename):
|
||||||
source_code = ""
|
source_code = ""
|
||||||
|
|
||||||
with open(filename, encoding="utf8") as file:
|
with open(filename, "r", encoding="utf8") as file:
|
||||||
source_code = file.read()
|
source_code = file.read()
|
||||||
|
|
||||||
nodes = []
|
nodes = []
|
||||||
@@ -80,7 +81,7 @@ def load_nodes():
|
|||||||
module = importlib.import_module(
|
module = importlib.import_module(
|
||||||
f".nodes.{module_name}", package=__package__
|
f".nodes.{module_name}", package=__package__
|
||||||
)
|
)
|
||||||
_nodes = getattr(module, "__nodes__", [])
|
_nodes = getattr(module, "__nodes__")
|
||||||
nodes.extend(_nodes)
|
nodes.extend(_nodes)
|
||||||
log.debug(f"Imported {module_name} nodes")
|
log.debug(f"Imported {module_name} nodes")
|
||||||
|
|
||||||
@@ -96,7 +97,7 @@ def load_nodes():
|
|||||||
|
|
||||||
if errors:
|
if errors:
|
||||||
log.debug(
|
log.debug(
|
||||||
"Some nodes failed to load:\n\t"
|
f"Some nodes failed to load:\n\t"
|
||||||
+ "\n\t".join(errors)
|
+ "\n\t".join(errors)
|
||||||
+ "\n\n"
|
+ "\n\n"
|
||||||
+ "Check that you properly installed the dependencies.\n"
|
+ "Check that you properly installed the dependencies.\n"
|
||||||
@@ -126,10 +127,6 @@ if web_mtb.exists() and hasattr(nodes, "EXTENSION_WEB_DIRS"):
|
|||||||
nodes, failed = load_nodes()
|
nodes, failed = load_nodes()
|
||||||
for node_class in nodes:
|
for node_class in nodes:
|
||||||
class_name = node_class.__name__
|
class_name = node_class.__name__
|
||||||
# fallback to __doc__
|
|
||||||
if not hasattr(node_class, "DESCRIPTION") and node_class.__doc__:
|
|
||||||
node_class.DESCRIPTION = node_class.__doc__
|
|
||||||
|
|
||||||
node_label = f"{get_label(class_name)} (mtb)"
|
node_label = f"{get_label(class_name)} (mtb)"
|
||||||
NODE_CLASS_MAPPINGS[node_label] = node_class
|
NODE_CLASS_MAPPINGS[node_label] = node_class
|
||||||
NODE_DISPLAY_NAME_MAPPINGS[class_name] = node_label
|
NODE_DISPLAY_NAME_MAPPINGS[class_name] = node_label
|
||||||
@@ -150,7 +147,7 @@ for node_class in nodes:
|
|||||||
)
|
)
|
||||||
|
|
||||||
log.debug(
|
log.debug(
|
||||||
"Loaded the following nodes:\n\t"
|
f"Loaded the following nodes:\n\t"
|
||||||
+ "\n\t".join(
|
+ "\n\t".join(
|
||||||
f"{cyan_text(k)}: {blue_text(get_summary(doc)) if doc else '-'}"
|
f"{cyan_text(k)}: {blue_text(get_summary(doc)) if doc else '-'}"
|
||||||
for k, doc in NODE_CLASS_MAPPINGS_DEBUG.items()
|
for k, doc in NODE_CLASS_MAPPINGS_DEBUG.items()
|
||||||
@@ -185,12 +182,6 @@ if hasattr(PromptServer, "instance"):
|
|||||||
"/mtb-assets/", path=(here / "html").as_posix()
|
"/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")
|
@PromptServer.instance.routes.get("/mtb/manage")
|
||||||
async def manage(request):
|
async def manage(request):
|
||||||
from . import endpoint
|
from . import endpoint
|
||||||
@@ -331,6 +322,14 @@ if hasattr(PromptServer, "instance"):
|
|||||||
|
|
||||||
return await endpoint.do_action(request)
|
return await endpoint.do_action(request)
|
||||||
|
|
||||||
|
@PromptServer.instance.routes.get("/mtb/audio")
|
||||||
|
async def get_audio(request):
|
||||||
|
from . import endpoint
|
||||||
|
|
||||||
|
reload(endpoint)
|
||||||
|
|
||||||
|
return await endpoint.get_audio(request)
|
||||||
|
|
||||||
|
|
||||||
# - WAS Dictionary
|
# - WAS Dictionary
|
||||||
MANIFEST = {
|
MANIFEST = {
|
||||||
|
|||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://biomejs.dev/schemas/1.6.1/schema.json",
|
|
||||||
"organizeImports": {
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
"linter": {
|
|
||||||
"enabled": true,
|
|
||||||
"rules": {
|
|
||||||
"recommended": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"javascript": {
|
|
||||||
"formatter": {
|
|
||||||
"quoteStyle": "single",
|
|
||||||
"semicolons": "asNeeded",
|
|
||||||
"indentWidth": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-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"
|
|
||||||
+55
-4
@@ -3,7 +3,16 @@ import csv
|
|||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
|
||||||
from .log import mklog
|
from .log import mklog
|
||||||
from .utils import backup_file, here, import_install, reqs_map, run_command, styles_dir
|
from .utils import (
|
||||||
|
audioInputDir,
|
||||||
|
backup_file,
|
||||||
|
comfy_dir,
|
||||||
|
here,
|
||||||
|
import_install,
|
||||||
|
reqs_map,
|
||||||
|
run_command,
|
||||||
|
styles_dir,
|
||||||
|
)
|
||||||
|
|
||||||
endlog = mklog("mtb endpoint")
|
endlog = mklog("mtb endpoint")
|
||||||
|
|
||||||
@@ -15,6 +24,29 @@ from pathlib import Path
|
|||||||
import_install("requirements")
|
import_install("requirements")
|
||||||
|
|
||||||
|
|
||||||
|
def ACTIONS_loadAudio(args):
|
||||||
|
if not audioInputDir.exists():
|
||||||
|
audioInputDir.mkdir()
|
||||||
|
|
||||||
|
endlog.debug(f"Received Load Audio request for {args}")
|
||||||
|
|
||||||
|
if not args.file:
|
||||||
|
return web.Response(status=400)
|
||||||
|
|
||||||
|
filename = args.filename
|
||||||
|
if not filename:
|
||||||
|
return web.Response(status=400)
|
||||||
|
|
||||||
|
target = audioInputDir / filename
|
||||||
|
if target.exists():
|
||||||
|
target.unlink()
|
||||||
|
|
||||||
|
with target.open("wb") as f:
|
||||||
|
f.write(args.file.read())
|
||||||
|
|
||||||
|
return {"name": filename}
|
||||||
|
|
||||||
|
|
||||||
def ACTIONS_installDependency(dependency_names=None):
|
def ACTIONS_installDependency(dependency_names=None):
|
||||||
if dependency_names is None:
|
if dependency_names is None:
|
||||||
return {"error": "No dependency name provided"}
|
return {"error": "No dependency name provided"}
|
||||||
@@ -88,7 +120,7 @@ def ACTIONS_saveStyle(data):
|
|||||||
|
|
||||||
async def do_action(request) -> web.Response:
|
async def do_action(request) -> web.Response:
|
||||||
endlog.debug("Init action request")
|
endlog.debug("Init action request")
|
||||||
request_data = await request.json()
|
request_data = await request.post()
|
||||||
name = request_data.get("name")
|
name = request_data.get("name")
|
||||||
args = request_data.get("args")
|
args = request_data.get("args")
|
||||||
|
|
||||||
@@ -100,14 +132,33 @@ async def do_action(request) -> web.Response:
|
|||||||
if callable(method):
|
if callable(method):
|
||||||
result = method(args) if args else method()
|
result = method(args) if args else method()
|
||||||
endlog.debug(f"Action result: {result}")
|
endlog.debug(f"Action result: {result}")
|
||||||
return web.json_response({"result": result})
|
return web.json_response({"result": result}, status=200)
|
||||||
|
|
||||||
available_methods = [
|
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(
|
return web.json_response(
|
||||||
{"error": "Invalid method name.", "available_methods": available_methods}
|
{"error": "Invalid method name.", "available_methods": available_methods},
|
||||||
|
status=400,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def get_audio(request):
|
||||||
|
name = request.rel_url.query.get("filename")
|
||||||
|
if not name:
|
||||||
|
return web.json_response(
|
||||||
|
{"error": "No filename provided as url query."}, status=400
|
||||||
|
)
|
||||||
|
|
||||||
|
target = audioInputDir / name
|
||||||
|
if not target.exists():
|
||||||
|
return web.json_response(
|
||||||
|
{"error": f"File {name} (in {audioInputDir}) not found..."}, status=404
|
||||||
|
)
|
||||||
|
|
||||||
|
return web.FileResponse(
|
||||||
|
target, headers={"Content-Disposition": f'filename="{name}"'}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
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}
|
|
||||||
@@ -42,7 +42,6 @@
|
|||||||
"Mask To Image (mtb)": "Converts a mask (alpha) to an RGB image with a color and background",
|
"Mask To Image (mtb)": "Converts a mask (alpha) to an RGB image with a color and background",
|
||||||
"Math Expression (mtb)": "Node to evaluate a simple math expression string",
|
"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)",
|
"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",
|
"Qr Code (mtb)": "Basic QR Code generator",
|
||||||
"Restore Face (mtb)": "Uses GFPGan to restore faces",
|
"Restore Face (mtb)": "Uses GFPGan to restore faces",
|
||||||
"Save Gif (mtb)": "Save the images from the batch as a GIF",
|
"Save Gif (mtb)": "Save the images from the batch as a GIF",
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
"""MTB Nodes module."""
|
|
||||||
|
|||||||
+3
-33
@@ -1,8 +1,8 @@
|
|||||||
from ..log import log
|
from ..log import log
|
||||||
|
|
||||||
|
|
||||||
class MTB_AnimationBuilder:
|
class AnimationBuilder:
|
||||||
"""Simple maths for animation."""
|
"""Convenient way to manage basic animation maths at the core of many of my workflows"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
@@ -21,36 +21,6 @@ class MTB_AnimationBuilder:
|
|||||||
RETURN_NAMES = ("frame", "0-1 (scaled)", "count", "loop_ended")
|
RETURN_NAMES = ("frame", "0-1 (scaled)", "count", "loop_ended")
|
||||||
CATEGORY = "mtb/animation"
|
CATEGORY = "mtb/animation"
|
||||||
FUNCTION = "build_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(
|
def build_animation(
|
||||||
self,
|
self,
|
||||||
@@ -71,4 +41,4 @@ to create a zoom-in animation on a static image
|
|||||||
return (frame, scaled, raw_loop, (frame == (total_frames - 1)))
|
return (frame, scaled, raw_loop, (frame == (total_frames - 1)))
|
||||||
|
|
||||||
|
|
||||||
__nodes__ = [MTB_AnimationBuilder]
|
__nodes__ = [AnimationBuilder]
|
||||||
|
|||||||
+108
-236
@@ -1,6 +1,7 @@
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
|
import torchaudio
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
@@ -9,6 +10,11 @@ from ..log import log
|
|||||||
from ..utils import apply_easing, pil2tensor
|
from ..utils import apply_easing, pil2tensor
|
||||||
from .transform import TransformImage
|
from .transform import TransformImage
|
||||||
|
|
||||||
|
try:
|
||||||
|
import librosa
|
||||||
|
except ImportError:
|
||||||
|
log.warning("librosa not installed. Batch Audio features will not be available.")
|
||||||
|
|
||||||
|
|
||||||
def hex_to_rgb(hex_color, bgr=False):
|
def hex_to_rgb(hex_color, bgr=False):
|
||||||
hex_color = hex_color.lstrip("#")
|
hex_color = hex_color.lstrip("#")
|
||||||
@@ -18,7 +24,7 @@ def hex_to_rgb(hex_color, bgr=False):
|
|||||||
return tuple(int(hex_color[i : i + 2], 16) for i in (0, 2, 4))
|
return tuple(int(hex_color[i : i + 2], 16) for i in (0, 2, 4))
|
||||||
|
|
||||||
|
|
||||||
class MTB_BatchMake:
|
class BatchMake:
|
||||||
"""Simply duplicates the input frame as a batch"""
|
"""Simply duplicates the input frame as a batch"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -41,7 +47,7 @@ class MTB_BatchMake:
|
|||||||
return (image.repeat(count, 1, 1, 1),)
|
return (image.repeat(count, 1, 1, 1),)
|
||||||
|
|
||||||
|
|
||||||
class MTB_BatchShape:
|
class BatchShape:
|
||||||
"""Generates a batch of 2D shapes with optional shading (experimental)"""
|
"""Generates a batch of 2D shapes with optional shading (experimental)"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -50,8 +56,8 @@ class MTB_BatchShape:
|
|||||||
"required": {
|
"required": {
|
||||||
"count": ("INT", {"default": 1}),
|
"count": ("INT", {"default": 1}),
|
||||||
"shape": (
|
"shape": (
|
||||||
["Box", "Circle", "Diamond", "Tube"],
|
["Box", "Circle", "Diamond"],
|
||||||
{"default": "Circle"},
|
{"default": "Box"},
|
||||||
),
|
),
|
||||||
"image_width": ("INT", {"default": 512}),
|
"image_width": ("INT", {"default": 512}),
|
||||||
"image_height": ("INT", {"default": 512}),
|
"image_height": ("INT", {"default": 512}),
|
||||||
@@ -59,7 +65,6 @@ class MTB_BatchShape:
|
|||||||
"color": ("COLOR", {"default": "#ffffff"}),
|
"color": ("COLOR", {"default": "#ffffff"}),
|
||||||
"bg_color": ("COLOR", {"default": "#000000"}),
|
"bg_color": ("COLOR", {"default": "#000000"}),
|
||||||
"shade_color": ("COLOR", {"default": "#000000"}),
|
"shade_color": ("COLOR", {"default": "#000000"}),
|
||||||
"thickness": ("INT", {"default": 5}),
|
|
||||||
"shadex": ("FLOAT", {"default": 0.0}),
|
"shadex": ("FLOAT", {"default": 0.0}),
|
||||||
"shadey": ("FLOAT", {"default": 0.0}),
|
"shadey": ("FLOAT", {"default": 0.0}),
|
||||||
},
|
},
|
||||||
@@ -79,13 +84,12 @@ class MTB_BatchShape:
|
|||||||
color,
|
color,
|
||||||
bg_color,
|
bg_color,
|
||||||
shade_color,
|
shade_color,
|
||||||
thickness,
|
|
||||||
shadex,
|
shadex,
|
||||||
shadey,
|
shadey,
|
||||||
):
|
):
|
||||||
log.debug(f"COLOR: {color}")
|
print(f"COLOR: {color}")
|
||||||
log.debug(f"BG_COLOR: {bg_color}")
|
print(f"BG_COLOR: {bg_color}")
|
||||||
log.debug(f"SHADE_COLOR: {shade_color}")
|
print(f"SHADE_COLOR: {shade_color}")
|
||||||
|
|
||||||
# Parse color input to BGR tuple for OpenCV
|
# Parse color input to BGR tuple for OpenCV
|
||||||
color = hex_to_rgb(color)
|
color = hex_to_rgb(color)
|
||||||
@@ -94,9 +98,7 @@ class MTB_BatchShape:
|
|||||||
res = []
|
res = []
|
||||||
for x in range(count):
|
for x in range(count):
|
||||||
# Initialize an image canvas
|
# Initialize an image canvas
|
||||||
canvas = np.full(
|
canvas = np.full((image_height, image_width, 3), bg_color, dtype=np.uint8)
|
||||||
(image_height, image_width, 3), bg_color, dtype=np.uint8
|
|
||||||
)
|
|
||||||
mask = np.zeros((image_height, image_width), dtype=np.uint8)
|
mask = np.zeros((image_height, image_width), dtype=np.uint8)
|
||||||
|
|
||||||
# Compute the center point of the shape
|
# Compute the center point of the shape
|
||||||
@@ -120,27 +122,13 @@ class MTB_BatchShape:
|
|||||||
)
|
)
|
||||||
cv2.fillPoly(mask, [pts], 255)
|
cv2.fillPoly(mask, [pts], 255)
|
||||||
|
|
||||||
elif shape == "Tube":
|
|
||||||
cv2.ellipse(
|
|
||||||
mask,
|
|
||||||
center,
|
|
||||||
(shape_size // 2, shape_size // 2),
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
360,
|
|
||||||
255,
|
|
||||||
thickness,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Color the shape
|
# Color the shape
|
||||||
canvas[mask == 255] = color
|
canvas[mask == 255] = color
|
||||||
|
|
||||||
# Apply shading effects to a separate shading canvas
|
# Apply shading effects to a separate shading canvas
|
||||||
shading = np.zeros_like(canvas, dtype=np.float32)
|
shading = np.zeros_like(canvas, dtype=np.float32)
|
||||||
shading[:, :, 0] = shadex * np.linspace(0, 1, image_width)
|
shading[:, :, 0] = shadex * np.linspace(0, 1, image_width)
|
||||||
shading[:, :, 1] = shadey * np.linspace(
|
shading[:, :, 1] = shadey * np.linspace(0, 1, image_height).reshape(-1, 1)
|
||||||
0, 1, image_height
|
|
||||||
).reshape(-1, 1)
|
|
||||||
shading_canvas = cv2.addWeighted(
|
shading_canvas = cv2.addWeighted(
|
||||||
canvas.astype(np.float32), 1, shading, 1, 0
|
canvas.astype(np.float32), 1, shading, 1, 0
|
||||||
).astype(np.uint8)
|
).astype(np.uint8)
|
||||||
@@ -152,7 +140,7 @@ class MTB_BatchShape:
|
|||||||
return (pil2tensor(res),)
|
return (pil2tensor(res),)
|
||||||
|
|
||||||
|
|
||||||
class MTB_BatchFloatFill:
|
class BatchFloatFill:
|
||||||
"""Fills a batch float with a single value until it reaches the target length"""
|
"""Fills a batch float with a single value until it reaches the target length"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -173,9 +161,7 @@ class MTB_BatchFloatFill:
|
|||||||
def fill_floats(self, floats, direction, value, count):
|
def fill_floats(self, floats, direction, value, count):
|
||||||
size = len(floats)
|
size = len(floats)
|
||||||
if size > count:
|
if size > count:
|
||||||
raise ValueError(
|
raise ValueError(f"Size ({size}) is less then target count ({count})")
|
||||||
f"Size ({size}) is less then target count ({count})"
|
|
||||||
)
|
|
||||||
|
|
||||||
rem = count - size
|
rem = count - size
|
||||||
if direction == "tail":
|
if direction == "tail":
|
||||||
@@ -185,7 +171,7 @@ class MTB_BatchFloatFill:
|
|||||||
return (floats,)
|
return (floats,)
|
||||||
|
|
||||||
|
|
||||||
class MTB_BatchFloatAssemble:
|
class BatchFloatAssemble:
|
||||||
"""Assembles mutiple batches of floats into a single stream (batch)"""
|
"""Assembles mutiple batches of floats into a single stream (batch)"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -208,7 +194,7 @@ class MTB_BatchFloatAssemble:
|
|||||||
return (res,)
|
return (res,)
|
||||||
|
|
||||||
|
|
||||||
class MTB_BatchFloat:
|
class BatchFloat:
|
||||||
"""Generates a batch of float values with interpolation"""
|
"""Generates a batch of float values with interpolation"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -220,8 +206,8 @@ class MTB_BatchFloat:
|
|||||||
{"default": "Steps"},
|
{"default": "Steps"},
|
||||||
),
|
),
|
||||||
"count": ("INT", {"default": 1}),
|
"count": ("INT", {"default": 1}),
|
||||||
"min": ("FLOAT", {"default": 0.0, "step": 0.001}),
|
"min": ("FLOAT", {"default": 0.0}),
|
||||||
"max": ("FLOAT", {"default": 1.0, "step": 0.001}),
|
"max": ("FLOAT", {"default": 1.0}),
|
||||||
"easing": (
|
"easing": (
|
||||||
[
|
[
|
||||||
"Linear",
|
"Linear",
|
||||||
@@ -271,17 +257,14 @@ class MTB_BatchFloat:
|
|||||||
return (keyframes,)
|
return (keyframes,)
|
||||||
|
|
||||||
|
|
||||||
class MTB_BatchMerge:
|
class BatchMerge:
|
||||||
"""Merges multiple image batches with different frame counts"""
|
"""Merges multiple image batches with different frame counts"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"fusion_mode": (
|
"fusion_mode": (["add", "multiply", "average"], {"default": "average"}),
|
||||||
["add", "multiply", "average"],
|
|
||||||
{"default": "average"},
|
|
||||||
),
|
|
||||||
"fill": (["head", "tail"], {"default": "tail"}),
|
"fill": (["head", "tail"], {"default": "tail"}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,7 +273,7 @@ class MTB_BatchMerge:
|
|||||||
FUNCTION = "merge_batches"
|
FUNCTION = "merge_batches"
|
||||||
CATEGORY = "mtb/batch"
|
CATEGORY = "mtb/batch"
|
||||||
|
|
||||||
def merge_batches(self, fusion_mode: str, fill: str, **kwargs):
|
def merge_batches(self, fusion_mode, fill, **kwargs):
|
||||||
images = kwargs.values()
|
images = kwargs.values()
|
||||||
max_frames = max(img.shape[0] for img in images)
|
max_frames = max(img.shape[0] for img in images)
|
||||||
|
|
||||||
@@ -299,9 +282,7 @@ class MTB_BatchMerge:
|
|||||||
frame_count = img.shape[0]
|
frame_count = img.shape[0]
|
||||||
if frame_count < max_frames:
|
if frame_count < max_frames:
|
||||||
fill_frame = img[0] if fill == "head" else img[-1]
|
fill_frame = img[0] if fill == "head" else img[-1]
|
||||||
fill_frames = fill_frame.repeat(
|
fill_frames = fill_frame.repeat(max_frames - frame_count, 1, 1, 1)
|
||||||
max_frames - frame_count, 1, 1, 1
|
|
||||||
)
|
|
||||||
adjusted_batch = (
|
adjusted_batch = (
|
||||||
torch.cat((fill_frames, img), dim=0)
|
torch.cat((fill_frames, img), dim=0)
|
||||||
if fill == "head"
|
if fill == "head"
|
||||||
@@ -327,7 +308,7 @@ class MTB_BatchMerge:
|
|||||||
return (merged_image,)
|
return (merged_image,)
|
||||||
|
|
||||||
|
|
||||||
class MTB_Batch2dTransform:
|
class Batch2dTransform:
|
||||||
"""Transform a batch of images using a batch of keyframes"""
|
"""Transform a batch of images using a batch of keyframes"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -354,12 +335,9 @@ class MTB_Batch2dTransform:
|
|||||||
FUNCTION = "transform_batch"
|
FUNCTION = "transform_batch"
|
||||||
CATEGORY = "mtb/batch"
|
CATEGORY = "mtb/batch"
|
||||||
|
|
||||||
def get_num_elements(
|
def get_num_elements(self, param) -> int:
|
||||||
self, param: None | torch.Tensor | list[torch.Tensor] | list[float]
|
|
||||||
) -> int:
|
|
||||||
if isinstance(param, torch.Tensor):
|
if isinstance(param, torch.Tensor):
|
||||||
return torch.numel(param)
|
return torch.numel(param)
|
||||||
|
|
||||||
elif isinstance(param, list):
|
elif isinstance(param, list):
|
||||||
return len(param)
|
return len(param)
|
||||||
|
|
||||||
@@ -368,42 +346,32 @@ class MTB_Batch2dTransform:
|
|||||||
def transform_batch(
|
def transform_batch(
|
||||||
self,
|
self,
|
||||||
image: torch.Tensor,
|
image: torch.Tensor,
|
||||||
border_handling: str,
|
border_handling,
|
||||||
constant_color: str,
|
constant_color,
|
||||||
x: list[float] | None = None,
|
x=None,
|
||||||
y: list[float] | None = None,
|
y=None,
|
||||||
zoom: list[float] | None = None,
|
zoom=None,
|
||||||
angle: list[float] | None = None,
|
angle=None,
|
||||||
shear: list[float] | None = None,
|
shear=None,
|
||||||
):
|
):
|
||||||
if all(
|
if all(
|
||||||
self.get_num_elements(param) <= 0
|
self.get_num_elements(param) <= 0 for param in [x, y, zoom, angle, shear]
|
||||||
for param in [x, y, zoom, angle, shear]
|
|
||||||
):
|
):
|
||||||
raise ValueError(
|
raise ValueError("At least one transform parameter must be provided")
|
||||||
"At least one transform parameter must be provided"
|
|
||||||
)
|
|
||||||
|
|
||||||
keyframes: dict[str, list[float]] = {
|
keyframes = {"x": [], "y": [], "zoom": [], "angle": [], "shear": []}
|
||||||
"x": [],
|
|
||||||
"y": [],
|
|
||||||
"zoom": [],
|
|
||||||
"angle": [],
|
|
||||||
"shear": [],
|
|
||||||
}
|
|
||||||
|
|
||||||
default_vals = {"x": 0, "y": 0, "zoom": 1.0, "angle": 0, "shear": 0}
|
default_vals = {"x": 0, "y": 0, "zoom": 1.0, "angle": 0, "shear": 0}
|
||||||
|
|
||||||
if x and self.get_num_elements(x) > 0:
|
if self.get_num_elements(x) > 0:
|
||||||
keyframes["x"] = x
|
keyframes["x"] = x
|
||||||
if y and self.get_num_elements(y) > 0:
|
if self.get_num_elements(y) > 0:
|
||||||
keyframes["y"] = y
|
keyframes["y"] = y
|
||||||
if zoom and self.get_num_elements(zoom) > 0:
|
if self.get_num_elements(zoom) > 0:
|
||||||
# some easing types like elastic can pull back... maybe it should abs the value?
|
keyframes["zoom"] = zoom
|
||||||
keyframes["zoom"] = [max(x, 0.00001) for x in zoom]
|
if self.get_num_elements(angle) > 0:
|
||||||
if angle and self.get_num_elements(angle) > 0:
|
|
||||||
keyframes["angle"] = angle
|
keyframes["angle"] = angle
|
||||||
if shear and self.get_num_elements(shear) > 0:
|
if self.get_num_elements(shear) > 0:
|
||||||
keyframes["shear"] = shear
|
keyframes["shear"] = shear
|
||||||
|
|
||||||
for name, values in keyframes.items():
|
for name, values in keyframes.items():
|
||||||
@@ -432,142 +400,10 @@ class MTB_Batch2dTransform:
|
|||||||
return (torch.cat(res, dim=0),)
|
return (torch.cat(res, dim=0),)
|
||||||
|
|
||||||
|
|
||||||
class MTB_PlotBatchFloat:
|
|
||||||
"""Plot floats"""
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def INPUT_TYPES(cls):
|
|
||||||
return {
|
|
||||||
"required": {
|
|
||||||
"width": ("INT", {"default": 768}),
|
|
||||||
"height": ("INT", {"default": 768}),
|
|
||||||
"point_size": ("INT", {"default": 4}),
|
|
||||||
"seed": ("INT", {"default": 1}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RETURN_TYPES = ("IMAGE",)
|
|
||||||
RETURN_NAMES = ("plot",)
|
|
||||||
FUNCTION = "plot"
|
|
||||||
CATEGORY = "mtb/batch"
|
|
||||||
|
|
||||||
def plot(self, width, height, point_size, seed, **kwargs):
|
|
||||||
import matplotlib
|
|
||||||
|
|
||||||
matplotlib.use("Agg")
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
|
|
||||||
fig, ax = plt.subplots(figsize=(width / 100, height / 100), dpi=100)
|
|
||||||
fig.set_edgecolor("black")
|
|
||||||
fig.patch.set_facecolor("#2e2e2e")
|
|
||||||
# Setting background color and grid
|
|
||||||
ax.set_facecolor("#2e2e2e") # Dark gray background
|
|
||||||
ax.grid(color="gray", linestyle="-", linewidth=0.5, alpha=0.5)
|
|
||||||
|
|
||||||
# Finding global min and max across all lists for scaling the plot
|
|
||||||
global_min = min(min(values) for values in kwargs.values())
|
|
||||||
global_max = max(max(values) for values in kwargs.values())
|
|
||||||
|
|
||||||
# Color cycle to ensure each plot has a distinct color
|
|
||||||
colormap = plt.cm.get_cmap("viridis", len(kwargs))
|
|
||||||
color_normalization_factor = (
|
|
||||||
0.5 if len(kwargs) == 1 else (len(kwargs) - 1)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Plotting each list with a unique color
|
|
||||||
for i, (label, values) in enumerate(kwargs.items()):
|
|
||||||
color_value = i / color_normalization_factor
|
|
||||||
ax.plot(values, label=label, color=colormap(color_value))
|
|
||||||
|
|
||||||
ax.set_ylim(global_min, global_max) # Scaling the y-axis
|
|
||||||
ax.legend(
|
|
||||||
title="Legend",
|
|
||||||
title_fontsize="large",
|
|
||||||
fontsize="medium",
|
|
||||||
edgecolor="black",
|
|
||||||
)
|
|
||||||
|
|
||||||
# Setting labels and title
|
|
||||||
ax.set_xlabel("Time", fontsize="large", color="white")
|
|
||||||
ax.set_ylabel("Value", fontsize="large", color="white")
|
|
||||||
ax.set_title(
|
|
||||||
"Plot of Values over Time", fontsize="x-large", color="white"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Adjusting tick colors to be visible on dark background
|
|
||||||
ax.tick_params(colors="white")
|
|
||||||
|
|
||||||
# Changing color of the axes border
|
|
||||||
for _, spine in ax.spines.items():
|
|
||||||
spine.set_edgecolor("white")
|
|
||||||
|
|
||||||
# Rendering the plot into a NumPy array
|
|
||||||
buf = BytesIO()
|
|
||||||
plt.savefig(buf, format="png", bbox_inches="tight")
|
|
||||||
buf.seek(0)
|
|
||||||
image = Image.open(buf)
|
|
||||||
plt.close(fig) # Closing the figure to free up memory
|
|
||||||
|
|
||||||
return (pil2tensor(image),)
|
|
||||||
|
|
||||||
def draw_point(self, image, point, color, point_size):
|
|
||||||
x, y = point
|
|
||||||
y = image.shape[0] - 1 - y # Invert Y-coordinate
|
|
||||||
half_size = point_size // 2
|
|
||||||
x_start, x_end = (
|
|
||||||
max(0, x - half_size),
|
|
||||||
min(image.shape[1], x + half_size + 1),
|
|
||||||
)
|
|
||||||
y_start, y_end = (
|
|
||||||
max(0, y - half_size),
|
|
||||||
min(image.shape[0], y + half_size + 1),
|
|
||||||
)
|
|
||||||
image[y_start:y_end, x_start:x_end] = color
|
|
||||||
|
|
||||||
def draw_line(self, image, start, end, color):
|
|
||||||
x1, y1 = start
|
|
||||||
x2, y2 = end
|
|
||||||
|
|
||||||
# Invert Y-coordinate
|
|
||||||
y1 = image.shape[0] - 1 - y1
|
|
||||||
y2 = image.shape[0] - 1 - y2
|
|
||||||
|
|
||||||
dx = x2 - x1
|
|
||||||
dy = y2 - y1
|
|
||||||
is_steep = abs(dy) > abs(dx)
|
|
||||||
if is_steep:
|
|
||||||
x1, y1 = y1, x1
|
|
||||||
x2, y2 = y2, x2
|
|
||||||
swapped = False
|
|
||||||
if x1 > x2:
|
|
||||||
x1, x2 = x2, x1
|
|
||||||
y1, y2 = y2, y1
|
|
||||||
swapped = True
|
|
||||||
dx = x2 - x1
|
|
||||||
dy = y2 - y1
|
|
||||||
error = int(dx / 2.0)
|
|
||||||
y = y1
|
|
||||||
ystep = None
|
|
||||||
if y1 < y2:
|
|
||||||
ystep = 1
|
|
||||||
else:
|
|
||||||
ystep = -1
|
|
||||||
for x in range(x1, x2 + 1):
|
|
||||||
coord = (y, x) if is_steep else (x, y)
|
|
||||||
image[coord] = color
|
|
||||||
error -= abs(dy)
|
|
||||||
if error < 0:
|
|
||||||
y += ystep
|
|
||||||
error += dx
|
|
||||||
if swapped:
|
|
||||||
image[(x1, y1)] = color
|
|
||||||
image[(x2, y2)] = color
|
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_INTERPOLANT = lambda t: t * t * t * (t * (t * 6 - 15) + 10)
|
DEFAULT_INTERPOLANT = lambda t: t * t * t * (t * (t * 6 - 15) + 10)
|
||||||
|
|
||||||
|
|
||||||
class MTB_BatchShake:
|
class BatchShake:
|
||||||
"""Applies a shaking effect to batches of images."""
|
"""Applies a shaking effect to batches of images."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -609,21 +445,17 @@ class MTB_BatchShake:
|
|||||||
interpolant: The interpolation function, defaults to
|
interpolant: The interpolation function, defaults to
|
||||||
t*t*t*(t*(t*6 - 15) + 10).
|
t*t*t*(t*(t*6 - 15) + 10).
|
||||||
|
|
||||||
Returns
|
Returns:
|
||||||
-------
|
|
||||||
A numpy array of shape shape with the generated noise.
|
A numpy array of shape shape with the generated noise.
|
||||||
|
|
||||||
Raises
|
Raises:
|
||||||
------
|
|
||||||
ValueError: If shape is not a multiple of res.
|
ValueError: If shape is not a multiple of res.
|
||||||
"""
|
"""
|
||||||
interpolant = interpolant or DEFAULT_INTERPOLANT
|
interpolant = interpolant or DEFAULT_INTERPOLANT
|
||||||
delta = (res[0] / shape[0], res[1] / shape[1])
|
delta = (res[0] / shape[0], res[1] / shape[1])
|
||||||
d = (shape[0] // res[0], shape[1] // res[1])
|
d = (shape[0] // res[0], shape[1] // res[1])
|
||||||
grid = (
|
grid = (
|
||||||
np.mgrid[0 : res[0] : delta[0], 0 : res[1] : delta[1]].transpose(
|
np.mgrid[0 : res[0] : delta[0], 0 : res[1] : delta[1]].transpose(1, 2, 0)
|
||||||
1, 2, 0
|
|
||||||
)
|
|
||||||
% 1
|
% 1
|
||||||
)
|
)
|
||||||
# Gradients
|
# Gradients
|
||||||
@@ -642,9 +474,7 @@ class MTB_BatchShake:
|
|||||||
n00 = np.sum(np.dstack((grid[:, :, 0], grid[:, :, 1])) * g00, 2)
|
n00 = np.sum(np.dstack((grid[:, :, 0], grid[:, :, 1])) * g00, 2)
|
||||||
n10 = np.sum(np.dstack((grid[:, :, 0] - 1, grid[:, :, 1])) * g10, 2)
|
n10 = np.sum(np.dstack((grid[:, :, 0] - 1, grid[:, :, 1])) * g10, 2)
|
||||||
n01 = np.sum(np.dstack((grid[:, :, 0], grid[:, :, 1] - 1)) * g01, 2)
|
n01 = np.sum(np.dstack((grid[:, :, 0], grid[:, :, 1] - 1)) * g01, 2)
|
||||||
n11 = np.sum(
|
n11 = np.sum(np.dstack((grid[:, :, 0] - 1, grid[:, :, 1] - 1)) * g11, 2)
|
||||||
np.dstack((grid[:, :, 0] - 1, grid[:, :, 1] - 1)) * g11, 2
|
|
||||||
)
|
|
||||||
# Interpolation
|
# Interpolation
|
||||||
t = interpolant(grid)
|
t = interpolant(grid)
|
||||||
n0 = n00 * (1 - t[:, :, 0]) + t[:, :, 0] * n10
|
n0 = n00 * (1 - t[:, :, 0]) + t[:, :, 0] * n10
|
||||||
@@ -677,13 +507,11 @@ class MTB_BatchShake:
|
|||||||
interpolant: The, interpolation function, defaults to
|
interpolant: The, interpolation function, defaults to
|
||||||
t*t*t*(t*(t*6 - 15) + 10).
|
t*t*t*(t*(t*6 - 15) + 10).
|
||||||
|
|
||||||
Returns
|
Returns:
|
||||||
-------
|
|
||||||
A numpy array of fractal noise and of shape shape generated by
|
A numpy array of fractal noise and of shape shape generated by
|
||||||
combining several octaves of perlin noise.
|
combining several octaves of perlin noise.
|
||||||
|
|
||||||
Raises
|
Raises:
|
||||||
------
|
|
||||||
ValueError: If shape is not a multiple of
|
ValueError: If shape is not a multiple of
|
||||||
(lacunarity**(octaves-1)*res).
|
(lacunarity**(octaves-1)*res).
|
||||||
"""
|
"""
|
||||||
@@ -694,10 +522,7 @@ class MTB_BatchShake:
|
|||||||
amplitude = 1
|
amplitude = 1
|
||||||
for _ in range(octaves):
|
for _ in range(octaves):
|
||||||
noise += amplitude * self.generate_perlin_noise_2d(
|
noise += amplitude * self.generate_perlin_noise_2d(
|
||||||
shape,
|
shape, (frequency * res[0], frequency * res[1]), tileable, interpolant
|
||||||
(frequency * res[0], frequency * res[1]),
|
|
||||||
tileable,
|
|
||||||
interpolant,
|
|
||||||
)
|
)
|
||||||
frequency *= lacunarity
|
frequency *= lacunarity
|
||||||
amplitude *= persistence
|
amplitude *= persistence
|
||||||
@@ -772,7 +597,7 @@ class MTB_BatchShake:
|
|||||||
# rotations = torch.tensor(rotations, dtype=torch.float32)
|
# rotations = torch.tensor(rotations, dtype=torch.float32)
|
||||||
|
|
||||||
# Create an instance of Batch2dTransform
|
# Create an instance of Batch2dTransform
|
||||||
transform = MTB_Batch2dTransform()
|
transform = Batch2dTransform()
|
||||||
|
|
||||||
log.debug(
|
log.debug(
|
||||||
f"Applying shaking with parameters: \nposition {position_amount_x}, {position_amount_y}\nrotation {rotation_amount}\nfrequency {frequency}\noctaves {octaves}"
|
f"Applying shaking with parameters: \nposition {position_amount_x}, {position_amount_y}\nrotation {rotation_amount}\nfrequency {frequency}\noctaves {octaves}"
|
||||||
@@ -791,14 +616,61 @@ class MTB_BatchShake:
|
|||||||
return (shaken_images, x_translations, y_translations, rotations)
|
return (shaken_images, x_translations, y_translations, rotations)
|
||||||
|
|
||||||
|
|
||||||
|
class BatchFloatsFromSound:
|
||||||
|
"""Extracts a list of floats based on audio frequency band peaks."""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(cls):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"audio": ("AUDIO",),
|
||||||
|
"sensitivity": ("FLOAT", {"default": 1.0}),
|
||||||
|
"low_freq": ("FLOAT", {"default": 100.0}),
|
||||||
|
"high_freq": ("FLOAT", {"default": 2000.0}),
|
||||||
|
"hop_length": ("INT", {"default": 512}),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_TYPES = ("FLOATS",)
|
||||||
|
RETURN_NAMES = ("float_data",)
|
||||||
|
FUNCTION = "process_audio"
|
||||||
|
CATEGORY = "mtb/audio"
|
||||||
|
|
||||||
|
def process_audio(
|
||||||
|
self,
|
||||||
|
audio,
|
||||||
|
sensitivity=1.0,
|
||||||
|
low_freq=100,
|
||||||
|
high_freq=2000,
|
||||||
|
hop_length=512,
|
||||||
|
):
|
||||||
|
# audio_data, _ = librosa.load(audio_file_path, sr=sample_rate)
|
||||||
|
|
||||||
|
# audio_data_tensor = audio.squeeze(1) # Remove the channel dimension if present
|
||||||
|
# audio_tensor = audio_data_tensor.float()
|
||||||
|
audio_data = audio.to(device=torchaudio.transforms.Spectrogram().window.device)
|
||||||
|
|
||||||
|
hop_length = 512
|
||||||
|
stft = torchaudio.transforms.Spectrogram()(audio_data)
|
||||||
|
freqs = torchaudio.transforms.FrequencyMasking(low_freq, high_freq)(stft)
|
||||||
|
band_energy = torch.sum(freqs, dim=1)
|
||||||
|
|
||||||
|
min_val = torch.min(band_energy)
|
||||||
|
max_val = torch.max(band_energy)
|
||||||
|
normalized_peaks = (band_energy - min_val) / (max_val - min_val)
|
||||||
|
scaled_peaks = normalized_peaks * sensitivity
|
||||||
|
|
||||||
|
return (scaled_peaks.tolist(),)
|
||||||
|
|
||||||
|
|
||||||
__nodes__ = [
|
__nodes__ = [
|
||||||
MTB_BatchFloat,
|
BatchFloat,
|
||||||
MTB_Batch2dTransform,
|
Batch2dTransform,
|
||||||
MTB_BatchShape,
|
BatchFloatsFromSound,
|
||||||
MTB_BatchMake,
|
BatchShape,
|
||||||
MTB_BatchFloatAssemble,
|
BatchMake,
|
||||||
MTB_BatchFloatFill,
|
BatchFloatAssemble,
|
||||||
MTB_BatchMerge,
|
BatchFloatFill,
|
||||||
MTB_BatchShake,
|
BatchMerge,
|
||||||
MTB_PlotBatchFloat,
|
BatchShake,
|
||||||
]
|
]
|
||||||
|
|||||||
+6
-13
@@ -1,4 +1,5 @@
|
|||||||
import csv, shutil
|
import csv
|
||||||
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import folder_paths
|
import folder_paths
|
||||||
@@ -156,21 +157,13 @@ class StylesLoader:
|
|||||||
for file in files:
|
for file in files:
|
||||||
with open(file, "r", encoding="utf8") as f:
|
with open(file, "r", encoding="utf8") as f:
|
||||||
parsed = csv.reader(f)
|
parsed = csv.reader(f)
|
||||||
for i, row in enumerate(parsed):
|
for row in parsed:
|
||||||
log.debug(f"Adding style {row[0]}")
|
log.debug(f"Adding style {row[0]}")
|
||||||
try:
|
try:
|
||||||
name, positive, negative = (row + [None] * 3)[:3]
|
cls.options[row[0]] = (row[1], row[2])
|
||||||
positive = positive or ""
|
except Exception:
|
||||||
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(
|
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}"
|
f"There was an error while parsing {file}, make sure it respects A1111 format, i.e 3 columns name, positive, negative"
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -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]
|
|
||||||
+21
-60
@@ -1,6 +1,6 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
from PIL import Image, ImageDraw, ImageFilter
|
from PIL import Image, ImageChops, ImageDraw, ImageFilter
|
||||||
|
|
||||||
from ..log import log
|
from ..log import log
|
||||||
from ..utils import np2tensor, pil2tensor, tensor2np, tensor2pil
|
from ..utils import np2tensor, pil2tensor, tensor2np, tensor2pil
|
||||||
@@ -14,14 +14,8 @@ class Bbox:
|
|||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
# "bbox": ("BBOX",),
|
# "bbox": ("BBOX",),
|
||||||
"x": (
|
"x": ("INT", {"default": 0, "max": 10000000, "min": 0, "step": 1}),
|
||||||
"INT",
|
"y": ("INT", {"default": 0, "max": 10000000, "min": 0, "step": 1}),
|
||||||
{"default": 0, "max": 10000000, "min": 0, "step": 1},
|
|
||||||
),
|
|
||||||
"y": (
|
|
||||||
"INT",
|
|
||||||
{"default": 0, "max": 10000000, "min": 0, "step": 1},
|
|
||||||
),
|
|
||||||
"width": (
|
"width": (
|
||||||
"INT",
|
"INT",
|
||||||
{"default": 256, "max": 10000000, "min": 0, "step": 1},
|
{"default": 256, "max": 10000000, "min": 0, "step": 1},
|
||||||
@@ -37,8 +31,9 @@ class Bbox:
|
|||||||
FUNCTION = "do_crop"
|
FUNCTION = "do_crop"
|
||||||
CATEGORY = "mtb/crop"
|
CATEGORY = "mtb/crop"
|
||||||
|
|
||||||
def do_crop(self, x: int, y: int, width: int, height: int): # bbox
|
def do_crop(self, x, y, width, height): # bbox
|
||||||
return ((x, y, width, height),)
|
return ((x, y, width, height),)
|
||||||
|
# return bbox
|
||||||
|
|
||||||
|
|
||||||
class BboxFromMask:
|
class BboxFromMask:
|
||||||
@@ -49,7 +44,6 @@ class BboxFromMask:
|
|||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"mask": ("MASK",),
|
"mask": ("MASK",),
|
||||||
"invert": ("BOOLEAN", {"default": False}),
|
|
||||||
},
|
},
|
||||||
"optional": {
|
"optional": {
|
||||||
"image": ("IMAGE",),
|
"image": ("IMAGE",),
|
||||||
@@ -67,9 +61,7 @@ class BboxFromMask:
|
|||||||
FUNCTION = "extract_bounding_box"
|
FUNCTION = "extract_bounding_box"
|
||||||
CATEGORY = "mtb/crop"
|
CATEGORY = "mtb/crop"
|
||||||
|
|
||||||
def extract_bounding_box(
|
def extract_bounding_box(self, mask: torch.Tensor, image=None):
|
||||||
self, mask: torch.Tensor, invert: bool, image=None
|
|
||||||
):
|
|
||||||
# if image != None:
|
# if image != None:
|
||||||
# if mask.size(0) != image.size(0):
|
# if mask.size(0) != image.size(0):
|
||||||
# if mask.size(0) != 1:
|
# if mask.size(0) != 1:
|
||||||
@@ -81,8 +73,9 @@ class 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})"
|
# 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
|
# we invert it
|
||||||
_mask = tensor2pil(1.0 - mask)[0] if invert else tensor2pil(mask)[0]
|
|
||||||
alpha_channel = np.array(_mask)
|
alpha_channel = np.array(_mask)
|
||||||
|
|
||||||
non_zero_indices = np.nonzero(alpha_channel)
|
non_zero_indices = np.nonzero(alpha_channel)
|
||||||
@@ -125,14 +118,8 @@ class Crop:
|
|||||||
},
|
},
|
||||||
"optional": {
|
"optional": {
|
||||||
"mask": ("MASK",),
|
"mask": ("MASK",),
|
||||||
"x": (
|
"x": ("INT", {"default": 0, "max": 10000000, "min": 0, "step": 1}),
|
||||||
"INT",
|
"y": ("INT", {"default": 0, "max": 10000000, "min": 0, "step": 1}),
|
||||||
{"default": 0, "max": 10000000, "min": 0, "step": 1},
|
|
||||||
),
|
|
||||||
"y": (
|
|
||||||
"INT",
|
|
||||||
{"default": 0, "max": 10000000, "min": 0, "step": 1},
|
|
||||||
),
|
|
||||||
"width": (
|
"width": (
|
||||||
"INT",
|
"INT",
|
||||||
{"default": 256, "max": 10000000, "min": 0, "step": 1},
|
{"default": 256, "max": 10000000, "min": 0, "step": 1},
|
||||||
@@ -151,37 +138,22 @@ class Crop:
|
|||||||
CATEGORY = "mtb/crop"
|
CATEGORY = "mtb/crop"
|
||||||
|
|
||||||
def do_crop(
|
def do_crop(
|
||||||
self,
|
self, image: torch.Tensor, mask=None, x=0, y=0, width=256, height=256, bbox=None
|
||||||
image: torch.Tensor,
|
|
||||||
mask=None,
|
|
||||||
x=0,
|
|
||||||
y=0,
|
|
||||||
width=256,
|
|
||||||
height=256,
|
|
||||||
bbox=None,
|
|
||||||
):
|
):
|
||||||
image = image.numpy()
|
image = image.numpy()
|
||||||
if mask is not None:
|
if mask:
|
||||||
mask = mask.numpy()
|
mask = mask.numpy()
|
||||||
|
|
||||||
if bbox is not None:
|
if bbox != None:
|
||||||
x, y, width, height = bbox
|
x, y, width, height = bbox
|
||||||
|
|
||||||
cropped_image = image[:, y : y + height, x : x + width, :]
|
cropped_image = image[:, y : y + height, x : x + width, :]
|
||||||
cropped_mask = None
|
cropped_mask = mask[y : y + height, x : x + width] if mask != None else None
|
||||||
if mask is not None:
|
|
||||||
cropped_mask = (
|
|
||||||
mask[:, y : y + height, x : x + width]
|
|
||||||
if mask is not None
|
|
||||||
else None
|
|
||||||
)
|
|
||||||
crop_data = (x, y, width, height)
|
crop_data = (x, y, width, height)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
torch.from_numpy(cropped_image),
|
torch.from_numpy(cropped_image),
|
||||||
torch.from_numpy(cropped_mask)
|
torch.from_numpy(cropped_mask) if mask != None else None,
|
||||||
if cropped_mask is not None
|
|
||||||
else None,
|
|
||||||
crop_data,
|
crop_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -222,8 +194,7 @@ class Uncrop:
|
|||||||
"""Uncrops an image to a given bounding box
|
"""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 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
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
@@ -247,15 +218,11 @@ class Uncrop:
|
|||||||
def do_crop(self, image, crop_image, bbox, border_blending):
|
def do_crop(self, image, crop_image, bbox, border_blending):
|
||||||
def inset_border(image, border_width=20, border_color=(0)):
|
def inset_border(image, border_width=20, border_color=(0)):
|
||||||
width, height = image.size
|
width, height = image.size
|
||||||
bordered_image = Image.new(
|
bordered_image = Image.new(image.mode, (width, height), border_color)
|
||||||
image.mode, (width, height), border_color
|
|
||||||
)
|
|
||||||
bordered_image.paste(image, (0, 0))
|
bordered_image.paste(image, (0, 0))
|
||||||
draw = ImageDraw.Draw(bordered_image)
|
draw = ImageDraw.Draw(bordered_image)
|
||||||
draw.rectangle(
|
draw.rectangle(
|
||||||
(0, 0, width - 1, height - 1),
|
(0, 0, width - 1, height - 1), outline=border_color, width=border_width
|
||||||
outline=border_color,
|
|
||||||
width=border_width,
|
|
||||||
)
|
)
|
||||||
return bordered_image
|
return bordered_image
|
||||||
|
|
||||||
@@ -278,9 +245,7 @@ class Uncrop:
|
|||||||
# uncrop the image based on the bounding box
|
# uncrop the image based on the bounding box
|
||||||
bb_x, bb_y, bb_width, bb_height = bbox
|
bb_x, bb_y, bb_width, bb_height = bbox
|
||||||
|
|
||||||
paste_region = bbox_to_region(
|
paste_region = bbox_to_region((bb_x, bb_y, bb_width, bb_height), img.size)
|
||||||
(bb_x, bb_y, bb_width, bb_height), img.size
|
|
||||||
)
|
|
||||||
# log.debug(f"Paste region: {paste_region}")
|
# log.debug(f"Paste region: {paste_region}")
|
||||||
# new_region = adjust_paste_region(img.size, paste_region)
|
# new_region = adjust_paste_region(img.size, paste_region)
|
||||||
# log.debug(f"Adjusted paste region: {new_region}")
|
# log.debug(f"Adjusted paste region: {new_region}")
|
||||||
@@ -306,16 +271,12 @@ class Uncrop:
|
|||||||
|
|
||||||
mask.paste(mask_block, paste_region)
|
mask.paste(mask_block, paste_region)
|
||||||
log.debug(f"Blend size: {blend.size} | kind {blend.mode}")
|
log.debug(f"Blend size: {blend.size} | kind {blend.mode}")
|
||||||
log.debug(
|
log.debug(f"Crop image size: {crop_img.size} | kind {crop_img.mode}")
|
||||||
f"Crop image size: {crop_img.size} | kind {crop_img.mode}"
|
|
||||||
)
|
|
||||||
log.debug(f"BBox: {paste_region}")
|
log.debug(f"BBox: {paste_region}")
|
||||||
blend.paste(crop_img, paste_region)
|
blend.paste(crop_img, paste_region)
|
||||||
|
|
||||||
mask = mask.filter(ImageFilter.BoxBlur(radius=blend_ratio / 4))
|
mask = mask.filter(ImageFilter.BoxBlur(radius=blend_ratio / 4))
|
||||||
mask = mask.filter(
|
mask = mask.filter(ImageFilter.GaussianBlur(radius=blend_ratio / 4))
|
||||||
ImageFilter.GaussianBlur(radius=blend_ratio / 4)
|
|
||||||
)
|
|
||||||
|
|
||||||
blend.putalpha(mask)
|
blend.putalpha(mask)
|
||||||
img = Image.alpha_composite(img.convert("RGBA"), blend)
|
img = Image.alpha_composite(img.convert("RGBA"), blend)
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
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 MTB_Curve:
|
|
||||||
"""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):
|
|
||||||
return (curve,)
|
|
||||||
|
|
||||||
|
|
||||||
__nodes__ = [MTB_Curve]
|
|
||||||
+14
-26
@@ -39,16 +39,11 @@ def process_list(anything):
|
|||||||
and isinstance(first_element[0], torch.Tensor)
|
and isinstance(first_element[0], torch.Tensor)
|
||||||
):
|
):
|
||||||
text.append(
|
text.append(
|
||||||
"List of List of Tensors: "
|
f"List of List of Tensors: {first_element[0].shape} (x{len(anything)})"
|
||||||
f"{first_element[0].shape} (x{len(anything)})"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
elif isinstance(first_element, torch.Tensor):
|
elif isinstance(first_element, torch.Tensor):
|
||||||
text.append(
|
text.append(f"List of Tensors: {first_element.shape} (x{len(anything)})")
|
||||||
f"List of Tensors: {first_element.shape} (x{len(anything)})"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
text.append(f"Array: {anything}")
|
|
||||||
|
|
||||||
return {"text": text}
|
return {"text": text}
|
||||||
|
|
||||||
@@ -56,9 +51,7 @@ def process_list(anything):
|
|||||||
def process_dict(anything):
|
def process_dict(anything):
|
||||||
text = []
|
text = []
|
||||||
if "samples" in anything:
|
if "samples" in anything:
|
||||||
is_empty = (
|
is_empty = "(empty)" if torch.count_nonzero(anything["samples"]) == 0 else ""
|
||||||
"(empty)" if torch.count_nonzero(anything["samples"]) == 0 else ""
|
|
||||||
)
|
|
||||||
text.append(f"Latent Samples: {anything['samples'].shape} {is_empty}")
|
text.append(f"Latent Samples: {anything['samples'].shape} {is_empty}")
|
||||||
|
|
||||||
return {"text": text}
|
return {"text": text}
|
||||||
@@ -75,11 +68,8 @@ def process_text(anything):
|
|||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
class MTB_Debug:
|
class Debug:
|
||||||
"""Experimental node to debug any Comfy values.
|
"""Experimental node to debug any Comfy values, support for more types and widgets is planned"""
|
||||||
|
|
||||||
support for more types and widgets is planned.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
@@ -92,7 +82,7 @@ class MTB_Debug:
|
|||||||
CATEGORY = "mtb/debug"
|
CATEGORY = "mtb/debug"
|
||||||
OUTPUT_NODE = True
|
OUTPUT_NODE = True
|
||||||
|
|
||||||
def do_debug(self, output_to_console: bool, **kwargs):
|
def do_debug(self, output_to_console, **kwargs):
|
||||||
output = {
|
output = {
|
||||||
"ui": {"b64_images": [], "text": []},
|
"ui": {"b64_images": [], "text": []},
|
||||||
# "result": ("A"),
|
# "result": ("A"),
|
||||||
@@ -105,8 +95,7 @@ class MTB_Debug:
|
|||||||
bool: process_bool,
|
bool: process_bool,
|
||||||
}
|
}
|
||||||
if output_to_console:
|
if output_to_console:
|
||||||
for k, v in kwargs.items():
|
print("bouh!")
|
||||||
print(f"{k}: {v}")
|
|
||||||
|
|
||||||
for anything in kwargs.values():
|
for anything in kwargs.values():
|
||||||
processor = processors.get(type(anything), process_text)
|
processor = processors.get(type(anything), process_text)
|
||||||
@@ -114,15 +103,15 @@ class MTB_Debug:
|
|||||||
|
|
||||||
for ui_key, ui_value in processed_data.items():
|
for ui_key, ui_value in processed_data.items():
|
||||||
output["ui"][ui_key].extend(ui_value)
|
output["ui"][ui_key].extend(ui_value)
|
||||||
|
# log.debug(
|
||||||
|
# f"Processed input {k}, found {len(processed_data.get('b64_images', []))} images and {len(processed_data.get('text', []))} text items."
|
||||||
|
# )
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
class MTB_SaveTensors:
|
class SaveTensors:
|
||||||
"""Save torch tensors (image, mask or latent) to disk.
|
"""Save torch tensors (image, mask or latent) to disk, useful to debug things outside comfy"""
|
||||||
|
|
||||||
useful to debug things outside comfy.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.output_dir = folder_paths.get_output_directory()
|
self.output_dir = folder_paths.get_output_directory()
|
||||||
@@ -177,10 +166,9 @@ class MTB_SaveTensors:
|
|||||||
torch.save(latent, full_output_folder / latent_file)
|
torch.save(latent, full_output_folder / latent_file)
|
||||||
# pickle.dump(latent, open(full_output_folder/ latent_file, "wb"))
|
# pickle.dump(latent, open(full_output_folder/ latent_file, "wb"))
|
||||||
|
|
||||||
# np.save(full_output_folder / latent_file,
|
# np.save(full_output_folder/ latent_file, latent[""].cpu().numpy())
|
||||||
# latent[""].cpu().numpy())
|
|
||||||
|
|
||||||
return f"{filename_prefix}_{counter:05}"
|
return f"{filename_prefix}_{counter:05}"
|
||||||
|
|
||||||
|
|
||||||
__nodes__ = [MTB_Debug, MTB_SaveTensors]
|
__nodes__ = [Debug, SaveTensors]
|
||||||
|
|||||||
+35
-70
@@ -8,13 +8,7 @@ from PIL import Image
|
|||||||
|
|
||||||
from ..errors import ModelNotFound
|
from ..errors import ModelNotFound
|
||||||
from ..log import mklog
|
from ..log import mklog
|
||||||
from ..utils import (
|
from ..utils import get_model_path, tensor2pil, tiles_infer, tiles_merge, tiles_split
|
||||||
get_model_path,
|
|
||||||
tensor2pil,
|
|
||||||
tiles_infer,
|
|
||||||
tiles_merge,
|
|
||||||
tiles_split,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Disable MS telemetry
|
# Disable MS telemetry
|
||||||
ort.disable_telemetry_events()
|
ort.disable_telemetry_events()
|
||||||
@@ -22,13 +16,9 @@ log = mklog(__name__)
|
|||||||
|
|
||||||
|
|
||||||
# - COLOR to NORMALS
|
# - COLOR to NORMALS
|
||||||
def color_to_normals(
|
def color_to_normals(color_img, overlap, progress_callback, save_temp=False):
|
||||||
color_img, overlap, progress_callback, *, save_temp=False
|
"""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'.
|
||||||
"""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'.
|
|
||||||
"""
|
"""
|
||||||
temp_dir = Path(tempfile.mkdtemp()) if save_temp else None
|
temp_dir = Path(tempfile.mkdtemp()) if save_temp else None
|
||||||
|
|
||||||
@@ -41,8 +31,7 @@ def color_to_normals(
|
|||||||
)
|
)
|
||||||
|
|
||||||
log.debug(
|
log.debug(
|
||||||
"Converting color image to grayscale by taking "
|
f"Converting color image to grayscale by taking the mean over color channels: {img.shape}"
|
||||||
f"the mean over color channels: {img.shape}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Split image in tiles
|
# Split image in tiles
|
||||||
@@ -73,15 +62,13 @@ def color_to_normals(
|
|||||||
|
|
||||||
# Predict normal map for each tile
|
# Predict normal map for each tile
|
||||||
log.debug("DeepBump Color → Normals : generating")
|
log.debug("DeepBump Color → Normals : generating")
|
||||||
pred_tiles = tiles_infer(
|
pred_tiles = tiles_infer(tiles, ort_session, progress_callback=progress_callback)
|
||||||
tiles, ort_session, progress_callback=progress_callback
|
|
||||||
)
|
|
||||||
|
|
||||||
if temp_dir:
|
if temp_dir:
|
||||||
for i, pred_tile in enumerate(pred_tiles):
|
for i, pred_tile in enumerate(pred_tiles):
|
||||||
Image.fromarray(
|
Image.fromarray((pred_tile.transpose(1, 2, 0) * 255).astype(np.uint8)).save(
|
||||||
(pred_tile.transpose(1, 2, 0) * 255).astype(np.uint8)
|
temp_dir / f"pred_tile_{i}.png"
|
||||||
).save(temp_dir / f"pred_tile_{i}.png")
|
)
|
||||||
|
|
||||||
# Merge tiles
|
# Merge tiles
|
||||||
log.debug("DeepBump Color → Normals : merging")
|
log.debug("DeepBump Color → Normals : merging")
|
||||||
@@ -93,17 +80,17 @@ def color_to_normals(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if temp_dir:
|
if temp_dir:
|
||||||
Image.fromarray(
|
Image.fromarray((pred_img.transpose(1, 2, 0) * 255).astype(np.uint8)).save(
|
||||||
(pred_img.transpose(1, 2, 0) * 255).astype(np.uint8)
|
temp_dir / "merged_img.png"
|
||||||
).save(temp_dir / "merged_img.png")
|
)
|
||||||
|
|
||||||
# Normalize each pixel to unit vector
|
# Normalize each pixel to unit vector
|
||||||
pred_img = normalize(pred_img)
|
pred_img = normalize(pred_img)
|
||||||
|
|
||||||
if temp_dir:
|
if temp_dir:
|
||||||
Image.fromarray(
|
Image.fromarray((pred_img.transpose(1, 2, 0) * 255).astype(np.uint8)).save(
|
||||||
(pred_img.transpose(1, 2, 0) * 255).astype(np.uint8)
|
temp_dir / "final_img.png"
|
||||||
).save(temp_dir / "final_img.png")
|
)
|
||||||
|
|
||||||
log.debug(f"Debug images saved in {temp_dir}")
|
log.debug(f"Debug images saved in {temp_dir}")
|
||||||
|
|
||||||
@@ -112,47 +99,40 @@ def color_to_normals(
|
|||||||
|
|
||||||
# - NORMALS to CURVATURE
|
# - NORMALS to CURVATURE
|
||||||
def conv_1d(array, kernel_1d):
|
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
|
# Input kernel length must be odd
|
||||||
k_l = len(kernel_1d)
|
k_l = len(kernel_1d)
|
||||||
|
|
||||||
assert k_l % 2 != 0
|
assert k_l % 2 != 0
|
||||||
# Convolution is repeat-padded
|
# Convolution is repeat-padded
|
||||||
extended = np.pad(array, k_l // 2, mode="wrap")
|
extended = np.pad(array, k_l // 2, mode="wrap")
|
||||||
# Output has same size as input (padded, valid-mode convolution)
|
# Output has same size as input (padded, valid-mode convolution)
|
||||||
output = np.empty(array.shape)
|
output = np.empty(array.shape)
|
||||||
for i in range(array.shape[0]):
|
for i in range(array.shape[0]):
|
||||||
output[i] = np.convolve(
|
output[i] = np.convolve(extended[i + (k_l // 2)], kernel_1d, mode="valid")
|
||||||
extended[i + (k_l // 2)], kernel_1d, mode="valid"
|
|
||||||
)
|
|
||||||
|
|
||||||
return output * -1
|
return output * -1
|
||||||
|
|
||||||
|
|
||||||
def gaussian_kernel(length, sigma):
|
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)
|
space = np.linspace(-(length - 1) / 2, (length - 1) / 2, length)
|
||||||
kernel = np.exp(-0.5 * np.square(space) / np.square(sigma))
|
kernel = np.exp(-0.5 * np.square(space) / np.square(sigma))
|
||||||
return kernel / np.sum(kernel)
|
return kernel / np.sum(kernel)
|
||||||
|
|
||||||
|
|
||||||
def normalize(np_array):
|
def normalize(np_array):
|
||||||
"""Normalize all elements of the given numpy array to [0,1]."""
|
"""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)
|
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):
|
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
|
# Convolutions on normal map red & green channels
|
||||||
if progress_callback is not None:
|
if progress_callback is not None:
|
||||||
progress_callback(0, 4)
|
progress_callback(0, 4)
|
||||||
@@ -177,12 +157,8 @@ def normals_to_curvature(normals_img, blur_radius, progress_callback):
|
|||||||
"LARGER": 1 / 8,
|
"LARGER": 1 / 8,
|
||||||
"LARGEST": 1 / 4,
|
"LARGEST": 1 / 4,
|
||||||
}
|
}
|
||||||
if blur_radius not in blur_factors:
|
assert blur_radius 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])
|
||||||
|
|
||||||
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 too small, do not blur
|
||||||
if blur_radius_px < 2:
|
if blur_radius_px < 2:
|
||||||
@@ -219,9 +195,8 @@ def normals_to_grad(normals_img):
|
|||||||
|
|
||||||
def copy_flip(grad_x, grad_y):
|
def copy_flip(grad_x, grad_y):
|
||||||
"""Concat 4 flipped copies of input gradients (makes them wrap).
|
"""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_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)])
|
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])
|
new_grad_x = np.vstack([grad_x_top, grad_x_bottom])
|
||||||
@@ -235,6 +210,7 @@ def copy_flip(grad_x, grad_y):
|
|||||||
|
|
||||||
def frankot_chellappa(grad_x, grad_y, progress_callback=None):
|
def frankot_chellappa(grad_x, grad_y, progress_callback=None):
|
||||||
"""Frankot-Chellappa depth-from-gradient algorithm."""
|
"""Frankot-Chellappa depth-from-gradient algorithm."""
|
||||||
|
|
||||||
if progress_callback is not None:
|
if progress_callback is not None:
|
||||||
progress_callback(0, 3)
|
progress_callback(0, 3)
|
||||||
|
|
||||||
@@ -274,8 +250,8 @@ def frankot_chellappa(grad_x, grad_y, progress_callback=None):
|
|||||||
def normals_to_height(normals_img, seamless, progress_callback):
|
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
|
"""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'
|
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 height axis
|
||||||
flip_img = np.flip(normals_img, axis=1)
|
flip_img = np.flip(normals_img, axis=1)
|
||||||
|
|
||||||
@@ -289,9 +265,7 @@ def normals_to_height(normals_img, seamless, progress_callback):
|
|||||||
grad_x, grad_y = copy_flip(grad_x, grad_y)
|
grad_x, grad_y = copy_flip(grad_x, grad_y)
|
||||||
|
|
||||||
# Compute height
|
# Compute height
|
||||||
pred_img = frankot_chellappa(
|
pred_img = frankot_chellappa(-grad_x, grad_y, progress_callback=progress_callback)
|
||||||
-grad_x, grad_y, progress_callback=progress_callback
|
|
||||||
)
|
|
||||||
|
|
||||||
# Cut to valid part if gradients were expanded
|
# Cut to valid part if gradients were expanded
|
||||||
if not seamless:
|
if not seamless:
|
||||||
@@ -312,11 +286,7 @@ class DeepBump:
|
|||||||
"required": {
|
"required": {
|
||||||
"image": ("IMAGE",),
|
"image": ("IMAGE",),
|
||||||
"mode": (
|
"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"],),
|
"color_to_normals_overlap": (["SMALL", "MEDIUM", "LARGE"],),
|
||||||
"normals_to_curvature_blur_radius": (
|
"normals_to_curvature_blur_radius": (
|
||||||
@@ -341,7 +311,6 @@ class DeepBump:
|
|||||||
|
|
||||||
def apply(
|
def apply(
|
||||||
self,
|
self,
|
||||||
*,
|
|
||||||
image,
|
image,
|
||||||
mode="Color to Normals",
|
mode="Color to Normals",
|
||||||
color_to_normals_overlap="SMALL",
|
color_to_normals_overlap="SMALL",
|
||||||
@@ -360,17 +329,13 @@ class DeepBump:
|
|||||||
|
|
||||||
# Apply processing
|
# Apply processing
|
||||||
if mode == "Color to Normals":
|
if mode == "Color to Normals":
|
||||||
out_img = color_to_normals(
|
out_img = color_to_normals(in_img, color_to_normals_overlap, None)
|
||||||
in_img, color_to_normals_overlap, None
|
|
||||||
)
|
|
||||||
if mode == "Normals to Curvature":
|
if mode == "Normals to Curvature":
|
||||||
out_img = normals_to_curvature(
|
out_img = normals_to_curvature(
|
||||||
in_img, normals_to_curvature_blur_radius, None
|
in_img, normals_to_curvature_blur_radius, None
|
||||||
)
|
)
|
||||||
if mode == "Normals to Height":
|
if mode == "Normals to Height":
|
||||||
out_img = normals_to_height(
|
out_img = normals_to_height(in_img, normals_to_height_seamless, None)
|
||||||
in_img, normals_to_height_seamless, None
|
|
||||||
)
|
|
||||||
|
|
||||||
if out_img is not None:
|
if out_img is not None:
|
||||||
log.debug(f"Output image shape: {out_img.shape}")
|
log.debug(f"Output image shape: {out_img.shape}")
|
||||||
|
|||||||
+12
-29
@@ -40,12 +40,12 @@ class LoadFaceEnhanceModel:
|
|||||||
log.warning("Face restoration models not found.")
|
log.warning("Face restoration models not found.")
|
||||||
return []
|
return []
|
||||||
if not fr_models_path.exists():
|
if not fr_models_path.exists():
|
||||||
# log.warning(
|
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)"
|
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(
|
log.warning(
|
||||||
# "For now we fallback to upscale_models but this will be removed in a future version"
|
"For now we fallback to upscale_models but this will be removed in a future version"
|
||||||
# )
|
)
|
||||||
if um_models_path.exists():
|
if um_models_path.exists():
|
||||||
return [
|
return [
|
||||||
x
|
x
|
||||||
@@ -98,9 +98,7 @@ class LoadFaceEnhanceModel:
|
|||||||
(fr_root if fr_root.exists() else um_root) / model_name
|
(fr_root if fr_root.exists() else um_root) / model_name
|
||||||
).as_posix(),
|
).as_posix(),
|
||||||
upscale=upscale,
|
upscale=upscale,
|
||||||
arch="clean"
|
arch="clean" if basic else "RestoreFormer", # or original for v1.0 only
|
||||||
if basic
|
|
||||||
else "RestoreFormer", # or original for v1.0 only
|
|
||||||
channel_multiplier=2, # 1 for v1.0 only
|
channel_multiplier=2, # 1 for v1.0 only
|
||||||
bg_upsampler=bg_upsampler,
|
bg_upsampler=bg_upsampler,
|
||||||
)
|
)
|
||||||
@@ -124,11 +122,7 @@ class BGUpscaleWrapper:
|
|||||||
imgt = imgt.movedim(-1, -3).to(device)
|
imgt = imgt.movedim(-1, -3).to(device)
|
||||||
|
|
||||||
steps = imgt.shape[0] * comfy.utils.get_tiled_scale_steps(
|
steps = imgt.shape[0] * comfy.utils.get_tiled_scale_steps(
|
||||||
imgt.shape[3],
|
imgt.shape[3], imgt.shape[2], tile_x=tile, tile_y=tile, overlap=overlap
|
||||||
imgt.shape[2],
|
|
||||||
tile_x=tile,
|
|
||||||
tile_y=tile,
|
|
||||||
overlap=overlap,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
log.debug(f"Steps: {steps}")
|
log.debug(f"Steps: {steps}")
|
||||||
@@ -205,14 +199,10 @@ class RestoreFace:
|
|||||||
log.warning(f"Weight value has no effect for now. (value: {weight})")
|
log.warning(f"Weight value has no effect for now. (value: {weight})")
|
||||||
|
|
||||||
if save_tmp_steps:
|
if save_tmp_steps:
|
||||||
self.save_intermediate_images(
|
self.save_intermediate_images(cropped_faces, restored_faces, height, width)
|
||||||
cropped_faces, restored_faces, height, width
|
|
||||||
)
|
|
||||||
output = None
|
output = None
|
||||||
if restored_img is not None:
|
if restored_img is not None:
|
||||||
output = Image.fromarray(
|
output = Image.fromarray(cv2.cvtColor(restored_img, cv2.COLOR_BGR2RGB))
|
||||||
cv2.cvtColor(restored_img, cv2.COLOR_BGR2RGB)
|
|
||||||
)
|
|
||||||
# imwrite(restored_img, save_restore_path)
|
# imwrite(restored_img, save_restore_path)
|
||||||
|
|
||||||
return pil2tensor(output)
|
return pil2tensor(output)
|
||||||
@@ -228,12 +218,7 @@ class RestoreFace:
|
|||||||
) -> Tuple[torch.Tensor]:
|
) -> Tuple[torch.Tensor]:
|
||||||
out = [
|
out = [
|
||||||
self.do_restore(
|
self.do_restore(
|
||||||
image[i],
|
image[i], model, aligned, only_center_face, weight, save_tmp_steps
|
||||||
model,
|
|
||||||
aligned,
|
|
||||||
only_center_face,
|
|
||||||
weight,
|
|
||||||
save_tmp_steps,
|
|
||||||
)
|
)
|
||||||
for i in range(image.size(0))
|
for i in range(image.size(0))
|
||||||
]
|
]
|
||||||
@@ -255,9 +240,7 @@ class RestoreFace:
|
|||||||
|
|
||||||
return os.path.join(full_output_folder, file)
|
return os.path.join(full_output_folder, file)
|
||||||
|
|
||||||
def save_intermediate_images(
|
def save_intermediate_images(self, cropped_faces, restored_faces, height, width):
|
||||||
self, cropped_faces, restored_faces, height, width
|
|
||||||
):
|
|
||||||
for idx, (cropped_face, restored_face) in enumerate(
|
for idx, (cropped_face, restored_face) in enumerate(
|
||||||
zip(cropped_faces, restored_faces)
|
zip(cropped_faces, restored_faces)
|
||||||
):
|
):
|
||||||
|
|||||||
+11
-30
@@ -48,7 +48,7 @@ class LoadFaceAnalysisModel:
|
|||||||
|
|
||||||
face_analyser = insightface.app.FaceAnalysis(
|
face_analyser = insightface.app.FaceAnalysis(
|
||||||
name=faceswap_model,
|
name=faceswap_model,
|
||||||
root=get_model_path("insightface").as_posix(),
|
root=get_model_path("insightface"),
|
||||||
)
|
)
|
||||||
return (face_analyser,)
|
return (face_analyser,)
|
||||||
|
|
||||||
@@ -57,12 +57,9 @@ class LoadFaceSwapModel:
|
|||||||
"""Loads a faceswap model"""
|
"""Loads a faceswap model"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_models() -> list[Path]:
|
def get_models() -> List[Path]:
|
||||||
models_path = get_model_path("insightface")
|
models_path = get_model_path("insightface").iterdir()
|
||||||
if models_path.exists():
|
return [x for x in models_path if x.suffix in [".onnx", ".pth"]]
|
||||||
models = models_path.iterdir()
|
|
||||||
return [x for x in models if x.suffix in [".onnx", ".pth"]]
|
|
||||||
return []
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
@@ -113,10 +110,7 @@ class FaceSwap:
|
|||||||
"image": ("IMAGE",),
|
"image": ("IMAGE",),
|
||||||
"reference": ("IMAGE",),
|
"reference": ("IMAGE",),
|
||||||
"faces_index": ("STRING", {"default": "0"}),
|
"faces_index": ("STRING", {"default": "0"}),
|
||||||
"faceanalysis_model": (
|
"faceanalysis_model": ("FACE_ANALYSIS_MODEL", {"default": "None"}),
|
||||||
"FACE_ANALYSIS_MODEL",
|
|
||||||
{"default": "None"},
|
|
||||||
),
|
|
||||||
"faceswap_model": ("FACESWAP_MODEL", {"default": "None"}),
|
"faceswap_model": ("FACESWAP_MODEL", {"default": "None"}),
|
||||||
},
|
},
|
||||||
"optional": {},
|
"optional": {},
|
||||||
@@ -139,14 +133,10 @@ class FaceSwap:
|
|||||||
img = tensor2pil(img)[0]
|
img = tensor2pil(img)[0]
|
||||||
ref = tensor2pil(reference)[0]
|
ref = tensor2pil(reference)[0]
|
||||||
face_ids = {
|
face_ids = {
|
||||||
int(x)
|
int(x) for x in faces_index.strip(",").split(",") if x.isnumeric()
|
||||||
for x in faces_index.strip(",").split(",")
|
|
||||||
if x.isnumeric()
|
|
||||||
}
|
}
|
||||||
sys.stdout = NullWriter()
|
sys.stdout = NullWriter()
|
||||||
swapped = swap_face(
|
swapped = swap_face(faceanalysis_model, ref, img, faceswap_model, face_ids)
|
||||||
faceanalysis_model, ref, img, faceswap_model, face_ids
|
|
||||||
)
|
|
||||||
sys.stdout = sys.__stdout__
|
sys.stdout = sys.__stdout__
|
||||||
return pil2tensor(swapped)
|
return pil2tensor(swapped)
|
||||||
|
|
||||||
@@ -180,10 +170,7 @@ def get_face_single(
|
|||||||
log.debug("No face ed, trying again with smaller image")
|
log.debug("No face ed, trying again with smaller image")
|
||||||
det_size_half = (det_size[0] // 2, det_size[1] // 2)
|
det_size_half = (det_size[0] // 2, det_size[1] // 2)
|
||||||
return get_face_single(
|
return get_face_single(
|
||||||
face_analyser,
|
face_analyser, img_data, face_index=face_index, det_size=det_size_half
|
||||||
img_data,
|
|
||||||
face_index=face_index,
|
|
||||||
det_size=det_size_half,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -207,9 +194,7 @@ def swap_face(
|
|||||||
if face_swapper_model is not None:
|
if face_swapper_model is not None:
|
||||||
cv_source_img = cv2.cvtColor(np.array(source_img), cv2.COLOR_RGB2BGR)
|
cv_source_img = cv2.cvtColor(np.array(source_img), cv2.COLOR_RGB2BGR)
|
||||||
cv_target_img = cv2.cvtColor(np.array(target_img), cv2.COLOR_RGB2BGR)
|
cv_target_img = cv2.cvtColor(np.array(target_img), cv2.COLOR_RGB2BGR)
|
||||||
source_face = get_face_single(
|
source_face = get_face_single(face_analyser, cv_source_img, face_index=0)
|
||||||
face_analyser, cv_source_img, face_index=0
|
|
||||||
)
|
|
||||||
if source_face is not None:
|
if source_face is not None:
|
||||||
result = cv_target_img
|
result = cv_target_img
|
||||||
|
|
||||||
@@ -219,16 +204,12 @@ def swap_face(
|
|||||||
)
|
)
|
||||||
if target_face is not None:
|
if target_face is not None:
|
||||||
sys.stdout = NullWriter()
|
sys.stdout = NullWriter()
|
||||||
result = face_swapper_model.get(
|
result = face_swapper_model.get(result, target_face, source_face)
|
||||||
result, target_face, source_face
|
|
||||||
)
|
|
||||||
sys.stdout = sys.__stdout__
|
sys.stdout = sys.__stdout__
|
||||||
else:
|
else:
|
||||||
log.warning(f"No target face found for {face_num}")
|
log.warning(f"No target face found for {face_num}")
|
||||||
|
|
||||||
result_image = Image.fromarray(
|
result_image = Image.fromarray(cv2.cvtColor(result, cv2.COLOR_BGR2RGB))
|
||||||
cv2.cvtColor(result, cv2.COLOR_BGR2RGB)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
log.warning("No source face found")
|
log.warning("No source face found")
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
import torch
|
|
||||||
|
|
||||||
|
|
||||||
class MTB_FilterZ:
|
|
||||||
"""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__ = [MTB_FilterZ]
|
|
||||||
+48
-133
@@ -1,8 +1,9 @@
|
|||||||
import qrcode
|
import qrcode
|
||||||
|
from ..utils import pil2tensor
|
||||||
|
from ..utils import comfy_dir
|
||||||
|
from typing import cast
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from ..log import log
|
from ..log import log
|
||||||
from ..utils import comfy_dir, font_path, pil2tensor
|
|
||||||
|
|
||||||
# class MtbExamples:
|
# class MtbExamples:
|
||||||
# """MTB Example Images"""
|
# """MTB Example Images"""
|
||||||
@@ -59,18 +60,9 @@ class UnsplashImage:
|
|||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"width": (
|
"width": ("INT", {"default": 512, "max": 8096, "min": 0, "step": 1}),
|
||||||
"INT",
|
"height": ("INT", {"default": 512, "max": 8096, "min": 0, "step": 1}),
|
||||||
{"default": 512, "max": 8096, "min": 0, "step": 1},
|
"random_seed": ("INT", {"default": 0, "max": 1e5, "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": {
|
"optional": {
|
||||||
"keyword": ("STRING", {"default": "nature"}),
|
"keyword": ("STRING", {"default": "nature"}),
|
||||||
@@ -82,9 +74,8 @@ class UnsplashImage:
|
|||||||
CATEGORY = "mtb/generate"
|
CATEGORY = "mtb/generate"
|
||||||
|
|
||||||
def do_unsplash_image(self, width, height, random_seed, keyword=None):
|
def do_unsplash_image(self, width, height, random_seed, keyword=None):
|
||||||
import io
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
import io
|
||||||
|
|
||||||
base_url = "https://source.unsplash.com/random/"
|
base_url = "https://source.unsplash.com/random/"
|
||||||
|
|
||||||
@@ -130,14 +121,8 @@ class QrCode:
|
|||||||
{"default": 256, "max": 8096, "min": 0, "step": 1},
|
{"default": 256, "max": 8096, "min": 0, "step": 1},
|
||||||
),
|
),
|
||||||
"error_correct": (("L", "M", "Q", "H"), {"default": "L"}),
|
"error_correct": (("L", "M", "Q", "H"), {"default": "L"}),
|
||||||
"box_size": (
|
"box_size": ("INT", {"default": 10, "max": 8096, "min": 0, "step": 1}),
|
||||||
"INT",
|
"border": ("INT", {"default": 4, "max": 8096, "min": 0, "step": 1}),
|
||||||
{"default": 10, "max": 8096, "min": 0, "step": 1},
|
|
||||||
),
|
|
||||||
"border": (
|
|
||||||
"INT",
|
|
||||||
{"default": 4, "max": 8096, "min": 0, "step": 1},
|
|
||||||
),
|
|
||||||
"invert": (("BOOLEAN",), {"default": False}),
|
"invert": (("BOOLEAN",), {"default": False}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,9 +131,7 @@ class QrCode:
|
|||||||
FUNCTION = "do_qr"
|
FUNCTION = "do_qr"
|
||||||
CATEGORY = "mtb/generate"
|
CATEGORY = "mtb/generate"
|
||||||
|
|
||||||
def do_qr(
|
def do_qr(self, url, width, height, error_correct, box_size, border, invert):
|
||||||
self, url, width, height, error_correct, box_size, border, invert
|
|
||||||
):
|
|
||||||
log.warning(
|
log.warning(
|
||||||
"This node will soon be deprecated, there are much better alternatives like https://github.com/coreyryanhanson/comfy-qr"
|
"This node will soon be deprecated, there are much better alternatives like https://github.com/coreyryanhanson/comfy-qr"
|
||||||
)
|
)
|
||||||
@@ -173,9 +156,7 @@ class QrCode:
|
|||||||
back_color = (255, 255, 255) if invert else (0, 0, 0)
|
back_color = (255, 255, 255) if invert else (0, 0, 0)
|
||||||
fill_color = (0, 0, 0) if invert else (255, 255, 255)
|
fill_color = (0, 0, 0) if invert else (255, 255, 255)
|
||||||
|
|
||||||
code = img = qr.make_image(
|
code = img = qr.make_image(back_color=back_color, fill_color=fill_color)
|
||||||
back_color=back_color, fill_color=fill_color
|
|
||||||
)
|
|
||||||
|
|
||||||
# that we now resize without filtering
|
# that we now resize without filtering
|
||||||
code = code.resize((width, height), Image.NEAREST)
|
code = code.resize((width, height), Image.NEAREST)
|
||||||
@@ -190,46 +171,37 @@ def bbox_dim(bbox):
|
|||||||
return width, height
|
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.
|
The tool looks for any .ttf file in the Comfy folder hierarchy.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
fonts = {}
|
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):
|
def __init__(self):
|
||||||
# - This is executed when the graph is executed,
|
# - This is executed when the graph is executed, we could conditionaly reload fonts there
|
||||||
# - we could conditionaly reload fonts there
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def CACHE_FONTS(cls):
|
def CACHE_FONTS(cls):
|
||||||
font_extensions = ["*.ttf", "*.otf", "*.woff", "*.woff2", "*.eot"]
|
font_extensions = ["*.ttf", "*.otf", "*.woff", "*.woff2", "*.eot"]
|
||||||
fonts = [font_path]
|
fonts = []
|
||||||
|
|
||||||
for extension in font_extensions:
|
for extension in font_extensions:
|
||||||
try:
|
fonts.extend(comfy_dir.glob(f"**/{extension}"))
|
||||||
if comfy_dir.exists():
|
|
||||||
fonts.extend(comfy_dir.glob(f"fonts/**/{extension}"))
|
if not fonts:
|
||||||
else:
|
log.warn(
|
||||||
log.warn(f"Directory {comfy_dir} does not exist.")
|
"> No fonts found in the comfy folder, place at least one font file somewhere in ComfyUI's hierarchy"
|
||||||
except Exception as e:
|
)
|
||||||
log.error(f"Error during font caching: {e}")
|
else:
|
||||||
|
log.debug(f"> Found {len(fonts)} fonts")
|
||||||
|
|
||||||
for font in fonts:
|
for font in fonts:
|
||||||
log.debug(f"Adding font {font}")
|
log.debug(f"Adding font {font}")
|
||||||
MTB_TextToImage.fonts[font.stem] = font.as_posix()
|
cls.fonts[font.stem] = font.as_posix()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
@@ -244,15 +216,13 @@ by default it fallsback to a default font.
|
|||||||
{"default": "Hello world!"},
|
{"default": "Hello world!"},
|
||||||
),
|
),
|
||||||
"font": ((sorted(cls.fonts.keys())),),
|
"font": ((sorted(cls.fonts.keys())),),
|
||||||
"wrap": ("BOOLEAN", {"default": True}),
|
"wrap": (
|
||||||
"trim": ("BOOLEAN", {"default": True}),
|
"INT",
|
||||||
"line_height": (
|
{"default": 120, "min": 0, "max": 8096, "step": 1},
|
||||||
"FLOAT",
|
|
||||||
{"default": 1.0, "min": 0, "step": 0.1},
|
|
||||||
),
|
),
|
||||||
"font_size": (
|
"font_size": (
|
||||||
"INT",
|
"INT",
|
||||||
{"default": 32, "min": 1, "max": 2500, "step": 1},
|
{"default": 12, "min": 1, "max": 2500, "step": 1},
|
||||||
),
|
),
|
||||||
"width": (
|
"width": (
|
||||||
"INT",
|
"INT",
|
||||||
@@ -262,6 +232,7 @@ by default it fallsback to a default font.
|
|||||||
"INT",
|
"INT",
|
||||||
{"default": 512, "min": 1, "max": 8096, "step": 1},
|
{"default": 512, "min": 1, "max": 8096, "step": 1},
|
||||||
),
|
),
|
||||||
|
# "position": (["INT"], {"default": 0, "min": 0, "max": 100, "step": 1}),
|
||||||
"color": (
|
"color": (
|
||||||
"COLOR",
|
"COLOR",
|
||||||
{"default": "black"},
|
{"default": "black"},
|
||||||
@@ -270,20 +241,6 @@ by default it fallsback to a default font.
|
|||||||
"COLOR",
|
"COLOR",
|
||||||
{"default": "white"},
|
{"default": "white"},
|
||||||
),
|
),
|
||||||
"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},
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,79 +250,37 @@ by default it fallsback to a default font.
|
|||||||
CATEGORY = "mtb/generate"
|
CATEGORY = "mtb/generate"
|
||||||
|
|
||||||
def text_to_image(
|
def text_to_image(
|
||||||
self,
|
self, text, font, wrap, font_size, width, height, color, background
|
||||||
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,
|
|
||||||
):
|
):
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
font = self.fonts[font]
|
||||||
|
font = cast(ImageFont.FreeTypeFont, ImageFont.truetype(font, font_size))
|
||||||
font_path = self.fonts[font]
|
if wrap == 0:
|
||||||
|
wrap = width / font_size
|
||||||
text = (
|
lines = textwrap.wrap(text, width=wrap)
|
||||||
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)
|
|
||||||
log.debug(f"Lines: {lines}")
|
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)
|
draw = ImageDraw.Draw(img)
|
||||||
|
y_text = 0
|
||||||
line_height_px = line_height * font_size
|
# - bbox is [left, upper, right, lower]
|
||||||
|
|
||||||
# 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
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
line_width = get_width(line)
|
width, height = bbox_dim(font.getbbox(line))
|
||||||
# Horizontal alignment
|
draw.text((0, y_text), line, color, font=font)
|
||||||
if h_align == "left":
|
y_text += height
|
||||||
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
|
|
||||||
|
|
||||||
|
# img.save(os.path.join(folder_paths.base_path, f'{str(uuid.uuid4())}.png'))
|
||||||
return (pil2tensor(img),)
|
return (pil2tensor(img),)
|
||||||
|
|
||||||
|
|
||||||
__nodes__ = [
|
__nodes__ = [
|
||||||
QrCode,
|
QrCode,
|
||||||
UnsplashImage,
|
UnsplashImage,
|
||||||
MTB_TextToImage,
|
TextToImage
|
||||||
# MtbExamples,
|
# MtbExamples,
|
||||||
]
|
]
|
||||||
|
|||||||
+20
-293
@@ -2,24 +2,13 @@ import io
|
|||||||
import json
|
import json
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from math import pi
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
import comfy.model_management as model_management
|
|
||||||
import comfy.utils
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
import torchvision.transforms.functional as F
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from ..log import log
|
from ..log import log
|
||||||
from ..utils import (
|
from ..utils import apply_easing, get_server_info, pil2tensor
|
||||||
apply_easing,
|
|
||||||
get_server_info,
|
|
||||||
numpy_NFOV,
|
|
||||||
pil2tensor,
|
|
||||||
tensor2np,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def get_image(filename, subfolder, folder_type):
|
def get_image(filename, subfolder, folder_type):
|
||||||
@@ -36,259 +25,10 @@ def get_image(filename, subfolder, folder_type):
|
|||||||
return io.BytesIO(response.read())
|
return io.BytesIO(response.read())
|
||||||
|
|
||||||
|
|
||||||
class MTB_ToDevice:
|
class GetBatchFromHistory:
|
||||||
"""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: Optional[torch.Tensor] = None,
|
|
||||||
mask: Optional[torch.Tensor] = 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
|
|
||||||
):
|
|
||||||
_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 = [
|
|
||||||
F.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_FloatsToFloat:
|
|
||||||
"""AD, IPA, Fitz etc have commonly choose to mistype float lists as FLOAT.
|
|
||||||
|
|
||||||
This is just a hack to be compatible with these
|
|
||||||
"""
|
|
||||||
|
|
||||||
@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:
|
|
||||||
"""Very experimental node to load images from the history of the server.
|
"""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
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
@@ -311,7 +51,6 @@ class MTB_GetBatchFromHistory:
|
|||||||
|
|
||||||
def load_from_history(
|
def load_from_history(
|
||||||
self,
|
self,
|
||||||
*,
|
|
||||||
enable=True,
|
enable=True,
|
||||||
count=0,
|
count=0,
|
||||||
offset=0,
|
offset=0,
|
||||||
@@ -349,9 +88,7 @@ class MTB_GetBatchFromHistory:
|
|||||||
if "images" in node_output:
|
if "images" in node_output:
|
||||||
for image in node_output["images"]:
|
for image in node_output["images"]:
|
||||||
image_data = get_image(
|
image_data = get_image(
|
||||||
image["filename"],
|
image["filename"], image["subfolder"], image["type"]
|
||||||
image["subfolder"],
|
|
||||||
image["type"],
|
|
||||||
)
|
)
|
||||||
output_images.append(image_data)
|
output_images.append(image_data)
|
||||||
|
|
||||||
@@ -373,8 +110,8 @@ class MTB_GetBatchFromHistory:
|
|||||||
return pil2tensor(frames)
|
return pil2tensor(frames)
|
||||||
|
|
||||||
|
|
||||||
class MTB_AnyToString:
|
class AnyToString:
|
||||||
"""Tries to take any input and convert it to a string."""
|
"""Tries to take any input and convert it to a string"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
@@ -394,22 +131,18 @@ class MTB_AnyToString:
|
|||||||
elif isinstance(input, Image.Image):
|
elif isinstance(input, Image.Image):
|
||||||
return (f"PIL Image of size {input.size} and mode {input.mode}",)
|
return (f"PIL Image of size {input.size} and mode {input.mode}",)
|
||||||
elif isinstance(input, np.ndarray):
|
elif isinstance(input, np.ndarray):
|
||||||
return (
|
return (f"Numpy array of shape {input.shape} and dtype {input.dtype}",)
|
||||||
f"Numpy array of shape {input.shape} and dtype {input.dtype}",
|
|
||||||
)
|
|
||||||
|
|
||||||
elif isinstance(input, dict):
|
elif isinstance(input, dict):
|
||||||
return (
|
return (f"Dictionary of {len(input)} items, with keys {input.keys()}",)
|
||||||
f"Dictionary of {len(input)} items, with keys {input.keys()}",
|
|
||||||
)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log.debug(f"Falling back to string conversion of {input}")
|
log.debug(f"Falling back to string conversion of {input}")
|
||||||
return (str(input),)
|
return (str(input),)
|
||||||
|
|
||||||
|
|
||||||
class MTB_StringReplace:
|
class StringReplace:
|
||||||
"""Basic string replacement."""
|
"""Basic string replacement"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
@@ -452,11 +185,10 @@ class MTB_MathExpression:
|
|||||||
RETURN_TYPES = ("FLOAT", "INT")
|
RETURN_TYPES = ("FLOAT", "INT")
|
||||||
RETURN_NAMES = ("result (float)", "result (int)")
|
RETURN_NAMES = ("result (float)", "result (int)")
|
||||||
CATEGORY = "mtb/math"
|
CATEGORY = "mtb/math"
|
||||||
DESCRIPTION = (
|
DESCRIPTION = "evaluate a simple math expression string (!! Fallsback to eval)"
|
||||||
"evaluate a simple math expression string (!! Fallsback to eval)"
|
|
||||||
)
|
|
||||||
|
|
||||||
def eval_expression(self, expression, **kwargs):
|
def eval_expression(self, expression, **kwargs):
|
||||||
|
import math
|
||||||
from ast import literal_eval
|
from ast import literal_eval
|
||||||
|
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
@@ -484,7 +216,7 @@ class MTB_MathExpression:
|
|||||||
return (result, int(result))
|
return (result, int(result))
|
||||||
|
|
||||||
|
|
||||||
class MTB_FitNumber:
|
class FitNumber:
|
||||||
"""Fit the input float using a source and target range"""
|
"""Fit the input float using a source and target range"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -557,8 +289,8 @@ class MTB_FitNumber:
|
|||||||
return (res,)
|
return (res,)
|
||||||
|
|
||||||
|
|
||||||
class MTB_ConcatImages:
|
class ConcatImages:
|
||||||
"""Add images to batch."""
|
"""Add images to batch"""
|
||||||
|
|
||||||
RETURN_TYPES = ("IMAGE",)
|
RETURN_TYPES = ("IMAGE",)
|
||||||
FUNCTION = "concatenate_tensors"
|
FUNCTION = "concatenate_tensors"
|
||||||
@@ -585,15 +317,10 @@ class MTB_ConcatImages:
|
|||||||
|
|
||||||
|
|
||||||
__nodes__ = [
|
__nodes__ = [
|
||||||
MTB_StringReplace,
|
StringReplace,
|
||||||
MTB_FitNumber,
|
FitNumber,
|
||||||
MTB_GetBatchFromHistory,
|
GetBatchFromHistory,
|
||||||
MTB_AnyToString,
|
AnyToString,
|
||||||
MTB_ConcatImages,
|
ConcatImages,
|
||||||
MTB_MathExpression,
|
MTB_MathExpression,
|
||||||
MTB_ToDevice,
|
|
||||||
MTB_ApplyTextTemplate,
|
|
||||||
MTB_MatchDimensions,
|
|
||||||
MTB_AutoPanEquilateral,
|
|
||||||
MTB_FloatsToFloat,
|
|
||||||
]
|
]
|
||||||
|
|||||||
+81
-183
@@ -3,17 +3,18 @@ import json
|
|||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import cv2
|
||||||
import folder_paths
|
import folder_paths
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
import torch.nn.functional as F
|
import torch.nn.functional as F
|
||||||
from PIL import Image, ImageOps
|
from PIL import Image
|
||||||
from PIL.PngImagePlugin import PngInfo
|
from PIL.PngImagePlugin import PngInfo
|
||||||
from skimage.filters import gaussian
|
from skimage.filters import gaussian
|
||||||
from skimage.util import compare_images
|
from skimage.util import compare_images
|
||||||
|
|
||||||
from ..log import log
|
from ..log import log
|
||||||
from ..utils import np2tensor, pil2tensor, tensor2np, tensor2pil
|
from ..utils import pil2tensor, tensor2np, tensor2pil
|
||||||
|
|
||||||
# try:
|
# try:
|
||||||
# from cv2.ximgproc import guidedFilter
|
# from cv2.ximgproc import guidedFilter
|
||||||
@@ -21,9 +22,7 @@ from ..utils import np2tensor, pil2tensor, tensor2np, tensor2pil
|
|||||||
# log.warning("cv2.ximgproc.guidedFilter not found, use opencv-contrib-python")
|
# log.warning("cv2.ximgproc.guidedFilter not found, use opencv-contrib-python")
|
||||||
|
|
||||||
|
|
||||||
def gaussian_kernel(
|
def gaussian_kernel(kernel_size: int, sigma_x: float, sigma_y: float, device=None):
|
||||||
kernel_size: int, sigma_x: float, sigma_y: float, device=None
|
|
||||||
):
|
|
||||||
x, y = torch.meshgrid(
|
x, y = torch.meshgrid(
|
||||||
torch.linspace(-1, 1, kernel_size, device=device),
|
torch.linspace(-1, 1, kernel_size, device=device),
|
||||||
torch.linspace(-1, 1, kernel_size, device=device),
|
torch.linspace(-1, 1, kernel_size, device=device),
|
||||||
@@ -35,7 +34,7 @@ def gaussian_kernel(
|
|||||||
return g / g.sum()
|
return g / g.sum()
|
||||||
|
|
||||||
|
|
||||||
class MTB_ColorCorrect:
|
class ColorCorrect:
|
||||||
"""Various color correction methods"""
|
"""Various color correction methods"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -116,9 +115,7 @@ class MTB_ColorCorrect:
|
|||||||
return pil2tensor(out)
|
return pil2tensor(out)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def hsv_adjustment_tensor_not_working(
|
def hsv_adjustment_tensor_not_working(image: torch.Tensor, hue, saturation, value):
|
||||||
image: torch.Tensor, hue, saturation, value
|
|
||||||
):
|
|
||||||
"""Abandonning for now"""
|
"""Abandonning for now"""
|
||||||
image = image.squeeze(0).permute(2, 0, 1)
|
image = image.squeeze(0).permute(2, 0, 1)
|
||||||
|
|
||||||
@@ -195,7 +192,7 @@ class MTB_ColorCorrect:
|
|||||||
return (image,)
|
return (image,)
|
||||||
|
|
||||||
|
|
||||||
class MTB_ImageCompare:
|
class ImageCompare_:
|
||||||
"""Compare two images and return a difference image"""
|
"""Compare two images and return a difference image"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -231,7 +228,7 @@ class MTB_ImageCompare:
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
class MTB_LoadImageFromUrl:
|
class LoadImageFromUrl_:
|
||||||
"""Load an image from the given URL"""
|
"""Load an image from the given URL"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -254,11 +251,10 @@ class MTB_LoadImageFromUrl:
|
|||||||
def load(self, url):
|
def load(self, url):
|
||||||
# get the image from the url
|
# get the image from the url
|
||||||
image = Image.open(requests.get(url, stream=True).raw)
|
image = Image.open(requests.get(url, stream=True).raw)
|
||||||
image = ImageOps.exif_transpose(image)
|
|
||||||
return (pil2tensor(image),)
|
return (pil2tensor(image),)
|
||||||
|
|
||||||
|
|
||||||
class MTB_Blur:
|
class Blur_:
|
||||||
"""Blur an image using a Gaussian filter."""
|
"""Blur an image using a Gaussian filter."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -268,55 +264,28 @@ class MTB_Blur:
|
|||||||
"image": ("IMAGE",),
|
"image": ("IMAGE",),
|
||||||
"sigmaX": (
|
"sigmaX": (
|
||||||
"FLOAT",
|
"FLOAT",
|
||||||
{"default": 3.0, "min": 0.0, "max": 200.0, "step": 0.01},
|
{"default": 3.0, "min": 0.0, "max": 10.0, "step": 0.01},
|
||||||
),
|
),
|
||||||
"sigmaY": (
|
"sigmaY": (
|
||||||
"FLOAT",
|
"FLOAT",
|
||||||
{"default": 3.0, "min": 0.0, "max": 200.0, "step": 0.01},
|
{"default": 3.0, "min": 0.0, "max": 10.0, "step": 0.01},
|
||||||
),
|
),
|
||||||
},
|
}
|
||||||
"optional": {"sigmasX": ("FLOATS",), "sigmasY": ("FLOATS",)},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("IMAGE",)
|
RETURN_TYPES = ("IMAGE",)
|
||||||
FUNCTION = "blur"
|
FUNCTION = "blur"
|
||||||
CATEGORY = "mtb/image processing"
|
CATEGORY = "mtb/image processing"
|
||||||
|
|
||||||
def blur(
|
def blur(self, image: torch.Tensor, sigmaX, sigmaY):
|
||||||
self, image: torch.Tensor, sigmaX, sigmaY, sigmasX=None, sigmasY=None
|
image = image.numpy()
|
||||||
):
|
image = image.transpose(1, 2, 3, 0)
|
||||||
image_np = image.numpy() * 255
|
image = gaussian(image, sigma=(sigmaX, sigmaY, 0, 0))
|
||||||
|
image = image.transpose(3, 0, 1, 2)
|
||||||
blurred_images = []
|
return (torch.from_numpy(image),)
|
||||||
if sigmasX is not None:
|
|
||||||
if sigmasY is None:
|
|
||||||
sigmasY = sigmasX
|
|
||||||
if len(sigmasX) != image.size(0):
|
|
||||||
raise ValueError(
|
|
||||||
f"SigmasX must have same length as image, sigmasX is {len(sigmasX)} but the batch size is {image.size(0)}"
|
|
||||||
)
|
|
||||||
|
|
||||||
for i in range(image.size(0)):
|
|
||||||
blurred = gaussian(
|
|
||||||
image_np[i],
|
|
||||||
sigma=(sigmasX[i], sigmasY[i], 0),
|
|
||||||
channel_axis=2,
|
|
||||||
)
|
|
||||||
blurred_images.append(blurred)
|
|
||||||
|
|
||||||
image_np = np.array(blurred_images)
|
|
||||||
else:
|
|
||||||
for i in range(image.size(0)):
|
|
||||||
blurred = gaussian(
|
|
||||||
image_np[i], sigma=(sigmaX, sigmaY, 0), channel_axis=2
|
|
||||||
)
|
|
||||||
blurred_images.append(blurred)
|
|
||||||
|
|
||||||
image_np = np.array(blurred_images)
|
|
||||||
return (np2tensor(image_np).squeeze(0),)
|
|
||||||
|
|
||||||
|
|
||||||
class MTB_Sharpen:
|
class Sharpen_:
|
||||||
"""Sharpens an image using a Gaussian kernel."""
|
"""Sharpens an image using a Gaussian kernel."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -375,16 +344,11 @@ class MTB_Sharpen:
|
|||||||
(sharpen_radius, sharpen_radius, sharpen_radius, sharpen_radius),
|
(sharpen_radius, sharpen_radius, sharpen_radius, sharpen_radius),
|
||||||
"reflect",
|
"reflect",
|
||||||
)
|
)
|
||||||
sharpened = F.conv2d(
|
sharpened = F.conv2d(tensor_image, kernel, padding=center, groups=channels)
|
||||||
tensor_image, kernel, padding=center, groups=channels
|
|
||||||
)
|
|
||||||
|
|
||||||
# Remove padding
|
# Remove padding
|
||||||
sharpened = sharpened[
|
sharpened = sharpened[
|
||||||
:,
|
:, :, sharpen_radius:-sharpen_radius, sharpen_radius:-sharpen_radius
|
||||||
:,
|
|
||||||
sharpen_radius:-sharpen_radius,
|
|
||||||
sharpen_radius:-sharpen_radius,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
sharpened = sharpened.permute(0, 2, 3, 1)
|
sharpened = sharpened.permute(0, 2, 3, 1)
|
||||||
@@ -419,7 +383,7 @@ class MTB_Sharpen:
|
|||||||
# return (np2tensor(deglaze_np_img(tensor2np(image))),)
|
# return (np2tensor(deglaze_np_img(tensor2np(image))),)
|
||||||
|
|
||||||
|
|
||||||
class MTB_MaskToImage:
|
class MaskToImage:
|
||||||
"""Converts a mask (alpha) to an RGB image with a color and background"""
|
"""Converts a mask (alpha) to an RGB image with a color and background"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -439,14 +403,12 @@ class MTB_MaskToImage:
|
|||||||
FUNCTION = "render_mask"
|
FUNCTION = "render_mask"
|
||||||
|
|
||||||
def render_mask(self, mask, color, background):
|
def render_mask(self, mask, color, background):
|
||||||
masks = tensor2np(mask)[0]
|
masks = tensor2np(mask)
|
||||||
images = []
|
images = []
|
||||||
for m in masks:
|
for m in masks:
|
||||||
_mask = Image.fromarray(m).convert("L")
|
_mask = Image.fromarray(m).convert("L")
|
||||||
|
|
||||||
log.debug(
|
log.debug(f"Converted mask to PIL Image format, size: {_mask.size}")
|
||||||
f"Converted mask to PIL Image format, size: {_mask.size}"
|
|
||||||
)
|
|
||||||
|
|
||||||
image = Image.new("RGBA", _mask.size, color=color)
|
image = Image.new("RGBA", _mask.size, color=color)
|
||||||
# apply the mask
|
# apply the mask
|
||||||
@@ -463,8 +425,8 @@ class MTB_MaskToImage:
|
|||||||
return (pil2tensor(images),)
|
return (pil2tensor(images),)
|
||||||
|
|
||||||
|
|
||||||
class MTB_ColoredImage:
|
class ColoredImage:
|
||||||
"""Constant color image of given size."""
|
"""Constant color image of given size"""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
pass
|
pass
|
||||||
@@ -489,101 +451,49 @@ class MTB_ColoredImage:
|
|||||||
|
|
||||||
FUNCTION = "render_img"
|
FUNCTION = "render_img"
|
||||||
|
|
||||||
def resize_and_crop(self, img, target_size):
|
|
||||||
# Calculate scaling factors for both dimensions
|
|
||||||
scale_x = target_size[0] / img.width
|
|
||||||
scale_y = target_size[1] / img.height
|
|
||||||
|
|
||||||
# Use the smaller scaling factor to maintain aspect ratio
|
|
||||||
scale = max(scale_x, scale_y)
|
|
||||||
|
|
||||||
# Resize the image based on calculated scale
|
|
||||||
new_size = (int(img.width * scale), int(img.height * scale))
|
|
||||||
img = img.resize(new_size, Image.LANCZOS)
|
|
||||||
|
|
||||||
# Calculate cropping coordinates
|
|
||||||
left = (img.width - target_size[0]) / 2
|
|
||||||
top = (img.height - target_size[1]) / 2
|
|
||||||
right = (img.width + target_size[0]) / 2
|
|
||||||
bottom = (img.height + target_size[1]) / 2
|
|
||||||
|
|
||||||
# Crop and return the image
|
|
||||||
return img.crop((left, top, right, bottom))
|
|
||||||
|
|
||||||
def resize_and_crop_thumbnails(self, img, target_size):
|
|
||||||
img.thumbnail(target_size, Image.LANCZOS)
|
|
||||||
left = (img.width - target_size[0]) / 2
|
|
||||||
top = (img.height - target_size[1]) / 2
|
|
||||||
right = (img.width + target_size[0]) / 2
|
|
||||||
bottom = (img.height + target_size[1]) / 2
|
|
||||||
return img.crop((left, top, right, bottom))
|
|
||||||
|
|
||||||
def render_img(
|
def render_img(
|
||||||
self,
|
self, color, width, height, foreground_image=None, foreground_mask=None
|
||||||
color,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
foreground_image: torch.Tensor | None = None,
|
|
||||||
foreground_mask: torch.Tensor | None = None,
|
|
||||||
):
|
):
|
||||||
image = Image.new("RGBA", (width, height), color=color)
|
image = Image.new("RGBA", (width, height), color=color)
|
||||||
output = []
|
output = []
|
||||||
if foreground_image is not None:
|
if foreground_image is not None:
|
||||||
fg_masks = [None] * foreground_image.size()[0]
|
if foreground_mask is None:
|
||||||
|
fg_images = tensor2pil(foreground_image)
|
||||||
if foreground_mask is not None:
|
for img in fg_images:
|
||||||
fg_size = foreground_image.size()[0]
|
if image.size != img.size:
|
||||||
mask_size = foreground_mask.size()[0]
|
|
||||||
|
|
||||||
if fg_size == 1 and mask_size > fg_size:
|
|
||||||
foreground_image = foreground_image.repeat(
|
|
||||||
mask_size, 1, 1, 1
|
|
||||||
)
|
|
||||||
|
|
||||||
if foreground_image.size()[0] != foreground_mask.size()[0]:
|
|
||||||
raise ValueError(
|
|
||||||
"Foreground image and mask must have same batch size"
|
|
||||||
)
|
|
||||||
fg_masks = tensor2pil(foreground_mask.unsqueeze(-1))
|
|
||||||
|
|
||||||
fg_images = tensor2pil(foreground_image)
|
|
||||||
|
|
||||||
for fg_image, fg_mask in zip(fg_images, fg_masks):
|
|
||||||
# Resize and crop if dimensions mismatch
|
|
||||||
if fg_image.size != image.size:
|
|
||||||
fg_image = self.resize_and_crop(fg_image, image.size)
|
|
||||||
if fg_mask:
|
|
||||||
fg_mask = self.resize_and_crop(fg_mask, image.size)
|
|
||||||
|
|
||||||
if fg_mask:
|
|
||||||
output.append(
|
|
||||||
Image.composite(
|
|
||||||
fg_image.convert("RGBA"),
|
|
||||||
image,
|
|
||||||
fg_mask,
|
|
||||||
).convert("RGB")
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
if fg_image.mode != "RGBA":
|
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Foreground image must be in 'RGBA' mode "
|
f"Dimension mismatch: image {image.size}, img {img.size}"
|
||||||
f"when no mask is provided, got {fg_image.mode}"
|
|
||||||
)
|
)
|
||||||
output.append(
|
|
||||||
Image.alpha_composite(image, fg_image).convert("RGB")
|
|
||||||
)
|
|
||||||
|
|
||||||
else:
|
if img.mode != "RGBA":
|
||||||
if foreground_mask is not None:
|
raise ValueError(
|
||||||
log.warn("Mask ignored because no foreground image is given")
|
f"Foreground image must be in 'RGBA' mode when no mask is provided, got {img.mode}"
|
||||||
output.append(image.convert("RGB"))
|
)
|
||||||
|
|
||||||
|
output.append(Image.alpha_composite(image, img).convert("RGB"))
|
||||||
|
|
||||||
|
elif foreground_image.size[0] != foreground_mask.size[0]:
|
||||||
|
raise ValueError("Foreground image and mask must have same batch size")
|
||||||
|
else:
|
||||||
|
fg_images = tensor2pil(foreground_image)
|
||||||
|
fg_masks = tensor2pil(foreground_mask)
|
||||||
|
output.extend(
|
||||||
|
Image.composite(
|
||||||
|
fg_image.convert("RGBA"),
|
||||||
|
image,
|
||||||
|
fg_mask,
|
||||||
|
).convert("RGB")
|
||||||
|
for fg_image, fg_mask in zip(fg_images, fg_masks)
|
||||||
|
)
|
||||||
|
elif foreground_mask is not None:
|
||||||
|
log.warn("Mask ignored because no foreground image is given")
|
||||||
|
|
||||||
output = pil2tensor(output)
|
output = pil2tensor(output)
|
||||||
|
|
||||||
return (output,)
|
return (output,)
|
||||||
|
|
||||||
|
|
||||||
class MTB_ImagePremultiply:
|
class ImagePremultiply:
|
||||||
"""Premultiply image with mask"""
|
"""Premultiply image with mask"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -622,7 +532,7 @@ class MTB_ImagePremultiply:
|
|||||||
return (pil2tensor(out),)
|
return (pil2tensor(out),)
|
||||||
|
|
||||||
|
|
||||||
class MTB_ImageResizeFactor:
|
class ImageResizeFactor:
|
||||||
"""Extracted mostly from WAS Node Suite, with a few edits (most notably multiple image support) and less features."""
|
"""Extracted mostly from WAS Node Suite, with a few edits (most notably multiple image support) and less features."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -667,9 +577,7 @@ class MTB_ImageResizeFactor:
|
|||||||
):
|
):
|
||||||
# Check if the tensor has the correct dimension
|
# Check if the tensor has the correct dimension
|
||||||
if len(image.shape) not in [3, 4]: # HxWxC or BxHxWxC
|
if len(image.shape) not in [3, 4]: # HxWxC or BxHxWxC
|
||||||
raise ValueError(
|
raise ValueError("Expected image tensor of shape (H, W, C) or (B, H, W, C)")
|
||||||
"Expected image tensor of shape (H, W, C) or (B, H, W, C)"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Transpose to CxHxW or BxCxHxW for PyTorch
|
# Transpose to CxHxW or BxCxHxW for PyTorch
|
||||||
if len(image.shape) == 3:
|
if len(image.shape) == 3:
|
||||||
@@ -716,7 +624,7 @@ class MTB_ImageResizeFactor:
|
|||||||
return (resized_image,)
|
return (resized_image,)
|
||||||
|
|
||||||
|
|
||||||
class MTB_SaveImageGrid:
|
class SaveImageGrid_:
|
||||||
"""Save all the images in the input batch as a grid of images."""
|
"""Save all the images in the input batch as a grid of images."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -781,10 +689,7 @@ class MTB_SaveImageGrid:
|
|||||||
subfolder,
|
subfolder,
|
||||||
filename_prefix,
|
filename_prefix,
|
||||||
) = folder_paths.get_save_image_path(
|
) = folder_paths.get_save_image_path(
|
||||||
filename_prefix,
|
filename_prefix, self.output_dir, images[0].shape[1], images[0].shape[0]
|
||||||
self.output_dir,
|
|
||||||
images[0].shape[1],
|
|
||||||
images[0].shape[0],
|
|
||||||
)
|
)
|
||||||
image_list = []
|
image_list = []
|
||||||
batch_counter = counter
|
batch_counter = counter
|
||||||
@@ -814,18 +719,14 @@ class MTB_SaveImageGrid:
|
|||||||
file = f"{filename}_{counter:05}_.png"
|
file = f"{filename}_{counter:05}_.png"
|
||||||
grid = self.create_image_grid(image_list)
|
grid = self.create_image_grid(image_list)
|
||||||
grid.save(
|
grid.save(
|
||||||
os.path.join(full_output_folder, file),
|
os.path.join(full_output_folder, file), pnginfo=metadata, compress_level=4
|
||||||
pnginfo=metadata,
|
|
||||||
compress_level=4,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
results = [
|
results = [{"filename": file, "subfolder": subfolder, "type": self.type}]
|
||||||
{"filename": file, "subfolder": subfolder, "type": self.type}
|
|
||||||
]
|
|
||||||
return {"ui": {"images": results}}
|
return {"ui": {"images": results}}
|
||||||
|
|
||||||
|
|
||||||
class MTB_ImageTileOffset:
|
class ImageTileOffset:
|
||||||
"""Mimics an old photoshop technique to check for seamless textures"""
|
"""Mimics an old photoshop technique to check for seamless textures"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -833,8 +734,7 @@ class MTB_ImageTileOffset:
|
|||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"image": ("IMAGE",),
|
"image": ("IMAGE",),
|
||||||
"tilesX": ("INT", {"default": 2, "min": 1}),
|
"tiles": ("INT", {"default": 2}),
|
||||||
"tilesY": ("INT", {"default": 2, "min": 1}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -844,19 +744,17 @@ class MTB_ImageTileOffset:
|
|||||||
|
|
||||||
FUNCTION = "tile_image"
|
FUNCTION = "tile_image"
|
||||||
|
|
||||||
def tile_image(
|
def tile_image(self, image: torch.Tensor, tiles: int = 2):
|
||||||
self, image: torch.Tensor, tilesX: int = 2, tilesY: int = 2
|
if tiles < 1:
|
||||||
):
|
|
||||||
if tilesX < 1 or tilesY < 1:
|
|
||||||
raise ValueError("The number of tiles must be at least 1.")
|
raise ValueError("The number of tiles must be at least 1.")
|
||||||
|
|
||||||
batch_size, height, width, channels = image.shape
|
batch_size, height, width, channels = image.shape
|
||||||
tile_height = height // tilesY
|
tile_height = height // tiles
|
||||||
tile_width = width // tilesX
|
tile_width = width // tiles
|
||||||
|
|
||||||
output_image = torch.zeros_like(image)
|
output_image = torch.zeros_like(image)
|
||||||
|
|
||||||
for i, j in itertools.product(range(tilesY), range(tilesX)):
|
for i, j in itertools.product(range(tiles), range(tiles)):
|
||||||
start_h = i * tile_height
|
start_h = i * tile_height
|
||||||
end_h = start_h + tile_height
|
end_h = start_h + tile_height
|
||||||
start_w = j * tile_width
|
start_w = j * tile_width
|
||||||
@@ -864,8 +762,8 @@ class MTB_ImageTileOffset:
|
|||||||
|
|
||||||
tile = image[:, start_h:end_h, start_w:end_w, :]
|
tile = image[:, start_h:end_h, start_w:end_w, :]
|
||||||
|
|
||||||
output_start_h = (i + 1) % tilesY * tile_height
|
output_start_h = (i + 1) % tiles * tile_height
|
||||||
output_start_w = (j + 1) % tilesX * tile_width
|
output_start_w = (j + 1) % tiles * tile_width
|
||||||
output_end_h = output_start_h + tile_height
|
output_end_h = output_start_h + tile_height
|
||||||
output_end_w = output_start_w + tile_width
|
output_end_w = output_start_w + tile_width
|
||||||
|
|
||||||
@@ -877,16 +775,16 @@ class MTB_ImageTileOffset:
|
|||||||
|
|
||||||
|
|
||||||
__nodes__ = [
|
__nodes__ = [
|
||||||
MTB_ColorCorrect,
|
ColorCorrect,
|
||||||
MTB_ImageCompare,
|
ImageCompare_,
|
||||||
MTB_ImageTileOffset,
|
ImageTileOffset,
|
||||||
MTB_Blur,
|
Blur_,
|
||||||
# DeglazeImage,
|
# DeglazeImage,
|
||||||
MTB_MaskToImage,
|
MaskToImage,
|
||||||
MTB_ColoredImage,
|
ColoredImage,
|
||||||
MTB_ImagePremultiply,
|
ImagePremultiply,
|
||||||
MTB_ImageResizeFactor,
|
ImageResizeFactor,
|
||||||
MTB_SaveImageGrid,
|
SaveImageGrid_,
|
||||||
MTB_LoadImageFromUrl,
|
LoadImageFromUrl_,
|
||||||
MTB_Sharpen,
|
Sharpen_,
|
||||||
]
|
]
|
||||||
|
|||||||
+12
-81
@@ -3,8 +3,8 @@ import torch
|
|||||||
from ..log import log
|
from ..log import log
|
||||||
|
|
||||||
|
|
||||||
class MTB_StackImages:
|
class StackImages:
|
||||||
"""Stack the input images horizontally or vertically."""
|
"""Stack the input images horizontally or vertically"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
@@ -20,91 +20,22 @@ class MTB_StackImages:
|
|||||||
|
|
||||||
tensors = list(kwargs.values())
|
tensors = list(kwargs.values())
|
||||||
log.debug(
|
log.debug(
|
||||||
f"Stacking {len(tensors)} tensors "
|
f"Stacking {len(tensors)} tensors {'vertically' if vertical else 'horizontally'}"
|
||||||
f"{'vertically' if vertical else 'horizontally'}"
|
|
||||||
)
|
)
|
||||||
|
log.debug(list(kwargs.keys()))
|
||||||
|
|
||||||
normalized_tensors = [
|
ref_shape = tensors[0].shape
|
||||||
self.normalize_to_rgba(tensor) for tensor in tensors
|
for tensor in tensors[1:]:
|
||||||
]
|
if tensor.shape[1:] != ref_shape[1:]:
|
||||||
|
|
||||||
if vertical:
|
|
||||||
width = normalized_tensors[0].shape[2]
|
|
||||||
if any(tensor.shape[2] != width for tensor in normalized_tensors):
|
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"All tensors must have the same width "
|
"All tensors must have the same dimensions except for the stacking dimension."
|
||||||
"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)
|
dim = 1 if vertical else 2
|
||||||
|
|
||||||
|
stacked_tensor = torch.cat(tensors, dim=dim)
|
||||||
|
|
||||||
return (stacked_tensor,)
|
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)."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
__nodes__ = [StackImages]
|
||||||
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]
|
|
||||||
|
|||||||
+70
-220
@@ -8,136 +8,62 @@ import comfy.model_management as model_management
|
|||||||
import folder_paths
|
import folder_paths
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
|
from comfy.model_management import get_torch_device
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from ..log import log
|
from ..log import log
|
||||||
from ..utils import PIL_FILTER_MAP, output_dir, session_id, tensor2np
|
from ..utils import PIL_FILTER_MAP, audioInputDir, tensor2np
|
||||||
|
|
||||||
|
try:
|
||||||
|
import librosa
|
||||||
|
except ImportError:
|
||||||
|
log.warning("librosa not installed. I/O Audio features will not be available.")
|
||||||
|
|
||||||
|
|
||||||
def get_playlist_path(playlist_name: str, persistant_playlist=False):
|
class LoadAudio_:
|
||||||
if persistant_playlist:
|
"""Load an audio file from the input folder (supports upload)"""
|
||||||
return output_dir / "playlists" / f"{playlist_name}.json"
|
|
||||||
|
|
||||||
return output_dir / "playlists" / session_id / f"{playlist_name}.json"
|
|
||||||
|
|
||||||
|
|
||||||
class ReadPlaylist:
|
|
||||||
"""Read a playlist"""
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"enable": ("BOOLEAN", {"default": True}),
|
"audio": ("AUDIO_UPLOAD",),
|
||||||
"persistant_playlist": ("BOOLEAN", {"default": False}),
|
"sample_rate": ("INT", {"default": 44100}),
|
||||||
"playlist_name": (
|
|
||||||
"STRING",
|
|
||||||
{"default": "playlist_{index:04d}"},
|
|
||||||
),
|
|
||||||
"index": ("INT", {"default": 0, "min": 0}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("PLAYLIST",)
|
RETURN_TYPES = ("AUDIO",)
|
||||||
FUNCTION = "read_playlist"
|
RETURN_NAMES = ("audio",)
|
||||||
CATEGORY = "mtb/IO"
|
FUNCTION = "load_audio"
|
||||||
|
CATEGORY = "mtb/audio"
|
||||||
|
|
||||||
def read_playlist(
|
def load_audio(self, audio: str, sample_rate: int):
|
||||||
self,
|
log.debug(f"Audio file: {audio}")
|
||||||
enable: bool,
|
audio_file_path = audioInputDir / audio
|
||||||
persistant_playlist: bool,
|
log.debug(f"Loading audio file: {audio_file_path}")
|
||||||
playlist_name: str,
|
audio_data, _ = librosa.load(audio_file_path.as_posix(), sr=sample_rate)
|
||||||
index: int,
|
audio_tensor = torch.from_numpy(audio_data).to(get_torch_device())
|
||||||
):
|
return (audio_tensor.unsqueeze(0).float(),)
|
||||||
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:
|
class ExportWithFfmpeg:
|
||||||
"""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"
|
|
||||||
|
|
||||||
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)"""
|
"""Export with FFmpeg (Experimental)"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(cls):
|
def INPUT_TYPES(cls):
|
||||||
return {
|
return {
|
||||||
"optional": {
|
|
||||||
"images": ("IMAGE",),
|
|
||||||
"playlist": ("PLAYLIST",),
|
|
||||||
},
|
|
||||||
"required": {
|
"required": {
|
||||||
|
"images": ("IMAGE",),
|
||||||
|
# "frames": ("FRAMES",),
|
||||||
"fps": ("FLOAT", {"default": 24, "min": 1}),
|
"fps": ("FLOAT", {"default": 24, "min": 1}),
|
||||||
"prefix": ("STRING", {"default": "export"}),
|
"prefix": ("STRING", {"default": "export"}),
|
||||||
"format": (
|
"format": (["mov", "mp4", "mkv", "avi"], {"default": "mov"}),
|
||||||
["mov", "mp4", "mkv", "gif", "avi"],
|
|
||||||
{"default": "mov"},
|
|
||||||
),
|
|
||||||
"codec": (
|
"codec": (
|
||||||
["prores_ks", "libx264", "libx265", "gif"],
|
["prores_ks", "libx264", "libx265"],
|
||||||
{"default": "prores_ks"},
|
{"default": "prores_ks"},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_TYPES = ("VIDEO",)
|
RETURN_TYPES = ("VIDEO",)
|
||||||
@@ -147,99 +73,52 @@ class MTB_ExportWithFfmpeg:
|
|||||||
|
|
||||||
def export_prores(
|
def export_prores(
|
||||||
self,
|
self,
|
||||||
|
images: torch.Tensor,
|
||||||
fps: float,
|
fps: float,
|
||||||
prefix: str,
|
prefix: str,
|
||||||
format: str,
|
format: str,
|
||||||
codec: str,
|
codec: str,
|
||||||
images: Optional[torch.Tensor] = None,
|
prompt=None,
|
||||||
playlist: Optional[List[str]] = None,
|
extra_pnginfo=None,
|
||||||
):
|
):
|
||||||
|
metadata = {}
|
||||||
|
if images.size(0) == 0:
|
||||||
|
return ("",)
|
||||||
|
|
||||||
|
if extra_pnginfo is not None:
|
||||||
|
metadata["extra"] = {}
|
||||||
|
for x in extra_pnginfo:
|
||||||
|
metadata["extra"][x] = json.dumps(extra_pnginfo[x])
|
||||||
|
|
||||||
|
if prompt is not None:
|
||||||
|
metadata["prompt"] = json.dumps(prompt)
|
||||||
|
|
||||||
|
output_dir = Path(folder_paths.get_output_directory())
|
||||||
pix_fmt = "rgb48le" if codec == "prores_ks" else "yuv420p"
|
pix_fmt = "rgb48le" if codec == "prores_ks" else "yuv420p"
|
||||||
file_ext = format
|
file_ext = format
|
||||||
file_id = f"{prefix}_{uuid.uuid4()}.{file_ext}"
|
file_id = f"{prefix}_{uuid.uuid4()}.{file_ext}"
|
||||||
|
|
||||||
if playlist is not None and images is not None:
|
log.debug(f"Exporting to {output_dir / file_id}")
|
||||||
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 ("",)
|
|
||||||
|
|
||||||
frames = tensor2np(images)
|
frames = tensor2np(images)
|
||||||
log.debug(f"Frames type {type(frames[0])}")
|
log.debug(f"Frames type {type(frames[0])}")
|
||||||
log.debug(f"Exporting {len(frames)} frames")
|
log.debug(f"Exporting {len(frames)} frames")
|
||||||
|
|
||||||
if codec == "gif":
|
frames = [frame.astype(np.uint16) * 257 for frame in frames]
|
||||||
out_path = (output_dir / file_id).as_posix()
|
|
||||||
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()
|
|
||||||
else:
|
|
||||||
frames = [frame.astype(np.uint16) * 257 for frame in frames]
|
|
||||||
|
|
||||||
height, width, _ = frames[0].shape
|
height, width, _ = frames[0].shape
|
||||||
|
|
||||||
out_path = (output_dir / file_id).as_posix()
|
out_path = (output_dir / file_id).as_posix()
|
||||||
|
|
||||||
|
metadata_cmd = []
|
||||||
|
|
||||||
|
if metadata:
|
||||||
|
for k, v in metadata.items():
|
||||||
|
metadata_cmd += [
|
||||||
|
"-metadata:s:v",
|
||||||
|
f"{k}='{v if isinstance(v,str) else json.dumps(v)}'",
|
||||||
|
]
|
||||||
|
|
||||||
# Prepare the FFmpeg command
|
# Prepare the FFmpeg command
|
||||||
command = [
|
command = [
|
||||||
"ffmpeg",
|
"ffmpeg",
|
||||||
@@ -258,6 +137,7 @@ class MTB_ExportWithFfmpeg:
|
|||||||
"-",
|
"-",
|
||||||
"-c:v",
|
"-c:v",
|
||||||
codec,
|
codec,
|
||||||
|
*metadata_cmd,
|
||||||
"-r",
|
"-r",
|
||||||
str(fps),
|
str(fps),
|
||||||
"-y",
|
"-y",
|
||||||
@@ -307,7 +187,7 @@ def prepare_animated_batch(
|
|||||||
|
|
||||||
|
|
||||||
# todo: deprecate for apng
|
# todo: deprecate for apng
|
||||||
class MTB_SaveGif:
|
class SaveGif:
|
||||||
"""Save the images from the batch as a GIF"""
|
"""Save the images from the batch as a GIF"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -319,8 +199,9 @@ class MTB_SaveGif:
|
|||||||
"resize_by": ("FLOAT", {"default": 1.0, "min": 0.1}),
|
"resize_by": ("FLOAT", {"default": 1.0, "min": 0.1}),
|
||||||
"optimize": ("BOOLEAN", {"default": False}),
|
"optimize": ("BOOLEAN", {"default": False}),
|
||||||
"pingpong": ("BOOLEAN", {"default": False}),
|
"pingpong": ("BOOLEAN", {"default": False}),
|
||||||
|
},
|
||||||
|
"optional": {
|
||||||
"resample_filter": (list(PIL_FILTER_MAP.keys()),),
|
"resample_filter": (list(PIL_FILTER_MAP.keys()),),
|
||||||
"use_ffmpeg": ("BOOLEAN", {"default": False}),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +218,6 @@ class MTB_SaveGif:
|
|||||||
optimize=False,
|
optimize=False,
|
||||||
pingpong=False,
|
pingpong=False,
|
||||||
resample_filter=None,
|
resample_filter=None,
|
||||||
use_ffmpeg=False,
|
|
||||||
):
|
):
|
||||||
if image.size(0) == 0:
|
if image.size(0) == 0:
|
||||||
return ("",)
|
return ("",)
|
||||||
@@ -356,48 +236,18 @@ class MTB_SaveGif:
|
|||||||
ruuid = ruuid.hex[:10]
|
ruuid = ruuid.hex[:10]
|
||||||
out_path = f"{folder_paths.output_directory}/{ruuid}.gif"
|
out_path = f"{folder_paths.output_directory}/{ruuid}.gif"
|
||||||
|
|
||||||
if use_ffmpeg:
|
# Create the GIF from PIL images
|
||||||
# Use FFmpeg to create the GIF from PIL images
|
pil_images[0].save(
|
||||||
command = [
|
out_path,
|
||||||
"ffmpeg",
|
save_all=True,
|
||||||
"-f",
|
append_images=pil_images[1:],
|
||||||
"image2pipe",
|
optimize=optimize,
|
||||||
"-vcodec",
|
duration=int(1000 / fps),
|
||||||
"png",
|
loop=0,
|
||||||
"-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()
|
|
||||||
|
|
||||||
else:
|
results = [{"filename": f"{ruuid}.gif", "subfolder": "", "type": "output"}]
|
||||||
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"}
|
|
||||||
]
|
|
||||||
return {"ui": {"gif": results}}
|
return {"ui": {"gif": results}}
|
||||||
|
|
||||||
|
|
||||||
__nodes__ = [
|
__nodes__ = [SaveGif, ExportWithFfmpeg, LoadAudio_]
|
||||||
MTB_SaveGif,
|
|
||||||
MTB_ExportWithFfmpeg,
|
|
||||||
MTB_AddToPlaylist,
|
|
||||||
ReadPlaylist,
|
|
||||||
]
|
|
||||||
|
|||||||
+3
-7
@@ -5,7 +5,7 @@ from rembg import remove
|
|||||||
from ..utils import pil2tensor, tensor2pil
|
from ..utils import pil2tensor, tensor2pil
|
||||||
|
|
||||||
|
|
||||||
class MTB_ImageRemoveBackgroundRembg:
|
class ImageRemoveBackgroundRembg:
|
||||||
"""Removes the background from the input using Rembg."""
|
"""Removes the background from the input using Rembg."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -100,13 +100,9 @@ class MTB_ImageRemoveBackgroundRembg:
|
|||||||
|
|
||||||
pbar.update(1)
|
pbar.update(1)
|
||||||
|
|
||||||
return (
|
return (pil2tensor(out_img), pil2tensor(out_mask), pil2tensor(out_img_on_bg))
|
||||||
pil2tensor(out_img),
|
|
||||||
pil2tensor(out_mask),
|
|
||||||
pil2tensor(out_img_on_bg),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
__nodes__ = [
|
__nodes__ = [
|
||||||
MTB_ImageRemoveBackgroundRembg,
|
ImageRemoveBackgroundRembg,
|
||||||
]
|
]
|
||||||
|
|||||||
+10
-66
@@ -1,13 +1,11 @@
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch.nn import functional as F
|
|
||||||
from torch.nn.modules.utils import _pair
|
|
||||||
|
|
||||||
from ..log import log
|
from ..log import log
|
||||||
|
|
||||||
|
|
||||||
class MTB_VaeDecode:
|
class VaeDecode_:
|
||||||
"""Wrapper for the 2 core decoders but also adding the sd seamless hack, taken from: FlyingFireCo/tiled_ksampler"""
|
"""Wrapper for the 2 core decoders but also adding the sd seamless hack, taken from: FlyingFireCo/tiled_ksampler"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -31,12 +29,7 @@ class MTB_VaeDecode:
|
|||||||
CATEGORY = "mtb/decode"
|
CATEGORY = "mtb/decode"
|
||||||
|
|
||||||
def decode(
|
def decode(
|
||||||
self,
|
self, vae, samples, seamless_model, use_tiling_decoder=True, tile_size=512
|
||||||
vae,
|
|
||||||
samples,
|
|
||||||
seamless_model,
|
|
||||||
use_tiling_decoder=True,
|
|
||||||
tile_size=512,
|
|
||||||
):
|
):
|
||||||
if seamless_model:
|
if seamless_model:
|
||||||
if use_tiling_decoder:
|
if use_tiling_decoder:
|
||||||
@@ -62,24 +55,6 @@ class MTB_VaeDecode:
|
|||||||
return (vae.decode(samples["samples"]),)
|
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 ModelPatchSeamless:
|
class ModelPatchSeamless:
|
||||||
"""Uses the stable diffusion 'hack' to infer seamless images by setting the model layers padding mode to circular (experimental)"""
|
"""Uses the stable diffusion 'hack' to infer seamless images by setting the model layers padding mode to circular (experimental)"""
|
||||||
|
|
||||||
@@ -88,16 +63,10 @@ class ModelPatchSeamless:
|
|||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"model": ("MODEL",),
|
"model": ("MODEL",),
|
||||||
"startStep": ("INT", {"default": 0}),
|
"tiling": (
|
||||||
"stopStep": ("INT", {"default": 999}),
|
|
||||||
"tilingX": (
|
|
||||||
"BOOLEAN",
|
"BOOLEAN",
|
||||||
{"default": True},
|
{"default": True},
|
||||||
),
|
), # kept for testing not sure why it should be false
|
||||||
"tilingY": (
|
|
||||||
"BOOLEAN",
|
|
||||||
{"default": True},
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,46 +79,21 @@ class ModelPatchSeamless:
|
|||||||
|
|
||||||
CATEGORY = "mtb/textures"
|
CATEGORY = "mtb/textures"
|
||||||
|
|
||||||
def apply_circular(self, model, startStep, stopStep, x, y):
|
def apply_circular(self, model, enable):
|
||||||
for layer in [
|
for layer in [
|
||||||
layer
|
layer for layer in model.modules() if isinstance(layer, torch.nn.Conv2d)
|
||||||
for layer in model.modules()
|
|
||||||
if isinstance(layer, torch.nn.Conv2d)
|
|
||||||
]:
|
]:
|
||||||
layer.padding_modeX = "circular" if x else "constant"
|
layer.padding_mode = "circular" if enable else "zeros"
|
||||||
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
|
return model
|
||||||
|
|
||||||
def hack(
|
def hack(
|
||||||
self,
|
self,
|
||||||
model,
|
model,
|
||||||
startStep,
|
tiling,
|
||||||
stopStep,
|
|
||||||
tilingX,
|
|
||||||
tilingY,
|
|
||||||
):
|
):
|
||||||
hacked_model = copy.deepcopy(model)
|
hacked_model = copy.deepcopy(model)
|
||||||
self.apply_circular(
|
self.apply_circular(hacked_model.model, tiling)
|
||||||
hacked_model.model, startStep, stopStep, tilingX, tilingY
|
|
||||||
)
|
|
||||||
return (model, hacked_model)
|
return (model, hacked_model)
|
||||||
|
|
||||||
|
|
||||||
__nodes__ = [ModelPatchSeamless, MTB_VaeDecode]
|
__nodes__ = [ModelPatchSeamless, VaeDecode_]
|
||||||
|
|||||||
+6
-6
@@ -1,4 +1,4 @@
|
|||||||
class MTB_IntToBool:
|
class IntToBool:
|
||||||
"""Basic int to bool conversion"""
|
"""Basic int to bool conversion"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -22,7 +22,7 @@ class MTB_IntToBool:
|
|||||||
return (bool(int),)
|
return (bool(int),)
|
||||||
|
|
||||||
|
|
||||||
class MTB_IntToNumber:
|
class IntToNumber:
|
||||||
"""Node addon for the WAS Suite. Converts a "comfy" INT to a NUMBER."""
|
"""Node addon for the WAS Suite. Converts a "comfy" INT to a NUMBER."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -50,7 +50,7 @@ class MTB_IntToNumber:
|
|||||||
return (int,)
|
return (int,)
|
||||||
|
|
||||||
|
|
||||||
class MTB_FloatToNumber:
|
class FloatToNumber:
|
||||||
"""Node addon for the WAS Suite. Converts a "comfy" FLOAT to a NUMBER."""
|
"""Node addon for the WAS Suite. Converts a "comfy" FLOAT to a NUMBER."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -81,7 +81,7 @@ class MTB_FloatToNumber:
|
|||||||
|
|
||||||
|
|
||||||
__nodes__ = [
|
__nodes__ = [
|
||||||
MTB_FloatToNumber,
|
FloatToNumber,
|
||||||
MTB_IntToBool,
|
IntToBool,
|
||||||
MTB_IntToNumber,
|
IntToNumber,
|
||||||
]
|
]
|
||||||
|
|||||||
+10
-15
@@ -1,11 +1,13 @@
|
|||||||
import hashlib, json, os, re
|
import os
|
||||||
from pathlib import Path
|
import re
|
||||||
|
|
||||||
import folder_paths
|
|
||||||
import numpy as np
|
|
||||||
import torch
|
import torch
|
||||||
|
import numpy as np
|
||||||
|
import hashlib
|
||||||
from PIL import Image, ImageOps
|
from PIL import Image, ImageOps
|
||||||
from PIL.PngImagePlugin import PngInfo
|
from PIL.PngImagePlugin import PngInfo
|
||||||
|
import folder_paths
|
||||||
|
from pathlib import Path
|
||||||
|
import json
|
||||||
|
|
||||||
from ..log import log
|
from ..log import log
|
||||||
|
|
||||||
@@ -171,10 +173,7 @@ class SaveImageSequence:
|
|||||||
"required": {
|
"required": {
|
||||||
"images": ("IMAGE",),
|
"images": ("IMAGE",),
|
||||||
"filename_prefix": ("STRING", {"default": "Sequence"}),
|
"filename_prefix": ("STRING", {"default": "Sequence"}),
|
||||||
"current_frame": (
|
"current_frame": ("INT", {"default": 0, "min": 0, "max": 9999999}),
|
||||||
"INT",
|
|
||||||
{"default": 0, "min": 0, "max": 9999999},
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
|
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
|
||||||
}
|
}
|
||||||
@@ -221,14 +220,10 @@ class SaveImageSequence:
|
|||||||
resolved_path = Path(self.output_dir) / filename_prefix
|
resolved_path = Path(self.output_dir) / filename_prefix
|
||||||
resolved_path.mkdir(parents=True, exist_ok=True)
|
resolved_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
resolved_img = (
|
resolved_img = resolved_path / f"{filename_prefix}_{current_frame:05}.png"
|
||||||
resolved_path / f"{filename_prefix}_{current_frame:05}.png"
|
|
||||||
)
|
|
||||||
|
|
||||||
output_image = images[0].cpu().numpy()
|
output_image = images[0].cpu().numpy()
|
||||||
img = Image.fromarray(
|
img = Image.fromarray(np.clip(output_image * 255.0, 0, 255).astype(np.uint8))
|
||||||
np.clip(output_image * 255.0, 0, 255).astype(np.uint8)
|
|
||||||
)
|
|
||||||
metadata = PngInfo()
|
metadata = PngInfo()
|
||||||
if prompt is not None:
|
if prompt is not None:
|
||||||
metadata.add_text("prompt", json.dumps(prompt))
|
metadata.add_text("prompt", json.dumps(prompt))
|
||||||
|
|||||||
-114
@@ -1,114 +0,0 @@
|
|||||||
[tool.poetry]
|
|
||||||
name = "comfy-mtb"
|
|
||||||
version = "0.4.0"
|
|
||||||
description = "Animation oriented nodes pack for ComfyUI."
|
|
||||||
license = "MIT"
|
|
||||||
readme = "README.md"
|
|
||||||
repository = "https://github.com/melMass/comfy_mtb"
|
|
||||||
authors = ["Mel Massadian"]
|
|
||||||
packages = [{ include = "comfy-mtb" }]
|
|
||||||
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",
|
|
||||||
]
|
|
||||||
|
|
||||||
[tool.poetry.urls]
|
|
||||||
"Bug Tracker" = "https://github.com/melMass/comfy_mtb/issues"
|
|
||||||
"Changelog" = "https://github.com/melMass/comfy_mtb/releases"
|
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
|
||||||
python = "^3.10"
|
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
|
||||||
black = { extras = ["jupyter"], version = "^23.7.0" }
|
|
||||||
codespell = "^2.2.5"
|
|
||||||
mypy = "^1.5.1"
|
|
||||||
pre-commit = "^3.3.3"
|
|
||||||
pytest = "^7.4.0"
|
|
||||||
pytest-cov = "^4.1.0"
|
|
||||||
pytest-random-order = "^1.1.0"
|
|
||||||
ruff = "^0.0.285"
|
|
||||||
|
|
||||||
[tool.poetry.group.docs]
|
|
||||||
optional = true
|
|
||||||
|
|
||||||
[tool.poetry.group.docs.dependencies]
|
|
||||||
docutils = "0.17.1"
|
|
||||||
jupyter-book = "^0.15.1"
|
|
||||||
sphinx-autobuild = "^2021.3.14"
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
[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)
|
|
||||||
# N802 - invalid-function-name (forced by comfy's arch)
|
|
||||||
ignore = ["D103", "D102", "D100", "N802"]
|
|
||||||
# exclude auto generated file
|
|
||||||
extend-exclude = ["./docs/conf.py"]
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
[tool.poetry-version-plugin]
|
|
||||||
source = "git-tag"
|
|
||||||
|
|
||||||
[build-system]
|
|
||||||
requires = ["poetry-core"]
|
|
||||||
build-backend = "poetry.core.masonry.api"
|
|
||||||
+2
-2
@@ -6,5 +6,5 @@ rembg
|
|||||||
imageio_ffmpeg
|
imageio_ffmpeg
|
||||||
rich
|
rich
|
||||||
rich_argparse
|
rich_argparse
|
||||||
matplotlib
|
librosa
|
||||||
pillow
|
torchaudio
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
$env.GITHUB_TOKEN = (gh auth token)
|
|
||||||
git cliff --tag main | save -f CHANGELOG.md
|
|
||||||
Vendored
-52
@@ -1,52 +0,0 @@
|
|||||||
// Some manual types I use to facilitate developing on top of
|
|
||||||
// Comfy's Litegraph implementation.
|
|
||||||
|
|
||||||
import type { ContextMenuItem, LGraphNode } from '../web/types/litegraph'
|
|
||||||
|
|
||||||
export type { ContextMenuItem } from '../web/types/litegraph'
|
|
||||||
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 ExtendedLGraphNode {
|
|
||||||
onNodeCreated: () => void
|
|
||||||
getExtraMenuOptions: () => ContextMenuItem[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NodeType /*extends LGraphNode*/ {
|
|
||||||
category: str
|
|
||||||
comfyClass: str
|
|
||||||
length: 0
|
|
||||||
name: str
|
|
||||||
nodeData: NodeData
|
|
||||||
prototype: LGraphNode & ExtendedLGraphNode
|
|
||||||
title: str
|
|
||||||
type: str
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NodeInput {
|
|
||||||
required: object
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: for prototype overriding
|
|
||||||
export type OnDrawForegroundParams = Parameters<LGraphNode['onDrawForeground']>
|
|
||||||
export type OnMouseDownParams = Parameters<LGraphNode['onMouseDown']>
|
|
||||||
export type OnConnectionsChangeParams = Parameters<
|
|
||||||
LGraphNode['onConnectionsChange']
|
|
||||||
>
|
|
||||||
export type OnNodeCreatedParams = Parameters<
|
|
||||||
ExtendedLGraphNode['onNodeCreated']
|
|
||||||
>
|
|
||||||
|
|
||||||
export interface DocumentationOptions {
|
|
||||||
icon_size?: number
|
|
||||||
icon_margin?: number
|
|
||||||
}
|
|
||||||
@@ -1,9 +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").getExtraMenuOptionsParams} getExtraMenuOptionsParams
|
|
||||||
*/
|
|
||||||
@@ -43,117 +43,6 @@ def make_report():
|
|||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
# region NFOV
|
|
||||||
class numpy_NFOV:
|
|
||||||
def __init__(self, fov=None, height: int = 400, width: int = 800):
|
|
||||||
self.field_of_view = fov or [0.45, 0.45]
|
|
||||||
self.PI = np.pi
|
|
||||||
self.PI_2 = np.pi * 0.5
|
|
||||||
self.PI2 = np.pi * 2.0
|
|
||||||
self.height = height
|
|
||||||
self.width = width
|
|
||||||
self.screen_points = self._get_screen_img()
|
|
||||||
|
|
||||||
def _get_coord_rad(self, is_center_point, center_point=None):
|
|
||||||
if is_center_point:
|
|
||||||
center_point = np.array(center_point)
|
|
||||||
return (center_point * 2 - 1) * np.array([self.PI, self.PI_2])
|
|
||||||
else:
|
|
||||||
return (
|
|
||||||
(self.screen_points * 2 - 1)
|
|
||||||
* np.array([self.PI, self.PI_2])
|
|
||||||
* (np.ones(self.screen_points.shape) * self.field_of_view)
|
|
||||||
)
|
|
||||||
|
|
||||||
def _get_screen_img(self):
|
|
||||||
xx, yy = np.meshgrid(
|
|
||||||
np.linspace(0, 1, self.width), np.linspace(0, 1, self.height)
|
|
||||||
)
|
|
||||||
return np.array([xx.ravel(), yy.ravel()]).T
|
|
||||||
|
|
||||||
def _calc_spherical_to_gnomonic(self, converted_screen_coord):
|
|
||||||
x = converted_screen_coord.T[0]
|
|
||||||
y = converted_screen_coord.T[1]
|
|
||||||
|
|
||||||
rou = np.sqrt(x**2 + y**2)
|
|
||||||
c = np.arctan(rou)
|
|
||||||
sin_c = np.sin(c)
|
|
||||||
cos_c = np.cos(c)
|
|
||||||
|
|
||||||
lat = np.arcsin(
|
|
||||||
cos_c * np.sin(self.cp[1]) + (y * sin_c * np.cos(self.cp[1])) / rou
|
|
||||||
)
|
|
||||||
lon = self.cp[0] + np.arctan2(
|
|
||||||
x * sin_c,
|
|
||||||
rou * np.cos(self.cp[1]) * cos_c - y * np.sin(self.cp[1]) * sin_c,
|
|
||||||
)
|
|
||||||
|
|
||||||
lat = (lat / self.PI_2 + 1.0) * 0.5
|
|
||||||
lon = (lon / self.PI + 1.0) * 0.5
|
|
||||||
|
|
||||||
return np.array([lon, lat]).T
|
|
||||||
|
|
||||||
def _bilinear_interpolation(self, screen_coord):
|
|
||||||
uf = np.mod(screen_coord.T[0], 1) * self.frame_width # long - width
|
|
||||||
vf = np.mod(screen_coord.T[1], 1) * self.frame_height # lat - height
|
|
||||||
|
|
||||||
x0 = np.floor(uf).astype(int) # coord of pixel to bottom left
|
|
||||||
y0 = np.floor(vf).astype(int)
|
|
||||||
x2 = np.add(
|
|
||||||
x0, np.ones(uf.shape).astype(int)
|
|
||||||
) # coords of pixel to top right
|
|
||||||
y2 = np.add(y0, np.ones(vf.shape).astype(int))
|
|
||||||
|
|
||||||
base_y0 = np.multiply(y0, self.frame_width)
|
|
||||||
base_y2 = np.multiply(y2, self.frame_width)
|
|
||||||
|
|
||||||
A_idx = np.add(base_y0, x0)
|
|
||||||
B_idx = np.add(base_y2, x0)
|
|
||||||
C_idx = np.add(base_y0, x2)
|
|
||||||
D_idx = np.add(base_y2, x2)
|
|
||||||
|
|
||||||
flat_img = np.reshape(self.frame, [-1, self.frame_channel])
|
|
||||||
|
|
||||||
A = np.take(flat_img, A_idx, axis=0)
|
|
||||||
B = np.take(flat_img, B_idx, axis=0)
|
|
||||||
C = np.take(flat_img, C_idx, axis=0)
|
|
||||||
D = np.take(flat_img, D_idx, axis=0)
|
|
||||||
|
|
||||||
wa = np.multiply(x2 - uf, y2 - vf)
|
|
||||||
wb = np.multiply(x2 - uf, vf - y0)
|
|
||||||
wc = np.multiply(uf - x0, y2 - vf)
|
|
||||||
wd = np.multiply(uf - x0, vf - y0)
|
|
||||||
|
|
||||||
# interpolate
|
|
||||||
AA = np.multiply(A, np.array([wa, wa, wa]).T)
|
|
||||||
BB = np.multiply(B, np.array([wb, wb, wb]).T)
|
|
||||||
CC = np.multiply(C, np.array([wc, wc, wc]).T)
|
|
||||||
DD = np.multiply(D, np.array([wd, wd, wd]).T)
|
|
||||||
nfov = np.reshape(
|
|
||||||
np.round(AA + BB + CC + DD).astype(np.uint8),
|
|
||||||
[self.height, self.width, 3],
|
|
||||||
)
|
|
||||||
|
|
||||||
return nfov
|
|
||||||
|
|
||||||
def to_nfov(self, frame, center_point):
|
|
||||||
self.frame = frame
|
|
||||||
self.frame_height = frame.shape[0]
|
|
||||||
self.frame_width = frame.shape[1]
|
|
||||||
self.frame_channel = frame.shape[2]
|
|
||||||
|
|
||||||
self.cp = self._get_coord_rad(
|
|
||||||
center_point=center_point, is_center_point=True
|
|
||||||
)
|
|
||||||
converted_screen_coord = self._get_coord_rad(is_center_point=False)
|
|
||||||
return self._bilinear_interpolation(
|
|
||||||
self._calc_spherical_to_gnomonic(converted_screen_coord)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
|
||||||
|
|
||||||
|
|
||||||
# region SERVER Utilities
|
# region SERVER Utilities
|
||||||
class IPChecker:
|
class IPChecker:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -197,9 +86,7 @@ def get_server_info():
|
|||||||
base_url = args.listen
|
base_url = args.listen
|
||||||
if base_url == "0.0.0.0":
|
if base_url == "0.0.0.0":
|
||||||
log.debug("Server set to 0.0.0.0, we will try to resolve the host IP")
|
log.debug("Server set to 0.0.0.0, we will try to resolve the host IP")
|
||||||
base_url = ip_checker.get_working_ip(
|
base_url = ip_checker.get_working_ip(f"http://{{}}:{args.port}/history")
|
||||||
f"http://{{}}:{args.port}/history"
|
|
||||||
)
|
|
||||||
log.debug(f"Setting ip to {base_url}")
|
log.debug(f"Setting ip to {base_url}")
|
||||||
return (base_url, args.port)
|
return (base_url, args.port)
|
||||||
|
|
||||||
@@ -279,9 +166,7 @@ def run_command(cmd, ignored_lines_start=None):
|
|||||||
try:
|
try:
|
||||||
_run_command(shell_cmd, ignored_lines_start)
|
_run_command(shell_cmd, ignored_lines_start)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(
|
print(f"Command failed with return code: {e.returncode}", file=sys.stderr)
|
||||||
f"Command failed with return code: {e.returncode}", file=sys.stderr
|
|
||||||
)
|
|
||||||
print(e.stderr.strip(), file=sys.stderr)
|
print(e.stderr.strip(), file=sys.stderr)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
@@ -329,13 +214,7 @@ def import_install(package_name):
|
|||||||
|
|
||||||
except Exception: # (ImportError, ModuleNotFoundError):
|
except Exception: # (ImportError, ModuleNotFoundError):
|
||||||
run_command(
|
run_command(
|
||||||
[
|
[Path(sys.executable).as_posix(), "-m", "pip", "install", package_spec]
|
||||||
Path(sys.executable).as_posix(),
|
|
||||||
"-m",
|
|
||||||
"pip",
|
|
||||||
"install",
|
|
||||||
package_spec,
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
importlib.import_module(package_name)
|
importlib.import_module(package_name)
|
||||||
|
|
||||||
@@ -359,11 +238,11 @@ here = Path(__file__).parent.absolute()
|
|||||||
# - Construct the absolute path to the ComfyUI directory
|
# - Construct the absolute path to the ComfyUI directory
|
||||||
comfy_dir = Path(folder_paths.base_path)
|
comfy_dir = Path(folder_paths.base_path)
|
||||||
models_dir = Path(folder_paths.models_dir)
|
models_dir = Path(folder_paths.models_dir)
|
||||||
output_dir = Path(folder_paths.output_directory)
|
|
||||||
styles_dir = comfy_dir / "styles"
|
styles_dir = comfy_dir / "styles"
|
||||||
session_id = str(uuid.uuid4())
|
audioInputDir = comfy_dir / "input" / "audio"
|
||||||
|
|
||||||
# - Construct the path to the font file
|
# - Construct the path to the font file
|
||||||
font_path = here / "data" / "font.ttf"
|
font_path = here / "font.ttf"
|
||||||
|
|
||||||
# - Add extern folder to path
|
# - Add extern folder to path
|
||||||
extern_root = here / "extern"
|
extern_root = here / "extern"
|
||||||
@@ -374,7 +253,7 @@ for pth in extern_root.iterdir():
|
|||||||
|
|
||||||
# - Add the ComfyUI directory and custom nodes path to the sys.path list
|
# - Add the ComfyUI directory and custom nodes path to the sys.path list
|
||||||
add_path(comfy_dir)
|
add_path(comfy_dir)
|
||||||
add_path(comfy_dir / "custom_nodes")
|
add_path((comfy_dir / "custom_nodes"))
|
||||||
|
|
||||||
PIL_FILTER_MAP = {
|
PIL_FILTER_MAP = {
|
||||||
"nearest": Image.Resampling.NEAREST,
|
"nearest": Image.Resampling.NEAREST,
|
||||||
@@ -398,9 +277,7 @@ def tensor2pil(image: torch.Tensor) -> List[Image.Image]:
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
Image.fromarray(
|
Image.fromarray(
|
||||||
np.clip(255.0 * image.cpu().numpy().squeeze(), 0, 255).astype(
|
np.clip(255.0 * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8)
|
||||||
np.uint8
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -409,9 +286,7 @@ def pil2tensor(image: Union[Image.Image, List[Image.Image]]) -> torch.Tensor:
|
|||||||
if isinstance(image, list):
|
if isinstance(image, list):
|
||||||
return torch.cat([pil2tensor(img) for img in image], dim=0)
|
return torch.cat([pil2tensor(img) for img in image], dim=0)
|
||||||
|
|
||||||
return torch.from_numpy(
|
return torch.from_numpy(np.array(image).astype(np.float32) / 255.0).unsqueeze(0)
|
||||||
np.array(image).astype(np.float32) / 255.0
|
|
||||||
).unsqueeze(0)
|
|
||||||
|
|
||||||
|
|
||||||
def np2tensor(img_np: Union[np.ndarray, List[np.ndarray]]) -> torch.Tensor:
|
def np2tensor(img_np: Union[np.ndarray, List[np.ndarray]]) -> torch.Tensor:
|
||||||
@@ -429,31 +304,23 @@ def tensor2np(tensor: torch.Tensor) -> List[np.ndarray]:
|
|||||||
out.extend(tensor2np(tensor[i]))
|
out.extend(tensor2np(tensor[i]))
|
||||||
return out
|
return out
|
||||||
|
|
||||||
return [
|
return [np.clip(255.0 * tensor.cpu().numpy().squeeze(), 0, 255).astype(np.uint8)]
|
||||||
np.clip(255.0 * tensor.cpu().numpy().squeeze(), 0, 255).astype(
|
|
||||||
np.uint8
|
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def pad(img, left, right, top, bottom):
|
def pad(img, left, right, top, bottom):
|
||||||
pad_width = np.array(((0, 0), (top, bottom), (left, right)))
|
pad_width = np.array(((0, 0), (top, bottom), (left, right)))
|
||||||
print(
|
print(f"pad_width: {pad_width}, shape: {pad_width.shape}") # Debugging line
|
||||||
f"pad_width: {pad_width}, shape: {pad_width.shape}"
|
|
||||||
) # Debugging line
|
|
||||||
return np.pad(img, pad_width, mode="wrap")
|
return np.pad(img, pad_width, mode="wrap")
|
||||||
|
|
||||||
|
|
||||||
def tiles_infer(tiles, ort_session, progress_callback=None):
|
def tiles_infer(tiles, ort_session, progress_callback=None):
|
||||||
"""Infer each tile with the given model. progress_callback will be called with
|
"""Infer each tile with the given model. progress_callback will be called with
|
||||||
arguments : current tile idx and total tiles amount (used to show progress on
|
arguments : current tile idx and total tiles amount (used to show progress on
|
||||||
cursor in Blender).
|
cursor in Blender)."""
|
||||||
"""
|
|
||||||
out_channels = 3 # normal map RGB channels
|
out_channels = 3 # normal map RGB channels
|
||||||
tiles_nb = tiles.shape[0]
|
tiles_nb = tiles.shape[0]
|
||||||
pred_tiles = np.empty(
|
pred_tiles = np.empty((tiles_nb, out_channels, tiles.shape[2], tiles.shape[3]))
|
||||||
(tiles_nb, out_channels, tiles.shape[2], tiles.shape[3])
|
|
||||||
)
|
|
||||||
|
|
||||||
for i in range(tiles_nb):
|
for i in range(tiles_nb):
|
||||||
if progress_callback != None:
|
if progress_callback != None:
|
||||||
@@ -467,6 +334,7 @@ def tiles_infer(tiles, ort_session, progress_callback=None):
|
|||||||
|
|
||||||
def generate_mask(tile_size, stride_size):
|
def generate_mask(tile_size, stride_size):
|
||||||
"""Generates a pyramidal-like mask. Used for mixing overlapping predicted tiles."""
|
"""Generates a pyramidal-like mask. Used for mixing overlapping predicted tiles."""
|
||||||
|
|
||||||
tile_h, tile_w = tile_size
|
tile_h, tile_w = tile_size
|
||||||
stride_h, stride_w = stride_size
|
stride_h, stride_w = stride_size
|
||||||
ramp_h = tile_h - stride_h
|
ramp_h = tile_h - stride_h
|
||||||
@@ -505,8 +373,8 @@ def generate_mask(tile_size, stride_size):
|
|||||||
|
|
||||||
def corner_mask(side_length):
|
def corner_mask(side_length):
|
||||||
"""Generates the corner part of the pyramidal-like mask.
|
"""Generates the corner part of the pyramidal-like mask.
|
||||||
Currently, only for square shapes.
|
Currently, only for square shapes."""
|
||||||
"""
|
|
||||||
corner = np.zeros([side_length, side_length])
|
corner = np.zeros([side_length, side_length])
|
||||||
|
|
||||||
for h in range(0, side_length):
|
for h in range(0, side_length):
|
||||||
@@ -542,8 +410,8 @@ def scaling_mask(side_length):
|
|||||||
|
|
||||||
def tiles_merge(tiles, stride_size, img_size, paddings):
|
def tiles_merge(tiles, stride_size, img_size, paddings):
|
||||||
"""Merges the list of tiles into one image. img_size is the original size, before
|
"""Merges the list of tiles into one image. img_size is the original size, before
|
||||||
padding.
|
padding."""
|
||||||
"""
|
|
||||||
_, tile_h, tile_w = tiles[0].shape
|
_, tile_h, tile_w = tiles[0].shape
|
||||||
pad_left, pad_right, pad_top, pad_bottom = paddings
|
pad_left, pad_right, pad_top, pad_bottom = paddings
|
||||||
height = img_size[1] + pad_top + pad_bottom
|
height = img_size[1] + pad_top + pad_bottom
|
||||||
@@ -576,8 +444,7 @@ def tiles_merge(tiles, stride_size, img_size, paddings):
|
|||||||
|
|
||||||
def tiles_split(img, tile_size, stride_size):
|
def tiles_split(img, tile_size, stride_size):
|
||||||
"""Returns list of tiles from the given image and the padding used to fit the tiles
|
"""Returns list of tiles from the given image and the padding used to fit the tiles
|
||||||
in it. Input image must have dimension C,H,W.
|
in it. Input image must have dimension C,H,W."""
|
||||||
"""
|
|
||||||
log.debug(f"Splitting img: tile {tile_size}, stride {stride_size} ")
|
log.debug(f"Splitting img: tile {tile_size}, stride {stride_size} ")
|
||||||
tile_h, tile_w = tile_size
|
tile_h, tile_w = tile_size
|
||||||
stride_h, stride_w = stride_size
|
stride_h, stride_w = stride_size
|
||||||
@@ -634,9 +501,7 @@ def tiles_split(img, tile_size, stride_size):
|
|||||||
|
|
||||||
# region MODEL Utilities
|
# region MODEL Utilities
|
||||||
def download_antelopev2():
|
def download_antelopev2():
|
||||||
antelopev2_url = (
|
antelopev2_url = "https://drive.google.com/uc?id=18wEUfMNohBJ4K3Ly5wpTejPfDzp-8fI8"
|
||||||
"https://drive.google.com/uc?id=18wEUfMNohBJ4K3Ly5wpTejPfDzp-8fI8"
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import gdown
|
import gdown
|
||||||
@@ -747,10 +612,7 @@ def apply_easing(value, easing_type):
|
|||||||
return 1
|
return 1
|
||||||
p = 0.3
|
p = 0.3
|
||||||
s = p / 4
|
s = p / 4
|
||||||
return -(
|
return -(math.pow(2, 10 * (t - 1)) * math.sin((t - 1 - s) * (2 * math.pi) / p))
|
||||||
math.pow(2, 10 * (t - 1))
|
|
||||||
* math.sin((t - 1 - s) * (2 * math.pi) / p)
|
|
||||||
)
|
|
||||||
|
|
||||||
def easeOutElastic(t):
|
def easeOutElastic(t):
|
||||||
if t == 0:
|
if t == 0:
|
||||||
@@ -771,13 +633,10 @@ def apply_easing(value, easing_type):
|
|||||||
t = t * 2
|
t = t * 2
|
||||||
if t < 1:
|
if t < 1:
|
||||||
return -0.5 * (
|
return -0.5 * (
|
||||||
math.pow(2, 10 * (t - 1))
|
math.pow(2, 10 * (t - 1)) * math.sin((t - 1 - s) * (2 * math.pi) / p)
|
||||||
* math.sin((t - 1 - s) * (2 * math.pi) / p)
|
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
0.5
|
0.5 * math.pow(2, -10 * (t - 1)) * math.sin((t - 1 - s) * (2 * math.pi) / p)
|
||||||
* math.pow(2, -10 * (t - 1))
|
|
||||||
* math.sin((t - 1 - s) * (2 * math.pi) / p)
|
|
||||||
+ 1
|
+ 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,6 @@ data otherwise:
|
|||||||

|

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

|
|
||||||
|
|
||||||
|
|
||||||
## Standalone
|
## Standalone
|
||||||
These scripts can be taken and placed independently of `comfy_mtb` or any other files, mimicking what pythongosss did for their
|
These scripts can be taken and placed independently of `comfy_mtb` or any other files, mimicking what pythongosss did for their
|
||||||
|
|||||||
+30
-475
@@ -7,74 +7,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Reference the shared typedefs file
|
|
||||||
/// <reference path="../types/typedefs.js" />
|
|
||||||
|
|
||||||
import { app } from '../../scripts/app.js'
|
import { app } from '../../scripts/app.js'
|
||||||
|
|
||||||
// - crude uuid
|
|
||||||
export function makeUUID() {
|
|
||||||
let dt = new Date().getTime()
|
|
||||||
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
||||||
const r = ((dt + Math.random() * 16) % 16) | 0
|
|
||||||
dt = Math.floor(dt / 16)
|
|
||||||
return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16)
|
|
||||||
})
|
|
||||||
return uuid
|
|
||||||
}
|
|
||||||
|
|
||||||
//- local storage manager
|
|
||||||
export class LocalStorageManager {
|
|
||||||
constructor(namespace) {
|
|
||||||
this.namespace = namespace
|
|
||||||
}
|
|
||||||
|
|
||||||
_namespacedKey(key) {
|
|
||||||
return `${this.namespace}:${key}`
|
|
||||||
}
|
|
||||||
|
|
||||||
set(key, value) {
|
|
||||||
const serializedValue = JSON.stringify(value)
|
|
||||||
localStorage.setItem(this._namespacedKey(key), serializedValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
get(key, default_val = null) {
|
|
||||||
const value = localStorage.getItem(this._namespacedKey(key))
|
|
||||||
return value ? JSON.parse(value) : default_val
|
|
||||||
}
|
|
||||||
|
|
||||||
remove(key) {
|
|
||||||
localStorage.removeItem(this._namespacedKey(key))
|
|
||||||
}
|
|
||||||
|
|
||||||
clear() {
|
|
||||||
for (const key of Object.keys(localStorage).filter((k) =>
|
|
||||||
k.startsWith(`${this.namespace}:`),
|
|
||||||
)) {
|
|
||||||
localStorage.removeItem(key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// - log utilities
|
|
||||||
|
|
||||||
function createLogger(emoji, color, consoleMethod = 'log') {
|
|
||||||
return (message, ...args) => {
|
|
||||||
if (window.MTB?.DEBUG) {
|
|
||||||
console[consoleMethod](
|
|
||||||
`%c${emoji} ${message}`,
|
|
||||||
`color: ${color};`,
|
|
||||||
...args,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const infoLogger = createLogger('i', 'yellow')
|
|
||||||
export const warnLogger = createLogger('!', 'orange', 'warn')
|
|
||||||
export const errorLogger = createLogger('🔥', 'red', 'error')
|
|
||||||
export const successLogger = createLogger('✅', 'green')
|
|
||||||
|
|
||||||
export const log = (...args) => {
|
export const log = (...args) => {
|
||||||
if (window.MTB?.DEBUG) {
|
if (window.MTB?.DEBUG) {
|
||||||
console.debug(...args)
|
console.debug(...args)
|
||||||
@@ -114,14 +48,14 @@ export function offsetDOMWidget(
|
|||||||
node,
|
node,
|
||||||
widgetWidth,
|
widgetWidth,
|
||||||
widgetY,
|
widgetY,
|
||||||
height,
|
height
|
||||||
) {
|
) {
|
||||||
const margin = 10
|
const margin = 10
|
||||||
const elRect = ctx.canvas.getBoundingClientRect()
|
const elRect = ctx.canvas.getBoundingClientRect()
|
||||||
const transform = new DOMMatrix()
|
const transform = new DOMMatrix()
|
||||||
.scaleSelf(
|
.scaleSelf(
|
||||||
elRect.width / ctx.canvas.width,
|
elRect.width / ctx.canvas.width,
|
||||||
elRect.height / ctx.canvas.height,
|
elRect.height / ctx.canvas.height
|
||||||
)
|
)
|
||||||
.multiplySelf(ctx.getTransform())
|
.multiplySelf(ctx.getTransform())
|
||||||
.translateSelf(margin, margin + widgetY)
|
.translateSelf(margin, margin + widgetY)
|
||||||
@@ -152,7 +86,7 @@ export function getWidgetType(config) {
|
|||||||
// Special handling for COMBO so we restrict links based on the entries
|
// Special handling for COMBO so we restrict links based on the entries
|
||||||
let type = config?.[0]
|
let type = config?.[0]
|
||||||
let linkType = type
|
let linkType = type
|
||||||
if (Array.isArray(type)) {
|
if (type instanceof Array) {
|
||||||
type = 'COMBO'
|
type = 'COMBO'
|
||||||
linkType = linkType.join(',')
|
linkType = linkType.join(',')
|
||||||
}
|
}
|
||||||
@@ -160,26 +94,23 @@ export function getWidgetType(config) {
|
|||||||
}
|
}
|
||||||
export const setupDynamicConnections = (nodeType, prefix, inputType) => {
|
export const setupDynamicConnections = (nodeType, prefix, inputType) => {
|
||||||
const onNodeCreated = nodeType.prototype.onNodeCreated
|
const onNodeCreated = nodeType.prototype.onNodeCreated
|
||||||
// check if it's a list
|
|
||||||
const inputList = typeof inputType === 'object'
|
|
||||||
nodeType.prototype.onNodeCreated = function () {
|
nodeType.prototype.onNodeCreated = function () {
|
||||||
const r = onNodeCreated ? onNodeCreated.apply(this, []) : undefined
|
const r = onNodeCreated ? onNodeCreated.apply(this, arguments) : undefined
|
||||||
this.addInput(`${prefix}_1`, inputList ? '*' : inputType)
|
this.addInput(`${prefix}_1`, inputType)
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
const onConnectionsChange = nodeType.prototype.onConnectionsChange
|
const onConnectionsChange = nodeType.prototype.onConnectionsChange
|
||||||
|
nodeType.prototype.onConnectionsChange = function (
|
||||||
/**
|
type,
|
||||||
* @param {OnConnectionsChangeParams} args
|
index,
|
||||||
*/
|
connected,
|
||||||
nodeType.prototype.onConnectionsChange = function (...args) {
|
link_info
|
||||||
const [_type, index, connected, _link_info] = args
|
) {
|
||||||
const r = onConnectionsChange
|
const r = onConnectionsChange
|
||||||
? onConnectionsChange.apply(this, args)
|
? onConnectionsChange.apply(this, arguments)
|
||||||
: undefined
|
: undefined
|
||||||
dynamic_connection(this, index, connected, `${prefix}_`, inputList)
|
dynamic_connection(this, index, connected, `${prefix}_`, inputType)
|
||||||
return r
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const dynamic_connection = (
|
export const dynamic_connection = (
|
||||||
@@ -188,13 +119,8 @@ export const dynamic_connection = (
|
|||||||
connected,
|
connected,
|
||||||
connectionPrefix = 'input_',
|
connectionPrefix = 'input_',
|
||||||
connectionType = 'PSDLAYER',
|
connectionType = 'PSDLAYER',
|
||||||
nameArray = [],
|
nameArray = []
|
||||||
) => {
|
) => {
|
||||||
if (!node.inputs[index].name.startsWith(connectionPrefix)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const listConnection = typeof connectionType === 'object'
|
|
||||||
|
|
||||||
// remove all non connected inputs
|
// remove all non connected inputs
|
||||||
if (!connected && node.inputs.length > 1) {
|
if (!connected && node.inputs.length > 1) {
|
||||||
log(`Removing input ${index} (${node.inputs[index].name})`)
|
log(`Removing input ${index} (${node.inputs[index].name})`)
|
||||||
@@ -217,7 +143,7 @@ export const dynamic_connection = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add an extra input
|
// add an extra input
|
||||||
if (node.inputs[node.inputs.length - 1].link !== undefined) {
|
if (node.inputs[node.inputs.length - 1].link != undefined) {
|
||||||
const nextIndex = node.inputs.length
|
const nextIndex = node.inputs.length
|
||||||
const name =
|
const name =
|
||||||
nextIndex < nameArray.length
|
nextIndex < nameArray.length
|
||||||
@@ -226,29 +152,10 @@ export const dynamic_connection = (
|
|||||||
|
|
||||||
log(`Adding input ${nextIndex + 1} (${name})`)
|
log(`Adding input ${nextIndex + 1} (${name})`)
|
||||||
|
|
||||||
node.addInput(name, listConnection ? '*' : connectionType)
|
node.addInput(name, connectionType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calculateTotalChildrenHeight(parentElement) {
|
|
||||||
let totalHeight = 0
|
|
||||||
|
|
||||||
for (const child of parentElement.children) {
|
|
||||||
const style = window.getComputedStyle(child)
|
|
||||||
|
|
||||||
// Get height as an integer (without 'px')
|
|
||||||
const height = Number.parseInt(style.height, 10)
|
|
||||||
|
|
||||||
// Get vertical margin as integers
|
|
||||||
const marginTop = Number.parseInt(style.marginTop, 10)
|
|
||||||
const marginBottom = Number.parseInt(style.marginBottom, 10)
|
|
||||||
|
|
||||||
// Sum up height and vertical margins
|
|
||||||
totalHeight += height + marginTop + marginBottom
|
|
||||||
}
|
|
||||||
|
|
||||||
return totalHeight
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Appends a callback to the extra menu options of a given node type.
|
* Appends a callback to the extra menu options of a given node type.
|
||||||
* @param {*} nodeType
|
* @param {*} nodeType
|
||||||
@@ -256,12 +163,9 @@ export function calculateTotalChildrenHeight(parentElement) {
|
|||||||
*/
|
*/
|
||||||
export function addMenuHandler(nodeType, cb) {
|
export function addMenuHandler(nodeType, cb) {
|
||||||
const getOpts = nodeType.prototype.getExtraMenuOptions
|
const getOpts = nodeType.prototype.getExtraMenuOptions
|
||||||
/**
|
|
||||||
* @returns {ContextMenuItem[]} items
|
|
||||||
*/
|
|
||||||
nodeType.prototype.getExtraMenuOptions = function () {
|
nodeType.prototype.getExtraMenuOptions = function () {
|
||||||
const r = getOpts.apply(this, [])
|
const r = getOpts.apply(this, arguments)
|
||||||
cb.apply(this, [])
|
cb.apply(this, arguments)
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,7 +191,7 @@ export function hideWidget(node, widget, suffix = '') {
|
|||||||
// Hide any linked widgets, e.g. seed+seedControl
|
// Hide any linked widgets, e.g. seed+seedControl
|
||||||
if (widget.linkedWidgets) {
|
if (widget.linkedWidgets) {
|
||||||
for (const w of widget.linkedWidgets) {
|
for (const w of widget.linkedWidgets) {
|
||||||
hideWidget(node, w, `:${widget.name}`)
|
hideWidget(node, w, ':' + widget.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -359,7 +263,7 @@ export function hideWidgetForGood(node, widget, suffix = '') {
|
|||||||
// Hide any linked widgets, e.g. seed+seedControl
|
// Hide any linked widgets, e.g. seed+seedControl
|
||||||
if (widget.linkedWidgets) {
|
if (widget.linkedWidgets) {
|
||||||
for (const w of widget.linkedWidgets) {
|
for (const w of widget.linkedWidgets) {
|
||||||
hideWidgetForGood(node, w, `:${widget.name}`)
|
hideWidgetForGood(node, w, ':' + widget.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -377,7 +281,7 @@ export function fixWidgets(node) {
|
|||||||
// continue
|
// continue
|
||||||
// }
|
// }
|
||||||
const w = node.widgets.find((w) => w.name === matching_widget.name)
|
const w = node.widgets.find((w) => w.name === matching_widget.name)
|
||||||
if (w && w.type !== CONVERTED_TYPE) {
|
if (w && w.type != CONVERTED_TYPE) {
|
||||||
log(w)
|
log(w)
|
||||||
log(`hidding ${w.name}(${w.type}) from ${node.type}`)
|
log(`hidding ${w.name}(${w.type}) from ${node.type}`)
|
||||||
log(node)
|
log(node)
|
||||||
@@ -392,16 +296,16 @@ export function fixWidgets(node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export function inner_value_change(widget, val, event = undefined) {
|
export function inner_value_change(widget, value, event = undefined) {
|
||||||
let value = val
|
if (widget.type == 'number' || widget.type == 'BBOX') {
|
||||||
if (widget.type === 'number' || widget.type === 'BBOX') {
|
|
||||||
value = Number(value)
|
value = Number(value)
|
||||||
} else if (widget.type === 'BOOL') {
|
} else if (widget.type == 'BOOL') {
|
||||||
value = Boolean(value)
|
value = Boolean(value)
|
||||||
}
|
}
|
||||||
widget.value = value
|
widget.value = value
|
||||||
if (
|
if (
|
||||||
widget.options?.property &&
|
widget.options &&
|
||||||
|
widget.options.property &&
|
||||||
node.properties[widget.options.property] !== undefined
|
node.properties[widget.options.property] !== undefined
|
||||||
) {
|
) {
|
||||||
node.setProperty(widget.options.property, value)
|
node.setProperty(widget.options.property, value)
|
||||||
@@ -419,51 +323,14 @@ export function isColorBright(rgb, threshold = 240) {
|
|||||||
|
|
||||||
function getBrightness(rgbObj) {
|
function getBrightness(rgbObj) {
|
||||||
return Math.round(
|
return Math.round(
|
||||||
(Number.parseInt(rgbObj[0]) * 299 +
|
(parseInt(rgbObj[0]) * 299 +
|
||||||
Number.parseInt(rgbObj[1]) * 587 +
|
parseInt(rgbObj[1]) * 587 +
|
||||||
Number.parseInt(rgbObj[2]) * 114) /
|
parseInt(rgbObj[2]) * 114) /
|
||||||
1000,
|
1000
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
//- HTML / CSS UTILS
|
//- HTML / CSS UTILS
|
||||||
export const loadScript = (
|
|
||||||
FILE_URL,
|
|
||||||
async = true,
|
|
||||||
type = 'text/javascript',
|
|
||||||
) => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
try {
|
|
||||||
// Check if the script already exists
|
|
||||||
const existingScript = document.querySelector(`script[src="${FILE_URL}"]`)
|
|
||||||
if (existingScript) {
|
|
||||||
resolve({ status: true, message: 'Script already loaded' })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const scriptEle = document.createElement('script')
|
|
||||||
scriptEle.type = type
|
|
||||||
scriptEle.async = async
|
|
||||||
scriptEle.src = FILE_URL
|
|
||||||
|
|
||||||
scriptEle.addEventListener('load', (_ev) => {
|
|
||||||
resolve({ status: true })
|
|
||||||
})
|
|
||||||
|
|
||||||
scriptEle.addEventListener('error', (_ev) => {
|
|
||||||
reject({
|
|
||||||
status: false,
|
|
||||||
message: `Failed to load the script ${FILE_URL}`,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
document.body.appendChild(scriptEle)
|
|
||||||
} catch (error) {
|
|
||||||
reject(error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function defineClass(className, classStyles) {
|
export function defineClass(className, classStyles) {
|
||||||
const styleSheets = document.styleSheets
|
const styleSheets = document.styleSheets
|
||||||
|
|
||||||
@@ -496,315 +363,3 @@ export function defineClass(className, classStyles) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Prefixes the node title with '[DEPRECATED]' and log the deprecation reason to the console.*/
|
|
||||||
export const addDeprecation = (nodeType, reason) => {
|
|
||||||
const title = nodeType.title
|
|
||||||
nodeType.title = `[DEPRECATED] ${title}`
|
|
||||||
// console.log(nodeType)
|
|
||||||
|
|
||||||
const styles = {
|
|
||||||
title: 'font-size:1.3em;font-weight:900;color:yellow; background: black',
|
|
||||||
reason: 'font-size:1.2em',
|
|
||||||
}
|
|
||||||
console.log(
|
|
||||||
`%c! ${title} is deprecated:%c ${reason}`,
|
|
||||||
styles.title,
|
|
||||||
styles.reason,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const create_documentation_stylesheet = () => {
|
|
||||||
const tag = 'mtb-documentation-stylesheet'
|
|
||||||
|
|
||||||
let styleTag = document.head.querySelector(tag)
|
|
||||||
|
|
||||||
if (!styleTag) {
|
|
||||||
styleTag = document.createElement('style')
|
|
||||||
styleTag.type = 'text/css'
|
|
||||||
styleTag.id = tag
|
|
||||||
|
|
||||||
styleTag.innerHTML = `
|
|
||||||
.documentation-popup {
|
|
||||||
background: var(--comfy-menu-bg);
|
|
||||||
position: absolute;
|
|
||||||
color: var(--fg-color);
|
|
||||||
font: 12px monospace;
|
|
||||||
line-height: 1.5em;
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 6px;
|
|
||||||
pointer-events: "inherit";
|
|
||||||
z-index: 5;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.documentation-wrapper {
|
|
||||||
padding: 0 2em;
|
|
||||||
overflow: auto;
|
|
||||||
max-height: 100%;
|
|
||||||
/* Scrollbar styling for Chrome */
|
|
||||||
&::-webkit-scrollbar {
|
|
||||||
width: 6px;
|
|
||||||
}
|
|
||||||
&::-webkit-scrollbar-track {
|
|
||||||
background: var(--bg-color);
|
|
||||||
}
|
|
||||||
&::-webkit-scrollbar-thumb {
|
|
||||||
background-color: var(--fg-color);
|
|
||||||
border-radius: 6px;
|
|
||||||
border: 3px solid var(--bg-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scrollbar styling for Firefox */
|
|
||||||
scrollbar-width: thin;
|
|
||||||
scrollbar-color: var(--fg-color) var(--bg-color);
|
|
||||||
a {
|
|
||||||
color: yellow;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: orange;
|
|
||||||
}
|
|
||||||
a:hover {
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.documentation-popup img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
.documentation-popup table {
|
|
||||||
border-collapse: collapse;
|
|
||||||
border: 1px var(--border-color) solid;
|
|
||||||
}
|
|
||||||
.documentation-popup th,
|
|
||||||
.documentation-popup td {
|
|
||||||
border: 1px var(--border-color) solid;
|
|
||||||
}
|
|
||||||
.documentation-popup th {
|
|
||||||
background-color: var(--comfy-input-bg);
|
|
||||||
}`
|
|
||||||
document.head.appendChild(styleTag)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let documentationConverter
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add documentation widget to the selected node
|
|
||||||
* @param {NodeData} nodeData
|
|
||||||
* @param {NodeType} nodeType
|
|
||||||
* @param {DocumentationOptions} opts
|
|
||||||
*/
|
|
||||||
export const addDocumentation = (
|
|
||||||
nodeData,
|
|
||||||
nodeType,
|
|
||||||
opts = { icon_size: 14, icon_margin: 4 },
|
|
||||||
) => {
|
|
||||||
if (!nodeData.description) {
|
|
||||||
infoLogger(
|
|
||||||
`Skipping ${nodeData.name} doesn't have a description, skipping...`,
|
|
||||||
)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!documentationConverter) {
|
|
||||||
infoLogger('Initializing our mardown converter')
|
|
||||||
documentationConverter = new showdown.Converter({
|
|
||||||
tables: true,
|
|
||||||
strikethrough: true,
|
|
||||||
emoji: true,
|
|
||||||
ghCodeBlocks: true,
|
|
||||||
tasklists: true,
|
|
||||||
ghMentions: true,
|
|
||||||
smoothLivePreview: true,
|
|
||||||
simplifiedAutoLink: true,
|
|
||||||
parseImgDimensions: true,
|
|
||||||
openLinksInNewWindow: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = opts || {}
|
|
||||||
const iconSize = options.icon_size || 14
|
|
||||||
const iconMargin = options.icon_margin || 4
|
|
||||||
let docElement = null
|
|
||||||
let wrapper = null
|
|
||||||
const drawFg = nodeType.prototype.onDrawForeground
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {OnDrawForegroundParams} args
|
|
||||||
*/
|
|
||||||
nodeType.prototype.onDrawForeground = function (...args) {
|
|
||||||
const [ctx, _canvas] = args
|
|
||||||
const r = drawFg ? drawFg.apply(this, args) : undefined
|
|
||||||
|
|
||||||
if (this.flags.collapsed) return r
|
|
||||||
|
|
||||||
// icon position
|
|
||||||
const x = this.size[0] - iconSize - iconMargin
|
|
||||||
|
|
||||||
if (this.show_doc && docElement === null) {
|
|
||||||
create_documentation_stylesheet()
|
|
||||||
|
|
||||||
docElement = document.createElement('div')
|
|
||||||
docElement.classList.add('documentation-popup')
|
|
||||||
document.body.appendChild(docElement)
|
|
||||||
// docElement.innerHTML = documentationConverter.makeHtml(
|
|
||||||
// nodeData.description,
|
|
||||||
// )
|
|
||||||
|
|
||||||
wrapper = document.createElement('div')
|
|
||||||
wrapper.classList.add('documentation-wrapper')
|
|
||||||
wrapper.innerHTML = documentationConverter.makeHtml(nodeData.description)
|
|
||||||
docElement.appendChild(wrapper)
|
|
||||||
|
|
||||||
// resize handle
|
|
||||||
const resizeHandle = document.createElement('div')
|
|
||||||
resizeHandle.style.width = '10px'
|
|
||||||
resizeHandle.style.height = '10px'
|
|
||||||
// resizeHandle.style.background = 'gray'
|
|
||||||
resizeHandle.style.position = 'absolute'
|
|
||||||
resizeHandle.style.bottom = '0'
|
|
||||||
resizeHandle.style.right = '0'
|
|
||||||
// resizeHandle.style.left = '95%'
|
|
||||||
resizeHandle.style.cursor = 'se-resize'
|
|
||||||
resizeHandle.style.userSelect = 'none'
|
|
||||||
|
|
||||||
const borderColor = getComputedStyle(document.documentElement)
|
|
||||||
.getPropertyValue('--border-color')
|
|
||||||
.trim()
|
|
||||||
resizeHandle.style.borderTop = '10px solid transparent'
|
|
||||||
resizeHandle.style.borderLeft = '10px solid transparent'
|
|
||||||
resizeHandle.style.borderBottom = `10px solid ${borderColor}`
|
|
||||||
resizeHandle.style.borderRight = `10px solid ${borderColor}`
|
|
||||||
|
|
||||||
wrapper.appendChild(resizeHandle)
|
|
||||||
let isResizing = false
|
|
||||||
|
|
||||||
let startX
|
|
||||||
let startY
|
|
||||||
let startWidth
|
|
||||||
let startHeight
|
|
||||||
|
|
||||||
resizeHandle.addEventListener('mousedown', (e) => {
|
|
||||||
e.stopPropagation()
|
|
||||||
isResizing = true
|
|
||||||
startX = e.clientX
|
|
||||||
startY = e.clientY
|
|
||||||
startWidth = Number.parseInt(
|
|
||||||
document.defaultView.getComputedStyle(docElement).width,
|
|
||||||
10,
|
|
||||||
)
|
|
||||||
startHeight = Number.parseInt(
|
|
||||||
document.defaultView.getComputedStyle(docElement).height,
|
|
||||||
10,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('mousemove', (e) => {
|
|
||||||
console.log('Moving mouse')
|
|
||||||
if (!isResizing) return
|
|
||||||
const newWidth = startWidth + e.clientX - startX
|
|
||||||
const newHeight = startHeight + e.clientY - startY
|
|
||||||
|
|
||||||
docElement.style.width = `${newWidth}px`
|
|
||||||
docElement.style.height = `${newHeight}px`
|
|
||||||
|
|
||||||
this.docPos = {
|
|
||||||
width: `${newWidth}px`,
|
|
||||||
height: `${newHeight}px`,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('mouseup', () => {
|
|
||||||
isResizing = false
|
|
||||||
})
|
|
||||||
} else if (!this.show_doc && docElement !== null) {
|
|
||||||
docElement.parentNode.removeChild(docElement)
|
|
||||||
docElement = null
|
|
||||||
}
|
|
||||||
|
|
||||||
// reposition
|
|
||||||
if (this.show_doc && docElement !== null) {
|
|
||||||
const rect = ctx.canvas.getBoundingClientRect()
|
|
||||||
|
|
||||||
const scaleX = rect.width / ctx.canvas.width
|
|
||||||
const scaleY = rect.height / ctx.canvas.height
|
|
||||||
const transform = new DOMMatrix()
|
|
||||||
.scaleSelf(scaleX, scaleY)
|
|
||||||
.multiplySelf(ctx.getTransform())
|
|
||||||
.translateSelf(this.size[0] * scaleX, 0)
|
|
||||||
.translateSelf(10, -32)
|
|
||||||
|
|
||||||
const scale = new DOMMatrix().scaleSelf(transform.a, transform.d)
|
|
||||||
|
|
||||||
Object.assign(docElement.style, {
|
|
||||||
transformOrigin: '0 0',
|
|
||||||
transform: scale,
|
|
||||||
left: `${transform.a + transform.e}px`,
|
|
||||||
top: `${transform.d + transform.f}px`,
|
|
||||||
width: this.docPos ? this.docPos.width : `${this.size[0] * 1.5}px`,
|
|
||||||
height: this.docPos?.height,
|
|
||||||
// width: `${this.size[0] * 2}px`,
|
|
||||||
// height: `${(widget.parent?.inputHeight || 32) - (margin * 2)}px`,
|
|
||||||
// height: `${this.size[1] || this.parent?.inputHeight || 32}px`,
|
|
||||||
|
|
||||||
// background: !node.color ? "" : node.color,
|
|
||||||
// color: "blue", //!node.color ? "" : "white",
|
|
||||||
})
|
|
||||||
|
|
||||||
if (this.docPos === undefined) {
|
|
||||||
this.docPos = {
|
|
||||||
width: docElement.style.width,
|
|
||||||
height: docElement.style.height,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// docElement.style.left = 140 - rect.right + "px";
|
|
||||||
// docElement.style.top = rect.top + "px";
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.save()
|
|
||||||
ctx.translate(x, iconSize - 34) // Position the icon on the canvas
|
|
||||||
ctx.scale(iconSize / 32, iconSize / 32) // Scale the icon to the desired size
|
|
||||||
ctx.strokeStyle = 'rgba(255,255,255,0.3)'
|
|
||||||
|
|
||||||
ctx.lineCap = 'round'
|
|
||||||
ctx.lineJoin = 'round'
|
|
||||||
|
|
||||||
ctx.lineWidth = 2.4
|
|
||||||
// ctx.stroke(questionMark);
|
|
||||||
ctx.font = 'bold 36px monospace'
|
|
||||||
ctx.fillText('?', 0, 24)
|
|
||||||
ctx.restore()
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
const mouseDown = nodeType.prototype.onMouseDown
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {OnMouseDownParams} args
|
|
||||||
*/
|
|
||||||
nodeType.prototype.onMouseDown = function (...args) {
|
|
||||||
const [_event, localPos, _graphCanvas] = args
|
|
||||||
const r = mouseDown ? mouseDown.apply(this, args) : undefined
|
|
||||||
const iconX = this.size[0] - iconSize - iconMargin
|
|
||||||
const iconY = iconSize - 34
|
|
||||||
if (
|
|
||||||
localPos[0] > iconX &&
|
|
||||||
localPos[0] < iconX + iconSize &&
|
|
||||||
localPos[1] > iconY &&
|
|
||||||
localPos[1] < iconY + iconSize
|
|
||||||
) {
|
|
||||||
// Pencil icon was clicked, open the editor
|
|
||||||
// this.openEditorDialog();
|
|
||||||
if (this.show_doc === undefined) {
|
|
||||||
this.show_doc = true
|
|
||||||
} else {
|
|
||||||
this.show_doc = !this.show_doc
|
|
||||||
}
|
|
||||||
return true // Return true to indicate the event was handled
|
|
||||||
}
|
|
||||||
|
|
||||||
return r // Return false to let the event propagate
|
|
||||||
|
|
||||||
// return r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
-262
@@ -1,262 +0,0 @@
|
|||||||
import { app } from '../../scripts/app.js'
|
|
||||||
import * as shared from './comfy_shared.js'
|
|
||||||
import { MtbWidgets } from './mtb_widgets.js'
|
|
||||||
|
|
||||||
export class Constant extends LiteGraph.LGraphNode {
|
|
||||||
constructor() {
|
|
||||||
super()
|
|
||||||
this.uuid = shared.makeUUID()
|
|
||||||
this.collapsable = true
|
|
||||||
|
|
||||||
// this avoid serializing the node when converting to prompt
|
|
||||||
this.isVirtualNode = true
|
|
||||||
|
|
||||||
this.shape = LiteGraph.BOX_SHAPE
|
|
||||||
this.serialize_widgets = true
|
|
||||||
|
|
||||||
// Properties
|
|
||||||
this.addProperty('type', 'number')
|
|
||||||
this.addProperty('value', 0)
|
|
||||||
|
|
||||||
// Inputs and outputs
|
|
||||||
this.addOutput('Output', '*')
|
|
||||||
|
|
||||||
// Widget for selecting the type
|
|
||||||
this.addWidget(
|
|
||||||
'combo',
|
|
||||||
'Type',
|
|
||||||
this.properties.type,
|
|
||||||
(value) => {
|
|
||||||
this.properties.type = value
|
|
||||||
this.updateWidgets()
|
|
||||||
this.updateOutputType()
|
|
||||||
},
|
|
||||||
{
|
|
||||||
values: ['number', 'string', 'vector2', 'vector3', 'vector4', 'color'],
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
// Initialize the node
|
|
||||||
this.updateWidgets()
|
|
||||||
this.updateOutputType()
|
|
||||||
}
|
|
||||||
// NOTE: this is called onPrompt
|
|
||||||
applyToGraph() {
|
|
||||||
this.updateTargetWidgets()
|
|
||||||
}
|
|
||||||
|
|
||||||
configure(info) {
|
|
||||||
super.configure(info)
|
|
||||||
this.properties.type = info.properties.type
|
|
||||||
this.properties.value = info.properties.value
|
|
||||||
|
|
||||||
shared.infoLogger('Configure Constant', { info, node: this })
|
|
||||||
this.updateWidgets()
|
|
||||||
this.updateOutputType()
|
|
||||||
}
|
|
||||||
|
|
||||||
updateWidgets() {
|
|
||||||
// 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)
|
|
||||||
switch (this.properties.type) {
|
|
||||||
case 'color': {
|
|
||||||
if (typeof this.properties.value !== 'string') {
|
|
||||||
this.properties.value = '#ffffff'
|
|
||||||
}
|
|
||||||
const col_widget = this.addCustomWidget(
|
|
||||||
MtbWidgets.COLOR('Value', this.properties.value || '#ff0000'),
|
|
||||||
)
|
|
||||||
col_widget.callback = (col) => {
|
|
||||||
this.properties.value = col
|
|
||||||
this.updateOutput()
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'number':
|
|
||||||
if (typeof this.properties.value !== 'number') {
|
|
||||||
this.properties.value = 0.0
|
|
||||||
}
|
|
||||||
this.addWidget('number', 'Value', this.properties.value, (value) => {
|
|
||||||
this.properties.value = value
|
|
||||||
this.updateOutput()
|
|
||||||
})
|
|
||||||
this.addWidget(
|
|
||||||
'toggle',
|
|
||||||
'Convert to Integer',
|
|
||||||
this.properties.force_int,
|
|
||||||
(value) => {
|
|
||||||
this.properties.force_int = value
|
|
||||||
this.updateOutputType()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
break
|
|
||||||
case 'string': {
|
|
||||||
if (typeof this.properties.value !== 'string') {
|
|
||||||
this.properties.value = `${this.properties.value}`
|
|
||||||
}
|
|
||||||
shared.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))
|
|
||||||
|
|
||||||
if (['string', 'number'].includes(typeof this.properties.value)) {
|
|
||||||
this.properties.value = Array.from({ length: numInputs }, () => 0.0)
|
|
||||||
} else if (this.properties.value.length !== numInputs) {
|
|
||||||
if (this.properties.value.length > numInputs) {
|
|
||||||
this.properties.value = this.properties.value.slice(0, numInputs)
|
|
||||||
} else {
|
|
||||||
this.properties.value = this.properties.value.concat(
|
|
||||||
new Array(numInputs - this.properties.value.length).fill(0.0),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (let i = 0; i < numInputs; i++) {
|
|
||||||
this.addWidget(
|
|
||||||
'number',
|
|
||||||
`Value ${i + 1}`,
|
|
||||||
this.properties.value[i] || 0,
|
|
||||||
(value) => {
|
|
||||||
this.properties.value[i] = value
|
|
||||||
this.updateOutput()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onConnectionsChange(type, slotIndex, isConnected, link, ioSlot) {
|
|
||||||
// super.onConnectionsChange(type, slotIndex, isConnected, link, ioSlot)
|
|
||||||
if (isConnected) {
|
|
||||||
this.updateTargetWidgets([link.id])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateOutputType() {
|
|
||||||
const cur_type = this.outputs[0].type
|
|
||||||
const rm_if_mismatch = (type) => {
|
|
||||||
if (cur_type !== type) {
|
|
||||||
for (let i = 0; i < this.outputs.length; i++) {
|
|
||||||
this.removeOutput(i)
|
|
||||||
}
|
|
||||||
this.addOutput('output', type)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch (this.properties.type) {
|
|
||||||
case 'color':
|
|
||||||
rm_if_mismatch('COLOR')
|
|
||||||
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':
|
|
||||||
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) {
|
|
||||||
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,
|
|
||||||
)
|
|
||||||
if (!tgt_widget) return
|
|
||||||
tgt_widget[0].value = this.properties.value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateOutput() {
|
|
||||||
const value = this.properties.value
|
|
||||||
|
|
||||||
switch (this.properties.type) {
|
|
||||||
case 'color':
|
|
||||||
this.setOutputData(0, value)
|
|
||||||
break
|
|
||||||
case 'number':
|
|
||||||
this.setOutputData(0, Number.parseFloat(value))
|
|
||||||
break
|
|
||||||
case 'string':
|
|
||||||
this.setOutputData(0, value.toString())
|
|
||||||
break
|
|
||||||
case 'vector2':
|
|
||||||
if (value.length >= 2) {
|
|
||||||
this.setOutputData(0, value.slice(0, 2))
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case 'vector3':
|
|
||||||
if (value.length >= 3) {
|
|
||||||
this.setOutputData(0, value.slice(0, 3))
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case 'vector4':
|
|
||||||
if (value.length >= 4) {
|
|
||||||
this.setOutputData(0, value.slice(0, 4))
|
|
||||||
}
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateTargetWidgets()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// app.registerExtension({
|
|
||||||
// name: 'mtb.constant',
|
|
||||||
// registerCustomNodes() {
|
|
||||||
// LiteGraph.registerNodeType('Constant (mtb)', Constant)
|
|
||||||
//
|
|
||||||
// Constant.category = 'mtb/utils'
|
|
||||||
// Constant.title = 'Constant (mtb)'
|
|
||||||
// },
|
|
||||||
// })
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
|
|
||||||
import { app } from '../../scripts/app.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(inputName, defaultValue) {
|
|
||||||
this.name = inputName || "Curve";
|
|
||||||
this._value = defaultValue || [{ x: 0, y: 0 }, { x: 1, y: 1 }];
|
|
||||||
this.type = "FLOAT_CURVE";
|
|
||||||
this.selectedPointIndex = null;
|
|
||||||
this.resize
|
|
||||||
}
|
|
||||||
|
|
||||||
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 < 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 };
|
|
||||||
}
|
|
||||||
|
|
||||||
draw(ctx, node, width, posY, height) {
|
|
||||||
const [cw, ch] = this.computeSize(width)
|
|
||||||
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.fillStyle = "#000";
|
|
||||||
//ctx.fillRect(0, posY, cw, ch);
|
|
||||||
ctx.strokeStyle = "#fff";
|
|
||||||
ctx.lineWidth = 2;
|
|
||||||
|
|
||||||
// normalized coordinates -> canvas coordinates
|
|
||||||
for (let i = 0; i < 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();
|
|
||||||
// this.drawBSpline(ctx, width, height, posY);
|
|
||||||
|
|
||||||
// points
|
|
||||||
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) {
|
|
||||||
// console.debug(event.type, pos, node)
|
|
||||||
let x = pos[0] - node.pos[0]
|
|
||||||
let y = pos[1] - node.pos[1]
|
|
||||||
let 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
detectPoint(localPos, width, height) {
|
|
||||||
const threshold = 20; // TODO: extract
|
|
||||||
for (let i = 0; i < this._value.length; i++) {
|
|
||||||
const p = this._value[i];
|
|
||||||
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 i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 };
|
|
||||||
this._value.push(normalizedPoint);
|
|
||||||
this._value.sort((a, b) => a.x - b.x);
|
|
||||||
this.value = JSON.stringify(this._value);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
this.value = JSON.stringify(this._value);
|
|
||||||
}
|
|
||||||
|
|
||||||
computeSize(width) {
|
|
||||||
return [width, 300];
|
|
||||||
}
|
|
||||||
|
|
||||||
configure(data) {
|
|
||||||
console.log(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
value() {
|
|
||||||
console.debug('Returning value', this._value)
|
|
||||||
return this._value
|
|
||||||
}
|
|
||||||
setValue(value) {
|
|
||||||
console.debug('Setting value', value)
|
|
||||||
this._value = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
app.registerExtension({
|
|
||||||
name: 'mtb.curves',
|
|
||||||
getCustomWidgets: function () {
|
|
||||||
return {
|
|
||||||
FLOAT_CURVE: (node, inputName, inputData, app) => {
|
|
||||||
console.debug('Registering float curve widget');
|
|
||||||
|
|
||||||
return {
|
|
||||||
widget: node.addCustomWidget(
|
|
||||||
new CurveWidget(inputName, inputData[1]?.default)
|
|
||||||
),
|
|
||||||
minWidth: 150,
|
|
||||||
minHeight: 30,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
})
|
|
||||||
+5
-5
@@ -41,7 +41,7 @@ app.registerExtension({
|
|||||||
type,
|
type,
|
||||||
index,
|
index,
|
||||||
connected,
|
connected,
|
||||||
link_info,
|
link_info
|
||||||
) {
|
) {
|
||||||
const r = onConnectionsChange
|
const r = onConnectionsChange
|
||||||
? onConnectionsChange.apply(this, arguments)
|
? onConnectionsChange.apply(this, arguments)
|
||||||
@@ -52,7 +52,7 @@ app.registerExtension({
|
|||||||
//- infer type
|
//- infer type
|
||||||
if (link_info) {
|
if (link_info) {
|
||||||
const fromNode = this.graph._nodes.find(
|
const fromNode = this.graph._nodes.find(
|
||||||
(otherNode) => otherNode.id === link_info.origin_id,
|
(otherNode) => otherNode.id == link_info.origin_id
|
||||||
)
|
)
|
||||||
const type = fromNode.outputs[link_info.origin_slot].type
|
const type = fromNode.outputs[link_info.origin_slot].type
|
||||||
this.inputs[index].type = type
|
this.inputs[index].type = type
|
||||||
@@ -63,7 +63,6 @@ app.registerExtension({
|
|||||||
this.inputs[index].type = '*'
|
this.inputs[index].type = '*'
|
||||||
this.inputs[index].label = `anything_${index + 1}`
|
this.inputs[index].label = `anything_${index + 1}`
|
||||||
}
|
}
|
||||||
return r
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onExecuted = nodeType.prototype.onExecuted
|
const onExecuted = nodeType.prototype.onExecuted
|
||||||
@@ -83,10 +82,11 @@ app.registerExtension({
|
|||||||
this.widgets.length = 1
|
this.widgets.length = 1
|
||||||
}
|
}
|
||||||
let widgetI = 1
|
let widgetI = 1
|
||||||
|
|
||||||
if (message.text) {
|
if (message.text) {
|
||||||
for (const txt of message.text) {
|
for (const txt of message.text) {
|
||||||
const w = this.addCustomWidget(
|
const w = this.addCustomWidget(
|
||||||
MtbWidgets.DEBUG_STRING(`${prefix}_${widgetI}`, escapeHtml(txt)),
|
MtbWidgets.DEBUG_STRING(`${prefix}_${widgetI}`, escapeHtml(txt))
|
||||||
)
|
)
|
||||||
w.parent = this
|
w.parent = this
|
||||||
widgetI++
|
widgetI++
|
||||||
@@ -95,7 +95,7 @@ app.registerExtension({
|
|||||||
if (message.b64_images) {
|
if (message.b64_images) {
|
||||||
for (const img of message.b64_images) {
|
for (const img of message.b64_images) {
|
||||||
const w = this.addCustomWidget(
|
const w = this.addCustomWidget(
|
||||||
MtbWidgets.DEBUG_IMG(`${prefix}_${widgetI}`, img),
|
MtbWidgets.DEBUG_IMG(`${prefix}_${widgetI}`, img)
|
||||||
)
|
)
|
||||||
w.parent = this
|
w.parent = this
|
||||||
widgetI++
|
widgetI++
|
||||||
|
|||||||
Vendored
-3
File diff suppressed because one or more lines are too long
Vendored
-3
File diff suppressed because one or more lines are too long
+6
-28
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
import { api } from '../../scripts/api.js'
|
import { api } from '../../scripts/api.js'
|
||||||
import { app } from '../../scripts/app.js'
|
import { app } from '../../scripts/app.js'
|
||||||
import { LocalStorageManager } from './comfy_shared.js'
|
|
||||||
const styles = {
|
const styles = {
|
||||||
lighbox: {
|
lighbox: {
|
||||||
position: 'fixed',
|
position: 'fixed',
|
||||||
@@ -53,39 +53,17 @@ let currentImageIndex = 0
|
|||||||
const imageUrls = []
|
const imageUrls = []
|
||||||
|
|
||||||
let image_menu = null
|
let image_menu = null
|
||||||
const storage = new LocalStorageManager('mtb')
|
let activated = true
|
||||||
|
|
||||||
let activated = storage.get('image_feed', false)
|
|
||||||
|
|
||||||
app.registerExtension({
|
app.registerExtension({
|
||||||
name: 'mtb.ImageFeed',
|
name: 'mtb.ImageFeed',
|
||||||
setup: () => {
|
|
||||||
app.ui.settings.addSetting({
|
|
||||||
id: 'mtb.imageFeed.enabled',
|
|
||||||
name: '[⚡mtb] Enable image feed',
|
|
||||||
type: 'boolean',
|
|
||||||
defaultValue: true,
|
|
||||||
attrs: {
|
|
||||||
style: {
|
|
||||||
fontFamily: 'monospace',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
async onChange(value) {
|
|
||||||
storage.set('image_feed', value)
|
|
||||||
activated = value
|
|
||||||
},
|
|
||||||
})
|
|
||||||
},
|
|
||||||
init: async () => {
|
init: async () => {
|
||||||
if (!activated) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const pythongossFeed = app.extensions.find(
|
const pythongossFeed = app.extensions.find(
|
||||||
(e) => e.name === 'pysssss.ImageFeed',
|
(e) => e.name == 'pysssss.ImageFeed'
|
||||||
)
|
)
|
||||||
if (pythongossFeed) {
|
if (pythongossFeed) {
|
||||||
console.warn(
|
console.warn(
|
||||||
"[mtb] - Aborting the loading of mtb's imageFeed in favor of pysssss.ImageFeed",
|
"[mtb] - Aborting the loading of mtb's imageFeed in favor of pysssss.ImageFeed"
|
||||||
)
|
)
|
||||||
activated = false // just in case other methods are added later on
|
activated = false // just in case other methods are added later on
|
||||||
return
|
return
|
||||||
@@ -116,7 +94,7 @@ app.registerExtension({
|
|||||||
const lightboxCloseBtn = document.createElement('button')
|
const lightboxCloseBtn = document.createElement('button')
|
||||||
Object.assign(
|
Object.assign(
|
||||||
lightboxCloseBtn.style,
|
lightboxCloseBtn.style,
|
||||||
styles.lightboxBtn({ right: '0', top: '0' }),
|
styles.lightboxBtn({ right: '0', top: '0' })
|
||||||
)
|
)
|
||||||
lightboxCloseBtn.textContent = '❌'
|
lightboxCloseBtn.textContent = '❌'
|
||||||
|
|
||||||
@@ -186,7 +164,7 @@ app.registerExtension({
|
|||||||
//- append to DOM
|
//- append to DOM
|
||||||
document.body.append(imageListContainer)
|
document.body.append(imageListContainer)
|
||||||
|
|
||||||
showBtn.textContent = '🖼'
|
showBtn.textContent = '🖼️'
|
||||||
showBtn.onclick = () => {
|
showBtn.onclick = () => {
|
||||||
imageListContainer.style.display = 'block'
|
imageListContainer.style.display = 'block'
|
||||||
showBtn.style.display = 'none'
|
showBtn.style.display = 'none'
|
||||||
|
|||||||
+247
-87
@@ -7,23 +7,14 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: Use the builtin addDOMWidget everywhere appropriate
|
|
||||||
|
|
||||||
import { app } from '../../scripts/app.js'
|
import { app } from '../../scripts/app.js'
|
||||||
import { api } from '../../scripts/api.js'
|
import { api } from '../../scripts/api.js'
|
||||||
|
|
||||||
import parseCss from './extern/parse-css.js'
|
import parseCss from './extern/parse-css.js'
|
||||||
import * as shared from './comfy_shared.js'
|
import * as shared from './comfy_shared.js'
|
||||||
import { log } from './comfy_shared.js'
|
import { log } from './comfy_shared.js'
|
||||||
import { Constant } from './constant.js'
|
|
||||||
|
|
||||||
// NOTE: new widget types registered by MTB Widgets
|
const newTypes = [, /*'BOOL'*/ 'COLOR', 'BBOX', 'AUDIO_UPLOAD']
|
||||||
const newTypes = [/*'BOOL'*/ , 'COLOR', 'BBOX']
|
|
||||||
|
|
||||||
const deprecated_nodes = {
|
|
||||||
// 'Animation Builder':
|
|
||||||
// 'Kept to avoid breaking older script but replaced by TimeEngine',
|
|
||||||
}
|
|
||||||
|
|
||||||
const withFont = (ctx, font, cb) => {
|
const withFont = (ctx, font, cb) => {
|
||||||
const oldFont = ctx.font
|
const oldFont = ctx.font
|
||||||
@@ -50,10 +41,58 @@ const calculateTextDimensions = (ctx, value, width, fontSize = 16) => {
|
|||||||
const textHeight = (lines.length + 1) * fontSize
|
const textHeight = (lines.length + 1) * fontSize
|
||||||
const maxLineWidth = lines.reduce(
|
const maxLineWidth = lines.reduce(
|
||||||
(maxWidth, line) => Math.max(maxWidth, ctx.measureText(line).width),
|
(maxWidth, line) => Math.max(maxWidth, ctx.measureText(line).width),
|
||||||
0,
|
0
|
||||||
)
|
)
|
||||||
return { textHeight, maxLineWidth }
|
return { textHeight, maxLineWidth }
|
||||||
}
|
}
|
||||||
|
function addPlaybackWidget(node, name, url) {
|
||||||
|
let isTick = true
|
||||||
|
const audio = new Audio(url)
|
||||||
|
const slider = node.addWidget(
|
||||||
|
'slider',
|
||||||
|
'loading',
|
||||||
|
0,
|
||||||
|
(v) => {
|
||||||
|
if (!isTick) {
|
||||||
|
audio.currentTime = v
|
||||||
|
}
|
||||||
|
isTick = false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
min: 0,
|
||||||
|
max: 0,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const button = node.addWidget('button', `Play ${name}`, 'play', () => {
|
||||||
|
try {
|
||||||
|
if (audio.paused) {
|
||||||
|
audio.play()
|
||||||
|
button.name = `Pause ${name}`
|
||||||
|
} else {
|
||||||
|
audio.pause()
|
||||||
|
button.name = `Play ${name}`
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
alert(error)
|
||||||
|
}
|
||||||
|
app.canvas.setDirty(true)
|
||||||
|
})
|
||||||
|
audio.addEventListener('timeupdate', () => {
|
||||||
|
isTick = true
|
||||||
|
slider.value = audio.currentTime
|
||||||
|
app.canvas.setDirty(true)
|
||||||
|
})
|
||||||
|
audio.addEventListener('ended', () => {
|
||||||
|
button.name = `Play ${name}`
|
||||||
|
app.canvas.setDirty(true)
|
||||||
|
})
|
||||||
|
audio.addEventListener('loadedmetadata', () => {
|
||||||
|
slider.options.max = audio.duration
|
||||||
|
slider.name = `(${audio.duration})`
|
||||||
|
app.canvas.setDirty(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const MtbWidgets = {
|
export const MtbWidgets = {
|
||||||
BBOX: (key, val) => {
|
BBOX: (key, val) => {
|
||||||
@@ -113,7 +152,7 @@ export const MtbWidgets = {
|
|||||||
ctx.fillText(
|
ctx.fillText(
|
||||||
this.label || this.name,
|
this.label || this.name,
|
||||||
margin * 2 + 5,
|
margin * 2 + 5,
|
||||||
currentY + H * 0.7,
|
currentY + H * 0.7
|
||||||
)
|
)
|
||||||
ctx.fillStyle = text_color
|
ctx.fillStyle = text_color
|
||||||
ctx.textAlign = 'right'
|
ctx.textAlign = 'right'
|
||||||
@@ -122,10 +161,10 @@ export const MtbWidgets = {
|
|||||||
Number(this.value).toFixed(
|
Number(this.value).toFixed(
|
||||||
this.options?.precision !== undefined
|
this.options?.precision !== undefined
|
||||||
? this.options.precision
|
? this.options.precision
|
||||||
: 3,
|
: 3
|
||||||
),
|
),
|
||||||
widget_width - margin * 2 - 20,
|
widget_width - margin * 2 - 20,
|
||||||
currentY + H * 0.7,
|
currentY + H * 0.7
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,7 +246,7 @@ export const MtbWidgets = {
|
|||||||
this.value = Number(v)
|
this.value = Number(v)
|
||||||
shared.inner_value_change(this, this.value, event)
|
shared.inner_value_change(this, this.value, event)
|
||||||
}.bind(w),
|
}.bind(w),
|
||||||
event,
|
event
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -217,7 +256,7 @@ export const MtbWidgets = {
|
|||||||
function () {
|
function () {
|
||||||
shared.inner_value_change(this, this.value, event)
|
shared.inner_value_change(this, this.value, event)
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
20,
|
20
|
||||||
)
|
)
|
||||||
|
|
||||||
app.canvas.setDirty(true)
|
app.canvas.setDirty(true)
|
||||||
@@ -266,7 +305,7 @@ export const MtbWidgets = {
|
|||||||
border,
|
border,
|
||||||
widgetY + border,
|
widgetY + border,
|
||||||
widgetWidth - border * 2,
|
widgetWidth - border * 2,
|
||||||
height - border * 2,
|
height - border * 2
|
||||||
)
|
)
|
||||||
const color = parseCss(this.value.default || this.value)
|
const color = parseCss(this.value.default || this.value)
|
||||||
if (!color) {
|
if (!color) {
|
||||||
@@ -298,7 +337,6 @@ export const MtbWidgets = {
|
|||||||
|
|
||||||
picker.addEventListener('change', () => {
|
picker.addEventListener('change', () => {
|
||||||
this.value = picker.value
|
this.value = picker.value
|
||||||
this.callback?.(this.value)
|
|
||||||
node.graph._version++
|
node.graph._version++
|
||||||
node.setDirtyCanvas(true, true)
|
node.setDirtyCanvas(true, true)
|
||||||
picker.remove()
|
picker.remove()
|
||||||
@@ -370,7 +408,7 @@ export const MtbWidgets = {
|
|||||||
})
|
})
|
||||||
const widgetWidth = Math.max(
|
const widgetWidth = Math.max(
|
||||||
width || this.width || 32,
|
width || this.width || 32,
|
||||||
dimensions.maxLineWidth,
|
dimensions.maxLineWidth
|
||||||
)
|
)
|
||||||
const widgetHeight = dimensions.textHeight * 1.5
|
const widgetHeight = dimensions.textHeight * 1.5
|
||||||
return [widgetWidth, widgetHeight]
|
return [widgetWidth, widgetHeight]
|
||||||
@@ -394,7 +432,7 @@ export const MtbWidgets = {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: ${fontSize}px;
|
font-size: ${fontSize}px;
|
||||||
color: var(--input-text);
|
color: var(--input-text);
|
||||||
line-height: 1em;
|
line-height: 0;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
`
|
`
|
||||||
w.value = val
|
w.value = val
|
||||||
@@ -402,6 +440,119 @@ export const MtbWidgets = {
|
|||||||
|
|
||||||
return w
|
return w
|
||||||
},
|
},
|
||||||
|
|
||||||
|
AUDIO_UPLOAD: function (name, val) {
|
||||||
|
const w = {
|
||||||
|
name,
|
||||||
|
type: 'audio_upload',
|
||||||
|
value: val,
|
||||||
|
draw: function (ctx, node, widgetWidth, widgetY, height) {
|
||||||
|
const [cw, ch] = this.computeSize(widgetWidth)
|
||||||
|
shared.offsetDOMWidget(this, ctx, node, widgetWidth, widgetY, ch)
|
||||||
|
},
|
||||||
|
computeSize: function (width) {
|
||||||
|
if (width) {
|
||||||
|
return [width, 64]
|
||||||
|
}
|
||||||
|
return [128, 128]
|
||||||
|
},
|
||||||
|
onRemoved: function () {
|
||||||
|
if (this.inputEl) {
|
||||||
|
this.inputEl.remove()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const uploadFile = async (file, node) => {
|
||||||
|
try {
|
||||||
|
const body = new FormData()
|
||||||
|
body.append('name', 'loadAudio')
|
||||||
|
body.append('args', file)
|
||||||
|
const loadAudio = await api.fetchApi('/mtb/actions', {
|
||||||
|
method: 'POST',
|
||||||
|
body,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (loadAudio.status === 200) {
|
||||||
|
const { result } = await loadAudio.json()
|
||||||
|
console.log('received from server', result)
|
||||||
|
console.log(
|
||||||
|
`Getting file /mtb/audio?filename=${encodeURIComponent(
|
||||||
|
result.name
|
||||||
|
)}`
|
||||||
|
)
|
||||||
|
|
||||||
|
w.value = result.name
|
||||||
|
addPlaybackWidget(
|
||||||
|
node,
|
||||||
|
result.name,
|
||||||
|
`/mtb/audio?filename=${encodeURIComponent(result.name)}`
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
alert(loadAudio.status + ' -' + loadAudio.statusText)
|
||||||
|
}
|
||||||
|
// if (resp.status === 200) {
|
||||||
|
// const { name } = await resp.json()
|
||||||
|
// pathWidget.value = name
|
||||||
|
// addPlaybackWidget(
|
||||||
|
// node,
|
||||||
|
// name,
|
||||||
|
// `/samplediffusion/audio?filename=${encodeURIComponent(name)}`
|
||||||
|
// )
|
||||||
|
// } else {
|
||||||
|
// alert(resp.status + ' - ' + resp.statusText)
|
||||||
|
// }
|
||||||
|
} catch (error) {
|
||||||
|
alert(error)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
w.inputEl = document.createElement('div')
|
||||||
|
const hidden_input = document.createElement('input')
|
||||||
|
const label = document.createElement('label')
|
||||||
|
|
||||||
|
const uniqueId = 'input_' + Date.now()
|
||||||
|
Object.assign(hidden_input, {
|
||||||
|
type: 'file',
|
||||||
|
accept: 'audio/mpeg,audio/wav,audio/x-wav',
|
||||||
|
id: uniqueId,
|
||||||
|
style: `
|
||||||
|
width: 0.1px;
|
||||||
|
height: 0.1px;
|
||||||
|
opacity: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
position: absolute;
|
||||||
|
z-index: -1;
|
||||||
|
|
||||||
|
`,
|
||||||
|
onchange: async () => {
|
||||||
|
if (hidden_input.files.length) {
|
||||||
|
console.log(hidden_input.files[0])
|
||||||
|
await uploadFile(hidden_input.files[0], this)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
Object.assign(label, {
|
||||||
|
htmlFor: uniqueId,
|
||||||
|
})
|
||||||
|
label.textContent = 'Upload Audio File'
|
||||||
|
label.style = `
|
||||||
|
font-size: 1.25em;
|
||||||
|
font-weight: 700;
|
||||||
|
font-family: monospace;
|
||||||
|
padding:0.5em;
|
||||||
|
border-radius: 5px;
|
||||||
|
color: white;
|
||||||
|
background-color: #1e1e1e;
|
||||||
|
display: inline-block;
|
||||||
|
`
|
||||||
|
document.body.appendChild(w.inputEl)
|
||||||
|
w.inputEl.appendChild(hidden_input)
|
||||||
|
w.inputEl.appendChild(label)
|
||||||
|
return w
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -427,7 +578,7 @@ const mtb_widgets = {
|
|||||||
setup: () => {
|
setup: () => {
|
||||||
app.ui.settings.addSetting({
|
app.ui.settings.addSetting({
|
||||||
id: 'mtb.Debug.enabled',
|
id: 'mtb.Debug.enabled',
|
||||||
name: '[⚡mtb] Enable Debug (py and js)',
|
name: '[mtb] Enable Debug (py and js)',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
|
||||||
@@ -460,12 +611,6 @@ const mtb_widgets = {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
registerCustomNodes() {
|
|
||||||
LiteGraph.registerNodeType('Constant (mtb)', Constant)
|
|
||||||
|
|
||||||
Constant.category = 'mtb/utils'
|
|
||||||
Constant.title = 'Constant (mtb)'
|
|
||||||
},
|
|
||||||
|
|
||||||
getCustomWidgets: function () {
|
getCustomWidgets: function () {
|
||||||
return {
|
return {
|
||||||
@@ -474,7 +619,7 @@ const mtb_widgets = {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
widget: node.addCustomWidget(
|
widget: node.addCustomWidget(
|
||||||
MtbWidgets.BOOL(inputName, inputData[1]?.default || false),
|
MtbWidgets.BOOL(inputName, inputData[1]?.default || false)
|
||||||
),
|
),
|
||||||
minWidth: 150,
|
minWidth: 150,
|
||||||
minHeight: 30,
|
minHeight: 30,
|
||||||
@@ -485,12 +630,26 @@ const mtb_widgets = {
|
|||||||
console.debug('Registering color')
|
console.debug('Registering color')
|
||||||
return {
|
return {
|
||||||
widget: node.addCustomWidget(
|
widget: node.addCustomWidget(
|
||||||
MtbWidgets.COLOR(inputName, inputData[1]?.default || '#ff0000'),
|
MtbWidgets.COLOR(inputName, inputData[1]?.default || '#ff0000')
|
||||||
),
|
),
|
||||||
minWidth: 150,
|
minWidth: 150,
|
||||||
minHeight: 30,
|
minHeight: 30,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
AUDIO_UPLOAD: (node, inputName, inputData, app) => {
|
||||||
|
console.debug('Registering audio')
|
||||||
|
return {
|
||||||
|
widget: node.addCustomWidget(
|
||||||
|
MtbWidgets.AUDIO_UPLOAD.bind(node)(
|
||||||
|
inputName,
|
||||||
|
inputData[1]?.default || ''
|
||||||
|
)
|
||||||
|
),
|
||||||
|
minWidth: 150,
|
||||||
|
minHeight: 30,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// BBOX: (node, inputName, inputData, app) => {
|
// BBOX: (node, inputName, inputData, app) => {
|
||||||
// console.debug("Registering bbox")
|
// console.debug("Registering bbox")
|
||||||
// return {
|
// return {
|
||||||
@@ -510,6 +669,10 @@ const mtb_widgets = {
|
|||||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||||
// const rinputs = nodeData.input?.required
|
// const rinputs = nodeData.input?.required
|
||||||
|
|
||||||
|
if (!nodeData.name.endsWith('(mtb)')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let has_custom = false
|
let has_custom = false
|
||||||
if (nodeData.input && nodeData.input.required) {
|
if (nodeData.input && nodeData.input.required) {
|
||||||
for (const i of Object.keys(nodeData.input.required)) {
|
for (const i of Object.keys(nodeData.input.required)) {
|
||||||
@@ -577,20 +740,24 @@ const mtb_widgets = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nodeData.name.endsWith('(mtb)')) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// console.log('MTB Node', { description: nodeData.description, nodeType })
|
|
||||||
|
|
||||||
shared.addDocumentation(nodeData, nodeType)
|
|
||||||
|
|
||||||
const deprecation = deprecated_nodes[nodeData.name.replace(' (mtb)', '')]
|
|
||||||
|
|
||||||
if (deprecation) {
|
|
||||||
shared.addDeprecation(nodeType, deprecation)
|
|
||||||
}
|
|
||||||
//- Extending Python Nodes
|
//- Extending Python Nodes
|
||||||
switch (nodeData.name) {
|
switch (nodeData.name) {
|
||||||
|
case 'Psd Save (mtb)': {
|
||||||
|
const onConnectionsChange = nodeType.prototype.onConnectionsChange
|
||||||
|
nodeType.prototype.onConnectionsChange = function (
|
||||||
|
type,
|
||||||
|
index,
|
||||||
|
connected,
|
||||||
|
link_info
|
||||||
|
) {
|
||||||
|
const r = onConnectionsChange
|
||||||
|
? onConnectionsChange.apply(this, arguments)
|
||||||
|
: undefined
|
||||||
|
shared.dynamic_connection(this, index, connected)
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
//TODO: remove this non sense
|
//TODO: remove this non sense
|
||||||
case 'Get Batch From History (mtb)': {
|
case 'Get Batch From History (mtb)': {
|
||||||
const onNodeCreated = nodeType.prototype.onNodeCreated
|
const onNodeCreated = nodeType.prototype.onNodeCreated
|
||||||
@@ -599,7 +766,7 @@ const mtb_widgets = {
|
|||||||
? onNodeCreated.apply(this, arguments)
|
? onNodeCreated.apply(this, arguments)
|
||||||
: undefined
|
: undefined
|
||||||
const internal_count = this.widgets.find(
|
const internal_count = this.widgets.find(
|
||||||
(w) => w.name === 'internal_count',
|
(w) => w.name === 'internal_count'
|
||||||
)
|
)
|
||||||
shared.hideWidgetForGood(this, internal_count)
|
shared.hideWidgetForGood(this, internal_count)
|
||||||
internal_count.afterQueued = function () {
|
internal_count.afterQueued = function () {
|
||||||
@@ -639,24 +806,24 @@ const mtb_widgets = {
|
|||||||
imgURLs = imgURLs.concat(
|
imgURLs = imgURLs.concat(
|
||||||
message.gif.map((params) => {
|
message.gif.map((params) => {
|
||||||
return api.apiURL(
|
return api.apiURL(
|
||||||
'/view?' + new URLSearchParams(params).toString(),
|
'/view?' + new URLSearchParams(params).toString()
|
||||||
)
|
)
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (message.apng) {
|
if (message.apng) {
|
||||||
imgURLs = imgURLs.concat(
|
imgURLs = imgURLs.concat(
|
||||||
message.apng.map((params) => {
|
message.apng.map((params) => {
|
||||||
return api.apiURL(
|
return api.apiURL(
|
||||||
'/view?' + new URLSearchParams(params).toString(),
|
'/view?' + new URLSearchParams(params).toString()
|
||||||
)
|
)
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
let i = 0
|
let i = 0
|
||||||
for (const img of imgURLs) {
|
for (const img of imgURLs) {
|
||||||
const w = this.addCustomWidget(
|
const w = this.addCustomWidget(
|
||||||
MtbWidgets.DEBUG_IMG(`${prefix}_${i}`, img),
|
MtbWidgets.DEBUG_IMG(`${prefix}_${i}`, img)
|
||||||
)
|
)
|
||||||
w.parent = this
|
w.parent = this
|
||||||
i++
|
i++
|
||||||
@@ -684,12 +851,12 @@ const mtb_widgets = {
|
|||||||
this.changeMode(LiteGraph.ALWAYS)
|
this.changeMode(LiteGraph.ALWAYS)
|
||||||
|
|
||||||
const raw_iteration = this.widgets.find(
|
const raw_iteration = this.widgets.find(
|
||||||
(w) => w.name === 'raw_iteration',
|
(w) => w.name === 'raw_iteration'
|
||||||
)
|
)
|
||||||
const raw_loop = this.widgets.find((w) => w.name === 'raw_loop')
|
const raw_loop = this.widgets.find((w) => w.name === 'raw_loop')
|
||||||
|
|
||||||
const total_frames = this.widgets.find(
|
const total_frames = this.widgets.find(
|
||||||
(w) => w.name === 'total_frames',
|
(w) => w.name === 'total_frames'
|
||||||
)
|
)
|
||||||
const loop_count = this.widgets.find((w) => w.name === 'loop_count')
|
const loop_count = this.widgets.find((w) => w.name === 'loop_count')
|
||||||
|
|
||||||
@@ -699,12 +866,12 @@ const mtb_widgets = {
|
|||||||
raw_iteration._value = 0
|
raw_iteration._value = 0
|
||||||
|
|
||||||
const value_preview = this.addCustomWidget(
|
const value_preview = this.addCustomWidget(
|
||||||
MtbWidgets['DEBUG_STRING']('value_preview', 'Idle'),
|
MtbWidgets['DEBUG_STRING']('value_preview', 'Idle')
|
||||||
)
|
)
|
||||||
value_preview.parent = this
|
value_preview.parent = this
|
||||||
|
|
||||||
const loop_preview = this.addCustomWidget(
|
const loop_preview = this.addCustomWidget(
|
||||||
MtbWidgets['DEBUG_STRING']('loop_preview', 'Iteration: Idle'),
|
MtbWidgets['DEBUG_STRING']('loop_preview', 'Iteration: Idle')
|
||||||
)
|
)
|
||||||
loop_preview.parent = this
|
loop_preview.parent = this
|
||||||
|
|
||||||
@@ -722,7 +889,7 @@ const mtb_widgets = {
|
|||||||
'button',
|
'button',
|
||||||
`Reset`,
|
`Reset`,
|
||||||
'reset',
|
'reset',
|
||||||
onReset,
|
onReset
|
||||||
)
|
)
|
||||||
|
|
||||||
const run_button = this.addWidget('button', `Queue`, 'queue', () => {
|
const run_button = this.addWidget('button', `Queue`, 'queue', () => {
|
||||||
@@ -732,7 +899,7 @@ const mtb_widgets = {
|
|||||||
`Started a queue of ${total_frames.value} frames (for ${
|
`Started a queue of ${total_frames.value} frames (for ${
|
||||||
loop_count.value
|
loop_count.value
|
||||||
} loop, so ${total_frames.value * loop_count.value})`,
|
} loop, so ${total_frames.value * loop_count.value})`,
|
||||||
5000,
|
5000
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -763,6 +930,23 @@ const mtb_widgets = {
|
|||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
case 'Text Encore Frames (mtb)': {
|
||||||
|
const onConnectionsChange = nodeType.prototype.onConnectionsChange
|
||||||
|
nodeType.prototype.onConnectionsChange = function (
|
||||||
|
type,
|
||||||
|
index,
|
||||||
|
connected,
|
||||||
|
link_info
|
||||||
|
) {
|
||||||
|
const r = onConnectionsChange
|
||||||
|
? onConnectionsChange.apply(this, arguments)
|
||||||
|
: undefined
|
||||||
|
|
||||||
|
shared.dynamic_connection(this, index, connected)
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
case 'Interpolate Clip Sequential (mtb)': {
|
case 'Interpolate Clip Sequential (mtb)': {
|
||||||
const onNodeCreated = nodeType.prototype.onNodeCreated
|
const onNodeCreated = nodeType.prototype.onNodeCreated
|
||||||
nodeType.prototype.onNodeCreated = function () {
|
nodeType.prototype.onNodeCreated = function () {
|
||||||
@@ -773,7 +957,7 @@ const mtb_widgets = {
|
|||||||
const input = this.addInput(
|
const input = this.addInput(
|
||||||
`replacement_${this.widgets.length}`,
|
`replacement_${this.widgets.length}`,
|
||||||
'STRING',
|
'STRING',
|
||||||
'',
|
''
|
||||||
)
|
)
|
||||||
console.log(input)
|
console.log(input)
|
||||||
this.addWidget('STRING', `replacement_${this.widgets.length}`, '')
|
this.addWidget('STRING', `replacement_${this.widgets.length}`, '')
|
||||||
@@ -790,7 +974,7 @@ const mtb_widgets = {
|
|||||||
'remove',
|
'remove',
|
||||||
function (value, widget, node) {
|
function (value, widget, node) {
|
||||||
console.log(`Button clicked: ${value}`, widget, node)
|
console.log(`Button clicked: ${value}`, widget, node)
|
||||||
},
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
return r
|
return r
|
||||||
@@ -831,16 +1015,15 @@ const mtb_widgets = {
|
|||||||
if (style && style.length >= 1) {
|
if (style && style.length >= 1) {
|
||||||
if (style[0]) {
|
if (style[0]) {
|
||||||
window.MTB?.notify?.(
|
window.MTB?.notify?.(
|
||||||
`Extracted positive from ${this.widgets[0].value}`,
|
`Extracted positive from ${this.widgets[0].value}`
|
||||||
)
|
)
|
||||||
// const tn = LiteGraph.createNode('Text box')
|
const tn = LiteGraph.createNode('Text box')
|
||||||
const tn = LiteGraph.createNode('CLIPTextEncode')
|
|
||||||
app.graph.add(tn)
|
app.graph.add(tn)
|
||||||
tn.title = `${this.widgets[0].value} (Positive)`
|
tn.title = `${this.widgets[0].value} (Positive)`
|
||||||
tn.widgets[0].value = style[0]
|
tn.widgets[0].value = style[0]
|
||||||
} else {
|
} else {
|
||||||
window.MTB?.notify?.(
|
window.MTB?.notify?.(
|
||||||
`No positive to extract for ${this.widgets[0].value}`,
|
`No positive to extract for ${this.widgets[0].value}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -853,15 +1036,15 @@ const mtb_widgets = {
|
|||||||
if (style && style.length >= 2) {
|
if (style && style.length >= 2) {
|
||||||
if (style[1]) {
|
if (style[1]) {
|
||||||
window.MTB?.notify?.(
|
window.MTB?.notify?.(
|
||||||
`Extracted negative from ${this.widgets[0].value}`,
|
`Extracted negative from ${this.widgets[0].value}`
|
||||||
)
|
)
|
||||||
const tn = LiteGraph.createNode('CLIPTextEncode')
|
const tn = LiteGraph.createNode('Text box')
|
||||||
app.graph.add(tn)
|
app.graph.add(tn)
|
||||||
tn.title = `${this.widgets[0].value} (Negative)`
|
tn.title = `${this.widgets[0].value} (Negative)`
|
||||||
tn.widgets[0].value = style[1]
|
tn.widgets[0].value = style[1]
|
||||||
} else {
|
} else {
|
||||||
window.MTB.notify(
|
window.MTB.notify(
|
||||||
`No negative to extract for ${this.widgets[0].value}`,
|
`No negative to extract for ${this.widgets[0].value}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -873,28 +1056,6 @@ const mtb_widgets = {
|
|||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: dynamic nodes
|
|
||||||
case 'Apply Text Template (mtb)': {
|
|
||||||
shared.setupDynamicConnections(nodeType, 'var', '*')
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'Save Data Bundle (mtb)': {
|
|
||||||
shared.setupDynamicConnections(nodeType, 'data', '*') // [MASK,IMAGE]
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'Add To Playlist (mtb)': {
|
|
||||||
shared.setupDynamicConnections(nodeType, 'video', 'VIDEO')
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 'Psd Save (mtb)': {
|
|
||||||
shared.setupDynamicConnections(nodeType, 'input_', 'PSDLAYER')
|
|
||||||
break
|
|
||||||
}
|
|
||||||
// case 'Text Encode Frames (mtb)' : {
|
|
||||||
// shared.setupDynamicConnections(nodeType, 'input_', 'IMAGE')
|
|
||||||
// break
|
|
||||||
// }
|
|
||||||
case 'Stack Images (mtb)':
|
case 'Stack Images (mtb)':
|
||||||
case 'Concat Images (mtb)': {
|
case 'Concat Images (mtb)': {
|
||||||
shared.setupDynamicConnections(nodeType, 'image', 'IMAGE')
|
shared.setupDynamicConnections(nodeType, 'image', 'IMAGE')
|
||||||
@@ -911,7 +1072,6 @@ const mtb_widgets = {
|
|||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// TODO: remove this, recommend pythongoss's version that is much better
|
|
||||||
case 'Math Expression (mtb)': {
|
case 'Math Expression (mtb)': {
|
||||||
const onNodeCreated = nodeType.prototype.onNodeCreated
|
const onNodeCreated = nodeType.prototype.onNodeCreated
|
||||||
nodeType.prototype.onNodeCreated = function () {
|
nodeType.prototype.onNodeCreated = function () {
|
||||||
@@ -927,7 +1087,7 @@ const mtb_widgets = {
|
|||||||
type,
|
type,
|
||||||
index,
|
index,
|
||||||
connected,
|
connected,
|
||||||
link_info,
|
link_info
|
||||||
) {
|
) {
|
||||||
const r = onConnectionsChange
|
const r = onConnectionsChange
|
||||||
? onConnectionsChange.apply(this, arguments)
|
? onConnectionsChange.apply(this, arguments)
|
||||||
@@ -941,7 +1101,7 @@ const mtb_widgets = {
|
|||||||
//- infer type
|
//- infer type
|
||||||
if (link_info) {
|
if (link_info) {
|
||||||
const fromNode = this.graph._nodes.find(
|
const fromNode = this.graph._nodes.find(
|
||||||
(otherNode) => otherNode.id == link_info.origin_id,
|
(otherNode) => otherNode.id == link_info.origin_id
|
||||||
)
|
)
|
||||||
const type = fromNode.outputs[link_info.origin_slot].type
|
const type = fromNode.outputs[link_info.origin_slot].type
|
||||||
this.inputs[index].type = type
|
this.inputs[index].type = type
|
||||||
|
|||||||
@@ -1,693 +0,0 @@
|
|||||||
import { app } from '../../scripts/app.js'
|
|
||||||
import * as shared from './comfy_shared.js'
|
|
||||||
import { infoLogger, successLogger, errorLogger } from './comfy_shared.js'
|
|
||||||
|
|
||||||
const DEFAULT_CSS = ''
|
|
||||||
const DEFAULT_HTML = `<p style='color:red;font-family:monospace'>
|
|
||||||
Note+
|
|
||||||
</p>`
|
|
||||||
const DEFAULT_MD = '## Note+'
|
|
||||||
const DEFAULT_MODE = 'markdown'
|
|
||||||
const DEFAULT_THEME = 'one_dark'
|
|
||||||
|
|
||||||
const CSS_RESET = `
|
|
||||||
* {
|
|
||||||
font-family: monospace;
|
|
||||||
line-height: 1.25em;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
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 {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
`
|
|
||||||
|
|
||||||
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',
|
|
||||||
]
|
|
||||||
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
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super()
|
|
||||||
this.uuid = shared.makeUUID()
|
|
||||||
|
|
||||||
infoLogger('Constructing Note+ instance')
|
|
||||||
// - 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
|
|
||||||
|
|
||||||
// - mardown converter
|
|
||||||
this.markdownConverter = new showdown.Converter({
|
|
||||||
tables: true,
|
|
||||||
strikethrough: true,
|
|
||||||
emoji: true,
|
|
||||||
ghCodeBlocks: true,
|
|
||||||
tasklists: true,
|
|
||||||
ghMentions: true,
|
|
||||||
smoothLivePreview: true,
|
|
||||||
simplifiedAutoLink: true,
|
|
||||||
parseImgDimensions: true,
|
|
||||||
openLinksInNewWindow: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
// - state
|
|
||||||
this.live = true
|
|
||||||
this.calculated_height = 0
|
|
||||||
|
|
||||||
// - add widgets
|
|
||||||
const inner = document.createElement('div')
|
|
||||||
inner.style.margin = '0'
|
|
||||||
inner.style.padding = '0'
|
|
||||||
inner.style.pointerEvents = 'none'
|
|
||||||
this.html_widget = this.addDOMWidget('HTML', 'html', inner, {
|
|
||||||
setValue: (val) => {
|
|
||||||
this._raw_html = val
|
|
||||||
},
|
|
||||||
getValue: () => this._raw_html,
|
|
||||||
getMinHeight: () => this.calculated_height, // (the edit button),
|
|
||||||
hideOnZoom: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
this.setupSerializationWidgets()
|
|
||||||
this.setupDialog()
|
|
||||||
this.loadAceEditor()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {CanvasRenderingContext2D} ctx
|
|
||||||
* @param {LGraphCanvas} graphcanvas
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
|
|
||||||
onDrawForeground(ctx, _graphcanvas) {
|
|
||||||
if (this.flags.collapsed) return
|
|
||||||
|
|
||||||
// Define the size and position of the icon
|
|
||||||
const iconSize = 14 // Size of the icon
|
|
||||||
const iconMargin = 8 // Margin from the edges
|
|
||||||
const x = this.size[0] - iconSize - iconMargin
|
|
||||||
const y = iconMargin * 1.5
|
|
||||||
|
|
||||||
// Create a new Path2D object from SVG path data
|
|
||||||
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',
|
|
||||||
)
|
|
||||||
|
|
||||||
// Draw the paths
|
|
||||||
ctx.save()
|
|
||||||
ctx.translate(x, y) // Position the icon on the canvas
|
|
||||||
ctx.scale(iconSize / 32, iconSize / 32) // Scale the icon to the desired size
|
|
||||||
ctx.strokeStyle = 'rgba(255,255,255,0.3)'
|
|
||||||
|
|
||||||
ctx.lineCap = 'round'
|
|
||||||
ctx.lineJoin = 'round'
|
|
||||||
|
|
||||||
ctx.lineWidth = 2.4
|
|
||||||
ctx.stroke(pencilPath)
|
|
||||||
ctx.stroke(folderPath)
|
|
||||||
ctx.restore()
|
|
||||||
}
|
|
||||||
onMouseDown(_e, localPos, _graphcanvas) {
|
|
||||||
// Check if the click is within the pencil icon bounds
|
|
||||||
const iconSize = 14
|
|
||||||
const iconMargin = 8
|
|
||||||
const iconX = this.size[0] - iconSize - iconMargin
|
|
||||||
const iconY = iconMargin * 1.5
|
|
||||||
|
|
||||||
if (
|
|
||||||
localPos[0] > iconX &&
|
|
||||||
localPos[0] < iconX + iconSize &&
|
|
||||||
localPos[1] > iconY &&
|
|
||||||
localPos[1] < iconY + iconSize
|
|
||||||
) {
|
|
||||||
// Pencil icon was clicked, open the editor
|
|
||||||
this.openEditorDialog()
|
|
||||||
return true // Return true to indicate the event was handled
|
|
||||||
}
|
|
||||||
|
|
||||||
return false // Return false to let the event propagate
|
|
||||||
}
|
|
||||||
|
|
||||||
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.addWidget('button', 'Edit', 'Edit', this.openEditorDialog.bind(this))
|
|
||||||
|
|
||||||
this.dialog = new app.ui.dialog.constructor()
|
|
||||||
this.dialog.element.classList.add('comfy-settings')
|
|
||||||
|
|
||||||
const closeButton = this.dialog.element.querySelector('button')
|
|
||||||
closeButton.textContent = 'CANCEL'
|
|
||||||
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.updateHTML(this.html_editor.getValue())
|
|
||||||
this.updateCSS(this.css_editor.getValue())
|
|
||||||
}
|
|
||||||
this.teardownEditors()
|
|
||||||
this.dialog.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
openEditorDialog() {
|
|
||||||
infoLogger(`Current edit mode ${this.edit_mode_widget.value}`)
|
|
||||||
const container = document.createElement('div')
|
|
||||||
|
|
||||||
Object.assign(container.style, {
|
|
||||||
display: 'flex',
|
|
||||||
gap: '10px',
|
|
||||||
flexDirection: 'column',
|
|
||||||
})
|
|
||||||
|
|
||||||
const editorsContainer = document.createElement('div')
|
|
||||||
Object.assign(editorsContainer.style, {
|
|
||||||
display: 'flex',
|
|
||||||
gap: '10px',
|
|
||||||
flexDirection: 'row',
|
|
||||||
})
|
|
||||||
|
|
||||||
container.append(editorsContainer)
|
|
||||||
|
|
||||||
this.dialog.show('')
|
|
||||||
this.dialog.textElement.append(container)
|
|
||||||
|
|
||||||
const aceHTML = document.createElement('div')
|
|
||||||
aceHTML.id = 'noteplus-html-editor'
|
|
||||||
Object.assign(aceHTML.style, {
|
|
||||||
width: '300px',
|
|
||||||
height: '300px',
|
|
||||||
// backgroundColor: 'rgb(30,30,30)',
|
|
||||||
// color: 'whitesmoke',
|
|
||||||
})
|
|
||||||
|
|
||||||
editorsContainer.append(aceHTML)
|
|
||||||
|
|
||||||
const aceCSS = document.createElement('div')
|
|
||||||
aceCSS.id = 'noteplus-css-editor'
|
|
||||||
Object.assign(aceCSS.style, {
|
|
||||||
width: '300px',
|
|
||||||
height: '300px',
|
|
||||||
// backgroundColor: 'rgb(30,30,30)',
|
|
||||||
// color: 'whitesmoke',
|
|
||||||
})
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
//- "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'
|
|
||||||
const html = this.markdownConverter.makeHtml(md)
|
|
||||||
this.html_widget.value = html
|
|
||||||
this.html_editor.setValue(html)
|
|
||||||
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
|
|
||||||
}
|
|
||||||
//- 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')
|
|
||||||
}
|
|
||||||
configure(info) {
|
|
||||||
super.configure(info)
|
|
||||||
infoLogger('Restoring serialized values', info)
|
|
||||||
// - update view from serialzed data
|
|
||||||
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)
|
|
||||||
this.setSize(info.size)
|
|
||||||
}
|
|
||||||
onNodeCreated() {
|
|
||||||
infoLogger('Node created', this.uuid)
|
|
||||||
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 options = []
|
|
||||||
// {
|
|
||||||
// content: string;
|
|
||||||
// callback?: ContextMenuEventListener;
|
|
||||||
// /** Used as innerHTML for extra child element */
|
|
||||||
// title?: string;
|
|
||||||
// disabled?: boolean;
|
|
||||||
// has_submenu?: boolean;
|
|
||||||
// submenu?: {
|
|
||||||
// options: ContextMenuItem[];
|
|
||||||
// } & IContextMenuOptions;
|
|
||||||
// className?: string;
|
|
||||||
// }
|
|
||||||
options.push({
|
|
||||||
content: `Set to ${
|
|
||||||
this.edit_mode_widget.value === 'html' ? 'markdown' : 'html'
|
|
||||||
}`,
|
|
||||||
callback: () => {
|
|
||||||
this.edit_mode_widget.value =
|
|
||||||
this.edit_mode_widget.value === 'html' ? 'markdown' : 'html'
|
|
||||||
this.updateHTML(this.html_widget.value)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
return options
|
|
||||||
}
|
|
||||||
|
|
||||||
_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())
|
|
||||||
}
|
|
||||||
|
|
||||||
updateHTML(val) {
|
|
||||||
const cleanHTML = DOMPurify.sanitize(val, { ADD_TAGS: ['iframe'] })
|
|
||||||
this.html_widget.value = cleanHTML
|
|
||||||
|
|
||||||
// update our widget preview
|
|
||||||
if (this.edit_mode_widget.value === 'html') {
|
|
||||||
this.html_widget.element.innerHTML = cleanHTML
|
|
||||||
} else if (this.edit_mode_widget.value === 'markdown') {
|
|
||||||
this.html_widget.element.innerHTML =
|
|
||||||
this.markdownConverter.makeHtml(cleanHTML)
|
|
||||||
}
|
|
||||||
this.calculateHeight()
|
|
||||||
// this.setSize(this.computeSize())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
app.registerExtension({
|
|
||||||
name: 'mtb.noteplus',
|
|
||||||
|
|
||||||
registerCustomNodes() {
|
|
||||||
LiteGraph.registerNodeType('Note Plus (mtb)', NotePlus)
|
|
||||||
|
|
||||||
NotePlus.category = 'mtb/utils'
|
|
||||||
NotePlus.title = 'Note+ (mtb)'
|
|
||||||
|
|
||||||
NotePlus.title_mode = LiteGraph.NO_TITLE
|
|
||||||
},
|
|
||||||
})
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
|||||||
ace.define("ace/ext/menu_tools/settings_menu.css",["require","exports","module"],function(e,t,n){n.exports="#ace_settingsmenu, #kbshortcutmenu {\n background-color: #F7F7F7;\n color: black;\n box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\n padding: 1em 0.5em 2em 1em;\n overflow: auto;\n position: absolute;\n margin: 0;\n bottom: 0;\n right: 0;\n top: 0;\n z-index: 9991;\n cursor: default;\n}\n\n.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\n box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\n background-color: rgba(255, 255, 255, 0.6);\n color: black;\n}\n\n.ace_optionsMenuEntry:hover {\n background-color: rgba(100, 100, 100, 0.1);\n transition: all 0.3s\n}\n\n.ace_closeButton {\n background: rgba(245, 146, 146, 0.5);\n border: 1px solid #F48A8A;\n border-radius: 50%;\n padding: 7px;\n position: absolute;\n right: -8px;\n top: -8px;\n z-index: 100000;\n}\n.ace_closeButton{\n background: rgba(245, 146, 146, 0.9);\n}\n.ace_optionsMenuKey {\n color: darkslateblue;\n font-weight: bold;\n}\n.ace_optionsMenuCommand {\n color: darkcyan;\n font-weight: normal;\n}\n.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\n vertical-align: middle;\n}\n\n.ace_optionsMenuEntry button[ace_selected_button=true] {\n background: #e7e7e7;\n box-shadow: 1px 0px 2px 0px #adadad inset;\n border-color: #adadad;\n}\n.ace_optionsMenuEntry button {\n background: white;\n border: 1px solid lightgray;\n margin: 0px;\n}\n.ace_optionsMenuEntry button:hover{\n background: #f0f0f0;\n}"}),ace.define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom","ace/ext/menu_tools/settings_menu.css"],function(e,t,n){"use strict";var r=e("../../lib/dom"),i=e("./settings_menu.css");r.importCssString(i,"settings_menu.css",!1),n.exports.overlayPage=function(t,n,r){function o(e){e.keyCode===27&&u()}function u(){if(!i)return;document.removeEventListener("keydown",o),i.parentNode.removeChild(i),t&&t.focus(),i=null,r&&r()}function a(e){s=e,e&&(i.style.pointerEvents="none",n.style.pointerEvents="auto")}var i=document.createElement("div"),s=!1;return i.style.cssText="margin: 0; padding: 0; position: fixed; top:0; bottom:0; left:0; right:0;z-index: 9990; "+(t?"background-color: rgba(0, 0, 0, 0.3);":""),i.addEventListener("click",function(e){s||u()}),document.addEventListener("keydown",o),n.addEventListener("click",function(e){e.stopPropagation()}),i.appendChild(n),document.body.appendChild(i),t&&t.blur(),{close:u,setIgnoreFocusOut:a}}}),ace.define("ace/ext/menu_tools/get_editor_keyboard_shortcuts",["require","exports","module","ace/lib/keys"],function(e,t,n){"use strict";var r=e("../../lib/keys");n.exports.getEditorKeybordShortcuts=function(e){var t=r.KEY_MODS,n=[],i={};return e.keyBinding.$handlers.forEach(function(e){var t=e.commandKeyBinding;for(var r in t){var s=r.replace(/(^|-)\w/g,function(e){return e.toUpperCase()}),o=t[r];Array.isArray(o)||(o=[o]),o.forEach(function(e){typeof e!="string"&&(e=e.name),i[e]?i[e].key+="|"+s:(i[e]={key:s,command:e},n.push(i[e]))})}}),n}}),ace.define("ace/ext/keybinding_menu",["require","exports","module","ace/editor","ace/ext/menu_tools/overlay_page","ace/ext/menu_tools/get_editor_keyboard_shortcuts"],function(e,t,n){"use strict";function i(t){if(!document.getElementById("kbshortcutmenu")){var n=e("./menu_tools/overlay_page").overlayPage,r=e("./menu_tools/get_editor_keyboard_shortcuts").getEditorKeybordShortcuts,i=r(t),s=document.createElement("div"),o=i.reduce(function(e,t){return e+'<div class="ace_optionsMenuEntry"><span class="ace_optionsMenuCommand">'+t.command+"</span> : "+'<span class="ace_optionsMenuKey">'+t.key+"</span></div>"},"");s.id="kbshortcutmenu",s.innerHTML="<h1>Keyboard Shortcuts</h1>"+o+"</div>",n(t,s)}}var r=e("../editor").Editor;n.exports.init=function(e){r.prototype.showKeyboardShortcuts=function(){i(this)},e.commands.addCommands([{name:"showKeyboardShortcuts",bindKey:{win:"Ctrl-Alt-h",mac:"Command-Alt-h"},exec:function(e,t){e.showKeyboardShortcuts()}}])}}); (function() {
|
|
||||||
ace.require(["ace/ext/keybinding_menu"], 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/linking",["require","exports","module","ace/editor","ace/config"],function(e,t,n){function i(e){var n=e.editor,r=e.getAccelKey();if(r){var n=e.editor,i=e.getDocumentPosition(),s=n.session,o=s.getTokenAt(i.row,i.column);t.previousLinkingHover&&t.previousLinkingHover!=o&&n._emit("linkHoverOut"),n._emit("linkHover",{position:i,token:o}),t.previousLinkingHover=o}else t.previousLinkingHover&&(n._emit("linkHoverOut"),t.previousLinkingHover=!1)}function s(e){var t=e.getAccelKey(),n=e.getButton();if(n==0&&t){var r=e.editor,i=e.getDocumentPosition(),s=r.session,o=s.getTokenAt(i.row,i.column);r._emit("linkClick",{position:i,token:o})}}var r=e("../editor").Editor;e("../config").defineOptions(r.prototype,"editor",{enableLinking:{set:function(e){e?(this.on("click",s),this.on("mousemove",i)):(this.off("click",s),this.off("mousemove",i))},value:!1}}),t.previousLinkingHover=!1}); (function() {
|
|
||||||
ace.require(["ace/ext/linking"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
ace.define("ace/ext/modelist",["require","exports","module"],function(e,t,n){"use strict";function i(e){var t=a.text,n=e.split(/[\/\\]/).pop();for(var i=0;i<r.length;i++)if(r[i].supportsFile(n)){t=r[i];break}return t}var r=[],s=function(){function e(e,t,n){this.name=e,this.caption=t,this.mode="ace/mode/"+e,this.extensions=n;var r;/\^/.test(n)?r=n.replace(/\|(\^)?/g,function(e,t){return"$|"+(t?"^":"^.*\\.")})+"$":r="^.*\\.("+n+")$",this.extRe=new RegExp(r,"gi")}return e.prototype.supportsFile=function(e){return e.match(this.extRe)},e}(),o={ABAP:["abap"],ABC:["abc"],ActionScript:["as"],ADA:["ada|adb"],Alda:["alda"],Apache_Conf:["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],Apex:["apex|cls|trigger|tgr"],AQL:["aql"],AsciiDoc:["asciidoc|adoc"],ASL:["dsl|asl|asl.json"],Assembly_ARM32:["s"],Assembly_x86:["asm|a"],Astro:["astro"],AutoHotKey:["ahk"],BatchFile:["bat|cmd"],BibTeX:["bib"],C_Cpp:["cpp|c|cc|cxx|h|hh|hpp|ino"],C9Search:["c9search_results"],Cirru:["cirru|cr"],Clojure:["clj|cljs"],Cobol:["CBL|COB"],coffee:["coffee|cf|cson|^Cakefile"],ColdFusion:["cfm|cfc"],Crystal:["cr"],CSharp:["cs"],Csound_Document:["csd"],Csound_Orchestra:["orc"],Csound_Score:["sco"],CSS:["css"],Curly:["curly"],Cuttlefish:["conf"],D:["d|di"],Dart:["dart"],Diff:["diff|patch"],Django:["djt|html.djt|dj.html|djhtml"],Dockerfile:["^Dockerfile"],Dot:["dot"],Drools:["drl"],Edifact:["edi"],Eiffel:["e|ge"],EJS:["ejs"],Elixir:["ex|exs"],Elm:["elm"],Erlang:["erl|hrl"],Flix:["flix"],Forth:["frt|fs|ldr|fth|4th"],Fortran:["f|f90"],FSharp:["fsi|fs|ml|mli|fsx|fsscript"],FSL:["fsl"],FTL:["ftl"],Gcode:["gcode"],Gherkin:["feature"],Gitignore:["^.gitignore"],Glsl:["glsl|frag|vert"],Gobstones:["gbs"],golang:["go"],GraphQLSchema:["gql"],Groovy:["groovy"],HAML:["haml"],Handlebars:["hbs|handlebars|tpl|mustache"],Haskell:["hs"],Haskell_Cabal:["cabal"],haXe:["hx"],Hjson:["hjson"],HTML:["html|htm|xhtml|we|wpy"],HTML_Elixir:["eex|html.eex"],HTML_Ruby:["erb|rhtml|html.erb"],INI:["ini|conf|cfg|prefs"],Io:["io"],Ion:["ion"],Jack:["jack"],Jade:["jade|pug"],Java:["java"],JavaScript:["js|jsm|cjs|mjs"],JEXL:["jexl"],JSON:["json"],JSON5:["json5"],JSONiq:["jq"],JSP:["jsp"],JSSM:["jssm|jssm_state"],JSX:["jsx"],Julia:["jl"],Kotlin:["kt|kts"],LaTeX:["tex|latex|ltx|bib"],Latte:["latte"],LESS:["less"],Liquid:["liquid"],Lisp:["lisp"],LiveScript:["ls"],Log:["log"],LogiQL:["logic|lql"],Logtalk:["lgt"],LSL:["lsl"],Lua:["lua"],LuaPage:["lp"],Lucene:["lucene"],Makefile:["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],Markdown:["md|markdown"],Mask:["mask"],MATLAB:["matlab"],Maze:["mz"],MediaWiki:["wiki|mediawiki"],MEL:["mel"],MIPS:["s|asm"],MIXAL:["mixal"],MUSHCode:["mc|mush"],MySQL:["mysql"],Nasal:["nas"],Nginx:["nginx|conf"],Nim:["nim"],Nix:["nix"],NSIS:["nsi|nsh"],Nunjucks:["nunjucks|nunjs|nj|njk"],ObjectiveC:["m|mm"],OCaml:["ml|mli"],Odin:["odin"],PartiQL:["partiql|pql"],Pascal:["pas|p"],Perl:["pl|pm"],pgSQL:["pgsql"],PHP:["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],PHP_Laravel_blade:["blade.php"],Pig:["pig"],PLSQL:["plsql"],Powershell:["ps1"],Praat:["praat|praatscript|psc|proc"],Prisma:["prisma"],Prolog:["plg|prolog"],Properties:["properties"],Protobuf:["proto"],PRQL:["prql"],Puppet:["epp|pp"],Python:["py"],QML:["qml"],R:["r"],Raku:["raku|rakumod|rakutest|p6|pl6|pm6"],Razor:["cshtml|asp"],RDoc:["Rd"],Red:["red|reds"],RHTML:["Rhtml"],Robot:["robot|resource"],RST:["rst"],Ruby:["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],Rust:["rs"],SaC:["sac"],SASS:["sass"],SCAD:["scad"],Scala:["scala|sbt"],Scheme:["scm|sm|rkt|oak|scheme"],Scrypt:["scrypt"],SCSS:["scss"],SH:["sh|bash|^.bashrc"],SJS:["sjs"],Slim:["slim|skim"],Smarty:["smarty|tpl"],Smithy:["smithy"],snippets:["snippets"],Soy_Template:["soy"],Space:["space"],SPARQL:["rq"],SQL:["sql"],SQLServer:["sqlserver"],Stylus:["styl|stylus"],SVG:["svg"],Swift:["swift"],Tcl:["tcl"],Terraform:["tf","tfvars","terragrunt"],Tex:["tex"],Text:["txt"],Textile:["textile"],Toml:["toml"],TSX:["tsx"],Turtle:["ttl"],Twig:["twig|swig"],Typescript:["ts|mts|cts|typescript|str"],Vala:["vala"],VBScript:["vbs|vb"],Velocity:["vm"],Verilog:["v|vh|sv|svh"],VHDL:["vhd|vhdl"],Visualforce:["vfp|component|page"],Vue:["vue"],Wollok:["wlk|wpgm|wtest"],XML:["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],XQuery:["xq"],YAML:["yaml|yml"],Zeek:["zeek|bro"],Zig:["zig"]},u={ObjectiveC:"Objective-C",CSharp:"C#",golang:"Go",C_Cpp:"C and C++",Csound_Document:"Csound Document",Csound_Orchestra:"Csound",Csound_Score:"Csound Score",coffee:"CoffeeScript",HTML_Ruby:"HTML (Ruby)",HTML_Elixir:"HTML (Elixir)",FTL:"FreeMarker",PHP_Laravel_blade:"PHP (Blade Template)",Perl6:"Perl 6",AutoHotKey:"AutoHotkey / AutoIt"},a={};for(var f in o){var l=o[f],c=(u[f]||f).replace(/_/g," "),h=f.toLowerCase(),p=new s(h,c,l[0]);a[h]=p,r.push(p)}n.exports={getModeForPath:i,modes:r,modesByName:a}}); (function() {
|
|
||||||
ace.require(["ace/ext/modelist"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
|||||||
ace.define("ace/ext/rtl",["require","exports","module","ace/editor","ace/config"],function(e,t,n){"use strict";function s(e,t){var n=t.getSelection().lead;t.session.$bidiHandler.isRtlLine(n.row)&&n.column===0&&(t.session.$bidiHandler.isMoveLeftOperation&&n.row>0?t.getSelection().moveCursorTo(n.row-1,t.session.getLine(n.row-1).length):t.getSelection().isEmpty()?n.column+=1:n.setPosition(n.row,n.column+1))}function o(e){e.editor.session.$bidiHandler.isMoveLeftOperation=/gotoleft|selectleft|backspace|removewordleft/.test(e.command.name)}function u(e,t){var n=t.session;n.$bidiHandler.currentRow=null;if(n.$bidiHandler.isRtlLine(e.start.row)&&e.action==="insert"&&e.lines.length>1)for(var r=e.start.row;r<e.end.row;r++)n.getLine(r+1).charAt(0)!==n.$bidiHandler.RLE&&(n.doc.$lines[r+1]=n.$bidiHandler.RLE+n.getLine(r+1))}function a(e,t){var n=t.session,r=n.$bidiHandler,i=t.$textLayer.$lines.cells,s=t.layerConfig.width-t.layerConfig.padding+"px";i.forEach(function(e){var t=e.element.style;r&&r.isRtlLine(e.row)?(t.direction="rtl",t.textAlign="right",t.width=s):(t.direction="",t.textAlign="",t.width="")})}function f(e){function n(e){var t=e.element.style;t.direction=t.textAlign=t.width=""}var t=e.$textLayer.$lines;t.cells.forEach(n),t.cellCache.forEach(n)}var r=[{name:"leftToRight",bindKey:{win:"Ctrl-Alt-Shift-L",mac:"Command-Alt-Shift-L"},exec:function(e){e.session.$bidiHandler.setRtlDirection(e,!1)},readOnly:!0},{name:"rightToLeft",bindKey:{win:"Ctrl-Alt-Shift-R",mac:"Command-Alt-Shift-R"},exec:function(e){e.session.$bidiHandler.setRtlDirection(e,!0)},readOnly:!0}],i=e("../editor").Editor;e("../config").defineOptions(i.prototype,"editor",{rtlText:{set:function(e){e?(this.on("change",u),this.on("changeSelection",s),this.renderer.on("afterRender",a),this.commands.on("exec",o),this.commands.addCommands(r)):(this.off("change",u),this.off("changeSelection",s),this.renderer.off("afterRender",a),this.commands.off("exec",o),this.commands.removeCommands(r),f(this.renderer)),this.renderer.updateFull()}},rtl:{set:function(e){this.session.$bidiHandler.$isRtl=e,e?(this.setOption("rtlText",!1),this.renderer.on("afterRender",a),this.session.$bidiHandler.seenBidi=!0):(this.renderer.off("afterRender",a),f(this.renderer)),this.renderer.updateFull()}}})}); (function() {
|
|
||||||
ace.require(["ace/ext/rtl"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
|||||||
ace.define("ace/ext/simple_tokenizer",["require","exports","module","ace/tokenizer","ace/layer/text_util"],function(e,t,n){"use strict";function o(e,t){var n=new s(e,new r(t.getRules())),o=[];for(var u=0;u<n.getLength();u++){var a=n.getTokens(u);o.push(a.map(function(e){return{className:i(e.type)?undefined:"ace_"+e.type.replace(/\./g," ace_"),value:e.value}}))}return o}var r=e("../tokenizer").Tokenizer,i=e("../layer/text_util").isTextToken,s=function(){function e(e,t){this._lines=e.split(/\r\n|\r|\n/),this._states=[],this._tokenizer=t}return e.prototype.getTokens=function(e){var t=this._lines[e],n=this._states[e-1],r=this._tokenizer.getLineTokens(t,n);return this._states[e]=r.state,r.tokens},e.prototype.getLength=function(){return this._lines.length},e}();n.exports={tokenize:o}}); (function() {
|
|
||||||
ace.require(["ace/ext/simple_tokenizer"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
ace.define("ace/ext/spellcheck",["require","exports","module","ace/lib/event","ace/editor","ace/config"],function(e,t,n){"use strict";var r=e("../lib/event");t.contextMenuHandler=function(e){var t=e.target,n=t.textInput.getElement();if(!t.selection.isEmpty())return;var i=t.getCursorPosition(),s=t.session.getWordRange(i.row,i.column),o=t.session.getTextRange(s);t.session.tokenRe.lastIndex=0;if(!t.session.tokenRe.test(o))return;var u="\x01\x01",a=o+" "+u;n.value=a,n.setSelectionRange(o.length,o.length+1),n.setSelectionRange(0,0),n.setSelectionRange(0,o.length);var f=!1;r.addListener(n,"keydown",function l(){r.removeListener(n,"keydown",l),f=!0}),t.textInput.setInputHandler(function(e){if(e==a)return"";if(e.lastIndexOf(a,0)===0)return e.slice(a.length);if(e.substr(n.selectionEnd)==a)return e.slice(0,-a.length);if(e.slice(-2)==u){var r=e.slice(0,-2);if(r.slice(-1)==" ")return f?r.substring(0,n.selectionEnd):(r=r.slice(0,-1),t.session.replace(s,r),"")}return e})};var i=e("../editor").Editor;e("../config").defineOptions(i.prototype,"editor",{spellcheck:{set:function(e){var n=this.textInput.getElement();n.spellcheck=!!e,e?this.on("nativecontextmenu",t.contextMenuHandler):this.removeListener("nativecontextmenu",t.contextMenuHandler)},value:!0}})}); (function() {
|
|
||||||
ace.require(["ace/ext/spellcheck"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
ace.define("ace/split",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/editor","ace/virtual_renderer","ace/edit_session"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/lang"),s=e("./lib/event_emitter").EventEmitter,o=e("./editor").Editor,u=e("./virtual_renderer").VirtualRenderer,a=e("./edit_session").EditSession,f;f=function(e,t,n){this.BELOW=1,this.BESIDE=0,this.$container=e,this.$theme=t,this.$splits=0,this.$editorCSS="",this.$editors=[],this.$orientation=this.BESIDE,this.setSplits(n||1),this.$cEditor=this.$editors[0],this.on("focus",function(e){this.$cEditor=e}.bind(this))},function(){r.implement(this,s),this.$createEditor=function(){var e=document.createElement("div");e.className=this.$editorCSS,e.style.cssText="position: absolute; top:0px; bottom:0px",this.$container.appendChild(e);var t=new o(new u(e,this.$theme));return t.on("focus",function(){this._emit("focus",t)}.bind(this)),this.$editors.push(t),t.setFontSize(this.$fontSize),t},this.setSplits=function(e){var t;if(e<1)throw"The number of splits have to be > 0!";if(e==this.$splits)return;if(e>this.$splits){while(this.$splits<this.$editors.length&&this.$splits<e)t=this.$editors[this.$splits],this.$container.appendChild(t.container),t.setFontSize(this.$fontSize),this.$splits++;while(this.$splits<e)this.$createEditor(),this.$splits++}else while(this.$splits>e)t=this.$editors[this.$splits-1],this.$container.removeChild(t.container),this.$splits--;this.resize()},this.getSplits=function(){return this.$splits},this.getEditor=function(e){return this.$editors[e]},this.getCurrentEditor=function(){return this.$cEditor},this.focus=function(){this.$cEditor.focus()},this.blur=function(){this.$cEditor.blur()},this.setTheme=function(e){this.$editors.forEach(function(t){t.setTheme(e)})},this.setKeyboardHandler=function(e){this.$editors.forEach(function(t){t.setKeyboardHandler(e)})},this.forEach=function(e,t){this.$editors.forEach(e,t)},this.$fontSize="",this.setFontSize=function(e){this.$fontSize=e,this.forEach(function(t){t.setFontSize(e)})},this.$cloneSession=function(e){var t=new a(e.getDocument(),e.getMode()),n=e.getUndoManager();return t.setUndoManager(n),t.setTabSize(e.getTabSize()),t.setUseSoftTabs(e.getUseSoftTabs()),t.setOverwrite(e.getOverwrite()),t.setBreakpoints(e.getBreakpoints()),t.setUseWrapMode(e.getUseWrapMode()),t.setUseWorker(e.getUseWorker()),t.setWrapLimitRange(e.$wrapLimitRange.min,e.$wrapLimitRange.max),t.$foldData=e.$cloneFoldData(),t},this.setSession=function(e,t){var n;t==null?n=this.$cEditor:n=this.$editors[t];var r=this.$editors.some(function(t){return t.session===e});return r&&(e=this.$cloneSession(e)),n.setSession(e),e},this.getOrientation=function(){return this.$orientation},this.setOrientation=function(e){if(this.$orientation==e)return;this.$orientation=e,this.resize()},this.resize=function(){var e=this.$container.clientWidth,t=this.$container.clientHeight,n;if(this.$orientation==this.BESIDE){var r=e/this.$splits;for(var i=0;i<this.$splits;i++)n=this.$editors[i],n.container.style.width=r+"px",n.container.style.top="0px",n.container.style.left=i*r+"px",n.container.style.height=t+"px",n.resize()}else{var s=t/this.$splits;for(var i=0;i<this.$splits;i++)n=this.$editors[i],n.container.style.width=e+"px",n.container.style.top=i*s+"px",n.container.style.left="0px",n.container.style.height=s+"px",n.resize()}}}.call(f.prototype),t.Split=f}),ace.define("ace/ext/split",["require","exports","module","ace/split"],function(e,t,n){"use strict";n.exports=e("../split")}); (function() {
|
|
||||||
ace.require(["ace/ext/split"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
ace.define("ace/ext/static-css",["require","exports","module"],function(e,t,n){n.exports=".ace_static_highlight {\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Source Code Pro', 'source-code-pro', 'Droid Sans Mono', monospace;\n font-size: 12px;\n white-space: pre-wrap\n}\n\n.ace_static_highlight .ace_gutter {\n width: 2em;\n text-align: right;\n padding: 0 3px 0 0;\n margin-right: 3px;\n contain: none;\n}\n\n.ace_static_highlight.ace_show_gutter .ace_line {\n padding-left: 2.6em;\n}\n\n.ace_static_highlight .ace_line { position: relative; }\n\n.ace_static_highlight .ace_gutter-cell {\n -moz-user-select: -moz-none;\n -khtml-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n top: 0;\n bottom: 0;\n left: 0;\n position: absolute;\n}\n\n\n.ace_static_highlight .ace_gutter-cell:before {\n content: counter(ace_line, decimal);\n counter-increment: ace_line;\n}\n.ace_static_highlight {\n counter-reset: ace_line;\n}\n"}),ace.define("ace/ext/static_highlight",["require","exports","module","ace/edit_session","ace/layer/text","ace/ext/static-css","ace/config","ace/lib/dom","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../edit_session").EditSession,i=e("../layer/text").Text,s=e("./static-css"),o=e("../config"),u=e("../lib/dom"),a=e("../lib/lang").escapeHTML,f=function(){function e(e){this.className,this.type=e,this.style={},this.textContent=""}return e.prototype.cloneNode=function(){return this},e.prototype.appendChild=function(e){this.textContent+=e.toString()},e.prototype.toString=function(){var e=[];if(this.type!="fragment"){e.push("<",this.type),this.className&&e.push(" class='",this.className,"'");var t=[];for(var n in this.style)t.push(n,":",this.style[n]);t.length&&e.push(" style='",t.join(""),"'"),e.push(">")}return this.textContent&&e.push(this.textContent),this.type!="fragment"&&e.push("</",this.type,">"),e.join("")},e}(),l={createTextNode:function(e,t){return a(e)},createElement:function(e){return new f(e)},createFragment:function(){return new f("fragment")}},c=function(){this.config={},this.dom=l};c.prototype=i.prototype;var h=function(e,t,n){var r=e.className.match(/lang-(\w+)/),i=t.mode||r&&"ace/mode/"+r[1];if(!i)return!1;var s=t.theme||"ace/theme/textmate",o="",a=[];if(e.firstElementChild){var f=0;for(var l=0;l<e.childNodes.length;l++){var c=e.childNodes[l];c.nodeType==3?(f+=c.data.length,o+=c.data):a.push(f,c)}}else o=e.textContent,t.trim&&(o=o.trim());h.render(o,i,s,t.firstLineNumber,!t.showGutter,function(t){u.importCssString(t.css,"ace_highlight",!0),e.innerHTML=t.html;var r=e.firstChild.firstChild;for(var i=0;i<a.length;i+=2){var s=t.session.doc.indexToPosition(a[i]),o=a[i+1],f=r.children[s.row];f&&f.appendChild(o)}n&&n()})};h.render=function(e,t,n,i,s,u){function c(){var r=h.renderSync(e,t,n,i,s);return u?u(r):r}var a=1,f=r.prototype.$modes;typeof n=="string"&&(a++,o.loadModule(["theme",n],function(e){n=e,--a||c()}));var l;return t&&typeof t=="object"&&!t.getTokenizer&&(l=t,t=l.path),typeof t=="string"&&(a++,o.loadModule(["mode",t],function(e){if(!f[t]||l)f[t]=new e.Mode(l);t=f[t],--a||c()})),--a||c()},h.renderSync=function(e,t,n,i,o){i=parseInt(i||1,10);var u=new r("");u.setUseWorker(!1),u.setMode(t);var a=new c;a.setSession(u),Object.keys(a.$tabStrings).forEach(function(e){if(typeof a.$tabStrings[e]=="string"){var t=l.createFragment();t.textContent=a.$tabStrings[e],a.$tabStrings[e]=t}}),u.setValue(e);var f=u.getLength(),h=l.createElement("div");h.className=n.cssClass;var p=l.createElement("div");p.className="ace_static_highlight"+(o?"":" ace_show_gutter"),p.style["counter-reset"]="ace_line "+(i-1);for(var d=0;d<f;d++){var v=l.createElement("div");v.className="ace_line";if(!o){var m=l.createElement("span");m.className="ace_gutter ace_gutter-cell",m.textContent="",v.appendChild(m)}a.$renderLine(v,d,!1),v.textContent+="\n",p.appendChild(v)}return h.appendChild(p),{css:s+n.cssText,html:h.toString(),session:u}},n.exports=h,n.exports.highlight=h}); (function() {
|
|
||||||
ace.require(["ace/ext/static_highlight"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
ace.define("ace/ext/statusbar",["require","exports","module","ace/lib/dom","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../lib/dom"),i=e("../lib/lang"),s=function(){function e(e,t){this.element=r.createElement("div"),this.element.className="ace_status-indicator",this.element.style.cssText="display: inline-block;",t.appendChild(this.element);var n=i.delayedCall(function(){this.updateStatus(e)}.bind(this)).schedule.bind(null,100);e.on("changeStatus",n),e.on("changeSelection",n),e.on("keyboardActivity",n)}return e.prototype.updateStatus=function(e){function n(e,n){e&&t.push(e,n||"|")}var t=[];n(e.keyBinding.getStatusText(e)),e.commands.recording&&n("REC");var r=e.selection,i=r.lead;if(!r.isEmpty()){var s=e.getSelectionRange();n("("+(s.end.row-s.start.row)+":"+(s.end.column-s.start.column)+")"," ")}n(i.row+":"+i.column," "),r.rangeCount&&n("["+r.rangeCount+"]"," "),t.pop(),this.element.textContent=t.join("")},e}();t.StatusBar=s}); (function() {
|
|
||||||
ace.require(["ace/ext/statusbar"], 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/themelist",["require","exports","module"],function(e,t,n){"use strict";var r=[["Chrome"],["Clouds"],["Crimson Editor"],["Dawn"],["Dreamweaver"],["Eclipse"],["GitHub"],["IPlastic"],["Solarized Light"],["TextMate"],["Tomorrow"],["XCode"],["Kuroir"],["KatzenMilch"],["SQL Server","sqlserver","light"],["CloudEditor","cloud_editor","light"],["Ambiance","ambiance","dark"],["Chaos","chaos","dark"],["Clouds Midnight","clouds_midnight","dark"],["Dracula","","dark"],["Cobalt","cobalt","dark"],["Gruvbox","gruvbox","dark"],["Green on Black","gob","dark"],["idle Fingers","idle_fingers","dark"],["krTheme","kr_theme","dark"],["Merbivore","merbivore","dark"],["Merbivore Soft","merbivore_soft","dark"],["Mono Industrial","mono_industrial","dark"],["Monokai","monokai","dark"],["Nord Dark","nord_dark","dark"],["One Dark","one_dark","dark"],["Pastel on dark","pastel_on_dark","dark"],["Solarized Dark","solarized_dark","dark"],["Terminal","terminal","dark"],["Tomorrow Night","tomorrow_night","dark"],["Tomorrow Night Blue","tomorrow_night_blue","dark"],["Tomorrow Night Bright","tomorrow_night_bright","dark"],["Tomorrow Night 80s","tomorrow_night_eighties","dark"],["Twilight","twilight","dark"],["Vibrant Ink","vibrant_ink","dark"],["GitHub Dark","github_dark","dark"],["CloudEditor Dark","cloud_editor_dark","dark"]];t.themesByName={},t.themes=r.map(function(e){var n=e[1]||e[0].replace(/ /g,"_").toLowerCase(),r={caption:e[0],theme:"ace/theme/"+n,isDark:e[2]=="dark",name:n};return t.themesByName[n]=r,r})}); (function() {
|
|
||||||
ace.require(["ace/ext/themelist"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
ace.define("ace/ext/whitespace",["require","exports","module","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../lib/lang");t.$detectIndentation=function(e,t){function c(e){var t=0;for(var r=e;r<n.length;r+=e)t+=n[r]||0;return t}var n=[],r=[],i=0,s=0,o=Math.min(e.length,1e3);for(var u=0;u<o;u++){var a=e[u];if(!/^\s*[^*+\-\s]/.test(a))continue;if(a[0]==" ")i++,s=-Number.MAX_VALUE;else{var f=a.match(/^ */)[0].length;if(f&&a[f]!=" "){var l=f-s;l>0&&!(s%l)&&!(f%l)&&(r[l]=(r[l]||0)+1),n[f]=(n[f]||0)+1}s=f}while(u<o&&a[a.length-1]=="\\")a=e[u++]}var h=r.reduce(function(e,t){return e+t},0),p={score:0,length:0},d=0;for(var u=1;u<12;u++){var v=c(u);u==1?(d=v,v=n[1]?.9:.8,n.length||(v=0)):v/=d,r[u]&&(v+=r[u]/h),v>p.score&&(p={score:v,length:u})}if(p.score&&p.score>1.4)var m=p.length;if(i>d+1){if(m==1||d<i/4||p.score<1.8)m=undefined;return{ch:" ",length:m}}if(d>i+1)return{ch:" ",length:m}},t.detectIndentation=function(e){var n=e.getLines(0,1e3),r=t.$detectIndentation(n)||{};return r.ch&&e.setUseSoftTabs(r.ch==" "),r.length&&e.setTabSize(r.length),r},t.trimTrailingSpace=function(e,t){var n=e.getDocument(),r=n.getAllLines(),i=t&&t.trimEmpty?-1:0,s=[],o=-1;t&&t.keepCursorPosition&&(e.selection.rangeCount?e.selection.rangeList.ranges.forEach(function(e,t,n){var r=n[t+1];if(r&&r.cursor.row==e.cursor.row)return;s.push(e.cursor)}):s.push(e.selection.getCursor()),o=0);var u=s[o]&&s[o].row;for(var a=0,f=r.length;a<f;a++){var l=r[a],c=l.search(/\s+$/);a==u&&(c<s[o].column&&c>i&&(c=s[o].column),o++,u=s[o]?s[o].row:-1),c>i&&n.removeInLine(a,c,l.length)}},t.convertIndentation=function(e,t,n){var i=e.getTabString()[0],s=e.getTabSize();n||(n=s),t||(t=i);var o=t==" "?t:r.stringRepeat(t,n),u=e.doc,a=u.getAllLines(),f={},l={};for(var c=0,h=a.length;c<h;c++){var p=a[c],d=p.match(/^\s*/)[0];if(d){var v=e.$getStringScreenWidth(d)[0],m=Math.floor(v/s),g=v%s,y=f[m]||(f[m]=r.stringRepeat(o,m));y+=l[g]||(l[g]=r.stringRepeat(" ",g)),y!=d&&(u.removeInLine(c,0,d.length),u.insertInLine({row:c,column:0},y))}}e.setTabSize(n),e.setUseSoftTabs(t==" ")},t.$parseStringArg=function(e){var t={};/t/.test(e)?t.ch=" ":/s/.test(e)&&(t.ch=" ");var n=e.match(/\d+/);return n&&(t.length=parseInt(n[0],10)),t},t.$parseArg=function(e){return e?typeof e=="string"?t.$parseStringArg(e):typeof e.text=="string"?t.$parseStringArg(e.text):e:{}},t.commands=[{name:"detectIndentation",description:"Detect indentation from content",exec:function(e){t.detectIndentation(e.session)}},{name:"trimTrailingSpace",description:"Trim trailing whitespace",exec:function(e,n){t.trimTrailingSpace(e.session,n)}},{name:"convertIndentation",description:"Convert indentation to ...",exec:function(e,n){var r=t.$parseArg(n);t.convertIndentation(e.session,r.ch,r.length)}},{name:"setIndentation",description:"Set indentation",exec:function(e,n){var r=t.$parseArg(n);r.length&&e.session.setTabSize(r.length),r.ch&&e.session.setUseSoftTabs(r.ch==" ")}}]}); (function() {
|
|
||||||
ace.require(["ace/ext/whitespace"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
|||||||
; (function() {
|
|
||||||
ace.require(["ace/snippets/json"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
; (function() {
|
|
||||||
ace.require(["ace/snippets/json5"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
ace.define("ace/snippets/markdown.snippets",["require","exports","module"],function(e,t,n){n.exports='# Markdown\n\n# Includes octopress (http://octopress.org/) snippets\n\nsnippet [\n [${1:text}](http://${2:address} "${3:title}")\nsnippet [*\n [${1:link}](${2:`@*`} "${3:title}")${4}\n\nsnippet [:\n [${1:id}]: http://${2:url} "${3:title}"\nsnippet [:*\n [${1:id}]: ${2:`@*`} "${3:title}"\n\nsnippet \nsnippet ${4}\n\nsnippet ![:\n ![${1:id}]: ${2:url} "${3:title}"\nsnippet ![:*\n ![${1:id}]: ${2:`@*`} "${3:title}"\n\nsnippet ===\nregex /^/=+/=*//\n ${PREV_LINE/./=/g}\n \n ${0}\nsnippet ---\nregex /^/-+/-*//\n ${PREV_LINE/./-/g}\n \n ${0}\nsnippet blockquote\n {% blockquote %}\n ${1:quote}\n {% endblockquote %}\n\nsnippet blockquote-author\n {% blockquote ${1:author}, ${2:title} %}\n ${3:quote}\n {% endblockquote %}\n\nsnippet blockquote-link\n {% blockquote ${1:author} ${2:URL} ${3:link_text} %}\n ${4:quote}\n {% endblockquote %}\n\nsnippet bt-codeblock-short\n ```\n ${1:code_snippet}\n ```\n\nsnippet bt-codeblock-full\n ``` ${1:language} ${2:title} ${3:URL} ${4:link_text}\n ${5:code_snippet}\n ```\n\nsnippet codeblock-short\n {% codeblock %}\n ${1:code_snippet}\n {% endcodeblock %}\n\nsnippet codeblock-full\n {% codeblock ${1:title} lang:${2:language} ${3:URL} ${4:link_text} %}\n ${5:code_snippet}\n {% endcodeblock %}\n\nsnippet gist-full\n {% gist ${1:gist_id} ${2:filename} %}\n\nsnippet gist-short\n {% gist ${1:gist_id} %}\n\nsnippet img\n {% img ${1:class} ${2:URL} ${3:width} ${4:height} ${5:title_text} ${6:alt_text} %}\n\nsnippet youtube\n {% youtube ${1:video_id} %}\n\n# The quote should appear only once in the text. It is inherently part of it.\n# See http://octopress.org/docs/plugins/pullquote/ for more info.\n\nsnippet pullquote\n {% pullquote %}\n ${1:text} {" ${2:quote} "} ${3:text}\n {% endpullquote %}\n'}),ace.define("ace/snippets/markdown",["require","exports","module","ace/snippets/markdown.snippets"],function(e,t,n){"use strict";t.snippetText=e("./markdown.snippets"),t.scope="markdown"}); (function() {
|
|
||||||
ace.require(["ace/snippets/markdown"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
ace.define("ace/snippets/python.snippets",["require","exports","module"],function(e,t,n){n.exports='snippet #!\n #!/usr/bin/env python\nsnippet imp\n import ${1:module}\nsnippet from\n from ${1:package} import ${2:module}\n# Module Docstring\nsnippet docs\n \'\'\'\n File: ${1:FILENAME:file_name}\n Author: ${2:author}\n Description: ${3}\n \'\'\'\nsnippet wh\n while ${1:condition}:\n ${2:# TODO: write code...}\n# dowh - does the same as do...while in other languages\nsnippet dowh\n while True:\n ${1:# TODO: write code...}\n if ${2:condition}:\n break\nsnippet with\n with ${1:expr} as ${2:var}:\n ${3:# TODO: write code...}\n# New Class\nsnippet cl\n class ${1:ClassName}(${2:object}):\n """${3:docstring for $1}"""\n def __init__(self, ${4:arg}):\n ${5:super($1, self).__init__()}\n self.$4 = $4\n ${6}\n# New Function\nsnippet def\n def ${1:fname}(${2:`indent(\'.\') ? \'self\' : \'\'`}):\n """${3:docstring for $1}"""\n ${4:# TODO: write code...}\nsnippet deff\n def ${1:fname}(${2:`indent(\'.\') ? \'self\' : \'\'`}):\n ${3:# TODO: write code...}\n# New Method\nsnippet defs\n def ${1:mname}(self, ${2:arg}):\n ${3:# TODO: write code...}\n# New Property\nsnippet property\n def ${1:foo}():\n doc = "${2:The $1 property.}"\n def fget(self):\n ${3:return self._$1}\n def fset(self, value):\n ${4:self._$1 = value}\n# Ifs\nsnippet if\n if ${1:condition}:\n ${2:# TODO: write code...}\nsnippet el\n else:\n ${1:# TODO: write code...}\nsnippet ei\n elif ${1:condition}:\n ${2:# TODO: write code...}\n# For\nsnippet for\n for ${1:item} in ${2:items}:\n ${3:# TODO: write code...}\n# Encodes\nsnippet cutf8\n # -*- coding: utf-8 -*-\nsnippet clatin1\n # -*- coding: latin-1 -*-\nsnippet cascii\n # -*- coding: ascii -*-\n# Lambda\nsnippet ld\n ${1:var} = lambda ${2:vars} : ${3:action}\nsnippet .\n self.\nsnippet try Try/Except\n try:\n ${1:# TODO: write code...}\n except ${2:Exception}, ${3:e}:\n ${4:raise $3}\nsnippet try Try/Except/Else\n try:\n ${1:# TODO: write code...}\n except ${2:Exception}, ${3:e}:\n ${4:raise $3}\n else:\n ${5:# TODO: write code...}\nsnippet try Try/Except/Finally\n try:\n ${1:# TODO: write code...}\n except ${2:Exception}, ${3:e}:\n ${4:raise $3}\n finally:\n ${5:# TODO: write code...}\nsnippet try Try/Except/Else/Finally\n try:\n ${1:# TODO: write code...}\n except ${2:Exception}, ${3:e}:\n ${4:raise $3}\n else:\n ${5:# TODO: write code...}\n finally:\n ${6:# TODO: write code...}\n# if __name__ == \'__main__\':\nsnippet ifmain\n if __name__ == \'__main__\':\n ${1:main()}\n# __magic__\nsnippet _\n __${1:init}__${2}\n# python debugger (pdb)\nsnippet pdb\n import pdb; pdb.set_trace()\n# ipython debugger (ipdb)\nsnippet ipdb\n import ipdb; ipdb.set_trace()\n# ipython debugger (pdbbb)\nsnippet pdbbb\n import pdbpp; pdbpp.set_trace()\nsnippet pprint\n import pprint; pprint.pprint(${1})${2}\nsnippet "\n """\n ${1:doc}\n """\n# test function/method\nsnippet test\n def test_${1:description}(${2:self}):\n ${3:# TODO: write code...}\n# test case\nsnippet testcase\n class ${1:ExampleCase}(unittest.TestCase):\n \n def test_${2:description}(self):\n ${3:# TODO: write code...}\nsnippet fut\n from __future__ import ${1}\n#getopt\nsnippet getopt\n try:\n # Short option syntax: "hv:"\n # Long option syntax: "help" or "verbose="\n opts, args = getopt.getopt(sys.argv[1:], "${1:short_options}", [${2:long_options}])\n \n except getopt.GetoptError, err:\n # Print debug info\n print str(err)\n ${3:error_action}\n\n for option, argument in opts:\n if option in ("-h", "--help"):\n ${4}\n elif option in ("-v", "--verbose"):\n verbose = argument\n'}),ace.define("ace/snippets/python",["require","exports","module","ace/snippets/python.snippets"],function(e,t,n){"use strict";t.snippetText=e("./python.snippets"),t.scope="python"}); (function() {
|
|
||||||
ace.require(["ace/snippets/python"], function(m) {
|
|
||||||
if (typeof module == "object" && typeof exports == "object" && module) {
|
|
||||||
module.exports = m;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
; (function() {
|
|
||||||
ace.require(["ace/snippets/typescript"], 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/theme/chaos-css",["require","exports","module"],function(e,t,n){n.exports=".ace-chaos .ace_gutter {\n background: #141414;\n color: #595959;\n border-right: 1px solid #282828;\n}\n.ace-chaos .ace_gutter-cell.ace_warning {\n background-image: none;\n background: #FC0;\n border-left: none;\n padding-left: 0;\n color: #000;\n}\n.ace-chaos .ace_gutter-cell.ace_error {\n background-position: -6px center;\n background-image: none;\n background: #F10;\n border-left: none;\n padding-left: 0;\n color: #000;\n}\n.ace-chaos .ace_print-margin {\n border-left: 1px solid #555;\n right: 0;\n background: #1D1D1D;\n}\n.ace-chaos {\n background-color: #161616;\n color: #E6E1DC;\n}\n\n.ace-chaos .ace_cursor {\n border-left: 2px solid #FFFFFF;\n}\n.ace-chaos .ace_cursor.ace_overwrite {\n border-left: 0px;\n border-bottom: 1px solid #FFFFFF;\n}\n.ace-chaos .ace_marker-layer .ace_selection {\n background: #494836;\n}\n.ace-chaos .ace_marker-layer .ace_step {\n background: rgb(198, 219, 174);\n}\n.ace-chaos .ace_marker-layer .ace_bracket {\n margin: -1px 0 0 -1px;\n border: 1px solid #FCE94F;\n}\n.ace-chaos .ace_marker-layer .ace_active-line {\n background: #333;\n}\n.ace-chaos .ace_gutter-active-line {\n background-color: #222;\n}\n.ace-chaos .ace_invisible {\n color: #404040;\n}\n.ace-chaos .ace_keyword {\n color:#00698F;\n}\n.ace-chaos .ace_keyword.ace_operator {\n color:#FF308F;\n}\n.ace-chaos .ace_constant {\n color:#1EDAFB;\n}\n.ace-chaos .ace_constant.ace_language {\n color:#FDC251;\n}\n.ace-chaos .ace_constant.ace_library {\n color:#8DFF0A;\n}\n.ace-chaos .ace_constant.ace_numeric {\n color:#58C554;\n}\n.ace-chaos .ace_invalid {\n color:#FFFFFF;\n background-color:#990000;\n}\n.ace-chaos .ace_invalid.ace_deprecated {\n color:#FFFFFF;\n background-color:#990000;\n}\n.ace-chaos .ace_support {\n color: #999;\n}\n.ace-chaos .ace_support.ace_function {\n color:#00AEEF;\n}\n.ace-chaos .ace_function {\n color:#00AEEF;\n}\n.ace-chaos .ace_string {\n color:#58C554;\n}\n.ace-chaos .ace_comment {\n color:#555;\n font-style:italic;\n padding-bottom: 0px;\n}\n.ace-chaos .ace_variable {\n color:#997744;\n}\n.ace-chaos .ace_meta.ace_tag {\n color:#BE53E6;\n}\n.ace-chaos .ace_entity.ace_other.ace_attribute-name {\n color:#FFFF89;\n}\n.ace-chaos .ace_markup.ace_underline {\n text-decoration: underline;\n}\n.ace-chaos .ace_fold-widget {\n text-align: center;\n}\n\n.ace-chaos .ace_fold-widget:hover {\n color: #777;\n}\n\n.ace-chaos .ace_fold-widget.ace_start,\n.ace-chaos .ace_fold-widget.ace_end,\n.ace-chaos .ace_fold-widget.ace_closed{\n background: none !important;\n border: none;\n box-shadow: none;\n}\n\n.ace-chaos .ace_fold-widget.ace_start:after {\n content: '\u25be'\n}\n\n.ace-chaos .ace_fold-widget.ace_end:after {\n content: '\u25b4'\n}\n\n.ace-chaos .ace_fold-widget.ace_closed:after {\n content: '\u2023'\n}\n\n.ace-chaos .ace_indent-guide {\n border-right:1px dotted #333333;\n margin-right:-1px;\n}\n\n.ace-chaos .ace_indent-guide-active {\n border-right:1px dotted #afafaf;\n margin-right:-1px;\n}\n\n.ace-chaos .ace_fold { \n background: #222; \n border-radius: 3px; \n color: #7AF; \n border: none; \n}\n.ace-chaos .ace_fold:hover {\n background: #CCC; \n color: #000;\n}\n"}),ace.define("ace/theme/chaos",["require","exports","module","ace/theme/chaos-css","ace/lib/dom"],function(e,t,n){t.isDark=!0,t.cssClass="ace-chaos",t.cssText=e("./chaos-css");var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass,!1)}); (function() {
|
|
||||||
ace.require(["ace/theme/chaos"], 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