https://github.com/braun-steven/dfi-tensorflow

Implementation of Deep Feature Interpolation in Tensorflow using a VGG19 model

https://github.com/braun-steven/dfi-tensorflow

Science Score: 33.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
    1 of 2 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.0%) to scientific vocabulary

Keywords

deep-learning deep-neural-networks machine-learning tensorflow
Last synced: 10 months ago · JSON representation

Repository

Implementation of Deep Feature Interpolation in Tensorflow using a VGG19 model

Basic Info
  • Host: GitHub
  • Owner: braun-steven
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 116 MB
Statistics
  • Stars: 64
  • Watchers: 9
  • Forks: 13
  • Open Issues: 1
  • Releases: 0
Topics
deep-learning deep-neural-networks machine-learning tensorflow
Created over 9 years ago · Last pushed over 9 years ago
Metadata Files
Readme

README.md

Deep Feature Interpolation

Implementation of the Deep Feature Interpolation for Image Content Changes paper in tensorflow.

The goal is to add a specific target feature to the face of a person. This may be a Mustache or a smiling mouth. The procedure starts with taking k images of people with the feature and k images of people without the feature. These sets (positive/negative) are the input to an - on IMAGENET pretrained - VGG19 network. The output of each image is then fetched at the Relu layers of the third, fourth and fifth convolutional block. This builds a deep feature representation of an image. The deep feature vector of the target feature is then calculated by taking the difference of the mean of the positive and the negative set. To add the target feature to a new image, the target feature vector in the deep feature space will be added to the deep feature representation of this image. The image will then be restored by reverse mapping the deep feature values into the original pixel space, using an optimizer of your choice and the following loss function:

Where z is the new image, x is the input image, phi is the mapping into deep feature space, alpha is a scalar and w is the deep feature vector of the target feature.

Examples

In these pictures a setting with the following parameters was used

| option | value | | ------ | ----- | |optimizer | adam | |lr | 0.1 | |k | 100 | |alpha | 0.4 | |beta | 2 | |lamb | 0.001 | |steps | 2000 |

Start images

Eyeglasses

Sunglasses

Mustache

Female

Heavy Makeup

Mouth wide open

Smiling

Asian

Example execution

bash ./env/bin/python dfi-tensorflow/src/main.py -d dfi-tensorflow/data/ \ -m vgg19.npy \ # Select the model -g \ # Enable gpu --optimizer adam \ # Use adam optimizer --steps 2000 \ # Set steps --lr 0.1 \ # Set learning rate --rebuild-cache \ # Disable caching --k 100 \ # Use 100 nearest neighbours for each set --lamb 0.001 \ # Set lambda --beta 2 \ # Set beta --alpha 0.4 \ # Set alpha -f 'Mustache' \ # Select feature 'Mustache' --person-image dfi-tensorflow/data/lfw-deepfunneled/Donald_Trump/Donald_Trump_0001.jpg # Start with Trump as input image

Setup

Model

Download the VGG19 model from here

Data

Download the LFW-Dataset from here

Python environment

Make sure you have virtualenv installed
Run: bash $ virtualenv -p /usr/bin/python3 env # Create virtual python environment $ ./env/bin/pip install -r requirements.txt # Install all necessary requirements

Enable GPU usage

Follow these instructions up to point 4 to install CUDA on your system.

Usage

``` $ ./env/bin/python src/main.py -h usage: Deep Feature Interpolation [-h] [--data-dir DATA_DIR] [--model-path MODEL_PATH] [--gpu] [--num-layers NUM_LAYERS] [--feature FEATURE] [--person-index PERSON_INDEX] [--person-image PERSON_IMAGE] [--list-features] [--optimizer OPTIMIZER] [--lr LR] [--steps STEPS] [--eps EPS] [--tk] [--k K] [--alpha ALPHA] [--beta BETA] [--lamb LAMB] [--rebuild-cache] [--random-start] [--verbose] [--invert]

optional arguments: -h, --help show this help message and exit --data-dir DATADIR, -d DATADIR Path to data directory containing the images --model-path MODELPATH, -m MODELPATH Path to the model file (*.npy) --gpu, -g Enable gpu computing --num-layers NUMLAYERS, -n NUMLAYERS Number of layers. One of {1,2,3} --feature FEATURE, -f FEATURE Name of the Feature. --person-index PERSONINDEX, -p PERSONINDEX Index of the start image. --person-image PERSONIMAGE Start image path. --list-features, -l List all available features. --optimizer OPTIMIZER, -o OPTIMIZER Optimizer type --lr LR Learning rate interval in log10 --steps STEPS, -s STEPS Number of steps --eps EPS, -e EPS Epsilon interval in log10 --tk Use TkInter --k K, -k K Number of nearest neighbours --alpha ALPHA, -a ALPHA Alpha param --beta BETA, -b BETA Beta param --lamb LAMB Lambda param --rebuild-cache, -rc Rebuild the cache --random-start, -rs Use random startimg --verbose, -v Set verbose --invert, -i Invert deep feature difference (No Beard -> Beard) ```

Owner

  • Name: Steven Braun
  • Login: braun-steven
  • Kind: user
  • Company: @ml-research

PhD Student at the AIML Lab @ml-research, Technical University of Darmstadt

GitHub Events

Total
Last Year

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 91
  • Total Committers: 2
  • Avg Commits per committer: 45.5
  • Development Distribution Score (DDS): 0.044
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Steven Lang s****3@s****e 87
hagenwest h****1@g****m 4
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 1
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 8.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • geopapyrus (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels