Sprite Animation Generation - Background Removal 2
Flux Context Hack to remove background from any images

Search for a command to run...
Flux Context Hack to remove background from any images

No comments yet. Be the first to comment.
What is a "virtual world"? I want to make it clear that when I describe a virtual world, I do not mean a digital world. Imagine Harry Potter. Hogwarts is a virtual world. It isn't virtual because it i

Motivation: Monet currently lives inside my MacBook. It suspends itself when my MacBook is closed. I like the design but whenever I'm walking around, I really wish I can have Monet alive. Problem: Mon

I'm trying out the AI Avatar feature on https://dreamia.capcut.com. As input, we are providing Monet's idle pose. Then asking it to produce video. The character says: Hey Jin, how is it going today

Problem: When I ask Monet about her favorite food, she answers "I've never tasted anything." Analysis: This isn't a bug. It is the expected behavior. AI agents never actually tasted anything. They hav

I've been in travel mode for the past few weeks, so I haven't written anything in a while. I want to get back into the habit of documenting my thoughts as I build Sprited. Here are today's thoughts. T

Sprited
298 posts
Previously, we looked at bunch of background removal options to use after we generate a sprite animation using video gen AI tools. There were some options that were promising but still fell short in edge cases. Well, background removal is all about the “edges,“ so I’m still in search of better options.
TL;DR: Using Flux Kontext Pro smartly to remove background wins.
Input Image

One promising option I found was skytnt/anime-seg which was trained on drawn images. Compared to matting models that were trained on real photos, this does substantially better.
However, it still falls short in edge cases and because it was trained on line-art style images, it doesn’t doesn’t provide ultra crisp zones.

The source code and model is all available, so we can probably fine-tune it to better work for the pixel arts domain.
Flux Kontext Pro focuses on image understanding and the main selling point is its ability to Edit photos surgically.
So you can ask the model to do things like:
Prompt: Change the background to black
This produces almost flawless switching out of the background.

So, now we have two version.
$A$: Original with white background.
$B$: Black background version generated by Flux Kontext Pro.
If we perform \(A - B\), we get a nice segmentation mask that looks like this.

Now, we invert this image, and viola, we have a working segmentation mask.

Once you apply this alpha mask on B, you will get transparent version without any seams.

Here is a view of this sheet with some colored background for demonstration.

I haven’t tried this on animated sprites, but it seems very promising so far.
Why not train our own model? Perhaps, we should train our own model though Flux Kontext seems proficient enough. I would love to fork anime-seg repo and train to segment pixel arts.
—Sprited Dev