All right.
Advanced consistent characters.
So how do you take a character in one image and use the exact same character in a different scene?
So this is the same guy in a business suit or playing tennis?
I have a little trick for doing this.
I used to do this in Midjourney, and I figured out a way to do it in foul recently, so that's what
we're trying to accomplish.
I'll just show you guys this how it works.
We're going to run through it one by one.
So first we need to just install the foul client, make sure it's there and then load the environment
variables so we can get a API key for foul the foul key.
So make sure you've done that there.
And then we just need to bring in the foul client.
So let's import foul client import request Pil image bytes IO.
And then get the Python display as well.
All right.
And we want to take the original image which is this rhino in a suit.
And then we want to shrink the image.
Oh, actually.
Sorry.
We want to basically create a new image which will double the width.
Right.
So create a new image with double width and white background.
All right.
So this doubles the width and that keeps the original height.
And then we're just creating this new image.
And then we just paste the original image on the left hand side.
And then we want to just save that and upload that to file.
So we have that.
And then here what we're doing is we are taking the the image size and basically creating a mask on
the right hand side.
So it's going to make the right hand side of the image black.
And it's going to make the left hand side of the image white.
And we basically just need to mask image paste paste that original image region on the canvas, and
then we can upload that as Tim mask.
Get the URL.
And then we're going to see both these side by side.
So this is all the hard work.
Essentially it's just to create this new image with a section on the right.
And you can't really see this very well.
But this image goes all the way across here.
So paste that image on here and then adds this section on the right hand side, which is a white section.
And then it adds a black mask.
So these two are going to be uploaded separately.
And then from there on out it's basically just inpainting.
And the reason why this works is that we have when you're inpainting, it takes into account the rest
of the image.
It'll stay consistent with that image.
And that's why this works.
Because if you just create something new from the prompt, it hasn't seen the other image.
And even with image to image, it doesn't always work that well.
Whereas when you're inpainting it has better prompt adherence is what I find.
So let's see what that looks like.
The prompt output is I've just again, we're just prompting for the right hand side of the image.
We're feeding it in the left and we're saying on the right, like making it look like a caption.
The photo of the same rhino wearing tennis clothes, carrying a tennis racket, playing tennis on a
tennis court.
And we're using this fill model, which is really good for out painting.
I think that's super important.
We've got the new width and the new height here.
We're passing that in the image size and here we go.
We've got the same rhino but playing tennis right.
So really cool.
And yeah you could do whatever you want.
The really useful thing I found is if you wanted to fine tune on the same character, you could go and
generate a bunch of these, you know, in different scenarios, different situations, and then chop
them all up programmatically, divide the image in half, and then you've got a load of different images
of the same character in different spaces.
And then that could be your fine tuning data.
So that's one of the ways I use this.
But yeah, lots of different ways to tease.
This is a good little hack.
Again, I did it in Midjourney primarily initially, but now you can program and make that programmatic
in.