{"id":19513152,"url":"https://github.com/djosix/iconflow","last_synced_at":"2025-04-26T04:31:41.066Z","repository":{"id":37682560,"uuid":"497088402","full_name":"djosix/IconFlow","owner":"djosix","description":"Code for \"Style-Structure Disentangled Features and Normalizing Flows for Diverse Icon Colorization\", CVPR 2022.","archived":true,"fork":false,"pushed_at":"2022-06-28T06:33:17.000Z","size":59,"stargazers_count":25,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T10:11:55.357Z","etag":null,"topics":["artificial-intelligence","automatic-colorization","colorization","computer-vision","conditional-normalizing-flows","continuous-normalizing-flows","cvpr","cvpr2022","deep-learning","image-colorization","machine-learning","normalizing-flow","sketch-colorization","u-net"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djosix.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":"2022-05-27T17:49:00.000Z","updated_at":"2025-02-15T11:46:18.000Z","dependencies_parsed_at":"2022-09-04T22:11:45.272Z","dependency_job_id":null,"html_url":"https://github.com/djosix/IconFlow","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/djosix%2FIconFlow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djosix%2FIconFlow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djosix%2FIconFlow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djosix%2FIconFlow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djosix","download_url":"https://codeload.github.com/djosix/IconFlow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250931030,"owners_count":21509805,"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":["artificial-intelligence","automatic-colorization","colorization","computer-vision","conditional-normalizing-flows","continuous-normalizing-flows","cvpr","cvpr2022","deep-learning","image-colorization","machine-learning","normalizing-flow","sketch-colorization","u-net"],"created_at":"2024-11-10T23:28:58.095Z","updated_at":"2025-04-26T04:31:40.498Z","avatar_url":"https://github.com/djosix.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Style-Structure Disentangled Features and Normalizing Flows for Diverse Icon Colorization\n\nCode for [\"Style-Structure Disentangled Features and Normalizing Flows for Diverse Icon Colorization\", CVPR 2022](https://bit.ly/3y26825).\n\n\u003e **Authors**: *Yuan-kui Li, Yun-Hsuan Lien, Yu-Shuen Wang - National Yang Ming Chiao Tung University*  \n\u003e **Abstract**: *In this study, we present a colorization network that generates flat-color icons according to given sketches and semantic colorization styles. Specifically, our network contains a style-structure disentangled colorization module and a normalizing flow. The colorization module transforms a paired sketch image and style image into a flat-color icon. To enhance network generalization and the quality of icons, we present a pixel-wise decoder, a global style code, and a contour loss to reduce color gradients at flat regions and increase color discontinuity at boundaries. The normalizing flow maps Gaussian vectors to diverse style codes conditioned on the given semantic colorization label. This conditional sampling enables users to control attributes and obtain diverse colorization results. Compared to previous colorization methods built upon conditional generative adversarial networks, our approach enjoys the advantages of both high image quality and diversity. To evaluate its effectiveness, we compared the flat-color icons generated by our approach and recent colorization and image-to-image translation methods on various conditions. Experiment results verify that our method outperforms state-of-the-arts qualitatively and quantitatively.*  \n\n[![DEMO GUI VIDEO](http://img.youtube.com/vi/nzeNb8ZIm0o/0.jpg)](https://www.youtube.com/watch?v=nzeNb8ZIm0o \"Demo video. Instructions to run the GUI application is in the 'Demo GUI' section\")\n\n## Setup\n\n```sh\ngit clone https://github.com/djosix/IconFlow.git\ncd IconFlow\n```\n\nInstall requirements:\n\n```\nnumpy==1.21.1\nPillow==8.3.1\ntorch==1.9.0\ntorchvision==0.10.0\ntorchdiffeq==0.2.2\nscikit-image==0.18.2\nopencv-python==4.5.3.56\ntensorboard==2.5.0\nfire==0.4.0\n```\n\n## Dataset\n\nDownload [dataset.zip](https://bit.ly/3tO2tlR) and unzip:\n\n```sh\nunzip -d dataset dataset.zip\n```\n\nPreprocess:\n\n```\npython3 -m iconflow.utils.dataset preprocess_images --dataset-dir dataset --resolutions '128,512' --num-workers 16\n```\n\nNow the directory layout looks like\n\n```\nIconFlow/\n├── iconflow/                   source code\n├── dataset/\n│   ├── raw/                    512x512 *.png raw icon images (dataset.zip)\n│   ├── ColorImageScale.pkl     color image scale information (dataset.zip)\n│   └── data/                   (generated)\n│       ├── 128/\n│       │   ├── contour/        128x128 *.png icon contours \n│       │   └── img/            128x128 *.png icons\n│       └── 512/\n│           ├── contour/        512x512 *.png icon contours\n│           └── img/            512x512 *.png icons\n└── ...\n```\n\n## Training\n\n1. Train the reference-based colorizer:\n    ```sh\n    python3 -m iconflow train_net --device cuda\n    ```\n2. Train c-CNF:\n    ```sh\n    python3 -m iconflow train_flow --device cuda\n    ```\n3. Train the upsampler (128x128 to 512x512):\n    ```sh\n    python3 -m iconflow train_up --device cuda --image-size 512\n    ```\n\nThe default output directory is `output`.\n\n```\nIconFlow/\n├── dataset/\n├── iconflow/\n├── output/\n│   ├── checkpoint.pt\n│   ├── events.out.tfevents.*\n│   ├── flow/\n│   |   ├── checkpoint.pt\n|   |   └── events.out.tfevents.*\n│   └── up_512/\n│       ├── checkpoint.pt\n|       └── events.out.tfevents.*\n└── ...\n```\n\nUse TensorBoard to monitor training progress:\n\n```sh\ntensorboard --logdir ./output\n```\n\n## Demo GUI\n\nAdditional requirements:\n\n```\nwxPython==4.1.1\nscikit-learn==0.24.2\n```\n\nAfter training you can run:\n\n```sh\npython3 -m app\n```\n\nWeights are loaded from the checkpoint files in the `output` directory. Pretrained checkpoints are also available in [output.zip](https://bit.ly/3zJRXQv).\n\n```sh\nunzip -d output output.zip\n```\n\n## Citation\n\n```\n@inproceedings{li2022style,\n  title={Style-Structure Disentangled Features and Normalizing Flows for Diverse Icon Colorization},\n  author={Li, Yuan-kui and Lien, Yun-Hsuan and Wang, Yu-Shuen},\n  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},\n  pages={11244--11253},\n  year={2022}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjosix%2Ficonflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjosix%2Ficonflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjosix%2Ficonflow/lists"}