{"id":13958395,"url":"https://github.com/bes-dev/MobileStyleGAN.pytorch","last_synced_at":"2025-07-20T23:31:20.819Z","repository":{"id":40630325,"uuid":"346864138","full_name":"bes-dev/MobileStyleGAN.pytorch","owner":"bes-dev","description":"An official implementation of MobileStyleGAN in PyTorch","archived":false,"fork":false,"pushed_at":"2022-04-27T22:30:34.000Z","size":326,"stargazers_count":673,"open_issues_count":21,"forks_count":81,"subscribers_count":11,"default_branch":"develop","last_synced_at":"2024-11-27T20:42:34.144Z","etag":null,"topics":["gan","image-synthesis","mobile-development","openvino","stylegan2","stylegan2-pytorch","sylegan"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bes-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-11T23:03:05.000Z","updated_at":"2024-11-12T03:15:02.000Z","dependencies_parsed_at":"2022-07-21T04:34:36.555Z","dependency_job_id":null,"html_url":"https://github.com/bes-dev/MobileStyleGAN.pytorch","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bes-dev%2FMobileStyleGAN.pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bes-dev%2FMobileStyleGAN.pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bes-dev%2FMobileStyleGAN.pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bes-dev%2FMobileStyleGAN.pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bes-dev","download_url":"https://codeload.github.com/bes-dev/MobileStyleGAN.pytorch/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226845013,"owners_count":17691140,"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","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":["gan","image-synthesis","mobile-development","openvino","stylegan2","stylegan2-pytorch","sylegan"],"created_at":"2024-08-08T13:01:31.555Z","updated_at":"2024-11-28T01:31:57.033Z","avatar_url":"https://github.com/bes-dev.png","language":"Python","funding_links":[],"categories":["人像\\姿势\\3D人脸"],"sub_categories":["网络服务_其他"],"readme":"## MobileStyleGAN: A Lightweight Convolutional Neural Network for High-Fidelity Image Synthesis\n\nOfficial PyTorch Implementation\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"res/faces.jpeg\"/\u003e\n\u003c/p\u003e\n\nThe accompanying videos can be found on [YouTube](https://www.youtube.com/playlist?list=PLstKhmdpWBtwsvq_27ALmPbf_mBLmk0uI).\nFor more details, please refer to the [paper](https://arxiv.org/abs/2104.04767).\n\n## Requirements\n\n* Python 3.8+\n* 1–8 high-end NVIDIA GPUs with at least 12 GB of memory. We have done all testing and development using DL Workstation with 4x2080Ti\n\n\n## Training\n\n```bash\npip install -r requirements.txt\npython train.py --cfg configs/mobile_stylegan_ffhq.json --gpus \u003cn_gpus\u003e\n```\n\n## Convert checkpoint from rosinality/stylegan2-pytorch\n\nOur framework supports StyleGAN2 checkpoints format from [rosinality/stylegan2-pytorch](https://github.com/rosinality/stylegan2-pytorch).\nTo convert ckpt your own checkpoint of StyleGAN2 to our framework:\n\n```bash\npython convert_rosinality_ckpt.py --ckpt \u003cpath_to_rosinality_stylegan2_ckpt\u003e --ckpt-mnet \u003cpath_to_output_mapping_network_ckpt\u003e --ckpt-snet \u003cpath_to_output_synthesis_network_ckpt\u003e --cfg-path \u003cpath_to_output_config_json\u003e\n```\n\n### Check converted checkpoint\n\nTo check that your checkpoint is converted correctly, just run demo visualization:\n\n```bash\npython demo.py --cfg \u003cpath_to_output_config_json\u003e --ckpt \"\" --generator teacher\n```\n\n## Generate images using MobileStyleGAN\n\n```bash\npython generate.py --cfg configs/mobile_stylegan_ffhq.json --device cuda --ckpt \u003cpath_to_ckpt\u003e --output-path \u003cpath_to_store_imgs\u003e --batch-size \u003cbatch_size\u003e --n-batches \u003cn_batches\u003e\n```\n\n## Evaluate FID score\n\nTo evaluate the FID score we use a modified version of [pytorch-fid](https://github.com/mseitzer/pytorch-fid) library:\n\n```bash\npython evaluate_fid.py \u003cpath_to_ref_dataset\u003e \u003cpath_to_generated_imgs\u003e\n```\n\n## Demo\n\nRun demo visualization using MobileStyleGAN:\n```bash\npython demo.py --cfg configs/mobile_stylegan_ffhq.json --ckpt \u003cpath_to_ckpt\u003e\n```\n\nRun visual comparison using StyleGAN2 vs. MobileStyleGAN:\n```bash\npython compare.py --cfg configs/mobile_stylegan_ffhq.json --ckpt \u003cpath_to_ckpt\u003e\n```\n\n## Convert to ONNX\n```bash\npython train.py --cfg configs/mobile_stylegan_ffhq.json --ckpt \u003cpath_to_ckpt\u003e --export-model onnx --export-dir \u003coutput_dir\u003e\n```\n\n## Convert to CoreML\n```bash\npython train.py --cfg configs/mobile_stylegan_ffhq.json --ckpt \u003cpath_to_ckpt\u003e --export-model coreml --export-dir \u003coutput_dir\u003e\n```\n\n## Deployment using OpenVINO\n\nWe provide external library [random_face](https://github.com/bes-dev/random_face) as an example of deploying our model at the edge devices using the [OpenVINO](https://github.com/openvinotoolkit/openvino) framework.\n\n## Pretrained models\n\n|Name|FID|\n|:---|:--|\n|[mobilestylegan_ffhq.ckpt](https://drive.google.com/uc?id=11Kja0XGE8liLb6R5slNZjF3j3v_6xydt)|7.75|\n\n(*) Our framework supports automatic download pretrained models, just use `--ckpt \u003cpretrined_model_name\u003e`.\n\n## Legacy license\n\n|Code|Source|License|\n|:---|:-----|:------|\n|[Custom CUDA kernels](core/models/modules/ops/)|https://github.com/NVlabs/stylegan2|[Nvidia License](LICENSE-NVIDIA)|\n|[StyleGAN2 blocks](core/models/modules/legacy.py)|https://github.com/rosinality/stylegan2-pytorch|MIT|\n\n## Acknowledgements\n\nWe want to thank the people whose works contributed to our project::\n* Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, Timo Aila for research related to style based generative models.\n* Kim Seonghyeon for implementation of StyleGAN2 in [PyTorch](https://github.com/rosinality/stylegan2-pytorch).\n* Fergal Cotter for implementation of Discrete Wavelet Transforms and Inverse Discrete Wavelet Transforms in [PyTorch](https://github.com/fbcotter/pytorch_wavelets).\n* Cyril Diagne for the excellent [demo of how to run MobileStyleGAN directly into the web-browser](https://github.com/cyrildiagne/mobilestylegan-web-demo).\n\n## Citation\n\nIf you are using the results and code of this work, please cite it as:\n\n```\n@misc{belousov2021mobilestylegan,\n      title={MobileStyleGAN: A Lightweight Convolutional Neural Network for High-Fidelity Image Synthesis},\n      author={Sergei Belousov},\n      year={2021},\n      eprint={2104.04767},\n      archivePrefix={arXiv},\n      primaryClass={cs.CV}\n}\n\n@article{BELOUSOV2021100115,\n      title = {MobileStyleGAN.pytorch: PyTorch-based toolkit to compress StyleGAN2 model},\n      journal = {Software Impacts},\n      year = {2021},\n      issn = {2665-9638},\n      doi = {https://doi.org/10.1016/j.simpa.2021.100115},\n      url = {https://www.sciencedirect.com/science/article/pii/S2665963821000452},\n      author = {Sergei Belousov},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbes-dev%2FMobileStyleGAN.pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbes-dev%2FMobileStyleGAN.pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbes-dev%2FMobileStyleGAN.pytorch/lists"}