{"id":17139723,"url":"https://github.com/hwalsuklee/tensorflow-fast-style-transfer","last_synced_at":"2025-05-07T04:05:20.125Z","repository":{"id":110398562,"uuid":"82381314","full_name":"hwalsuklee/tensorflow-fast-style-transfer","owner":"hwalsuklee","description":"A simple, concise tensorflow implementation of fast style transfer","archived":false,"fork":false,"pushed_at":"2018-03-19T11:24:50.000Z","size":12317,"stargazers_count":243,"open_issues_count":12,"forks_count":69,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-07T04:05:12.029Z","etag":null,"topics":["change-style","fast","neural-style","offline","style-transfer","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hwalsuklee.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":"2017-02-18T11:14:08.000Z","updated_at":"2025-02-02T02:20:20.000Z","dependencies_parsed_at":"2023-07-11T15:15:55.390Z","dependency_job_id":null,"html_url":"https://github.com/hwalsuklee/tensorflow-fast-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/hwalsuklee%2Ftensorflow-fast-style-transfer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwalsuklee%2Ftensorflow-fast-style-transfer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwalsuklee%2Ftensorflow-fast-style-transfer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwalsuklee%2Ftensorflow-fast-style-transfer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hwalsuklee","download_url":"https://codeload.github.com/hwalsuklee/tensorflow-fast-style-transfer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252810271,"owners_count":21807760,"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":["change-style","fast","neural-style","offline","style-transfer","tensorflow"],"created_at":"2024-10-14T20:12:54.056Z","updated_at":"2025-05-07T04:05:20.097Z","avatar_url":"https://github.com/hwalsuklee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fast Style Transfer\n\nA tensorflow implementation of fast style transfer described in the papers:\n* [Perceptual Losses for Real-Time Style Transfer and Super-Resolution](http://cs.stanford.edu/people/jcjohns/eccv16/) by Johnson\n* [Instance Normalization](https://arxiv.org/abs/1607.08022) by Ulyanov\n\nI recommend you to check my previous implementation of [A Neural Algorithm of Artistic Style](https://arxiv.org/abs/1508.06576) (Neural style) in [here](https://github.com/hwalsuklee/tensorflow-style-transfer), since implementation in here is almost similar to it.  \n\n## Sample results\n\nAll style-images and content-images to produce following sample results are given in `style` and `content` folders.\n\n### Chicago\nFollowing results with `--max_size 1024` are obtained from *chicago* image, which is commonly used in other implementations to show their performance.\n\nClick on result images to see full size images.\n\n\u003cp align='center'\u003e\n\u003cimg src = 'content/chicago.jpg' height=\"220px\"\u003e\n\u003c/p\u003e\n\u003cp align='center'\u003e\n\u003cimg src = 'style/thumbs/wave.jpg' height = '210px'\u003e\n\u003cimg src = 'samples/chicago_wave.jpg' height = '210px'\u003e\n\u003cimg src = 'samples/chicago_the_scream.jpg' height = '210px'\u003e\n\u003cimg src = 'style/thumbs/the_scream.jpg' height = '210px'\u003e\n\u003cbr\u003e\n\u003cimg src = 'style/thumbs/la_muse.jpg' height = '210px'\u003e\n\u003cimg src = 'samples/chicago_la_muse.jpg' height = '210px'\u003e\n\u003cimg src = 'samples/chicago_rain_princess.jpg' height = '210px'\u003e\n\u003cimg src = 'style/thumbs/rain_princess.jpg' height = '210px'\u003e\n\u003cbr\u003e\n\u003cimg src = 'style/thumbs/the_shipwreck_of_the_minotaur.jpg' height = '210px'\u003e\n\u003cimg src = 'samples/chicago_shipwreck.jpg' height = '210px'\u003e\n\u003cimg src = 'samples/chicago_udnie.jpg' height = '210px'\u003e\n\u003cimg src = 'style/thumbs/udnie.jpg' height = '210px'\u003e\n\u003cbr\u003e\n\u003c/p\u003e\n\n### Female Knight\nThe source image is from https://www.artstation.com/artwork/4zXxW\n\nResults were obtained from default setting except `--max_size 1920`.  \nAn image was rendered approximately after 100ms on  GTX 980 ti.\n\nClick on result images to see full size images.\n\n\u003cp align='center'\u003e\n\u003cimg src = 'content/female_knight.jpg' height=\"220px\"\u003e\n\u003c/p\u003e\n\u003cp align='center'\u003e\n\u003cimg src = 'style/thumbs/wave.jpg' height = '210px'\u003e\n\u003cimg src = 'samples/female_knight_wave.jpg' height = '210px'\u003e\n\u003cimg src = 'samples/female_knight_the_scream.jpg' height = '210px'\u003e\n\u003cimg src = 'style/thumbs/the_scream.jpg' height = '210px'\u003e\n\u003cbr\u003e\n\u003cimg src = 'style/thumbs/la_muse.jpg' height = '210px'\u003e\n\u003cimg src = 'samples/female_knight_la_muse.jpg' height = '210px'\u003e\n\u003cimg src = 'samples/female_knight_rain_princess.jpg' height = '210px'\u003e\n\u003cimg src = 'style/thumbs/rain_princess.jpg' height = '210px'\u003e\n\u003cbr\u003e\n\u003cimg src = 'style/thumbs/the_shipwreck_of_the_minotaur.jpg' height = '210px'\u003e\n\u003cimg src = 'samples/female_knight_shipwreck.jpg' height = '210px'\u003e\n\u003cimg src = 'samples/female_knight_udnie.jpg' height = '210px'\u003e\n\u003cimg src = 'style/thumbs/udnie.jpg' height = '210px'\u003e\n\u003cbr\u003e\n\u003c/p\u003e\n\n## Usage\n\n### Prerequisites\n1. Tensorflow\n2. Python packages : numpy, scipy, PIL(or Pillow), matplotlib\n3. Pretrained VGG19 file : [imagenet-vgg-verydeep-19.mat](http://www.vlfeat.org/matconvnet/models/imagenet-vgg-verydeep-19.mat)  \n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;* Please download the file from link above.  \n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;* Save the file under `pre_trained_model`  \n4. MSCOCO train2014 DB : [train2014.zip](http://msvocds.blob.core.windows.net/coco2014/train2014.zip)  \n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;* Please download the file from link above.  (Notice that the file size is over 12GB!!)  \n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;* Extract images to `train2014`.\n\n### Train\n```\npython run_train.py --style \u003cstyle file\u003e --output \u003coutput directory\u003e --trainDB \u003ctrainDB directory\u003e --vgg_model \u003cmodel directory\u003e\n```\n*Example*:\n`python run_train.py --style style/wave.jpg --output model --trainDB train2014 --vgg_model pre_trained_model`\n\n#### Arguments\n*Required* :  \n* `--style`: Filename of the style image. *Default*: `images/wave.jpg`\n* `--output`: File path for trained-model. Train-log is also saved here. *Default*: `models`\n* `--trainDB`: Relative or absolute directory path to MSCOCO DB. *Default*: `train2014`\n* `--vgg_model`: Relative or absolute directory path to pre trained model. *Default*: `pre_trained_model`\n\n*Optional* :  \n* `--content_weight`: Weight of content-loss. *Default*: `7.5e0`\n* `--style_weight`: Weight of style-loss. *Default*: `5e2`\n* `--tv_weight`: Weight of total-varaince-loss. *Default*: `2e2`\n* `--content_layers`: *Space-separated* VGG-19 layer names used for content loss computation. *Default*: `relu4_2`\n* `--style_layers`: *Space-separated* VGG-19 layer names used for style loss computation. *Default*: `relu1_1 relu2_1 relu3_1 relu4_1 relu5_1`\n* `--content_layer_weights`: *Space-separated* weights of each content layer to the content loss. *Default*: `1.0`\n* `--style_layer_weights`: *Space-separated* weights of each style layer to loss. *Default*: `0.2 0.2 0.2 0.2 0.2`\n* `--max_size`: Maximum width or height of the input images. *Default*: `None`\n* `--num_epochs`: The number of epochs to run. *Default*: `2`\n* `--batch_size`: Batch size. *Default*: `4`\n* `--learn_rate`: Learning rate for Adam optimizer. *Default*: `1e-3`\n* `--checkpoint_every`: Save-frequency for checkpoint. *Default*: `1000`\n* `--test`: Filename of the content image for *test during training*. *Default*: `None`\n* `--max_size`: Maximum width or height of the input image for test. *None* do not change image size. *Default*: `None` \n\n#### Trained models\nYou can download all the 6 trained models from [here](https://mega.nz/#F!VEAm1CDD!ILTR1TA5zFJ_Cp9I5DRofg)\n\n### Test  \n\n```\npython run_test.py --content \u003ccontent file\u003e --style_model \u003cstyle-model file\u003e --output \u003coutput file\u003e \n```\n*Example*:\n`python run_test.py --content content/female_knight.jpg --style_model models/wave.ckpt --output result.jpg`\n\n#### Arguments\n*Required* :  \n* `--content`: Filename of the content image. *Default*: `content/female_knight.jpg`\n* `--style-model`: Filename of the style model. *Default*: `models/wave.ckpt`\n* `--output`: Filename of the output image. *Default*: `result.jpg`  \n\n*Optional* :  \n* `--max_size`: Maximum width or height of the input images. *None* do not change image size. *Default*: `None`\n\n## Train time\n\nTrain time for 2 epochs with 8 batch size is 6~8 hours. It depends on which style image you use.\n\n## References\n\nThe implementation is based on the projects:\n\n[1] Torch implementation by paper author:  https://github.com/jcjohnson/fast-neural-style  \n* The major difference between [1] and implementation in here is to use VGG19 instead of VGG16 in calculation of loss functions. I did not want to give too much modification on my previous implementation on style-transfer.  \n\n[2] Tensorflow implementation : https://github.com/lengstrom/fast-style-transfer  \n* The major difference between [2] and implementation in here is the architecture of image-transform-network. I made it just as in the paper. Please see the [supplementary](http://cs.stanford.edu/people/jcjohns/papers/eccv16/JohnsonECCV16Supplementary.pdf) of the paper.\n\n## Acknowledgements\nThis implementation has been tested with Tensorflow over ver1.0 on Windows 10 and Ubuntu 14.04.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwalsuklee%2Ftensorflow-fast-style-transfer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhwalsuklee%2Ftensorflow-fast-style-transfer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwalsuklee%2Ftensorflow-fast-style-transfer/lists"}