Commit Graph
100 Commits
Author SHA1 Message Date
bmad4ever b29ed2bd3b Specify commit hash in external repo dependency
By pointing the specific commit, updating bmquilting repo won't change the comfyui_quilting behavior.
I already found & corrected a bug that changes the nodes behavior in bmquilting dev branch, so this change ensures users can have a stable experience.
Additionally, if I want to make more radical changes in the future, I don't risk breaking all the node versions that rely on the bmquilting repo.
2024-10-18 20:41:00 +01:00
Bruno Madeira cee706c881 attempt to install pyastar2d on first installation 2024-09-05 21:40:52 +01:00
bmad4ever c91b3241a2 Merge pull request #9 from bmad4ever/dev
Core implementation is now a package, available in another repo.
2024-09-05 21:27:00 +01:00
Bruno Madeira d76b7aa3c6 add install.py 2024-09-05 21:16:03 +01:00
Bruno Madeira 39b4b2c958 update uninstall.py 2024-09-05 21:15:50 +01:00
Bruno Madeira 0432f54d5f add uninstall.py 2024-09-05 21:00:40 +01:00
Bruno Madeira a15419ef9a update project to use python package instead 2024-09-05 20:58:48 +01:00
bmad4ever bb11a441c6 Merge pull request #8 from bmad4ever/feature-make-seamsless
Minor fix & change
2024-08-26 23:11:18 +01:00
Bruno Madeira deb3087144 update pyproject.toml - set version 2.1.1
* minor due to seed removal from SP nodes
* patch due to bug fix & documentation update
2024-08-26 23:08:04 +01:00
Bruno Madeira 75633f82f0 update README.md - clarify potential point of confusion when using lookup textures. 2024-08-26 23:05:31 +01:00
Bruno Madeira 7f728e17be fix LatentMakeSeamlessSB; remove seed from arguments; update SP workflows; rename some workflows.
reasoning behind seed removal in SP nodes: the cases where seed changes output are so rare that will just confuse the users and occupy unnecessary space in the workflow.
2024-08-26 22:52:53 +01:00
Bruno Madeira e8298ce1a9 fix typo - workflow name should use same abbreviation as the node's name & documentation. 2024-08-26 22:05:31 +01:00
bmad4ever 48dd2ca095 Merge pull request #7 from bmad4ever/feature-make-seamsless
New features and enhancements (also new dependencies)
2024-08-26 21:04:48 +01:00
Bruno Madeira d7b9f714e3 update README.md - fix typo 2024-08-26 20:55:43 +01:00
Bruno Madeira 0decdf076e on second though this import is a potential point of failure. now it should be fine, I think. 2024-08-26 20:43:33 +01:00
Bruno Madeira 5eb57897ec update pyproject.toml - update version.
I think it is ready for merge...
2024-08-26 20:15:30 +01:00
Bruno Madeira de69fa1284 update README.md - make clear what happens w/ overlap so that edge cases don't seem confusing. 2024-08-26 20:13:24 +01:00
Bruno Madeira 5d90545f02 fixes - "extreme" overlap values resulting in no or total overlap ; and, previous commit help arg refactor missing nodes.py in the commit. 2024-08-26 19:58:20 +01:00
Bruno Madeira 509e4f1c09 update README.md - minor detail 2024-08-26 18:52:24 +01:00
Bruno Madeira 9bb520ff67 minor cleanup 2024-08-26 18:32:41 +01:00
Bruno Madeira aa6a08480b update README.md - remove false statement.
can't recall what I was thinking when I wrote this...
2024-08-25 22:09:51 +01:00
Bruno Madeira c8f742846f update README.md - update intro. the details are hidden, so list all implemented features clearly. 2024-08-25 21:08:25 +01:00
Bruno Madeira acf7fa744f update README.md - installation & pystar2d.
___________________________________________
Additional developments:
Tried to automate tolerance by analyzing the min error distribution of random samples.
After some "adjustments" to avoid large tolerances, was able to get values within a nice range. However, for some textures, the value deed not seem adequate, despite falling within an acceptable range. Thus, I will not include this implementation for now, but it might be a good idea to save it as a gist for future reference.
2024-08-25 20:43:04 +01:00
Bruno Madeira ccf63650f6 remove prints & tests from "guess block size" related scripts. 2024-08-24 23:50:55 +01:00
Bruno Madeira 790d9fc7cf update README.md - note regarding overlap value in seamless nodes. 2024-08-24 23:41:19 +01:00
Bruno Madeira a57ea324ac update README.md - typo 2024-08-24 23:17:17 +01:00
Bruno Madeira ccf6b4ede0 update README.md - share potentially useful insight regarding tolerance. 2024-08-24 23:07:04 +01:00
Bruno Madeira 03fdf76d17 bug fix (related to 2391f91dd7) - replace vestigial args in function. 2024-08-24 22:32:17 +01:00
Bruno Madeira 2391f91dd7 bug fix - remove leftover extra argument 2024-08-24 22:16:35 +01:00
Bruno Madeira d48ff81009 update README.md - rename section title 2024-08-24 22:11:10 +01:00
Bruno Madeira 3f6b439c85 update README.md - better identify linked section as the link won't open the details when clicked. 2024-08-24 22:07:51 +01:00
Bruno Madeira 164e1c5c76 update README.md - add documentation about "nice" block size estimation. 2024-08-24 21:59:47 +01:00
Bruno Madeira c9f2ba8361 update README.md - document batch behavior. 2024-08-24 17:29:28 +01:00
Bruno Madeira b395ef5bc1 update README.md - add line separators in lvl 3 headers to facilitate navigation / readability 2024-08-24 17:14:11 +01:00
Bruno Madeira 14ed52b067 update workflows (only to keep images consistent with the output, the workflows remain unchanged) 2024-08-24 17:12:35 +01:00
Bruno Madeira 19405ec763 update README.md - added documentation for blend_into_patch & parallelization diagram 2024-08-24 17:06:56 +01:00
Bruno Madeira 7c145a6806 update synthesis_subroutines.py/blur_patch_mask: add slight blur along the cut when using blend_into_patch + minor refactor 2024-08-23 07:34:23 +01:00
Bruno Madeira 05db2da649 fix corners in make_seamless.py and top block on H patch. 2024-08-23 07:26:45 +01:00
Bruno Madeira 48fb4c006f update README.md
updated some sections of the documentation and added some ToDos
2024-08-22 23:45:04 +01:00
Bruno Madeira 264aae6f39 added new workflow for seamless latent + renamed existing workflow 2024-08-21 23:12:32 +01:00
Bruno Madeira 4a6244dcc8 replace advanced seamless setup.png.
previous workflow is unnecessarily complicated, the new one is better and simpler.
2024-08-21 21:13:18 +01:00
Bruno Madeira fc173c2713 update basic workflows ( breaks documentation, to be fixed later) 2024-08-20 23:52:15 +01:00
Bruno Madeira 33023ae806 refactoring + "micro" optimizations
* abstract repeated code in get_4way_min_cut_patch.
* with the exception of v0, masks are now 2 dimensional arrays.
* re-use already allocated memory when possible.
2024-08-20 16:44:48 +01:00
Bruno Madeira 82e67a2c4a fix issues w/ v0
* fix horizontal patching
* fix tolerance equal to zero
2024-08-20 00:24:50 +01:00
Bruno Madeira 881b5c0577 added blend_into_patch option + refactoring
________________________________
notes:
* patch_blending_vignette cache is cleared post node execution
* new GenParams cleans up args in function, and allows easier adjustments to args if the need arises.
* v0 uses jena2020, ignoring blend_into_patch option.
!! v0 output seemed bizarre on some tests, might have introduced a bug when refactoring...

________________________________
to think about:
* when generating cut mask, output it as single channel instead. blend_into_patch added redundant operation.
* overlap can be small with respect to the block_size, perhaps it is better to handle individual corners in get_4way_min_cut_patch?
* maybe add seed or generator to GenParams.
2024-08-19 23:57:25 +01:00
Bruno Madeira 657dd120e1 cleaning ...
* patch_search.py renamed to synthesis_subroutines.py.
* fixed number of channels when using cv.floodFill with latents in new min cut implementation.
* make_seamless.py and make_seamless2.py use same "min_cut_patch" implementation.
* quilting.py allows to use v0 implementation, but otherwise, also shares the same as seamless nodes.
* check optional lib using importlib
2024-08-19 15:56:04 +01:00
Bruno Madeira 217b71b426 update pyproject.toml - add required and optional dependencies. ; delete requirements.txt (redundant)
____________________________________________
Note:
Technically, opencv could be made optional too, but it would require extra work.
Seamless nodes would either have to be excluded or reworked.
Seems like too much work for some niche applications, not motivated to work on that for now. It would have been easier if I had thought about it apriori, but alas...
For now next planned steps are: to integrate the blend functionality; clean up the code; update the documentation; and update/add workflows.
2024-08-15 23:53:09 +01:00
bmad4ever 912371399f Merge pull request #6 from bmad4ever/main
Update pyproject.toml License
2024-08-15 23:32:54 +01:00
Bruno Madeira 37ebf1c1bd implemented alternative min cut (w/ slightly better performance) + moved stuff around + other minor changes
* blend option not yet added to nodes, might cleanup the code a bit first.
* patch_search.py needs to change name, or maybe be separated into different scripts; TBD.
2024-08-15 20:42:05 +01:00
Bruno Madeira 9c686fa4a8 implemented proper "overlap aware" vignette for blending patches. 2024-08-13 20:27:03 +01:00
Bruno Madeira 776742cdae updated make_seamless.py
* get_4way_min_cut_patch: make left block optional; rename resBlock to res_block; experimenting with blur (deactivated for now, must be added to node once finished).
* get_min_cut_patch_mask_horizontal: specified mask's dtype.

__________________________
Additional Notes:
* if no additional bugs are found, the function should be moved to another file so that it can be re-used by all implementations. Even if blur option ends up not being added, it allows for potential future changes to be applied to all operations.
* blur implementation using distance transform seems okay, but sometimes it seems that the patch's edges become noticeable. this shouldn't happen due to additional square vignette mask, either it is something independent of the blur or there is some bug/oversight.
2024-08-13 01:14:07 +01:00
Bruno Madeira 3fa227e1b6 updated patch_search.py - make clearer that there are two different cases; avoid misleading var name and len check when not using tolerance. 2024-08-13 01:01:39 +01:00
Bruno Madeira 49c239b6f6 fix bug in get_4way_min_cut_patch. 2024-08-12 20:05:40 +01:00
Bruno Madeira 66524c2610 update patch_search.py - fix edge case bug + fix exceptions 2024-08-12 16:16:01 +01:00
Bruno Madeira c91e3f3ca4 remove asserts and add exceptions w/ informative messages + some minor cleanups & documentation. 2024-08-12 14:43:12 +01:00
Bruno Madeira 1347c7bf80 update README.md - fix last item in Multi Patch itemize. 2024-08-12 00:31:26 +01:00
Bruno Madeira 4d1325ea13 update README.md - document SP & MP behavior and new arguments.
* Reminder: I left blur on seams out of the current solution... is it still worth it? might need some time to revisit the idea and test its usefulness within a workflow context.
2024-08-12 00:21:25 +01:00
Bruno Madeira 1664ca790b add documentation/h_seam.jpg 2024-08-11 22:05:50 +01:00
Bruno Madeira 195ce0dc47 added documentation/single_and_multi_patch_vis.jpg 2024-08-11 19:01:59 +01:00
Bruno Madeira 7464e89ba7 update README.md - document new block size options. 2024-08-10 22:09:40 +01:00
Bruno Madeira 5c0f6124e3 add two additional options to block size. 2024-08-10 21:12:24 +01:00
Bruno Madeira 9b7a73f7b2 add note and src res to advanced workflow.
* I feel like I've tried to solve the patch edges before differently; can't recall... hmm...
2024-08-10 21:04:34 +01:00
Bruno Madeira 3687c1a0a4 added 3 new example workflows and the textures used as input 2024-08-09 23:38:08 +01:00
Bruno Madeira 40bcf1220c increase max scale for image quilting. 2024-08-09 20:13:54 +01:00
Bruno Madeira 2f9175a05b Updated guess_block_size.py - fixed bug & changed "formula"
* fix lower bound being set prior to pairs being sorted.
* changed the guess formula.
2024-08-08 21:58:23 +01:00
Bruno Madeira 929dcc122b fixes in bse_desc_util.py
* fixed incomplete edge case handling
* fixed potential non deterministic behavior
2024-08-08 01:47:02 +01:00
Bruno Madeira 902395122e Update README.md & workflow images - add new version argument.
_______________________________
DevNote
a thought just occurred to me, of a likely blunder in nice block size.
there should, at the very minimum, be an addressable area of size equal to the lowest "best" multiple; and the bigger the addressable area the more variation allowed. Therefore, instead of aiming for a highest multiple to maximize performance, I should take this into consideration and further limit the maximum possible value, or define some criteria to better balance the decision.
2024-08-07 23:04:45 +01:00
Bruno Madeira 11ccd0f944 change default patch_search version.
* 2 or 3 should yield slightly better results than 1, so better make one of them the default.
2024-08-07 22:34:32 +01:00
Bruno Madeira 27a664c2cf Fix patch_search version 3 cv flag.
* Result were bizarre, turns out I used the wrong flag!
2024-08-07 22:19:54 +01:00
Bruno Madeira 40fa0855c8 Update REAME.md - document new block_size behavior 2024-08-07 18:29:28 +01:00
Bruno Madeira fc1385f166 seamless nodes for latents. 2024-08-06 18:41:28 +01:00
Bruno Madeira 48fdb5335d make "single block" seamless use src texture as lookup when none is provided 2024-08-06 18:39:42 +01:00
Bruno Madeira f39b88fc2b more robust parallel stripes
* use finally to ensure shared memory is closed/unliked
* use events to coordinate jobs
* "minor" refactoring
2024-08-06 11:36:33 +01:00
Bruno Madeira df0b1ee9d6 fix "version" argument position when calling fill_quad_ps (parallelization_lvl > 1 func) + remove redundant code blocks in nodes.py 2024-08-05 19:26:23 +01:00
Bruno Madeira 000bca3d24 add try/finally blocks to ensure pbar thread is stopped & shared memory released. 2024-08-05 16:30:50 +01:00
Bruno Madeira 28fa8fea58 added node + added feature + fixes.
* new node: GuessNiceBlockSize.
* new feature: image quilting nodes get a special block size range that uses guess_nice_block_size; also works with parallel batch but the guess must be done before parallelization in order to setup the total number of steps in pbar.
* fixes: node options using shallow copy fixed; fixed parallelization error when lookup is None; fixed edge case in bse_desc_util.py.
* misc: guess_nice_block_size can be given an alternative upper bound (needed when patching H seam); guess_nice_block_size can run bse_ft only for faster analysis.
2024-08-05 00:01:07 +01:00
Bruno Madeira 01afd3e042 constrain overlap to a maximum of 50% in seamless nodes. 2024-08-04 15:17:14 +01:00
Bruno Madeira 7081f0c71c type aliases 2024-08-04 14:26:06 +01:00
Bruno Madeira 4c319f8f1b remove misleading comment 2024-08-04 12:40:39 +01:00
Bruno Madeira c81ea5024c wavelength, not frequencies! (bse_ft_util.py) + minor change to guess_block_size.py. 2024-08-04 12:37:53 +01:00
Bruno Madeira 9afba8065c update requirements.txt 2024-08-04 00:39:38 +01:00
Bruno Madeira ede568e849 find "nice" block size. (only functions, no node yet)
* checks sift descriptors sizes.
* checks distances between above mentioned descriptors.
* checks freq. w/ high magnitude in ft.
* selects a size that is close to a multiple of the distances obtained in above listed analyses.
2024-08-04 00:36:13 +01:00
bmad4ever 88fbcbe3e8 Update pyproject.toml License 2024-08-02 23:15:48 +01:00
Bruno Madeira 0287e2d4a2 Refactoring + fixes + added node (ImageMakeSeamlessSB)
* refactored patch_search.py
* fixed H Seam position on v2
* fixed seamless node bar total steps not accounting for batch size
* added uicd logic to make_seamless2.py
* removed mains from make_seamless.py & make_seamless2.py
* other minor cleanups

- triggered error in find_patch_vx due to random gen having a value equal or lesser than zero as argument.
Was not able to reproduce the error again so far.
Conjecture: it may be the case that the min error was negative due to lack of precision when using patch v3, resulting in an empty list of candidates if tolerance is not zero; if this is the case the error should happen only when using version 3.
2024-07-31 16:10:14 +01:00
Bruno Madeira 431d45a090 finished batch related node refactor + added missing function in patch_search.py. 2024-07-31 12:27:40 +01:00
Bruno Madeira 8541318a70 fix bug reported in previous commit details.
* rows and columns args were given in incorrect order when using non parallel solution.
2024-07-31 00:50:15 +01:00
Bruno Madeira 5d1028916e implemented batch for seamless + fix ImageQuilting batch.
* remember to change LatentQuilting to follow the same design pattern!
* also found bug when using certain block_size/text size combos; suspect it is due to "extended" texture size when using parallel ( to be investigated ).
2024-07-31 00:01:11 +01:00
Bruno Madeira 4a315f5410 bare-bones node for seamless texture.
* implemented using 1st solution, from make_seamless.py.
* batches not yet implemented.
2024-07-29 23:55:01 +01:00
Bruno Madeira a2c3ff50e0 simplify & improve 1st solution.
* instead of extending the texture at the bottom, last block touches the bottom edge possibly overlapping prior block by more than the overlap section.

* both solutions should now be ready for node implementation after cleaning up unneeded code.
2024-07-27 15:34:07 +01:00
Bruno Madeira ffc44bab2d added functions patch_horizontal_seam (make_seamless.py) & seamless_both (make_seamless2.py);
added lookup_texture to make_seamless.py solution;
modified make_seamless.py to allow of bigger block_size in make_seamless_horizontally & make_seamless_vertically.
2024-07-25 01:21:05 +01:00
Bruno Madeira 8c26577ad5 make comment clearer.
in case of draw only, but likely rare... consider removing this line later or add a second tolerance argument that is separate from the auxiliary generation
2024-07-13 01:51:03 +01:00
Bruno Madeira e4e9f70733 y & x coords in template were swapped... my bad, look fine now.
deja vu, I feel like I had already fixed this before... maybe reverted by mistake?
2024-07-13 01:42:32 +01:00
Bruno Madeira bbab0d8ea0 whoops when fixing the previous whoops...
tested w/ coeff but when reverting back to source forgot the cv flag.
i think it is fix, but will have to look again with fresh eyes some other time...
2024-07-13 01:28:19 +01:00
Bruno Madeira f6d6c6696a whoops, forgot to roll! testing texture already seemed seamless. after retesting either this solution suck (comparing w/ the other) or there is some mistake in the mix. There might be some way to improve it further, but maybe not worth the ashle. 2024-07-13 01:23:46 +01:00
Bruno Madeira a45c4090c2 implemented alternative way to make the texture seamless.
TODO next:
1. need to clean code a bit for both implementations;
2. 2nd method does not have seamless for both directions. I can patch the texture using one of the other two already implemented fixes. However, it might be a good idea to setup both this new solution and the previous to place the seam in the same spot, so that I can re-use the code.
3. Implement the nodes and provide the relevant options.

I cannot recall by heart, but I think that point 2, or eventually 3 (if only using one node), will likely require the 1st implementation to not extend the texture size; seems likely that that option will be removed.
2024-07-12 22:38:29 +01:00
Bruno Madeira 506e67e2df Refactoring > added type for ui stuff.
I want to test an alternative approach to make the texture seamless, but, in order to re-use already existing code without using ui related stuff when testing all ui related args must be optional.
Bundling them within a single type simplifies the job and improves readability.
2024-07-10 01:54:28 +01:00
Bruno Madeira 1eeb968e14 Refactoring; Fixes; and other changes.
- Renamed quilting folder to jena2020 & parallel_quilting.py to quilting.py.
- Moved generateTextureMap from jena2020/generate.py to quilting.py; renamed it to generate_texture; replaced code sections with previously defined auxiliary methods.
- Fixed zero parallelization level to work with any version.
- Version 2 now converts image to Lab color space (supposes source is in RGB); this is only done to images, not to latent images. ***
- Changed find_patch_v3 behavior.

***
cv is now imported in nodes.py. Therefore, to use any node, cv must be installed.
note that in current implementation conversion to Lab format is done in the ImageQuilting node since it is only applicable when using images.
2024-07-09 18:19:47 +01:00
Bruno Madeira ec51afeba1 Add patch_search.py, which implements patch_search using opencv matchTemplate.
Updated requirements.txt to include opencv.
Add patch_search option (named version) to existing nodes.

Additional notes:
- make_seamless.py should use the methods implemented in path_search.py (currently it is not, and its implementation has a bug).
- consider importing cv only in functions, this way the prior solution can still be used w/o updating requirements... the speedup is so worth though... it might mislead potential users to keep using the 1st implementation... may should remove old solution and force opencv instead? ( to decide later, after seamless node implementation )
2024-07-09 01:36:46 +01:00
Bruno Madeira b6269a3c91 re-implemented patch search using opencv matchTemplate; added script to guess a "good" block size.
! changed previously tested func. to use the matchTemplate, it was not set everywhere in make_seamless.py.

* matchTemplate seems to have better matching (at least when using 4 ways, not sure if the same applies when generating a texture).
* matchTemplate seems considerably faster than "moving window" pixel by pixel in a for loop.
::  Likely a good idea to replace original implementation w/ matchTemplate.
!!  Once done it will be a breaking change.

! if guess_block_size proves useful, will likely add a node for it.
2024-07-08 02:09:58 +01:00
Bruno Madeira c216bde25f remove TODO comment, keep size option was added in prior commit dcc80174b1. 2024-07-07 21:31:16 +01:00