GithubHelp home page GithubHelp logo

interdigitalinc / hrfae Goto Github PK

View Code? Open in Web Editor NEW
288.0 7.0 64.0 2.8 MB

Official implementation for paper High Resolution Face Age Editing

Home Page: https://arxiv.org/abs/2005.04410

License: Other

Python 84.28% Shell 0.21% Jupyter Notebook 15.52%

hrfae's Introduction

HRFAE: High Resolution Face Age Editing

Official implementation for paper High Resolution Face Age Editing.

Teaser image

Dependencies

  • Python 3.7
  • Pytorch 1.1
  • Numpy
  • Opencv
  • TensorboardX
  • Tensorboard_logger

You can also create a new environment for this repo by running

conda env create -f env.yml

Load and test pretrained network

  1. You can download the pretrained model by running:

    cd ./logs/001
    ./download.sh
    
  2. Upload test images in the folder /test/input and run the test file. The output images will be saved in the folder /test/output. You can change the desired target age with --target_age.

    python test.py --config 001 --target_age 65
    

Train a new model

  1. Pretrained age classifier

    To get age information, we use an age classifier pretrained on IMDB-WIKI dataset. We use the model released from paper Deep expectation of real and apparent age from a single image without facial landmarks by Rothe et al.

    To prepare the model, you need to download the original caffe model and convert it to PyTorch format. We use the converter caffemodel2pytorch released by Vadim Kantorov. Then name the PyTorch model as dex_imdb_wiki.caffemodel.pt and put it in the folder /models.

  2. Preparing your dataset

    Download FFHQ dataset and unzip it to the /data/ffhq directory.

    Download age label to the /data directory.

    You can also train the model with your own dataset. Put your images in the /data directory. With the pretrained classifier, you can create a new label file with the age of each image.

  3. Training

    You can modify the training options of the config file in configs directory.

    python train.py --config 001 
    

Google Colab

We also provide a colab version for quick test. To run it using Google Colab, please click here.

Citation

@article{yao2020high,
    title   = {High Resolution Face Age Editing},
    author  = {Xu Yao and Gilles Puy and Alasdair Newson and Yann Gousseau and Pierre Hellier},
    journal = {CoRR},
    volume  = {abs/2005.04410},
    year    = {2020},
}

License

Copyright © 2020, InterDigital R&D France. All rights reserved.

This source code is made available under the license found in the LICENSE.txt in the root directory of this source tree.

hrfae's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hrfae's Issues

CELoss may be wrong?

Hello:
I find some code that I think may be wrong
return nn.CrossEntropyLoss()(x, target_age)
https://github.com/InterDigitalInc/HRFAE/blob/master/trainer.py#L62

which should be
return nn.CrossEntropyLoss(x, target_age)
?

I don't know if it has some impact.

the test model looks like based on cuda device

Hi bor:
when I try to run test.py, and when the code go into line 58:
trainer.load_checkpoint(log_dir + 'checkpoint')
then an error happend at here.
'''
raise RuntimeError('Attempting to deserialize object on a CUDA '
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

'''
this looks like means I must run these code on a cuda device.
or because of this test model is trained on a cuda device, I must build a new model which supported on CPU only?

dex_imdb_wiki.caffemodel.pt

Hi, I would like to train the model, but I had the problem when convert the caffe model to pt file. Is that possible to provide the dex_imdb_wiki.caffemodel.pt file for me?

how train in different resolution?

@Xu-Yao Thanks you very much for the code you shared.Could you please provide the code train for other resolution pictures and your dataset about 50,000 face images you made.

About age-equalized dataset

Hi @Xu-Yao
Thanks for sharing this code.

I checked the paper, and found that you are solving data imbalance using StyleGAN generated images (Section 4.1).
But unfortunately, not in the paper or here, there is no information on how to access this dataset (age-equalized).

If it is possible, could you share this dataset, please.

how much time

How much time do you spend on 70,000 pictures while training?

run download.sh failed

Hello,
looks like download weight URL died.
it returns HTTP ERROR 500 and get a 0 byte checkpoint file.
could you please fix it?
Thanks.

Problem converting dex_imdb_wiki.caffemodel to .pt

Hi, I had the problem when convert the caffe model to pt file. Problem is" FileNotFoundError: [Errno 2] No such file or directory: 'protoc': 'protoc' "
Is that possible to provide the dex_imdb_wiki.caffemodel.pt file for me ?
Thanks.

how to get faces of children

Thanks for your work very much.
there is a question that: when I test the pics prepared, i set '--target_age 5' , it can not generate faces of chilren well ?

How to convert to ONNX model?

Do anyone try to convert trained model to ONNX model, please?
Don't know how to use torch.export because there're multiple networks.
Hope can get help here, thanks.

Can't we change input data in configs file?

We have:

# Input data
input_w: 1024
input_h: 1024

in configs/001.yml file. Can't we change it to other pixel formats, for example, 3780x6720 or retaining the original size of images? Please feel free to throw some light on why it can't accept the image as is.

I tried changing it to given example but the program was immediately killed.

It gives weird outputs when the size is changed to 1024x1024. Check the images. The first one is original, second one is the output by the model.

Screenshot from 2020-05-17 18-21-24
Screenshot from 2020-05-17 18-03-02

no module named 'torch'

I have verified that I have installed pytorch, when I type conda list I see the following:

pytorch 1.5.0 py3.7_cuda102_cudnn7_0 pytorch

however, when I try to run this code after following your instructions and setting up an environment I receive the following error:

Traceback (most recent call last):
File "test.py", line 11, in
import torch
ModuleNotFoundError: No module named 'torch'

Any help with this issue would be greatly appreciated.

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.