Skip to content

Workflow to recreate input image

Hey all, been using ComfyUI for a couple months and absolutely love it. Also psyched this community seems to be so helpful. So much fun all around.

I'm trying to build a workflow that can take an input image and vary it by a given amount. This seems like an oft-asked and well documented problem. Best I can find is turning down denoise to stick to the source image. But this seems to be very nonlinear. In other words, denoise values from 0->0.8 give more or less the input image, and values 0.8->1 seem to give a totally new image. I'm trying to find a more linear solution to this.

The goal is to take an input image and a float between 0->1...the float determines how different the output image should be. So 0.2 would give a kinda-sorta similar image, 1.0 would be a totally new image, and 0.01 would be a very very similar image.

Very curious to hear what approaches folks would recommend! Thanks

2 points9 comments
Open on Reddit
About this post
Posted
Archived
Score
2 · 67% up
Kind
Text
ID
1946o7b

Author

2
posts
5
comments
0
media
View profile

13 comments

​

https://preview.redd.it/7bdzqigsdvbc1.png?width=1507&format=png&auto=webp&s=3726c89c71762e5173034fab68df09c68a5fc4a5

I uploaded the workflow in GH.

You upload image -> unsample -> Ksampler advanced -> same recreation of the original image.
After you can use the same latent and tweak start and end to manipulate it. Also added a second part where I just use a Rand noise in Latent blend. Hope this helps.

1 points

Spent some time playing with this, it's really helpful. Seeing an image Unsampler'ed and then resampled back to the original image was great. I modified this to something that seems to work for my needs, which is basically as follows..

(a) Input Image -> VAE Encode -> Unsampler (back to step 0) -> Inject this Noise into a Latent

(b) Empty Latent -> Inject Noise into this Latent

(c) Latent Blend node to combine a and b by the percentage I want

...then kSample for results. Inject Noise is used, and Get Sigma is used, both from ComfyUI Noise

With this I set the blend_factor on the Latent Blend to control how much noise is added. This seems to work for now, at least!

1 points

Hey there, you and guy you replied to are only people I could find on the internet talking about this latent blend node, it's similar to what I am doing now but not exactly. But this workflow I have could maybe have a use case for maybe creating SVD videos based on recreated input images, like you were talking about (but with added caveat of blending multiple similar images) Instead of the same image it can be a slight varation, thanks to the fully finetuned model. The vae encode node alone seems to reproduce the image but I would actually prefer a "close but not exact" image to originals that almost matches.

I just made a post about doing this to some extent with a funetuned subject because blending the latents with SVD latent was really drastically improving svd video results of a dreambooth subject I trained on.

I'll go over how I do this in case anyone wants to try: I used three three original txt2img worksflows that create three separate image generations of the subject (in this same workflow). Then having the latents from them go to multiple latent blend nodes in combination with the svd latent from svd image conditioner (same prompts, different seeds and models for each txt2img generator in the workflow) Then it goes into the main sampler's latent input, and the typical video combine stuff.

This is using three vae encodes for each txt2img workflow, with a dataset images cropped to 1024x577 (the vae encode with pixels input, vae input and latent output) for me that actually still produced flexible images and improved likeness, but they were still too different for my goal.

But anyways, then I merge all three images with the blend latent nodes and blend with the svd latent, and it goes into the main sampler's latent input, and it somehow fixes the weird augmentation blur for me that you typically see with SVD, and the boring camera pans went away, where there is no movement. It's like the AI brain used the information from the 3 separate views to make the video and likeness better.

My workflow is a huge mess and am trying to fix it and share it, but I'm 99% sure it's these blend nodes and blend multipliers doing it because the likeness increases in the videos when I mess with the settings. Just curious about if you still use this node and any findings you came across, or experiments you ran. Thanks!

Edit: Didn't explain right originally, corrected

1 points

Hey there, you and the guy that replied to you are only people I could find on the internet talking about this latent blend node, it's similar to what I am trying to do now but not exactly. I tried your workflow out because it seems it will help with what I'm trying to do.

This separate workflow I'm working on now could maybe have a use case for maybe creating SVD videos based on 3 recreated input images, but with added caveat of blending the latents with SVD latent.

Instead of the same image it can be a slight variation, thanks to the three fully finetuned models on the subject. The vae encode node alone seems to reproduce the image but I would actually prefer a "close but not exact" image to originals that almost matches.

I just made a post about doing this to some extent with a funetuned subject because blending the latents with SVD latent was really drastically improving svd video results of a dreambooth subject I trained on.

I'll go over how I do this in case anyone wants to try: I used three three original txt2img worksflows that create three separate image generations of the subject (in this same workflow). Then having the latents from them go to multiple latent blend nodes in combination with the svd latent from svd image conditioner (same prompts, different seeds and models for each txt2img generator in the workflow) Then it goes into the main sampler's latent input, and the typical video combine stuff.

This is using three vae encodes for each txt2img workflow, with a dataset images cropped to 1024x577 (the vae encode with pixels input, vae input and latent output) for me that actually still produced flexible images and improved likeness, but they were still too different for my goal.

But anyways, then I merge all three images with the blend latent nodes and blend with the svd latent, and it goes into the main sampler's latent input, and it somehow fixes the weird augmentation blur for me that you typically see with SVD, and the boring camera pans went away, where there is no movement. It's like the AI brain used the information from the 3 separate views to make the video and likeness better.

My workflow is a huge mess and am trying to fix it and share it, but I'm 99% sure it's these blend nodes and blend multipliers doing it because the likeness increases in the videos when I mess with the settings. Just curious about if you still use this node and any findings you came across, or experiments you ran. Thanks!

1 points

Hi! Sorry for the late response. Yeah, I used a lot the Unsampling nodes for get the same imagen and get the same latent image for that one so I can decide at which step I can make the variations. If you don't want to get the same image you can always use in the KSampler advanced something like:

X steps and start at 0 or more and end at less than X (x-y).

Ex: 100 steps, start at 20 (the later you start, more likeness you will have) and end at 90 (same here but in the contrary).

I still need to mess with some other nodes that came recently, one was created by matt3o called variations and I think it's a bit of what I explained here. Will tell you how it go ;).

1 points

You can also try to unsample the image (BNK unsampler for ex), get the latent-> inject the lateng in Ksampler advanced from start-end till you reach the image. With CFG 1 use to works.

1 points

Thanks all, these ideas sound along the lines of what I've been thinking. I have a setup which actually varies an empty latent by a 0->1 value and the results are pretty controllable.

Here is an image where I keep the prompt and the seed fixed, and gradually increase the VariationAmount (in my setup). Notice how the image changes as I increase the amount...

(top: variation workflow I use)

(bottom: results of increasing VariationAmount from 0->1, left to right)

https://preview.redd.it/3xdhfuxm1vbc1.png?width=3226&format=png&auto=webp&s=19e7b2a6573137163e21b6dc8f6ca47d161b30b2

My thinking is if I can get a workflow that takes an input image as a latent I can slowly apply this workflow to get variations. The trick is to get the noisy latent that produced the input image.

I know the Unsampler can do this, but when I pass it back through a kSampler, I get a really really contrasty image back.

1 points

I can do that in the Workflow. Will send it later in Discord.

1 points

Use ControlNet/T2I adapter as an additional method of controlling the Similarity/Difference.
This is extremely useful if you want to do things like change colors, but want to retain other aspects of the image (pose, depth, lineart, IE anything ControlNet can do).

I would also recommend some method of latent blending/noise injection as well, just for additional control. I like to use color gradients as latent to control lighting. BlenderNeko made some good nodes for this in their Noise Repo: https://github.com/BlenderNeko/ComfyUI_Noise

​

You can also do some very simple stuff like flipping the latent.

I can think of other ideas to do simple things like change eye or hair color with MediaPipeFaceMesh. LtDrData has some VERY good nodes that can do stuff like that in his Impact Pack: https://github.com/ltdrdata/ComfyUI-Impact-Pack
Inspire pack has controlnets for use with Impact Pack: https://github.com/ltdrdata/ComfyUI-Inspire-Pack

(Impact pact are the nodes I use the most and they are extremely useful).
It honestly depends on your definition of "Different." I think the best approach would be to refine exactly HOW you want the image to be different, and then make little groups of nodes that can accomplish each task, and then figure out how you would want those groups to interact with each-other.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.