{"id":13449416,"url":"https://github.com/albarji/neural-style-docker","last_synced_at":"2025-08-16T16:32:33.079Z","repository":{"id":49979946,"uuid":"68444333","full_name":"albarji/neural-style-docker","owner":"albarji","description":"A dockerized version of neural style transfer algorithms","archived":false,"fork":false,"pushed_at":"2022-07-09T21:52:17.000Z","size":99813,"stargazers_count":112,"open_issues_count":11,"forks_count":34,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-28T16:44:53.325Z","etag":null,"topics":["deep-learning","docker","gpu","neural-style","nvidia-docker"],"latest_commit_sha":null,"homepage":"","language":"Python","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/albarji.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":"2016-09-17T09:51:22.000Z","updated_at":"2023-09-28T20:08:58.000Z","dependencies_parsed_at":"2022-08-30T05:04:27.547Z","dependency_job_id":null,"html_url":"https://github.com/albarji/neural-style-docker","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albarji%2Fneural-style-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albarji%2Fneural-style-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albarji%2Fneural-style-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albarji%2Fneural-style-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/albarji","download_url":"https://codeload.github.com/albarji/neural-style-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230044815,"owners_count":18164224,"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":["deep-learning","docker","gpu","neural-style","nvidia-docker"],"created_at":"2024-07-31T06:00:37.532Z","updated_at":"2024-12-17T00:38:43.876Z","avatar_url":"https://github.com/albarji.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# neural-style-docker\n\n![Stylized Docker](./doc/docker_afremov_sw5000_ss1.png)\n![Stylized Docker](./doc/docker_broca_sw5000_ss1.png)\n![Stylized Docker](./doc/docker_brownrays_sw375_ss1.png)\n![Stylized Docker](./doc/docker_ediaonise_sw1500_ss1.png)\n![Stylized Docker](./doc/docker_edimburgGraffit_sw20000.0_ss1.png)\n![Stylized Docker](./doc/docker_himesama_sw10000_ss1.png)\n![Stylized Docker](./doc/docker_paisaje_urbano-hundertwasser_sw2000_ss1.png)\n![Stylized Docker](./doc/docker_potatoes_sw375_ss1.png)\n![Stylized Docker](./doc/docker_RenoirDogesPalaceVenice_sw1500_ss1.png)\n![Stylized Docker](./doc/docker_revellerAndCourtesan_sw2000_ss1.png)\n![Stylized Docker](./doc/docker_seated-nude_sw375_ss1.png)\n![Stylized Docker](./doc/docker_starryNight_sw1500_ss1.png)\n\nA dockerized version of neural style transfer algorithms.\n[nvidia-docker](https://github.com/NVIDIA/nvidia-docker) is used to make use of GPU hardware.\n\n## Install\n\n### Prerequisites\n\n* [docker](https://www.docker.com/)\n* [nvidia-docker](https://github.com/NVIDIA/nvidia-docker)\n* Appropriate [nvidia drivers](http://www.nvidia.es/Download/index.aspx) for your GPU\n\n### Installation\n\nYou can either pull the Docker image from Docker Hub with\n\n\tdocker pull albarji/neural-style\n\nor build the image locally with\n\n\tmake\n\n### Usage\n\nThis docker container operates by receiving images through a volume to be mounted at the **/images** directory.\nFor instance, to apply a **style** image *somestyle.png* onto a **content** image *somecontent.png* located at the \ncurrent directory, run: \n\n    nvidia-docker run --rm -v $(pwd):/images albarji/neural-style --content somecontent.png --style somestyle.png\n\nAll paths referenced in the arguments are regarded as relative to the /images folder within the container. So in case\nof having a local structure such as\n\n    contents/\n        docker.png\n        whatever.jpg\n    styles/\n        picasso.png\n        vangogh.png\n    results/\n        something.md\n        \napplying the *vangogh.png* style to the *docker.png* image amounts to\n\n    nvidia-docker run --rm -v $(pwd):/images albarji/neural-style --content contents/docker.png --style styles/vangogh.png\n    \nYou can provide several content and style images, in which case all cross-combinations will be generated.\n\n    nvidia-docker run --rm -v $(pwd):/images albarji/neural-style --content contents/docker.png contents/whatever.jpg --style styles/vangogh.png styles/picasso.png\n    \nBy default all generated images are saved into the container **/images**. When running the commands above the results\nwill get saved into the host local folder (through the mounted volume). If you want to locate the generated images at a \ndifferent folder you can use the --output parameters. Note that, similarly to the --content and --style arguments,\nthe path provided in --output will be regarded as relative to the /images folder. For instance, using the local \nstructure from the example above, saving the generated images in the \"results\" folder will require the following:\n\n    nvidia-docker run --rm -v $(pwd):/images albarji/neural-style --content contents/docker.png --style styles/vangogh.png --output results\n\n### Fine tuning the results\n\nBetter results can be attained by modifying some of the transfer parameters.\n\n#### Algorithm\n\nThe --alg parameter allows changing the neural style transfer algorithm to use.\n\n* **gatys**: highly detailed transfer, slow processing times (default)\n* **gatys-multiresolution**: multipass version of Gatys method, provides even better quality, but is also much slower\n* **chen-schmidt**: fast patch-based style transfer\n* **chen-schmidt-inverse**: even faster aproximation to chen-schmidt through the use of an inverse network\n\nThe following example illustrates kind of results to be expected by these different algorithms\n\n| Content image | Algorithm | Style image |\n| ------------- | --------- | ----------- |\n| ![Content](./doc/avila-walls.jpg) | Gatys ![Gatys](./doc/avila-walls_broca_gatys_ss1.0_sw10.0.jpg) | ![Style](./doc/broca.jpg) |\n| ![Content](./doc/avila-walls.jpg) | Gatys Multiresolution ![Gatys-Multiresolution](./doc/avila-walls_broca_gatys-multiresolution_ss1.0_sw3.0.jpg) | ![Style](./doc/broca.jpg) |\n| ![Content](./doc/avila-walls.jpg) | Chen-Schmidt ![Chen-Schmidt](./doc/avila-walls_broca_chen-schmidt_ss1.0.jpg) | ![Style](./doc/broca.jpg) | \n| ![Content](./doc/avila-walls.jpg) | Chen-Schmidt Inverse ![Chen-Schmidt Inverse](./doc/avila-walls_broca_chen-schmidt-inverse_ss1.0.jpg) | ![Style](./doc/broca.jpg) | \n\n#### Output image size\n\nBy default the output image will have the same size as the input content image, but a different target size can be\nspecified through the --size parameter. For example, to produce a 512 image\n\n    nvidia-docker run --rm -v $(pwd):/images albarji/neural-style --content contents/docker.png --style styles/vangogh.png --size 512\n    \nNote the proportions of the image are maintained, therefore the value of the size parameter is understood as the width \nof the target image, the height being scaled accordingly to keep proportion.\n\nIf the image to be generated is large, a tiling strategy will be used, applying the neural style transfer method\nto small tiles of the image and stitching them together. Tiles overlap to provide some guarantees on overall\nconsistency, though results might vary depending on the algorithm used.\n\n![Tiling](./doc/tiling.png)\n\nThe size of these tiles is defined through the configuration file **gpuconfig.json** inside the container.\nThis file contains dictionary keys for different GPU models and each neural style algorithm. Your GPU will be \nautomatically checked against the registered configurations and the appropriate tile size will be selected. These values\nhave been chosen to maximize the use of the available GPU memory, asumming the whole GPU is available for the style\ntransfer task.  \n\nIf your GPU is not included in the configuration file, the *default* values will we used instead, though to obtain\nbetter performance you might want to edit this file and rebuild the docker images.\n\nNote also that since the full style image is applied to each tile separately, as a result the style features will appear\nas smaller in the rendered image.\n\n#### Style weight\n\nGatys and Gatys Multiresolution algorithms allow to adjust the amount of style imposed over the content image, by means \nof the --sw parameter. By default a value of **5** is used, meaning the importance of the style is 5 times the \nimportance of the content. Smaller weight values result in the transfer of colors, while higher values transfer textures \nand even objects of the style.\n\nIf several weight values are provided, all combinations will be generated. For instance, to generate the same\nstyle transfer with three different weights, use\n\n    nvidia-docker run --rm -v $(pwd):/images albarji/neural-style --content contents/docker.png --style styles/vangogh.png --sw 5 10 20\n    \nNote also that they Gatys Multiresolution algorithm tends to produce a stronger style imprint, and this you might want\nto use weight values smaller than the default (e.g. 3). \n\n#### Style scale\n\nIf the transferred style results in too large or too small features, the scaling can be modified through the --ss \nparameter. A value of **1** keeps the style at its original scale. Smaller values reduce the scale of the style,\nresulting in smaller style features in the output image. Conversely, larger values produce larger features. \nSimilarly to the style weight, several values can be provided\n\n    nvidia-docker run --rm -v $(pwd):/images albarji/neural-style --content contents/docker.png --style styles/vangogh.png --ss 0.75 1 1.25\n    \nWarning: using a value larger than **1** will increasy the memory consumption. \n\n### Transparency\n\nTransparency values (alpha channels) are preserved by the neural style transfer. Note for instance how in the Wikipedia\nlogo example above the transparent background is not transformed.\n\n## References\n\n* [Gatys et al method](https://arxiv.org/abs/1508.06576), [implementation by jcjohnson](https://github.com/jcjohnson/neural-style)\n* [Chen-Schmidt method](https://arxiv.org/pdf/1612.04337.pdf), [implementation](https://github.com/rtqichen/style-swap)\n* [A review on style transfer methods](https://arxiv.org/pdf/1705.04058.pdf)\n* [Controlling Perceptual Factors in Neural Style Transfer](https://arxiv.org/abs/1611.07865)\n* [Neural-tiling method](https://github.com/ProGamerGov/Neural-Tile)\n* [Multiresolution strategy](https://gist.github.com/jcjohnson/ca1f29057a187bc7721a3a8c418cc7db)\n* [The Wikipedia logo](https://en.wikipedia.org/wiki/Wikipedia_logo)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbarji%2Fneural-style-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbarji%2Fneural-style-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbarji%2Fneural-style-docker/lists"}