{"id":13784270,"url":"https://github.com/Naagar/Normalizing_Flow_3x3_inv","last_synced_at":"2025-05-11T19:32:41.587Z","repository":{"id":83980223,"uuid":"332062328","full_name":"Naagar/Normalizing_Flow_3x3_inv","owner":"Naagar","description":"Implementation of CInC Flow paper, TensorFlow. ","archived":false,"fork":false,"pushed_at":"2023-07-14T08:29:57.000Z","size":2673,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-03T19:08:41.801Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/Naagar.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}},"created_at":"2021-01-22T21:04:57.000Z","updated_at":"2023-07-29T06:05:33.000Z","dependencies_parsed_at":"2024-01-17T02:16:01.669Z","dependency_job_id":"cc3bf33d-9f68-4be7-9b39-82e9f22d703b","html_url":"https://github.com/Naagar/Normalizing_Flow_3x3_inv","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/Naagar%2FNormalizing_Flow_3x3_inv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Naagar%2FNormalizing_Flow_3x3_inv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Naagar%2FNormalizing_Flow_3x3_inv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Naagar%2FNormalizing_Flow_3x3_inv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Naagar","download_url":"https://codeload.github.com/Naagar/Normalizing_Flow_3x3_inv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225086587,"owners_count":17418757,"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-03T19:00:38.956Z","updated_at":"2025-05-11T19:32:41.560Z","avatar_url":"https://github.com/Naagar.png","language":"Jupyter Notebook","funding_links":[],"categories":["📝 Publications \u003csmall\u003e(60)\u003c/small\u003e"],"sub_categories":[],"readme":"# [CInC Flow: Characterizable Invertible 3X3 Convolution](https://arxiv.org/abs/2107.01358)\n[OpenReview](https://openreview.net/forum?id=kl1ds_AeLRM)\n\nPAPER: [link](https://arxiv.org/abs/2107.01358)\n\n\nAccepted: 4th workshop TPM 2021 (UAI-21)\n![TPM-21](images/tpm21.png)\n\n\nImplementation of improvements for generative normalizing flows and more specifically Glow. \n\nWe extend the 1x1 convolutions used in glow to convolutions with any kernel size and we introduce a new coupling layer.\n\nThis work is adapted from [Emerging Convolutions for Generative Normalizing Flows](https://github.com/ehoogeboom/emerging):\n```\nEmiel Hoogeboom, Rianne van den Berg, and Max Welling. Emerging Convolutions for Generative Normalizing Flows. International Conference on Machine Learning, 2019.\n```\n## Method\n![Why CInC?](images/CInC_Flow.png)\n\n## Flow module\n\n![module](images/norm_flow.png)\n\n## Image interpolation sample \n![Changing Hair Color, original: right](images/blond_hair_id142.png )\n![Changing smile](images/high_cheekbones_id7.png)\n![Removing the glasses](images/glasses_id151.png)\n![Gradually changing the age parameter](images/id42_aging.png)\n\n## Requirements\nThe ```pip_installs``` script can be used to install all the required packages using pip.\n\n## Download datasets\nCIFAR10 is automatically downloaded.\nGalaxy images need to be downloaded [here](https://github.com/SpaceML/merger_transfer_learning).\n\nImageNet 32x32 and 64x64 was downloaded from the link on the Glow github: `https://storage.googleapis.com/glow-demo/data/{dataset_name}-tfr.tar`\nwith `imagenet-oord` as dataset_name.\n\n## How to start reading the code?\nThe quad coupling layer is defined on line 409 of the ```model.py``` file.\nThe convolution is defined on line 463 of the ```conv2d/conv2d.py``` file. The corresponding inversion operation can be found in ```conv2d/inverses/inverse_cython.py``` and ```conv2d\\inverses\\inverse_op_cython.pyx```.\n\n\n## Experiments\nTo get infos regarding the parameter use ```python3 train.py -h```.\n\n##### CIFAR-10 results\nEmerging:\n```\nmpiexec -n 2 python3 train.py --problem cifar10 --image_size 32 --n_level 3 --depth 32 --flow_permutation 3 --flow_coupling 1 --seed 2 --learnprior --lr 0.001 --n_bits_x 8 --epochs 4001\n```\n\nGlow:\n```\nmpiexec -n 2 python3 train.py --problem cifar10 --image_size 32 --n_level 3 --depth 32 --flow_permutation 2 --flow_coupling 1 --seed 2 --learnprior --lr 0.001 --n_bits_x 8 --epochs 4001\n```\n\n3x3 convolution:\n```\nmpiexec -n 2 python3 train.py --problem cifar10 --image_size 32 --n_level 3 --depth 32 --flow_permutation 7 --flow_coupling 1 --seed 2 --learnprior --lr 0.001 --n_bits_x 8 --epochs 4001\n```\n\n3x3 convolution and quad-coupling:\n```\nmpiexec -n 2 python3 train.py --problem cifar10 --image_size 32 --n_level 3 --depth 32 --flow_permutation 7 --flow_coupling 2 --seed 2 --learnprior --lr 0.001 --n_bits_x 8 --epochs 4001\n```\n\n##### ImageNet 32x32 results\nThis command lines assumes that the variable ```DATA_PATH``` contains the\npath to the imagenet dataset.\n\nEmerging:\n```\nmpiexec -n 4 python3 train.py --problem imagenet-oord --image_size 32 --n_level 3 --depth 48 --flow_permutation 3 --flow_coupling 1 --seed 0 --learnprior --lr 0.001 --n_bits_x 8 --data_dir $DATA_PATH\n```\n\nGlow:\n```\nmpiexec -n 4 python3 train.py --problem imagenet-oord --image_size 32 --n_level 3 --depth 48 --flow_permutation 2 --flow_coupling 1 --seed 0 --learnprior --lr 0.001 --n_bits_x 8 --data_dir $DATA_PATH\n```\n\n3x3 convolution:\n```\nmpiexec -n 4 python3 train.py --problem imagenet-oord --image_size 32 --n_level 3 --depth 48 --flow_permutation 7 --flow_coupling 1 --seed 0 --learnprior --lr 0.001 --n_bits_x 8 --data_dir $DATA_PATH\n```\n\n3x3 convolution and quad-coupling:\n```\nmpiexec -n 4 python3 train.py --problem imagenet-oord --image_size 32 --n_level 3 --depth 48 --flow_permutation 7 --flow_coupling 2 --seed 0 --learnprior --lr 0.001 --n_bits_x 8 --data_dir $DATA_PATH\n```\n\n##### ImageNet 64x64 results\nEmerging:\n```\nmpiexec -n 4 python3 train.py --problem imagenet-oord --image_size 64 --n_level 4 --depth 48 --flow_permutation 3 --flow_coupling 1 --seed 0 --learnprior --lr 0.001 --n_bits_x 8 --data_dir $DATA_PATH\n```\n\nGlow:\n```\nmpiexec -n 4 python3 train.py --problem imagenet-oord --image_size 64 --n_level 4 --depth 48 --flow_permutation 2 --flow_coupling 1 --seed 0 --learnprior --lr 0.001 --n_bits_x 8 --data_dir $DATA_PATH\n```\n\n3x3 convolution:\n```\nmpiexec -n 4 python3 train.py --problem imagenet-oord --image_size 64 --n_level 4 --depth 48 --flow_permutation 7 --flow_coupling 1 --seed 0 --learnprior --lr 0.001 --n_bits_x 8 --data_dir $DATA_PATH\n```\n\n3x3 convolution and quad-coupling:\n```\nmpiexec -n 4 python3 train.py --problem imagenet-oord --image_size 64 --n_level 4 --depth 48 --flow_permutation 7 --flow_coupling 2 --seed 0 --learnprior --lr 0.001 --n_bits_x 8 --data_dir $DATA_PATH\n```\n\n## Sample time results\nEmerging:\n```\nmpiexec -n 1 python3 train.py --problem cifar10 --image_size 32 --n_level 3 --depth 32 --flow_permutation 3 --flow_coupling 1 --seed 2 --learnprior --lr 0.001 --n_bits_x 8 --sample\n```\n\nGlow:\n```\nmpiexec -n 1 python3 train.py --problem cifar10 --image_size 32 --n_level 3 --depth 32 --flow_permutation 2 --flow_coupling 1 --seed 2 --learnprior --lr 0.001 --n_bits_x 8 --sample\n```\n\n3x3 convolution:\n```\nmpiexec -n 1 python3 train.py --problem cifar10 --image_size 32 --n_level 3 --depth 32 --flow_permutation 7 --flow_coupling 1 --seed 2 --learnprior --lr 0.001 --n_bits_x 8 --sample\n```\n\n3x3 convolution and quad-coupling:\n```\nmpiexec -n 1 python3 train.py --problem cifar10 --image_size 32 --n_level 3 --depth 32 --flow_permutation 7 --flow_coupling 2 --seed 2 --learnprior --lr 0.001 --n_bits_x 8 --sample\n```\n## have a question?,  contact: sandeep.nagar@research.iiit.ac.in\n\n## Cite:\n    @inproceedings{nagar2021cinc,\n    title={{CI}nC Flow: Characterizable Invertible $ 3 \\times 3 $ Convolution},\n    author={Sandeep Nagar and Marius Dufraisse and Girish Varma},\n    booktitle={The 4th Workshop on Tractable Probabilistic Modeling, Uncertainty in Artificial Intelligence (UAI)},\n    year={2021},\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNaagar%2FNormalizing_Flow_3x3_inv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNaagar%2FNormalizing_Flow_3x3_inv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNaagar%2FNormalizing_Flow_3x3_inv/lists"}