Giter Site home page Giter Site logo

splice-transfer's Introduction

Splice: Splicing ViT Features for Semantic Appearance Transfer

An unofficial implementation of Splice (CVPR 2022 Oral).

Getting Started

This code is developed with python version 3.8, PyTorch 1.13.0, CUDA 11.6 and torchvision 0.14.0.

In addition to DINO, we also investigated the performance of weakly-supervised ViT (CLIP) through feature inversion. Please download the pre-trained DINO-ViT & CLIP-ViT(optional) from here and place them in ./checkpoints.

Feature Inversion

There are two methods for feature inversion:

  1. solely optimizing the image pixels
  2. optimizing for the weights of a CNN that translates a fixed random noise z to an output image.

Note that solely optimizing the image pixels is insufficient for converging into a meaningful result, as mentioned in paper.

Run example:

python inversion.py --target=./data/0001.png --use_cnn=True --inv_type=cls --layer=11

Run python inversion.py --help for more details.

PCA Visualization

PCA visualization of the ViT facets' self-similarity. The leading components mostly capture semantic scene/objects parts, while discarding appearance information.

Run example:

python pca_visualization.py --image_path=./data/0001.png --facets=k,t --layers=2,5,11

Run python pca_visualization.py --help for more details.

Splice Transfer

Training

By default, we use the pretrained ViT(dino-base-8) as feature extractor. Given two images as source and target respectively, run the following command for training.

python splice.py --target=[TARGET_IMAGE_PATH] --source=[SOURCE_IMAGE_PATH]

Inference

python inference.py --ckpt=[GENERATOR_CHECKPOINT_FILEPATH] --source=[INPUT_IMAGE_FILEPATH] --output=[OUTPUT_DIRECTORY] --name=[OUTPUT_IMAGE_NAME]

splice-transfer's People

Contributors

zichongc avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.