pastiche


Namepastiche JSON
Version 1.5.0 PyPI version JSON
download
home_pagehttps://github.com/dstein64/pastiche
SummaryA PyTorch implementation of Neural Style Transfer (NST)
upload_time2024-06-30 23:22:48
maintainerNone
docs_urlNone
authorDaniel Steinberg
requires_python>=3.6
licenseMIT
keywords gatys style-transfer neural-style-transfer
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build Status](https://github.com/dstein64/pastiche/workflows/build/badge.svg)](https://github.com/dstein64/pastiche/actions)

pastiche
========

A PyTorch-based Python implementation of Neural Style Transfer [1].

<div align="center">
 <img src="https://github.com/dstein64/pastiche/blob/master/example/vangogh_starry_night.jpg?raw=true" height="256"/>
 <img src="https://github.com/dstein64/pastiche/blob/master/example/boston.jpg?raw=true" height="256"/>
 <br>
 <img src="https://github.com/dstein64/pastiche/blob/master/example/pastiche.jpg?raw=true" width="710"/>
</div>

Features
--------

- Support for saving intermediate images during optimization
- An option for preserving colors from the content image
- Multiple-device computation (`--supplemental-device`)
- Style transfers utilizing multiple style images

Installation
------------

#### Requirements

- Python 3.6 or greater

#### Install

```sh
$ pip3 install pastiche
```

#### Update

```sh
$ pip3 install --upgrade pastiche
```

Usage
-----

The program is intended to be used from the command line.

The general command line usage is shown below.

```sh
$ pastiche --content CONTENT --styles STYLE [STYLE ...] --output OUTPUT
```

`CONTENT` is the path to the content image, `STYLE` is the path to the style image, and `OUTPUT` is the path to save
the synthesized pastiche PNG file.

If the launcher script was not installed within a directory on your PATH, pastiche can be launched by passing its
module name to Python.

```sh
$ python3 -m pastiche --content CONTENT --styles STYLE [STYLE ...] --output OUTPUT
```

There are various options, including but not limited to:
- Devices (GPU, CPU, and/or a multi-device assortment)
- Number of optimization iterations
- VGG layers to utilize
- Loss function term weights

For the full list of options and the corresponding documentation, see the source code or use `--help`.

```sh
$ pastiche --help
```

Example
-------

<img src="https://github.com/dstein64/pastiche/blob/master/example/pastiche.jpg?raw=true" width="384"/>

The image above was generated by applying the style from Vincent van Gogh's `The Starry Night` to a photo I took in
Boston in 2015. The high-resolution image was generated incrementally, with increasing resolution, using the
coarse-to-fine approach described in [2]. Example commands are shown below. Depending on GPU memory availability, the
commands may necessitate execution partially on a CPU (e.g., `--device cuda:0 --supplemental-device cuda:1 10
--supplemental-device cpu 20` would configure GPU 0 for layers 0 through 9, GPU 1 for layers 10 through 19, and the
CPU for layers 20 through 36).

```sh
$ pastiche                            \
    --device cuda                     \
    --num-steps 2000                  \
    --content boston.jpg              \
    --styles vangogh_starry_night.jpg \
    --output pastiche0.png

$ pastiche                            \
    --device cuda                     \
    --size 1024                       \
    --num-steps 1000                  \
    --init pastiche0.png              \
    --content boston.jpg              \
    --styles vangogh_starry_night.jpg \
    --output pastiche1.png

# Split the computation across a GPU (layers 0 through 5 and 10 through 19), another GPU (layers 6
# through 9), and a CPU (layers 20 through 36). This device strategy is for the purpose of
# illustration. Tuning would be required for an actual device setup.
$ pastiche                            \
    --device cuda:0                   \
    --supplemental-device cuda:1 6    \
    --supplemental-device cuda:0 10   \
    --supplemental-device cpu 20      \
    --info-step 10                    \
    --size 2048                       \
    --num-steps 500                   \
    --init pastiche1.png              \
    --content boston.jpg              \
    --styles vangogh_starry_night.jpg \
    --output pastiche2.png

# Split the computation across a GPU (layers 0 through 3) and CPU (layers 4 through 36). This
# device strategy is for the purpose of illustration. Tuning would be required for an actual
# device setup.
$ pastiche                            \
    --device cuda                     \
    --supplemental-device cpu 4       \
    --info-step 1                     \
    --size 4096                       \
    --num-steps 100                   \
    --init pastiche2.png              \
    --content boston.jpg              \
    --styles vangogh_starry_night.jpg \
    --output pastiche3.png

$ convert pastiche3.png pastiche.jpg  # requires ImageMagick
```

The `--preserve-color` option can be used to retain colors from the content image. The image below was generated
using the same commands as above (up to `--size 2048`), with the addition of `--preserve-color`.

<img src="https://github.com/dstein64/pastiche/blob/master/example/pastiche_preserve_color.jpg?raw=true" width="384"/>

License
-------

The source code has an [MIT License](https://en.wikipedia.org/wiki/MIT_License).

See [LICENSE](https://github.com/dstein64/pastiche/blob/master/LICENSE).

References
----------

[1] Gatys, Leon A., Alexander S. Ecker, and Matthias Bethge. "A Neural Algorithm of Artistic Style."
ArXiv:1508.06576 [Cs, q-Bio], August 26, 2015. http://arxiv.org/abs/1508.06576.

[2] Gatys, Leon A., Alexander S. Ecker, Matthias Bethge, Aaron Hertzmann, and Eli Shechtman.
"Controlling Perceptual Factors in Neural Style Transfer." ArXiv:1611.07865 [Cs], November 23, 2016.
http://arxiv.org/abs/1611.07865.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dstein64/pastiche",
    "name": "pastiche",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "gatys, style-transfer, neural-style-transfer",
    "author": "Daniel Steinberg",
    "author_email": "ds@dannyadam.com",
    "download_url": "https://files.pythonhosted.org/packages/2a/88/c5282ea1d87922f6c511f38224a82d82a9f4cc186990550a299fe864c08a/pastiche-1.5.0.tar.gz",
    "platform": null,
    "description": "[![Build Status](https://github.com/dstein64/pastiche/workflows/build/badge.svg)](https://github.com/dstein64/pastiche/actions)\n\npastiche\n========\n\nA PyTorch-based Python implementation of Neural Style Transfer [1].\n\n<div align=\"center\">\n <img src=\"https://github.com/dstein64/pastiche/blob/master/example/vangogh_starry_night.jpg?raw=true\" height=\"256\"/>\n <img src=\"https://github.com/dstein64/pastiche/blob/master/example/boston.jpg?raw=true\" height=\"256\"/>\n <br>\n <img src=\"https://github.com/dstein64/pastiche/blob/master/example/pastiche.jpg?raw=true\" width=\"710\"/>\n</div>\n\nFeatures\n--------\n\n- Support for saving intermediate images during optimization\n- An option for preserving colors from the content image\n- Multiple-device computation (`--supplemental-device`)\n- Style transfers utilizing multiple style images\n\nInstallation\n------------\n\n#### Requirements\n\n- Python 3.6 or greater\n\n#### Install\n\n```sh\n$ pip3 install pastiche\n```\n\n#### Update\n\n```sh\n$ pip3 install --upgrade pastiche\n```\n\nUsage\n-----\n\nThe program is intended to be used from the command line.\n\nThe general command line usage is shown below.\n\n```sh\n$ pastiche --content CONTENT --styles STYLE [STYLE ...] --output OUTPUT\n```\n\n`CONTENT` is the path to the content image, `STYLE` is the path to the style image, and `OUTPUT` is the path to save\nthe synthesized pastiche PNG file.\n\nIf the launcher script was not installed within a directory on your PATH, pastiche can be launched by passing its\nmodule name to Python.\n\n```sh\n$ python3 -m pastiche --content CONTENT --styles STYLE [STYLE ...] --output OUTPUT\n```\n\nThere are various options, including but not limited to:\n- Devices (GPU, CPU, and/or a multi-device assortment)\n- Number of optimization iterations\n- VGG layers to utilize\n- Loss function term weights\n\nFor the full list of options and the corresponding documentation, see the source code or use `--help`.\n\n```sh\n$ pastiche --help\n```\n\nExample\n-------\n\n<img src=\"https://github.com/dstein64/pastiche/blob/master/example/pastiche.jpg?raw=true\" width=\"384\"/>\n\nThe image above was generated by applying the style from Vincent van Gogh's `The Starry Night` to a photo I took in\nBoston in 2015. The high-resolution image was generated incrementally, with increasing resolution, using the\ncoarse-to-fine approach described in [2]. Example commands are shown below. Depending on GPU memory availability, the\ncommands may necessitate execution partially on a CPU (e.g., `--device cuda:0 --supplemental-device cuda:1 10\n--supplemental-device cpu 20` would configure GPU 0 for layers 0 through 9, GPU 1 for layers 10 through 19, and the\nCPU for layers 20 through 36).\n\n```sh\n$ pastiche                            \\\n    --device cuda                     \\\n    --num-steps 2000                  \\\n    --content boston.jpg              \\\n    --styles vangogh_starry_night.jpg \\\n    --output pastiche0.png\n\n$ pastiche                            \\\n    --device cuda                     \\\n    --size 1024                       \\\n    --num-steps 1000                  \\\n    --init pastiche0.png              \\\n    --content boston.jpg              \\\n    --styles vangogh_starry_night.jpg \\\n    --output pastiche1.png\n\n# Split the computation across a GPU (layers 0 through 5 and 10 through 19), another GPU (layers 6\n# through 9), and a CPU (layers 20 through 36). This device strategy is for the purpose of\n# illustration. Tuning would be required for an actual device setup.\n$ pastiche                            \\\n    --device cuda:0                   \\\n    --supplemental-device cuda:1 6    \\\n    --supplemental-device cuda:0 10   \\\n    --supplemental-device cpu 20      \\\n    --info-step 10                    \\\n    --size 2048                       \\\n    --num-steps 500                   \\\n    --init pastiche1.png              \\\n    --content boston.jpg              \\\n    --styles vangogh_starry_night.jpg \\\n    --output pastiche2.png\n\n# Split the computation across a GPU (layers 0 through 3) and CPU (layers 4 through 36). This\n# device strategy is for the purpose of illustration. Tuning would be required for an actual\n# device setup.\n$ pastiche                            \\\n    --device cuda                     \\\n    --supplemental-device cpu 4       \\\n    --info-step 1                     \\\n    --size 4096                       \\\n    --num-steps 100                   \\\n    --init pastiche2.png              \\\n    --content boston.jpg              \\\n    --styles vangogh_starry_night.jpg \\\n    --output pastiche3.png\n\n$ convert pastiche3.png pastiche.jpg  # requires ImageMagick\n```\n\nThe `--preserve-color` option can be used to retain colors from the content image. The image below was generated\nusing the same commands as above (up to `--size 2048`), with the addition of `--preserve-color`.\n\n<img src=\"https://github.com/dstein64/pastiche/blob/master/example/pastiche_preserve_color.jpg?raw=true\" width=\"384\"/>\n\nLicense\n-------\n\nThe source code has an [MIT License](https://en.wikipedia.org/wiki/MIT_License).\n\nSee [LICENSE](https://github.com/dstein64/pastiche/blob/master/LICENSE).\n\nReferences\n----------\n\n[1] Gatys, Leon A., Alexander S. Ecker, and Matthias Bethge. \"A Neural Algorithm of Artistic Style.\"\nArXiv:1508.06576 [Cs, q-Bio], August 26, 2015. http://arxiv.org/abs/1508.06576.\n\n[2] Gatys, Leon A., Alexander S. Ecker, Matthias Bethge, Aaron Hertzmann, and Eli Shechtman.\n\"Controlling Perceptual Factors in Neural Style Transfer.\" ArXiv:1611.07865 [Cs], November 23, 2016.\nhttp://arxiv.org/abs/1611.07865.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A PyTorch implementation of Neural Style Transfer (NST)",
    "version": "1.5.0",
    "project_urls": {
        "Homepage": "https://github.com/dstein64/pastiche"
    },
    "split_keywords": [
        "gatys",
        " style-transfer",
        " neural-style-transfer"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a2f23054cef2e4f168caa5a81fc35e93f577995ed5e6c51fd97a5fbbfa63526",
                "md5": "85f9fb57129a9747310ddfab94959052",
                "sha256": "d3d9b136c9d48c654d5e0d6e729b85c44362a6cfe4616c05f8edc38cb4a6afc6"
            },
            "downloads": -1,
            "filename": "pastiche-1.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "85f9fb57129a9747310ddfab94959052",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 18522784,
            "upload_time": "2024-06-30T23:22:36",
            "upload_time_iso_8601": "2024-06-30T23:22:36.616636Z",
            "url": "https://files.pythonhosted.org/packages/0a/2f/23054cef2e4f168caa5a81fc35e93f577995ed5e6c51fd97a5fbbfa63526/pastiche-1.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a88c5282ea1d87922f6c511f38224a82d82a9f4cc186990550a299fe864c08a",
                "md5": "420cf8e1e7ee6fab52338910b1201714",
                "sha256": "c10fe3e3f72fbbfb1c3a639073c639136ccbe450f13319441d7ce4bf3edd35a9"
            },
            "downloads": -1,
            "filename": "pastiche-1.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "420cf8e1e7ee6fab52338910b1201714",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 18524032,
            "upload_time": "2024-06-30T23:22:48",
            "upload_time_iso_8601": "2024-06-30T23:22:48.088915Z",
            "url": "https://files.pythonhosted.org/packages/2a/88/c5282ea1d87922f6c511f38224a82d82a9f4cc186990550a299fe864c08a/pastiche-1.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-30 23:22:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dstein64",
    "github_project": "pastiche",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pastiche"
}
        
Elapsed time: 0.67436s