Okay, now we're going to put clown wigs on rhinos.
Now.
Whatever you want to do.
We're using the flux context model to do image editing.
So here's an image we already had of a rhino wearing a suit.
And we just wanted to add a clown wig to his head.
And it does a really good job.
You can see that the quality is quite high.
Like it doesn't change anything else about the scene.
So that's what we're trying to accomplish.
Now let's run through it together.
First we need to install file I.
And that's the library we're going to be using.
We'll also have to get an API key for them.
So if you don't have that already you just need to get that from file I dashboard keys.
And then put that in your env file locally under the name file key.
And then that code should just load that into memory.
And it should work hopefully.
All right.
You need to import the file client and also these other libraries for handling the image.
We're going to do this is like a pretty standard function for getting updates while file is processing.
We also need to upload the Rhino image.
So we've got this Rhino in a suit image that's just so we can get a URL online that we can we can pass
into file.
But if you already have the image saved online somewhere, you could just reference that URL.
And we're using specifically under Flux Pro, there's context which is the this relatively new model
here that will let you make changes to the image without making too many different changes to the rest
of the image, other than the thing you're specifically asking it to do, and we're just going to pass
in that on queue update function.
So we get updates as we go, and we're going to run this and see how we do.
So it's a really simple thing to do.
Image editing previously would have been a lot harder, but it's much better now.
Okay, we've got the image back.
Let's see what it looks like.
Yeah, here we go.
It worked.
So in order to show the image before and after, let's do say like before.
Before transformation.
And then we get the image URL.
We'll download that image using the request library and display it.
And then we'll say after transformation, what we actually want in the in here is like the original
image actually.
And then that's just going to display the original image.
And then from that should give us that before and after.
So on before.
And that's on after.
Cool.
So yeah it's pretty pretty straightforward to use.
You just pass in this model it can be relatively expensive.
So just keep an eye on your credits.
But other than that it works really well.