Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
B

Barbershop

> 编程语言
Open source

Barbershop: GAN-based Image Compositing using Segmentation Masks (SIGGRAPH Asia 2021)

1.4K stars0 likes0 views
WebsiteGitHub

About

Barbershop: GAN-based Image Compositing using Segmentation Masks (SIGGRAPH Asia 2021)

# Barbershop: GAN-based Image Compositing using Segmentation Masks > [**Barbershop: GAN-based Image Compositing using Segmentation Masks**](https://zpdesu.github.io/Barbershop/)
[Peihao Zhu](https://github.com/ZPdesu), [Rameen Abdal](https://github.com/RameenAbdal), [John Femiani](https://scholar.google.com/citations?user=rS1xJIIAAAAJ&hl=en), [Peter Wonka](http://peterwonka.net/)
> [arXiv](https://arxiv.org/abs/2106.01505) | [BibTeX](#bibtex) | [Project Page](https://zpdesu.github.io/Barbershop/) | [Video](https://youtu.be/ZU-yrAvoJfQ) > **Abstract** Seamlessly blending features from multiple images is extremely challenging because of complex relationships in lighting, geometry, and partial occlusion which cause coupling between different parts of the image. Even though recent work on GANs enables synthesis of realistic hair or faces, it remains difficult to combine them into a single, coherent, and plausible image rather than a disjointed set of image patches. We present a novel solution to image blending, particularly for the problem of hairstyle transfer, based on GAN-inversion. We propose a novel latent space for image blending which is better at preserving detail and encoding spatial information, and propose a new GAN-embedding algorithm which is able to slightly modify images to conform to a common segmentation mask. Our novel representation enables the transfer of the visual properties from multiple reference images including specific details such as moles and wrinkles, and because we do image blending in a latent-space we are able to synthesize images that are coherent. Our approach avoids blending artifacts present in other approaches and finds a globally consistent image. Our results demonstrate a significant improvement over the current state of the art in a user study, with users preferring our blending solution over 95 percent of the time. ## Description Official Implementation of Barbershop. **KEEP UPDATING! Please Git Pull the latest version.** ## Updates `2021/12/27` Add dilation and erosion parameters to smooth the boundary. #### `2021/12/24` Important Update: Add semantic mask inpainting module to solve the occlusion problem. Please git pull the latest version. `2021/12/18` Add a rough version of the project. `2021/06/02` Add project page. ## Installation - Clone the repository: ``` git clone https://github.com/ZPdesu/Barbershop.git cd Barbershop ``` - Dependencies: We recommend running this repository using [Anaconda](https://docs.anaconda.com/anaconda/install/). All dependencies for defining the environment are provided in `environment/environment.yaml`. ## Download II2S images Please download the [II2S](https://drive.google.com/drive/folders/15jsR9yy_pfDHiS9aE3HcYDgwtBbAneId?usp=sharing) and put them in the `input/face` folder. ## Getting Started Preprocess your own images. Please put the raw images in the `unprocessed` folder. ``` python align_face.py ``` Produce realistic results: ``` python main.py --im_path1 90.png --im_path2 15.png --im_path3 117.png --sign realistic --smooth 5 ``` Produce results faithful to the masks: ``` python main.py --im_path1 90.png --im_path2 15.png --im_path3 117.png --sign fidelity --smooth 5 ``` ## Todo List * add a detailed readme * update mask inpainting code * integrate image encoder * add preprocessing step * ... ## Acknowledgments This code borrows heavily from [II2S](https://github.com/ZPdesu/II2S). ## BibTeX ``` @misc{zhu2021barbershop, title={Barbershop: GAN-based Image Compositing using Segmentation Masks}, author={Peihao Zhu and Rameen Abdal and John Femiani and Peter Wonka}, year={2021}, eprint={2106.01505}, archivePrefix={arXiv}, primaryClass={cs.CV} } ```

GitHub Issues· 64 open

View all on GitHub
  • #73

    Collaboration Proposal for Enhancing Synthesis Quality of Barbershop

    Updated Jun 9, 2025
  • #72

    Very slow processing time (10-15 mins per image)

    Updated May 6, 2025
  • #71

    A newer version

    Updated Mar 8, 2025
  • #70

    Error running main.py

    Updated Dec 1, 2024
  • #63

    can't use the command conda env create -f environment/environment.yaml (different packages that are not found every time I ran the command)

    Updated Aug 14, 2024
  • #68

    Did anyone get this working?

    Updated Jul 17, 2024
  • #69

    ninja: build stopped: subcommand failed.

    Updated Jun 26, 2024
  • #10

    Black images output

    Updated Apr 4, 2024
  • #64

    Issue with align_face.py

    Updated Feb 18, 2024
  • #56

    Can this method be used in hairstyle transfer on full-body image of person?

    Updated Dec 7, 2023

Highlights

  • •Clone the repository:
  • •Dependencies:
  • •add a detailed readme
  • •update mask inpainting code
  • •integrate image encoder
  • •add preprocessing step

> Tags

Python

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言