{"id":18317337,"url":"https://github.com/compvis/adaptive-style-transfer","last_synced_at":"2025-04-04T21:08:34.662Z","repository":{"id":45480928,"uuid":"142374879","full_name":"CompVis/adaptive-style-transfer","owner":"CompVis","description":"source code for the ECCV18 paper A Style-Aware Content Loss for Real-time HD Style Transfer","archived":false,"fork":false,"pushed_at":"2021-01-11T12:05:30.000Z","size":185841,"stargazers_count":737,"open_issues_count":20,"forks_count":140,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-03-28T20:07:55.827Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://compvis.github.io/adaptive-style-transfer/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CompVis.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":"2018-07-26T01:59:16.000Z","updated_at":"2025-03-27T09:09:44.000Z","dependencies_parsed_at":"2022-07-15T03:47:04.505Z","dependency_job_id":null,"html_url":"https://github.com/CompVis/adaptive-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/CompVis%2Fadaptive-style-transfer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CompVis%2Fadaptive-style-transfer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CompVis%2Fadaptive-style-transfer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CompVis%2Fadaptive-style-transfer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CompVis","download_url":"https://codeload.github.com/CompVis/adaptive-style-transfer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249526,"owners_count":20908212,"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":[],"created_at":"2024-11-05T18:05:47.170Z","updated_at":"2025-04-04T21:08:34.642Z","avatar_url":"https://github.com/CompVis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Style-Aware Content Loss for Real-time HD Style Transfer\n***Artsiom Sanakoyeu\\*, Dmytro Kotovenko\\*, Sabine Lang, Björn Ommer*, In ECCV 2018 (Oral)**\n\n**Website**: https://compvis.github.io/adaptive-style-transfer   \n**Paper**: https://arxiv.org/abs/1807.10201\n\n![pipeline](https://compvis.github.io/adaptive-style-transfer/images/eccv_pipeline_diagram_new_symbols_v2_4.jpg \"Method pipeline\")\n\n\n[![example](https://compvis.github.io/adaptive-style-transfer/images/adaptive-style-transfer_chart_1800px.jpg \"Stylization\")](https://compvis.github.io/adaptive-style-transfer/images/adaptive-style-transfer_chart.jpg)\nPlease click on the image for a [high-res version](https://compvis.github.io/adaptive-style-transfer/images/adaptive-style-transfer_chart.jpg).\n\n## Requirements\n- python 2.7\n- tensorflow 1.2.\n- PIL, numpy, scipy\n- tqdm\n\n*Also tested in `python3.6 + tensorflow 1.12.0`*\n\n## Inference \n#### Simplest van Gogh example\nTo launch the inference on van Gogh style:\n1. Download the pretrained model [model_van-gogh_ckpt.tar.gz](https://drive.google.com/file/d/1JDLRlCsiEt4wrV1eGUkeq_j89WasilvR/view?usp=sharing) \n2. Download sample [photographs](https://drive.google.com/file/d/1BqTzKKCCJ3W778hPddiv8_4WyELChzxo/view?usp=sharing).  \n3. Extract the model to `./models/` folder and sample photographs to `./data/` folder.  \n4. Run the following command:\n```\nCUDA_VISIBLE_DEVICES=0 python main.py \\\n                 --model_name=model_van-gogh \\\n                 --phase=inference \\\n                 --image_size=1280\n```\nStylized photographs are stored in the folder `./models/model_van-gogh/inference_ckpt300000_sz1280/`\n\n#### Additional settings\n- `--ii_dir INPUT_DIR` - path to the folder containing target content images.  \nYou can specify multiple folders separated with commas (don't use spaces!).  \n- `--image_size SIZE` -  resolution of the images to generate. \n- `--save_dir SAVE_DIR` - path to the output dir where the generated images will be saved.\n- `--model_name NAME` - the name of the model (all model should as subfolders in `./models/`).\n    \nUsage example (inference):\n```\nCUDA_VISIBLE_DEVICES=0 python main.py \\\n                 --model_name=model_van-gogh \\\n                 --phase=inference \\\n                 --image_size=1280 \\\n                 --ii_dir ../my_photographs1/,../my_photographs2/ \\\n                 --save_dir=../save_processed_images_here/\n``` \nIf your GPU memory is not large enough, set the variable `CUDA_VISIBLE_DEVICES=\"\"` to use CPU. \n\n### Pretrained models\nWe provide pretrained models for the following artists:  \nPaul Cezanne,  \nEl-Greco,  \nPaul Gauguin,  \nWassily Kandinsky (_Василий Кандинский_),  \nErnst Ludwig Kirchner,  \nClaude Monet,  \nBerthe Morisot,  \nEdvard Munch,  \nSamuel Peploe,  \nPablo Picasso,  \nJackson Pollock,  \nNicholal Roerich (_Николай Рерих_),  \nVincent van Gogh.   \n\n**Download pretrained models:** [link](https://drive.google.com/drive/folders/1SrWcmpZXXZ2gh821a0MUApNKO8Rm69ku?usp=sharing).  \nExtract models to the folder `./models/`. \n\n    \n## Training\n\nContent images used for training: [Places365-Standard high-res train mages (105GB)](http://data.csail.mit.edu/places/places365/train_large_places365standard.tar).  \n\nStyle images used for training the aforementioned models: [download link](https://\n\n\n\n\n\ncloud.iwr.uni-heidelberg.de/index.php/s/NcJj2oLBTYuT1tf).    \nQuery style examples used to collect style images: [query_style_images.tar.gz](https://yadi.sk/d/5sormJouqyuI4A).\n\n- For example, Vincent van Gogh style: [vincent-van-gogh_road-with-cypresses-1890.tar.gz](https://drive.google.com/file/d/1Ld-Xwx7qZpB1MHuLgnx8SD13gDdmZqnD/view?usp=sharing).  \nThis is the dataset representing a particular artistic period of Vincent van Gogh and was automatically collected using \"Road with Cypress and Star, 1890\" painting as query.\n\n\n1. Download and extract style archives in folder `./data`.   \n2. Download and extract content images.\n3. Launch the training process (for example, on van Gogh):\n```\nCUDA_VISIBLE_DEVICES=1 python main.py \\\n                 --model_name=model_van-gogh_new \\\n                 --batch_size=1 \\\n                 --phase=train \\\n                 --image_size=768 \\\n                 --lr=0.0002 \\\n                 --dsr=0.8 \\\n                 --ptcd=/path/to/Places2/data_large \\\n                 --ptad=./data/vincent-van-gogh_road-with-cypresses-1890\n```                 \n\n## Evaluation\nHow to calculate **Deception Score** and where to download artist classification model is described in [evaluation](evaluation).\n\n## Video stylization\nTo stylize a video you can use the following script:\n\n```\n# split video on a set of frames\nffmpeg -i myvideo.mp4 -r 25 -f image2 image-%04d.png\n\nCUDA_VISIBLE_DEVICES=0 python main.py \\\n--model_name=model_van-gogh \\\n--phase=inference \\\n--image_size=1280 \\\n--ii_dir=input \\\n--save_dir=output\n\n# reassemble the video back from frames:\nffmpeg -i image-%04d_stylized.jpg kktie-out.mp4\n```\n\n## Reference\n\nIf you use this code or data, please cite the paper:\n```\n@inproceedings{sanakoyeu2018styleaware,\n  title={A Style-Aware Content Loss for Real-time HD Style Transfer},\n  author={Sanakoyeu, Artsiom and Kotovenko, Dmytro and Lang, Sabine and Ommer, Bj{\\\"o}rn},\n  booktitle={Proceedings of the European Conference on Computer Vision (ECCV)},\n  pages={698--714},\n  month = 10,\n  year={2018}\n}\n```\n\n### Copyright\n```\nAdaptive Style Transfer  \nCopyright (C) 2018  Artsiom Sanakoyeu, Dmytro Kotovenko  \n\nAdaptive Style Transfer is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see \u003chttps://www.gnu.org/licenses/\u003e.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompvis%2Fadaptive-style-transfer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompvis%2Fadaptive-style-transfer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompvis%2Fadaptive-style-transfer/lists"}