{"id":19234826,"url":"https://github.com/gr-menon/claritygan","last_synced_at":"2026-05-17T03:03:53.942Z","repository":{"id":242495552,"uuid":"808723944","full_name":"GR-Menon/ClarityGAN","owner":"GR-Menon","description":"Image Dehazing using CycleGAN.","archived":false,"fork":false,"pushed_at":"2024-07-30T13:47:09.000Z","size":446,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-05T01:12:51.188Z","etag":null,"topics":["computer-vision","deep-learning","generative-adversarial-network","pytorch"],"latest_commit_sha":null,"homepage":"","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/GR-Menon.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":"2024-05-31T17:17:54.000Z","updated_at":"2024-07-31T14:10:41.000Z","dependencies_parsed_at":"2024-06-10T13:58:04.761Z","dependency_job_id":"840e105b-828a-4355-b891-f96319f77efc","html_url":"https://github.com/GR-Menon/ClarityGAN","commit_stats":null,"previous_names":["gr-menon/claritygan"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GR-Menon%2FClarityGAN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GR-Menon%2FClarityGAN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GR-Menon%2FClarityGAN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GR-Menon%2FClarityGAN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GR-Menon","download_url":"https://codeload.github.com/GR-Menon/ClarityGAN/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240317434,"owners_count":19782390,"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":["computer-vision","deep-learning","generative-adversarial-network","pytorch"],"created_at":"2024-11-09T16:15:05.548Z","updated_at":"2026-05-17T03:03:53.937Z","avatar_url":"https://github.com/GR-Menon.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ClarityGAN\n\nImage Dehazing using CycleGANs.  \n\u003cbr\u003e\nDeveloped in collaboration with [Ansh Singhal](https://github.com/AnshDevelops).   \n\u003c/br\u003e\nCode Reference : https://github.com/aladdinpersson/Machine-Learning-Collection/tree/master/ML/Pytorch/GANs/CycleGAN  \n\u003c/br\u003e\n\nREalistic Single Image DEhazing dataset (RESIDE) :\n\n- [Official](https://sites.google.com/view/reside-dehaze-datasets/reside-standard)\n- [Kaggle](https://www.kaggle.com/datasets/balraj98/indoor-training-set-its-residestandard)\n\nKaggle notebooks:\n\n- [Regular Training](https://www.kaggle.com/code/gautamrmenon/claritygan-training)\n- [Mixed Precision Training](https://www.kaggle.com/code/gautamrmenon/claritygan-mixed-precision-training)\n\nModel Quantization notebooks:\n\n- [Quantization Aware Training](https://www.kaggle.com/code/gautamrmenon/claritygan-quantization-aware-training)\n- [Static / Dynamic Quantization](https://www.kaggle.com/code/gautamrmenon/claritygan-quantization-static-dynamic/notebook)\n\n### Results\n\n- Dehazed\n  Images ![dehazed_images](https://github.com/GR-Menon/ClarityGAN/assets/98706887/80e87459-57a0-42f9-9bd4-e598884ce587)\n- Haze Generated\n  Images ![haze_generated_images](https://github.com/GR-Menon/ClarityGAN/assets/98706887/9063ce63-aa12-4e7f-b0cf-aa722cdafeb7)  \n  \u003c/br\u003e\n\n# Details\n\n### Image-to-Image Translation\n\nThis is a class of vision problems where the goal is to learn the mapping between an input image and an output image\nusing a set of aligned image pairs. CycleGANs introduce an approach for learning to translate an image from source\ndomain $X$ to a target domain $Y$ in the absence of paired examples. Basically, the model learns a mapping $G \\ : \\ X \\ \\rightarrow \\ Y$ such that the distribution of images from $G(X)$ is indistinguishable from that of distribution $Y$.  \nCycleGANs do not rely on any task-specific, predefined similarity function between the input and output, nor does it assume that the input and output have to lie in the same low-dimensional embedding space.Since this mapping is highly under-constrained, the CycleGAN couples it with an inverse mapping $F \\ : \\ Y \\rightarrow \\ X$ and introduce a **cycle-consistency** loss to enforce $F(G(X)) \\approx X$.\n\n### Adversarial Loss\n\nAdversarial losses are applied to both mapping functions, $G \\ : \\ X \\rightarrow \\ Y$ and $F \\ : Y \\rightarrow \\ X$. For mapping function $G \\ : \\ X \\rightarrow Y$ and its discriminator $D_Y$, the adversarial loss is defined as :       \n```math\n\\mathcal {L}_{GAN}(G, D_Y, X, Y) \\ = \\ \\mathbb {E}_{y \\sim p_{data}(y)}[log \\ D_Y(y)] \\ + \\ \\mathbb {E}_{x\\sim p_{data}(x)}[log(1 \\ - \\ D_Y(G(x)))]\n```  \nwhere $G$ tries to generate images $G(x)$ that look similar to images in domain Y, while $D_Y$ tries to distinguish between translated samples $G(x)$ and real samples $y$.\n\n### Cycle Consistency Loss\n\nEven with the use of adversarial losses, given sufficient capacity, a network can learn to produce outputs that match the target domain's distribution, without learning to map each individual image to a specific desired output. Instead, it could map the same set of input images to any random permutation of images in the target domain, still matching the overall distribution.\n\nCycle consistency means that if you start with an image $x$ from domain $X$, transform it to domain $Y$ using $G$, and then transform it back to domain $X$ using $F$, we should get back the original image $x$.\n\nForward Consistency : $\\ x \\rightarrow G(x) \\rightarrow F(G(x)) \\approx x$\n\nBackward Consistency : $\\ y \\rightarrow F(y) \\rightarrow G(F(y)) \\approx y$\n\nCycle Consistency Loss is defined as :  \n```math\n\\mathcal{L}_{cyc}(G,F) \\ = \\ \\mathbb{E}_{x \\sim p_{data}(x)}\\big[ ||F(G(x)) \\ - \\ x||_1 \\big] \\ + \\ \\mathbb{E}_{y \\sim p_{data}{y}}\\big[ ||G(F(y)) \\ - \\ y||_1\\big]\n```\n\n### VGG Loss\n\nVGG Loss is a type of content loss introduced in [Perceptual Losses for Real-Time Style Transfer and Super-Resolution](https://paperswithcode.com/paper/perceptual-losses-for-real-time-style). It is an alternative to pixel-wise losses, and it attempts to be closer to perceptual similarity loss.\nIts based on the ReLU activation of the pre-trained VGG19 network.\n\n# References\n\n[Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks](https://arxiv.org/pdf/1703.10593)\n\n```markdown\n@misc{zhu2020unpairedimagetoimagetranslationusing,\ntitle={Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks},\nauthor={Jun-Yan Zhu and Taesung Park and Phillip Isola and Alexei A. Efros},\nyear={2020},\neprint={1703.10593},\narchivePrefix={arXiv},\nprimaryClass={cs.CV},\nurl={https://arxiv.org/abs/1703.10593},\n}\n```\n\n[Cycle-Dehaze: Enhanced CycleGAN for Single Image Dehazing](https://arxiv.org/pdf/1805.05308)\n\n```tex\n@misc{engin2018cycledehazeenhancedcyclegansingle,\n      title={Cycle-Dehaze: Enhanced CycleGAN for Single Image Dehazing},\n      author={Deniz Engin and Anıl Genç and Hazım Kemal Ekenel},\n      year={2018},\n      eprint={1805.05308},\n      archivePrefix={arXiv},\n      primaryClass={cs.CV},\n      url={https://arxiv.org/abs/1805.05308},\n}\n```\n\n[VGG Loss](https://paperswithcode.com/method/vgg-loss)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr-menon%2Fclaritygan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgr-menon%2Fclaritygan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr-menon%2Fclaritygan/lists"}