{"id":24169768,"url":"https://github.com/houxianxu/dfc-vae","last_synced_at":"2025-08-20T06:39:56.246Z","repository":{"id":71416035,"uuid":"72644921","full_name":"houxianxu/DFC-VAE","owner":"houxianxu","description":"Variational Autoencoder trained by Feature Perceputal Loss","archived":false,"fork":false,"pushed_at":"2019-04-12T02:38:34.000Z","size":26983,"stargazers_count":82,"open_issues_count":1,"forks_count":22,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-03T09:50:59.823Z","etag":null,"topics":["celeba-dataset","face-images","generative-model","torch","vae"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/houxianxu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-02T13:56:28.000Z","updated_at":"2024-10-06T06:48:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"85ac6388-9b91-486a-bf20-9702e013fe77","html_url":"https://github.com/houxianxu/DFC-VAE","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/houxianxu/DFC-VAE","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houxianxu%2FDFC-VAE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houxianxu%2FDFC-VAE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houxianxu%2FDFC-VAE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houxianxu%2FDFC-VAE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/houxianxu","download_url":"https://codeload.github.com/houxianxu/DFC-VAE/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houxianxu%2FDFC-VAE/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271279327,"owners_count":24731901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["celeba-dataset","face-images","generative-model","torch","vae"],"created_at":"2025-01-12T23:14:41.947Z","updated_at":"2025-08-20T06:39:56.234Z","avatar_url":"https://github.com/houxianxu.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# DFC-VAE\n\nThis is the code for the paper\n\n**[Deep Feature Consistent Variational Autoencoder](https://houxianxu.github.io/assets/project/dfcvae)**\n\nThe paper trained a Variational Autoencoder (VAE) model for face image generation. In addition, it provided a method to manipluate facial attributes by using attribute-specific vector.\n\u003c!-- ![This is a title]('images/results.png') --\u003e\n\n- Pretrained model trained on [CelebA dataset](http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html)\n- Code for training on GPU\n- Code for different analysis\n\n## Installation\nOur implementation is based on [Torch](http://torch.ch/) and several dependencies.\n\nAfter installing Torch according to [this tutorial](http://torch.ch/docs/getting-started.html), use following code to install dependencies:\n\n```bash\nsudo apt-get install libprotobuf-dev protobuf-compiler\nluarocks install loadcaffe\nluarocks install https://raw.githubusercontent.com/szym/display/master/display-scm-0.rockspec\nluarocks install nngraph\nsudo apt-get install libmatio2\nluarocks install matio\nluarocks install manifold\nsudo apt-get install libatlas3-base # for manifold\n```\n\nwe use a NVIDIA GPU for training and testing, so you also need install GPU related packages\n\n```bash\nluarocks install cutorch\nluarocks install cunn\nluarocks install cudnn\n```\n\n## Dataset preparation\n\n```bash\ncd celebA\n```\nDownload img_align_celeba.zip from http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html under the link \"Align\u0026Cropped Images\".\n\nDownload list_attr_celeba.txt for annotation.\n\n```bash\nunzip img_align_celeba.zip; cd ..\nDATA_ROOT=celebA th data/crop_celebA.lua\n```\n\nWe need pretrained VGG-19 to compute feature perceptual loss.\n```\ncd data/pretrained \u0026\u0026 bash download_models.sh \u0026\u0026 cd ../..\n```\n\n## Training\n\nOpen a new terminal and start the server for display images in the browser\n```bash\nth -ldisplay.start 8000 0.0.0.0\n```\nThe images can be seen at http://localhost:8000 in the browser\n\nTraining with feature perceptual loss.\n```bash\nDATA_ROOT=celebA th main_cvae_content.lua\n```\n\nTraining with pixel-by-pixel loss.\n```bash\nDATA_ROOT=celebA th main_cvae.lua\n```\n\n## Generate face images using pretrained Encoder and Decoder\n\n### Pretrained model\n\n```bash\nmkdir checkpoints; cd checkpoints\n```\n\nWe provide both **Encoder** and **Decoder**\n\n[cvae_content_123_encoder.t7](https://drive.google.com/open?id=0B2Nu6PGoZ7p4UDRpYUcxOW9Rd2s) and [cvae_content_123_decoder.t7](https://drive.google.com/open?id=0B2Nu6PGoZ7p4ZHRMTnFrUXVIck0) trained with relu1_1, relu2_1, relu3_1 in VGG.\n\n\nReconstruction with CelebA dataset:\n```bash\nDATA_ROOT=celebA reconstruction=1 th generate.lua\n```\n\nFace images randomly generated from latent variables:\n```bash\nDATA_ROOT=celebA reconstruction=0 th generate.lua\n```\n\nFollowing are some examples:\n\u003cdiv\u003e\n  \u003cimg src='images/output_content.png', width=\"60%\"\u003e\n\u003c/div\u003e\n## Linear interpolation between two face images\n\n```bash\nth linear_walk_two_images.lua\n```\n\u003c!-- \u003cimg src='images/linear_walk_man.jpg', width=\"60%\"\u003e --\u003e\n\u003cdiv\u003e\n  \u003cimg src='images/random.gif', width=\"40%\"\u003e\n\u003c/div\u003e\n## Vector arithmetic for visual attributes\n\nFirst preprocess the celebA dataset annotations to separate the dataset to two parts for each attribute, indicating whether containing the specific attribute or not.\n\n```bash\ncd celebA\npython get_binary_attr.py\n# should generate file: 'celebA/attr_binary_list.txt'\ncd ..\nth linear_walk_attribute_vector.lua\n```\n\nHere are some examples:\n\u003cdiv\u003e\n  \u003cimg src='images/combined.gif', width=\"40%\"\u003e\n\u003c/div\u003e\n\u003c!-- \u003cimg src='images/output_add_glass.jpg', width=\"60%\"\u003e --\u003e\n\n\n## Better face attributes manipulation by incorporating GAN\n\u003cdiv\u003e\n  \u003cimg src='images/new-results/bald.gif', width=\"30%\"\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n  \u003cimg src='images/new-results/smile.gif', width=\"30%\"\u003e\n\u003c/div\u003e\n\u003chr\u003e\n\n\u003cdiv\u003e\n  \u003cimg src='images/new-results/blackhair.gif', width=\"30%\"\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n  \u003cimg src='images/new-results/male.gif', width=\"30%\"\u003e\n\u003c/div\u003e\n\u003chr\u003e\n\n\u003cdiv\u003e\n  \u003cimg src='images/new-results/eyeglasses.gif', width=\"30%\"\u003e \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n  \u003cimg src='images/new-results/mustache.gif', width=\"30%\"\u003e\n\u003c/div\u003e\n\n\n\n## Credits\n\nThe code is based on [neural-style](https://github.com/jcjohnson/neural-style), [dcgan.torch](https://github.com/soumith/dcgan.torch), [VAE-Torch](https://github.com/y0ast/VAE-Torch) and [texture_nets](https://github.com/DmitryUlyanov/texture_nets).\n\n## Citation\n\nIf you find this code useful for your research, please cite:\n\n```\n@inproceedings{hou2017deep,\n  title={Deep Feature Consistent Variational Autoencoder},\n  author={Hou, Xianxu and Shen, Linlin and Sun, Ke and Qiu, Guoping},\n  booktitle={Applications of Computer Vision (WACV), 2017 IEEE Winter Conference on},\n  pages={1133--1141},\n  year={2017},\n  organization={IEEE}\n}\n```\n```\n@article{hou2019improving,\n  title={Improving Variational Autoencoder with Deep Feature Consistent and Generative Adversarial Training},\n  author={Hou, Xianxu and Sun, Ke and Shen, Linlin and Qiu, Guoping},\n  journal={Neurocomputing},\n  volume={341},\n  pages={183--194},\n  year={2019},\n  publisher={Elsevier},\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhouxianxu%2Fdfc-vae","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhouxianxu%2Fdfc-vae","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhouxianxu%2Fdfc-vae/lists"}