← all repositories
Ha0Tang/AttentionGAN

CycleGAN with a spotlight: teaching GANs to separate foreground from background

A PyTorch rethinking of unpaired image translation that uses learned attention masks to decide what to change and what to keep.

AttentionGAN
Velocity · 7d
+0.3
★ / day
Trend
steady
star history

What it does AttentionGAN performs unpaired image-to-image translation—think horses to zebras, selfies to anime, aerial photos to maps—using a generator that learns separate foreground and background attention masks. The foreground attention selects generated content for regions that should change, while the background attention preserves what ought to stay put. It is built on PyTorch 0.4.1 and follows the training and testing patterns established by CycleGAN.

The interesting bit Most CycleGAN variants transform the whole image and hope the identity loss keeps backgrounds stable. AttentionGAN instead makes the separation explicit: the generator outputs attention masks that act as soft segmentation, giving you a built-in rationale for why each pixel changed or survived. The repo also includes a variant for geometric transformations (AttentionGAN-geo) where source and target domains differ in shape, not just appearance.

Key highlights

  • Dual attention mechanism: foreground and background masks learned end-to-end
  • Supports both unpaired translation and multi-domain tasks (via AttentionGAN-v1 variants)
  • Pretrained models available for horse↔zebra, selfie↔anime, apple↔orange, map↔aerial, and others
  • Evaluation scripts included for FID and KID metrics
  • Academic research only: CC BY-NC-SA 4.0 license, commercial use requires contacting the author

Caveats

  • Requires PyTorch 0.4.1 and Python 3.6; the dependency stack is several years old
  • Paper-reproducible training needs an NVIDIA Tesla V100 with 16 GB memory
  • No mention of training times, convergence behavior, or how attention quality degrades on out-of-distribution images

Verdict Worth a look if you are researching interpretable image translation or need attention masks as a byproduct of generation. Skip if you want a maintained, production-ready pipeline; the tooling and dependencies show their age.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.