Generative AI Image Editing
I’ve always loved me some astronomy! Recently my imagination has been fired-up from my backyard, taking images (opens in a new tab) of the night sky and roaming the universe.

I generally capture multiple images of an astronomical object which I then stack and process using dedicated astronomical software, PixInsight (opens in a new tab). After which I tweak in Photoshop (opens in a new tab).
This got me thinking, how might generative AI be used for editing existing images?
As I covered in a previous blog post, we’ve just had a bumper year in AI due to generative algorithms, especially for images. Midjourney (opens in a new tab), Stable diffusion (opens in a new tab) and DALL∙E 2 (opens in a new tab) can produce stunning images from simple text prompts. Resources for creative people (opens in a new tab) have already started appearing and platforms for stock images are making provisions for AI-generated art (opens in a new tab). Much of the focus has been on image generation creating new images from scratch, but it’s very likely AI will soon have a big impact on processing too.
Adjusting image content (non-trivial semantic edits)
Sometimes a photo is great apart from that one thing. Perhaps there is a person in the background stealing cookies, ruining the family group photo, or you really wanted your cat and goat photo to have the goat jumping over the cat (these things matter).
Generally edits like this require pretty advanced knowledge of tools such as Photoshop (with hilarious results (opens in a new tab)). Text-based image editing such as SDEdit (opens in a new tab), DDIB (opens in a new tab), and Text2LIVE (opens in a new tab) have been available for the last couple of years, but these methods have been a bit constrained in various ways such as requiring multiple input images, being limited to certain domains and editing actions, or requiring multiple text directives.
However, in their 2022 Kawar et al (opens in a new tab) proposed a new powerful way to make text-based image editing a whole lot easier. Using a pre-trained text-to-image Diffusion Model which “produces a text embedding that aligns with both the input image and the target text, while fine-tuning the diffusion model to capture the image- specific appearance.”, they were able to alter images with only a single input image and text directive. Importantly their technique (called “Imagic”) can be used for any type of edits, any image domain, and doesn’t require complicated things like photo masks to indicate where in the image the edit should occur.

A new AI benchmark is born
Being such a new field, in the absence of existing benchmarks the authors also created a new one called TEdBench (Textual Editing Benchmark). This consists of 100 pairs of input images and editing text directives (eg “A goat jumping over a cat”). Using these they created comparisons of Imagic with two other leading text editing techniques and had humans review using Amazon Mechanical Turk (opens in a new tab). After 10,346 responses Imagic was preferred 63% of the time, suggesting that not only is Imagic simpler to use, the resulting quality is better too.

Deep Fakery
There is of course a dark side to this amazing work. It becomes even easier for bad actors to take an image and adjust it maliciously. It doesn’t take much to imagine images of stars (people, not astronomical) being altered to make headlines. The authors do note this in the paper and that future research is needed to address potential societal impact. Digital watermarks might work in some cases, but there isn’t anything to stop people training their own models to circumvent this, other than expertise and cost. It’s too early to see how this will all work out, but one hopes deep fakes will be easy to identify.
Where next?
Almost anything text can of course be spoken these days, Imagic’s simplicity and generalizable approach should make it possible to simply ask photo editing software to do what you’d like without having to know advanced image processing techniques, at least to a level acceptable to most users. It may be some time before this appears in photo editing software, hopefully after safety concerns have been addressed, but the way would appear to be open.
I won’t be happy though until it can accurately edit an image to show a lady holding a giant shrimp (opens in a new tab), but that day is coming.
EDIT:
Since writing this article, image editing with DALL-E2 is now available (beta).
I now have hair!
