{"id":16835949,"url":"https://github.com/xingangpan/gan2shape","last_synced_at":"2025-10-10T14:12:02.525Z","repository":{"id":37387942,"uuid":"309326870","full_name":"XingangPan/GAN2Shape","owner":"XingangPan","description":"Code for GAN2Shape (ICLR2021 oral)","archived":false,"fork":false,"pushed_at":"2023-07-04T03:56:43.000Z","size":22846,"stargazers_count":578,"open_issues_count":35,"forks_count":100,"subscribers_count":27,"default_branch":"main","last_synced_at":"2025-05-24T20:06:26.027Z","etag":null,"topics":["3d-reconstruction","deep-learning","gan","generative-adversarial-network","inverse-graphics"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2011.00844","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XingangPan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-11-02T09:54:43.000Z","updated_at":"2025-03-19T01:43:34.000Z","dependencies_parsed_at":"2024-10-26T00:40:33.497Z","dependency_job_id":null,"html_url":"https://github.com/XingangPan/GAN2Shape","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/XingangPan/GAN2Shape","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XingangPan%2FGAN2Shape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XingangPan%2FGAN2Shape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XingangPan%2FGAN2Shape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XingangPan%2FGAN2Shape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XingangPan","download_url":"https://codeload.github.com/XingangPan/GAN2Shape/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XingangPan%2FGAN2Shape/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004181,"owners_count":26083688,"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-10-10T02:00:06.843Z","response_time":62,"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":["3d-reconstruction","deep-learning","gan","generative-adversarial-network","inverse-graphics"],"created_at":"2024-10-13T12:11:50.461Z","updated_at":"2025-10-10T14:12:02.510Z","avatar_url":"https://github.com/XingangPan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Do 2D GANs Know 3D Shape? Unsupervised 3D Shape Reconstruction from 2D Image GANs\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"GAN2Shape_demo.gif\", width=\"900\"\u003e\n\u003c/p\u003e\n\n**Figure:** *Recovered 3D shape and rotation\u0026relighting effects using GAN2Shape.*\n\n\u003e **Do 2D GANs Know 3D Shape? Unsupervised 3D Shape Reconstruction from 2D Image GANs** \u003cbr\u003e\n\u003e Xingang Pan, Bo Dai, Ziwei Liu, Chen Change Loy, Ping Luo \u003cbr\u003e\n\u003e *ICLR2021* (**Oral**)\n\n[[Paper](https://openreview.net/pdf?id=FGqiDsBUKL0)]\n[[Project Page](https://xingangpan.github.io/projects/GAN2Shape.html)]\n\nIn this repository, we present **GAN2Shape**, which reconstructs the 3D shape of an image using off-the-shelf 2D image GANs in an unsupervised manner.\nOur method **does not rely on mannual annotations or external 3D models**, yet it achieves high-quality 3D reconstruction, object rotation, and relighting effects.\n\n## Requirements\n\n* python\u003e=3.6\n* [pytorch](https://pytorch.org/)=1.1 or 1.2\n* [neural_renderer](https://github.com/daniilidis-group/neural_renderer)\n    ```sh\n    pip install neural_renderer_pytorch  # or follow the guidance at https://github.com/elliottwu/unsup3d\n    ```\n* [mmcv](https://github.com/open-mmlab/mmcv)\n    ```sh\n    pip install mmcv\n    ```\n* other dependencies\n    ```sh\n    conda install -c conda-forge scikit-image matplotlib opencv pyyaml tensorboardX\n    ```\n\n## Dataset and pre-trained weights\n\nTo download dataset and pre-trained weights, simply run:\n```sh\nsh scripts/download.sh\n```\n\n## Training\n\nBefore training, you may optionally compile StyleGAN2 operations, which would be faster:\n```sh\ncd gan2shape/stylegan/stylegan2-pytorch/op\npython setup.py install\ncd ../../../..\n```\n\n**Example1**: training on car images:\n```sh\nsh scripts/run_car.sh\n```\nThis would run on 4 GPUs by default. You can view the results at `results/car/images` or Tensorboard.\n\n**Example2**: training on Celeba images:\n```sh\nsh scripts/run_celeba.sh\n```\nThis by default uses our provided pre-trained weights. You can also perform joint pre-training via:\n```sh\nsh scripts/run_celeba-pre.sh\n```\n\n**Example3**: evaluating on synface (BFM) dataset:\n```sh\nsh scripts/run_synface.sh\n```\nThis by default uses our provided pre-trained weights. You can also perform joint pre-training via:\n```sh\nsh scripts/run_synface-pre.sh\n```\n\nIf you want to train on new StyleGAN2 samples, simply run the following script to generate new samples:\n```sh\nsh scripts/run_sample.sh\n```\n\n**Note**:  \n\\- For human and cat faces, we perform joint training before instance-specific training, which produces better results.  \n\\- For car and church, the quality of StyleGAN2 samples vary a lot, thus our approach may not produce good result on every sample. The downloaded dataset contains examples of good samples.\n\n## Acknowledgement\n\nPart of the code is borrowed from [Unsup3d](https://github.com/elliottwu/unsup3d) and [StyleGAN2](https://github.com/rosinality/stylegan2-pytorch).  \nColab demo reproduced by [ucalyptus](https://github.com/ucalyptus): [Link](https://colab.research.google.com/drive/124D_f0RIu7Bbwa1SFV6pmvmBrNkB8Ow_?usp=sharing)\n\n## BibTeX\n\n```bibtex\n@inproceedings{pan2020gan2shape,\n  title   = {Do 2D GANs Know 3D Shape? Unsupervised 3D Shape Reconstruction from 2D Image GANs},\n  author  =  {Pan, Xingang and Dai, Bo and Liu, Ziwei and Loy, Chen Change and Luo, Ping},\n  booktitle = {International Conference on Learning Representations},\n  year    = {2021}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxingangpan%2Fgan2shape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxingangpan%2Fgan2shape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxingangpan%2Fgan2shape/lists"}