{"id":13778859,"url":"https://autonomousvision.github.io/graf/","last_synced_at":"2025-05-11T12:32:11.364Z","repository":{"id":37719583,"uuid":"305324984","full_name":"autonomousvision/graf","owner":"autonomousvision","description":"Official code release for \"GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis\"","archived":false,"fork":false,"pushed_at":"2021-02-05T13:45:20.000Z","size":32250,"stargazers_count":405,"open_issues_count":9,"forks_count":72,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-04-06T22:07:33.418Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","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/autonomousvision.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}},"created_at":"2020-10-19T09:05:23.000Z","updated_at":"2025-03-14T06:08:49.000Z","dependencies_parsed_at":"2022-08-24T23:40:48.301Z","dependency_job_id":null,"html_url":"https://github.com/autonomousvision/graf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autonomousvision%2Fgraf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autonomousvision%2Fgraf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autonomousvision%2Fgraf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autonomousvision%2Fgraf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/autonomousvision","download_url":"https://codeload.github.com/autonomousvision/graf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253566951,"owners_count":21928757,"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":[],"created_at":"2024-08-03T18:00:58.260Z","updated_at":"2025-05-11T12:32:08.964Z","avatar_url":"https://github.com/autonomousvision.png","language":"Jupyter Notebook","funding_links":[],"categories":["Generative Adverserial Networks with Implicit Representations"],"sub_categories":["For 3D"],"readme":"# GRAF\n\n\u003cdiv style=\"text-align: center\"\u003e\n\u003cimg src=\"animations/carla_256.gif\" width=\"512\"/\u003e\u003cbr\u003e\n\u003c/div\u003e\n\nThis repository contains official code for the paper\n[GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis](https://avg.is.tuebingen.mpg.de/publications/schwarz2020neurips).\n\nYou can find detailed usage instructions for training your own models and using pre-trained models below.\n\n\nIf you find our code or paper useful, please consider citing\n\n    @inproceedings{Schwarz2020NEURIPS,\n      title = {GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis},\n      author = {Schwarz, Katja and Liao, Yiyi and Niemeyer, Michael and Geiger, Andreas},\n      booktitle = {Advances in Neural Information Processing Systems (NeurIPS)},\n      year = {2020}\n    }\n\n## Installation\nFirst you have to make sure that you have all dependencies in place.\nThe simplest way to do so, is to use [anaconda](https://www.anaconda.com/). \n\nYou can create an anaconda environment called `graf` using\n```\nconda env create -f environment.yml\nconda activate graf\n```\n\nNext, for nerf-pytorch install torchsearchsorted. Note that this requires `torch\u003e=1.4.0` and `CUDA \u003e= v10.1`.\nYou can install torchsearchsorted via\n``` \ncd submodules/nerf_pytorch\npip install -r requirements.txt\ncd torchsearchsorted\npip install .\ncd ../../../\n```\n\n## Demo\n\nYou can now test our code via:\n```\npython eval.py configs/carla.yaml --pretrained --rotation_elevation\n```\nThis script should create a folder `results/carla_128_from_pretrained/eval/` where you can find generated videos varying camera pose for the Cars dataset.\n\n## Datasets\n\nIf you only want to generate images using our pretrained models you do not need to download the datasets.\nThe datasets are only needed if you want to train a model from scratch.\n\n### Cars\n\nTo download the Cars dataset from the paper simply run\n```\ncd data\n./download_carla.sh\ncd ..\n```\nThis creates a folder `data/carla/` downloads the images as a zip file and extracts them to `data/carla/`. \nWhile we do \u003cem\u003enot\u003c/em\u003e use camera poses in this project we provide them for completeness. Your can download them by running\n```\ncd data\n./download_carla_poses.sh\ncd ..\n```\nThis downloads the camera intrinsics (single file, equal for all images) and extrinsics corresponding to each image.  \n\n### Faces\n\nDownload [celebA](http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html).\nThen replace `data/celebA` in `configs/celebA.yaml` with `*PATH/TO/CELEBA*/Img/img_align_celebA`.\n\nDownload [celebA_hq](https://github.com/tkarras/progressive_growing_of_gans).\nThen replace `data/celebA_hq` in `configs/celebAHQ.yaml` with `*PATH/TO/CELEBA_HQ*`.\n\n### Cats\nDownload the [CatDataset](https://www.kaggle.com/crawford/cat-dataset).\nRun\n```\ncd data\npython preprocess_cats.py PATH/TO/CATS/DATASET\ncd ..\n```\nto preprocess the data and save it to `data/cats`.\nIf successful this script should print: `Preprocessed 9407 images.`\n\n### Birds\nDownload [CUB-200-2011](http://www.vision.caltech.edu/visipedia/CUB-200-2011.html) and the corresponding [Segmentation Masks](https://drive.google.com/file/d/1EamOKGLoTuZdtcVYbHMWNpkn3iAVj8TP/view).\nRun\n```\ncd data\npython preprocess_cub.py PATH/TO/CUB-200-2011 PATH/TO/SEGMENTATION/MASKS\ncd ..\n```\nto preprocess the data and save it to `data/cub`.\nIf successful this script should print: `Preprocessed 8444 images.`\n\n## Usage\n\nWhen you have installed all dependencies, you are ready to run our pre-trained models for 3D-aware image synthesis.\n\n### Generate images using a pretrained model\n\nTo evaluate a pretrained model, run \n```\npython eval.py CONFIG.yaml --pretrained --fid_kid --rotation_elevation --shape_appearance\n```\nwhere you replace CONFIG.yaml with one of the config files in `./configs`. \n\nThis script should create a folder `results/EXPNAME/eval` with FID and KID scores in `fid_kid.csv`, videos for rotation and elevation in the respective folders and an interpolation for shape and appearance, `shape_appearance.png`. \n\nNote that some pretrained models are available for different image sizes which you can choose by setting `data:imsize` in the config file to one of the following values:\n```\nconfigs/carla.yaml: \n    data:imsize 64 or 128 or 256 or 512\nconfigs/celebA.yaml:\n    data:imsize 64 or 128\nconfigs/celebAHQ.yaml:\n    data:imsize 256 or 512\n```\n\n### Train a model from scratch\n\nTo train a 3D-aware generative model from scratch run\n```\npython train.py CONFIG.yaml\n```\nwhere you replace `CONFIG.yaml` with your config file.\nThe easiest way is to use one of the existing config files in the `./configs` directory \nwhich correspond to the experiments presented in the paper. \nNote that this will train the model from scratch and will not resume training for a pretrained model.\n\nYou can monitor on \u003chttp://localhost:6006\u003e the training process using [tensorboard](https://www.tensorflow.org/guide/summaries_and_tensorboard):\n```\ncd OUTPUT_DIR\ntensorboard --logdir ./monitoring --port 6006\n```\nwhere you replace `OUTPUT_DIR` with the respective output directory.\n\nFor available training options, please take a look at `configs/default.yaml`.\n\n### Evaluation of a new model\n\nFor evaluation of the models run\n```\npython eval.py CONFIG.yaml --fid_kid --rotation_elevation --shape_appearance\n```\nwhere you replace `CONFIG.yaml` with your config file.\n\n## Multi-View Consistency Check\n\nYou can evaluate the multi-view consistency of the generated images by running a Multi-View-Stereo (MVS) algorithm on the generated images. This evaluation uses [COLMAP](https://colmap.github.io/) and make sure that you have COLMAP installed to run\n```\npython eval.py CONFIG.yaml --reconstruction\n```\nwhere you replace `CONFIG.yaml` with your config file. You can also evaluate our pretrained models via:\n```\npython eval.py configs/carla.yaml --pretrained --reconstruction\n```\nThis script should create a folder `results/EXPNAME/eval/reconstruction/` where you can find generated multi-view images in `images/` and the corresponding 3D reconstructions in `models/`.\n\n## Further Information\n\n### GAN training\n\nThis repository uses Lars Mescheder's awesome framework for [GAN training](https://github.com/LMescheder/GAN_stability).\n\n### NeRF\n\nWe base our code for the Generator on this great [Pytorch reimplementation](https://github.com/yenchenlin/nerf-pytorch) of Neural Radiance Fields.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/autonomousvision.github.io%2Fgraf%2F","html_url":"https://awesome.ecosyste.ms/projects/autonomousvision.github.io%2Fgraf%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/autonomousvision.github.io%2Fgraf%2F/lists"}