{"id":20886447,"url":"https://github.com/gsurma/style_transfer","last_synced_at":"2025-04-09T19:19:02.516Z","repository":{"id":45796943,"uuid":"161123961","full_name":"gsurma/style_transfer","owner":"gsurma","description":"CNN image style transfer 🎨.","archived":false,"fork":false,"pushed_at":"2021-07-09T08:50:48.000Z","size":17225,"stargazers_count":279,"open_issues_count":3,"forks_count":73,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-09T19:18:58.018Z","etag":null,"topics":["cnn","computer-vision","convolutional-neural-networks","deep-learning","jupyter-notebook","keras","machine-learning","neural-network","notebook","python","style-transfer"],"latest_commit_sha":null,"homepage":"https://gsurma.github.io","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/gsurma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"patreon":"gsurma"}},"created_at":"2018-12-10T05:52:01.000Z","updated_at":"2025-02-08T15:30:46.000Z","dependencies_parsed_at":"2022-07-17T00:46:10.886Z","dependency_job_id":null,"html_url":"https://github.com/gsurma/style_transfer","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/gsurma%2Fstyle_transfer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsurma%2Fstyle_transfer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsurma%2Fstyle_transfer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsurma%2Fstyle_transfer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gsurma","download_url":"https://codeload.github.com/gsurma/style_transfer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094990,"owners_count":21046770,"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":["cnn","computer-vision","convolutional-neural-networks","deep-learning","jupyter-notebook","keras","machine-learning","neural-network","notebook","python","style-transfer"],"created_at":"2024-11-18T08:16:58.719Z","updated_at":"2025-04-09T19:19:02.482Z","avatar_url":"https://github.com/gsurma.png","language":"Jupyter Notebook","funding_links":["https://patreon.com/gsurma"],"categories":[],"sub_categories":[],"readme":"\u003ch3 align=\"center\"\u003e\n  \u003cimg src=\"assets/style_transfer_web.png\" width=\"300\"\u003e\n\u003c/h3\u003e\n\n\n# Style Transfer\n\nStyle Transfer is a process in which we strive to modify the style of an image while preserving its content. Given an input image and a style image, we can compute an output image with the original content but a new style.\n\n[Kaggle kernel](https://www.kaggle.com/greg115/style-transfer)\n\nCheck out corresponding Medium article:\n\n[Style Transfer - Styling Images with Convolutional Neural Networks](https://towardsdatascience.com/style-transfer-styling-images-with-convolutional-neural-networks-7d215b58f461)\n\n\u003ch3 align=\"center\"\u003e\n  \u003cimg src=\"assets/combined.png\"\u003e\n\u003c/h3\u003e\n\n# How does it work?\n1. We take input image and style images and resize them to equal shapes.\n2. We load a pre-trained CNN (VGG16).\n3. Knowing that we can distinguish layers that are responsible for the style (basic shapes, colors etc.) and the ones responsible for the content (image-specific features), we can separate the layers to independently work on the content and style.\n4. Then we set our task as an optimization problem where we are going to minimize:\n\t* **content loss** (distance between the input and output images - we strive to preserve the content)\n\t* **style loss** (distance between the style and output images - we strive to apply a new style)\n\t* **total variation loss** (regularization - spatial smoothness to denoise the output image)\n5. Finally, we set our gradients and optimize with the [L-BFGS](https://en.wikipedia.org/wiki/Limited-memory_BFGS) algorithm.\n\n# Results\n\n## Input\n\n\u003ch3\u003e\n  \u003cimg src=\"assets/input.png\" width=\"500\"\u003e\n\u003c/h3\u003e\n\n\n## Style\n \n\u003ch3\u003e\n  \u003cimg src=\"assets/style.png\" width=\"500\"\u003e\n\u003c/h3\u003e\n\n\n## Output\n\n### 1 iteration\n\u003ch3\u003e\n  \u003cimg src=\"assets/1.png\" width=\"500\"\u003e\n\u003c/h3\u003e\n\n### 2 iterations\n\u003ch3\u003e\n  \u003cimg src=\"assets/2.png\" width=\"500\"\u003e\n\u003c/h3\u003e\n\n### 5 iterations\n\u003ch3\u003e\n  \u003cimg src=\"assets/5.png\" width=\"500\"\u003e\n\u003c/h3\u003e\n\n### 10 iterations\n \n\u003ch3\u003e\n  \u003cimg src=\"assets/10.png\" width=\"500\"\u003e\n\u003c/h3\u003e\n\n### 15 iterations\n \n\u003ch3\u003e\n  \u003cimg src=\"assets/15.png\" width=\"500\"\u003e\n\u003c/h3\u003e\n\n## Other examples\n\n\u003ch3\u003e\n  \u003cimg src=\"assets/examples/naish.png\"\u003e\n\u003c/h3\u003e\n\n\u003ch3\u003e\n  \u003cimg src=\"assets/examples/sf.png\"\u003e\n\u003c/h3\u003e\n\n\u003ch3\u003e\n  \u003cimg src=\"assets/examples/boston.png\"\u003e\n\u003c/h3\u003e\n\n\u003ch3\u003e\n  \u003cimg src=\"assets/examples/dolores.png\"\u003e\n\u003c/h3\u003e\n\n## Author\n\n**Greg (Grzegorz) Surma**\n\n[**PORTFOLIO**](https://gsurma.github.io)\n\n[**GITHUB**](https://github.com/gsurma)\n\n[**BLOG**](https://medium.com/@gsurma)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgsurma%2Fstyle_transfer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgsurma%2Fstyle_transfer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgsurma%2Fstyle_transfer/lists"}