Mimic Any Image With AI (CLIP Interrogator Demo)
How to use the free CLIP Interrogator tool to easily reverse-engineer photos and other types of images.
EDIT June 11, 2023: The original CLIP Interrogator seems to be discontinued, but there’s now the more advanced CLIP Interrogator 2.
AI image generators are impressive and fun to experiment with.
But what if you’re after a very specific look or style? What if you already have a reference image and want AI to create something visually similar?
Well, one option is to use Lexica to find a matching image and see which prompt was used to get it. (I discuss the Lexica site in a bit more detail in my post about testing text-to-image prompts.)
Here’s the thing: Lexica is great if the type of image you’re after has already been generated by someone using Stable Diffusion.
But:
If there’s no similar image in their database, you’re basically stuck.
It often takes quite a bit of time to search, browse, and sort through the images to find the one you need.
The alternative is to get really good at prompt engineering and learn exactly which descriptors get you the results you’re after.
That’s it. Those are the two options.
Thanks for reading. Good luck!
…except you’ve already read the title of this post and know there’s more.
So what if there was a tool that could scan an image and spit out a text prompt to generate similar ones?
That tool exists, and it’s called the CLIP Interrogator.
Best of all, the CLIP Interrogator is 100% free and stupidly easy to use.
Let’s take a quick look-see.
WTF is a “CLIP Interrogator”?
The “CLIP” part is for “Contrastive Language-Image Pre-Training”—it’s how you train AI models to correctly match text descriptors with the right images. OpenAI has this detailed article about CLIP, if that’s what you’re into.
The “Interrogator” part is pretty much what it says on the tin.
Putting it together, you get software that can look at an image and try to return a text string that might’ve been used to generate it.
Now let’s see how we can use it to quickly reverse-engineer images.
CLIP Interrogator step by step
EDIT: The original CLIP Interrogator doesn’t seem to be working. There’s a CLIP Interrogator 2 that works largely the same as below with a few bonus options.
It’s really quite a straightforward process.
I’ll walk you through it using a sample image.
1. Go to the CLIP Interrogator site on Hugging Face:
2. Upload or drop the image you want to mimic into the box on the left:
3. Click the orange “Submit” button:
4. Poof! Here’s your text prompt (it takes up to 1 minute):
5. Copy-paste the resulting prompt into your preferred Stable Diffusion art generator.
For quick basic images, you can just use the free Hugging Face demo version:
6. Generate your lookalike image(s).
I’ve used my go-to Stable Diffusion generator over at dreamlike.art. Here’s the result:
As you can see, most of the images closely match the lighting, composition, and general aesthetic of the original.
Pretty cool, huh?
Dealing with CLIP Interrogator’s limitations
On occasion, the CLIP Interrogator will spit out odd phrases or add details that are clearly not present in the original image. The good news is that the power is completely in your hands. You get to keep only those parts of the prompt that makes sense.
Similarly, the CLIP Interrogator may miss an important detail, as was the case with this AI-generated image of a squirrel I tried to reverse-engineer:
The prompt output was:
Note that while the prompt did include the terms “winged archer,” “cupid,” and “avian warrior,” it didn’t clearly attach the wings to the squirrel itself. So my mimicked squirrels, while very close, didn’t have any wings:
By simply adding the term “with cupid wings on its back,” I got a better outcome for several of the images:
There’s no way I would’ve gotten the rest of the look this close without first using the CLIP Interrogator.
So add what you need, remove what you don’t, and you’ll get the right doppleganger image every time!
Over to you…
Do you use an alternative method to generate images similar to an existing one? Have you found a better way to work with the CLIP Interrogator to get the results you want?
If so, I’d love to hear from you. Drop me an email or leave a comment below.
As of 9 June 2023 there seems to be a problem with the CLIP-Interrogator site (https://huggingface.co/spaces/pharma/CLIP-Interrogator). It loads with a Runtime Error message and generally doesn't look at all like the screenshot in your article.