# Sprite Animation Generation - Background Removal 2

**Previously**, we looked at bunch of [background removal options](https://blog.sprited.app/sprite-animation-generation-background-removal) 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**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753742841951/66cf9bf8-9770-4fd1-9122-a35cfcbc6e83.png align="center")

---

## Anime-Seg

One promising option I found was [skytnt/anime-seg](https://huggingface.co/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.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753742872249/7413c45f-330b-4ab9-9c1b-a598efc69232.png align="center")

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 Hack

**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.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753743069222/72135ced-1394-49e2-9cdf-9443418087da.png align="center")

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.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753743358259/361ad451-56c2-4ad1-9eea-fccd1328211d.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753743874738/26d52e0d-017f-4545-a4ad-01e383961a21.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753743949222/70edf019-9067-41b1-9817-05a36d40ea50.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1753743732375/1cf6f59e-478e-4eed-be15-2a8be009113a.png align="center")

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
