# -*- coding: utf-8 -*-
from setuptools import setup

package_dir = \
{'': 'src'}

packages = \
['dynamicprompts',
 'dynamicprompts.commands',
 'dynamicprompts.generators',
 'dynamicprompts.parser',
 'dynamicprompts.samplers',
 'dynamicprompts.wildcards',
 'dynamicprompts.wildcards.collection',
 'dynamicprompts.wildcards.tree']

package_data = \
{'': ['*']}

install_requires = \
['jinja2>=3.1.2,<4.0.0',
 'pyparsing>=3.0.9,<4.0.0',
 'requests>=2.28.1,<3.0.0',
 'tqdm>=4.64.1,<5.0.0']

extras_require = \
{':extra == "magicprompt"': ['transformers[torch]>=4.19.2'],
 'attentiongrabber': ['spacy>=3.4.4,<4.0.0']}

setup_kwargs = {
    'name': 'dynamicprompts',
    'version': '0.25.0',
    'description': 'Dynamic prompts templating library for Stable Diffusion',
    'long_description': '# Dynamic Prompts\n\n\n![MIT](https://img.shields.io/github/license/adieyal/dynamicprompts)\n&nbsp;-&nbsp;\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/adieyal/dynamicprompts/test.yml)\n[![Codecov](https://img.shields.io/codecov/c/github/adieyal/dynamicprompts)](https://app.codecov.io/gh/adieyal/dynamicprompts)\n&nbsp;-&nbsp;\n[![PyPI](https://img.shields.io/pypi/v/dynamicprompts)](https://pypi.org/project/dynamicprompts) ![PyPI - Downloads](https://img.shields.io/pypi/dm/dynamicprompts)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dynamicprompts)\n\nDynamic prompts is a Python library that provides developers with a **flexible and intuitive templating language** and **tools** for generating prompts for text-to-image generators like Stable Diffusion, MidJourney or Dall-e 2. It lets you create and manage **sophisticated prompt generation workflows** that seamlessly integrate with your existing text-to-image generation pipelines.\n\n<img src="images/famous_people_small.jpg">\n\nIt includes:\n* An easy-to-learn templating language that lets you create a number of unique prompts from a single template.\n* Support for wildcard files as placeholders in templates.\n* A mechanism for creating a wildcard library. Text, JSON, and YAML files are supported.\n* Exhaustive generation of all prompts from a template.\n* Variable assignment enabling re-usable prompt snippets.\n* Supports Magic Prompt which automatically spices up your prompt with modifiers\n* Provides an I\'m Feeling Lucky feature which uses the semantic search on Lexica.art to find similar prompts.\n* For systems that support attention syntax, Attention Grabber will emphasis random phrases in your prompt.\n* Jinja-powered templating for advanced prompt creation.\n\nThe dynamic prompts library powers the [Dynamic Prompts](https://github.com/adieyal/sd-dynamic-prompts) extension for Automatic1111.\n\n## Table of contents\n\n* [Dynamic Prompts](#dynamic-prompts)\n   * [Quick overview of the templating language:](#quick-overview-of-the-templating-language)\n      * [Variants](#variants)\n      * [Choosing multiple variants](#choosing-multiple-variants)\n      * [Wildcards](#wildcards)\n      * [Let\'s try a real-world prompt](#lets-try-a-real-world-prompt)\n      * [Use whitespace for readability](#use-whitespace-for-readability)\n   * [Installation](#installation)\n   * [Quick Start](#quick-start)\n      * [Combinatorial Generation](#combinatorial-generation)\n      * [Magic Prompt](#magic-prompt)\n       * [I\'m feeling lucky](#im-feeling-lucky)\n       * [Attention Generator](#attention-generator)\n    * [Jinja2 templates](#jinja2-templates)\n    * [Template syntax](#template-syntax)\n      * [Syntax customisation](#syntax-customisation)\n    * [Wildcard Collections](#wildcard-collections)\n    * [Dynamic Prompts in the wild.](#dynamic-prompts-in-the-wild)\n\n\n\n\n## Quick overview of the templating language:\n\n### Variants\n```\n{summer|autumn|winter|spring} is coming\n```\nRandomly generate one of:\n```\nsummer is coming\nautumn is coming\nwinter is coming\nspring is coming\n```\n\n### Choosing multiple variants\nThis syntax `{2$$ and $$A|B|C}` will choose two values from the list:\n```\nA and B\nA and C\nB and A\nB and C\nC and A\nC and B\n```\n\n### Wildcards\n```\n__season__ is coming\n```\nRandomly selects a value from season.txt in your wildcard directory.\n\n\n### Let\'s try a real-world prompt\nOne prompt template can generate a family of prompts:\n\n```\nFunky pop {yoda|darth vader|jabba the hutt|princess leia|chewbacca|luke skywalker} figurine, made of {wood|plastic|metal|stone}, product studio shot, on a white background, diffused lighting, centered\n```\n\n<img src="images/funkypop.jpg" style="width:50%">\n\n<br/>\n\n\nNow, how about two characters at the same time:\n\n```\nFunky pop {2$$ and $$yoda|darth vader|jabba the hutt|princess leia|chewbacca|luke skywalker} figurine, made of {wood|plastic|metal|stone}, product studio shot, on a white background, diffused lighting, centered\n```\n\n<img src="images/funkypop2.jpg" style="width:50%">\n\n\n<br/>\n\n### Use whitespace for readability\n```\n# Add comments like this\nFunky pop\n    {2$$ and $$\n  \t    yoda\n\t\t|darth vader\n\t\t|jabba the hutt\n\t\t|princess leia\n\t\t|chewbacca\n\t\t|luke skywalker\n\t}\n\tfigurine, made of\n\t{\n\t\twood\n\t\t|plastic\n\t\t|metal\n\t\t|stone\n\t}, product studio shot, on a white background, diffused lighting, centered\n```\n\n\nUse wildcards for re-usable lists:\n\n```\n# starwars.txt\nyoda\ndarth vader\njabba the hutt\nprincess leia\nchewbacca\nluke skywalker\n```\n\n```\n# material.txt\nwood\nplastic\nmetal\nstone\n```\n\n```\n# studio-shot.txt\nproduct studio shot, on a white background, diffused lighting, centered\n```\n\nNow compose your prompt like this:\n```\nFunky pop __starwars__ figurine, made of __material__, __studio-shot__\n```\n\nand easily change it to:\n```\nFunky pop __celebrities__ figurine, made of __material__, __studio-shot__\n```\n\n\nHat tip to [publicprompts](https://publicprompts.art/) for the funky pop prompt.\n\nThe complete syntax can be found [here](https://github.com/adieyal/sd-dynamic-prompts/blob/main/docs/SYNTAX.md).\n\n\n## Installation\n\n`pip install dynamicprompts`\n\nAdditional functionality (see below) can be installed with this command:\n\n`pip install "dynamicprompts[magicprompt, attentiongrabber]"`\n\n## Quick Start\n\nUse the RandomPromptGenerator to create 5 random prompts using a given template:\n\n```python\nfrom dynamicprompts.generators import RandomPromptGenerator\n\ngenerator = RandomPromptGenerator()\ngenerator.generate("I love {red|green|blue} roses", num_images=5)\n\n>> [\'I love blue roses\', \'I love red roses\', \'I love green roses\', \'I love red roses\', \'I love red roses\']\n```\n\nIf you want to use wildcards, instantiate a WildcardManager:\n\n```python\nfrom pathlib import Path\nfrom dynamicprompts.generators import RandomPromptGenerator\nfrom dynamicprompts.wildcards.wildcard_manager import WildcardManager\n\nwm = WildcardManager(Path("/path/to/wildcard/directory"))\n\ngenerator = RandomPromptGenerator(wildcard_manager=wm)\n```\n\nAssuming you have a file called colours.txt in /path/to/wildcards/directory with one colour per line, e.g.\n\n```\nred\ngreen\nblue\npurple\nyellow\n```\n\nthen\n\n```python\ngenerator.generate("I love __colours__ roses", num_prompts)\n>> [\'I love pink roses\', \'I love violet roses\', \'I love white roses\', \'I love violet roses\', \'I love blue roses\']\n```\n\n### Random seeds\n\nYou can pass a random seed in the constructor for predictable outputs\n```\ngenerator = RandomPromptGenerator(wildcard_manager=wm, seed=999)\n```\n\nA list of seeds can also be provided in the `generate` method.\n\n```\ngenerator.generate("I love __colours__ roses", num_prompts, seeds=[1,2,3])\n```\nIn this example, a seed is provided for each prompt generated. The number of seeds must equal the number of prompts, i.e. `len(seeds) == num_prompts`. If `len(seeds) == 1` then the same seed is used for every image.\n\nAs a convenience, `seeds` may also be an int value.\n\n```\ngenerator.generate("I love __colours__ roses", num_prompts=3, seeds=5)\n```\n\nis equivalent to:\n```\ngenerator.generate("I love __colours__ roses", num_prompts=3, seeds=[5, 5, 5])\n```\n\n### Combinatorial Generation\nInstead of generating random prompts from a template, combinatorial generation produces every possible prompt from the given string. For example:\n\n`I {love|hate} {New York|Chicago} in {June|July|August}`\n\nwill produce:\n> I love New York in June<br>\n> I love New York in July<br>\n> I love New York in August<br>\n> I love Chicago in June<br>\n> I love Chicago in July<br>\n> I love Chicago in August<br>\n> I hate New York in June<br>\n> I hate New York in July<br>\n> I hate New York in August<br>\n> I hate Chicago in June<br>\n> I hate Chicago in July<br>\n> I hate Chicago in August<br>\n\nIf a `__wildcard__` is provided, then a new prompt will be produced for every value in the wildcard file. For example:\n\n`My favourite season is __seasons__`\n\nwill produce:\n> My favourite season is Summer<br>\n> My favourite season is August<br>\n> My favourite season is Winter<br>\n> My favourite season is Sprint<br>\n\n#### Usage\n\n```python\nfrom dynamicprompts.generators import CombinatorialPromptGenerator\n\ngenerator = CombinatorialPromptGenerator()\ngenerator.generate("I love {red|green|blue} roses", max_prompts=5)\n\n>> [\'I love red roses\', \'I love green roses\', \'I love blue roses\']\n```\n\nNotice that only 3 prompts were generated, even though we requested 5. Since there are only three options, i.e. red, green, and blue, only 3 unique prompts can be created. `num_prompts` in this case acts as an upper bound. Combinatorial generation can very quickly produce many more prompts than you intended. `num_prompts` is a safeguard to ensure that you don\'t accidentally produced thousands or tens of thousands of prompts.\n\nConsider this template:\n\n`My favourite colours are __colours__, __colours__, and __colours__`\n\nIf colours.txt contains 10 different colours, a combinatorial enumeration of that template will create `10 * 10 * 10 = 1000` different prompts. e.g.\n\n> My favourite colours are red, green, and blue<br>\n> My favourite colours are red, green, and yellow<br>\n> My favourite colours are red, green, and purple<br>\n> My favourite colours are red, blue, and yellow<br>\n> My favourite colours are red, blue, and purple<br>\n> ...<br>\n\n\n### Magic Prompt\nUsing [Gustavosta](https://huggingface.co/Gustavosta/MagicPrompt-Stable-Diffusion)\'s MagicPrompt model, automatically generate new prompts from the input. Trained on 80,000 prompts from [Lexica.art](lexica.art), it can help give you interesting new prompts on a given subject. Here are some automatically generated variations for "dogs playing football":\n\n> dogs playing football, in the streets of a japanese town at night, with people watching in wonder, in the style of studio ghibli and makoto shinkai, highly detailed digital art, trending on artstation<br>\n> dogs playing football, in the background is a nuclear explosion. photorealism. hq. hyper. realistic. 4 k. award winning.<br>\n> dogs playing football, in the background is a nuclear explosion. photorealistic. realism. 4 k wideshot. cinematic. unreal engine. artgerm. marc simonetti. jc leyendecker<br>\n\nThis is compatible with the wildcard syntax described above.\n\n#### Usage\n\n```python\nfrom dynamicprompts.generators import RandomPromptGenerator\nfrom dynamicprompts.generators.magicprompt import MagicPromptGenerator\n\ngenerator = RandomPromptGenerator()\nmagic_generator = MagicPromptGenerator(generator, device=0) # device = 0 for CUDA or -1 for CPU\n\nnum_prompts = 5\ngenerator.generate("I love {red|green|blue} roses", num_prompts)\n\n>> [\'I love red roses trending on artstation #vividart #pixiv\', \'I love red roses trending on artstation artwork\', \'I love blue roses breakfast club, cute, intricate, highly detailed, digital painting, artstation, concept art, smooth, sharp focus, illustration, unreal engine 5, 8 k, art by artgerm and greg rutkowski and alphonse mucha\', \'I love green roses I love green flowers, smile, Tristan Eaton, victo ngai, artgerm, RHADS, ross draws\', \'I love red roses smile, Tristan Eaton, victo ngai, artgerm, RHADS, ross draws\']\n\n```\n\nThe first time you use it, the model is downloaded. It is approximately 500mb and so will take some time depending on how fast your connection is. It will also take a few seconds on first activation as the model is loaded into memory. Note, if you\'re low in VRAM, you might get a Cuda error. My GPU uses less than 8GB by YMMV.\n\nMagic Prompt is not available by default, you need to install it as follows:\n\n`pip install "dynamicprompts[magicprompt]"`\n\n#### Other models\nThere a few alternatives to Gustavosta\'s model available. You can try:\n\n```\nmagic_generator = MagicPromptGenerator(generator, "AUTOMATIC/promptgen-lexart")\nmagic_generator = MagicPromptGenerator(generator, "AUTOMATIC/promptgen-majinai-safe")\nmagic_generator = MagicPromptGenerator(generator, "AUTOMATIC/promptgen-majinai-unsafe")\n```\n\nYou can find a longer list [here](https://github.com/adieyal/sd-dynamic-prompts/blob/main/config/magicprompt_models.txt)\nNote that each model requires a download of large model files.\n\n### I\'m feeling lucky\nUse the [lexica.art](https://lexica.art) API to create random prompts. Useful if you\'re looking for inspiration, or are simply too lazy to think of your own prompts. When this option is selected, the template is used as a search string. For example, prompt "Mech warrior" might return:\n\n> A large robot stone statue in the middle of a forest by Greg Rutkowski, Sung Choi, Mitchell Mohrhauser, Maciej Kuciara, Johnson Ting, Maxim Verehin, Peter Konig, final fantasy , 8k photorealistic, cinematic lighting, HD, high details, atmospheric,\n\n> a beautiful portrait painting of a ( ( ( cyberpunk ) ) ) armor by simon stalenhag and pascal blanche and alphonse mucha and nekro. in style of digital art. colorful comic, film noirs, symmetry, brush stroke, vibrating colors, hyper detailed. octane render. trending on artstation\n\n> symmetry!! portrait of a robot astronaut, floral! horizon zero dawn machine, intricate, elegant, highly detailed, digital painting, artstation, concept art, smooth, sharp focus, illustration, art by artgerm and greg rutkowski and alphonse mucha, 8 k\n\n<img src="images/feeling-lucky.png">\n\n#### Usage\n\n```python\nfrom dynamicprompts.generators import RandomPromptGenerator\nfrom dynamicprompts.generators.feelinglucky import FeelingLuckyGenerator\n\ngenerator = RandomPromptGenerator()\nlucky_generator = FeelingLuckyGenerator(generator)\n\nnum_prompts = 5\nlucky_generator.generate("I love {red|green|blue} roses", num_prompts)\n\n>> [\'“ guns and roses ” \', \'🌹🥀🏜. 🌌🌠⭐. 💯. \', \'tattoo design, stencil, beautiful japanese girls face, roses and ivy surrounding by artgerm, artgerm, cat girl, anime \', \'rose made of glass dramatic lighting\', \'a wireframe render of a red rose\']\n\n```\n\n### Attention Generator\nIf you are using [Automatic1111](https://github.com/AUTOMATIC1111/stable-diffusion-webui/) or a similar frontend to Stable Diffusion that uses attention syntax, e.g. `(some text:1.4)`, AttentionGenerator will randomly add attention to various phrases in your prompt. This injects a small amount of randomness into your prompt.\n\n#### Usage\n\n```python\nfrom dynamicprompts.generators import RandomPromptGenerator\nfrom dynamicprompts.generators.attentiongenerator import AttentionGenerator\n\ngenerator = RandomPromptGenerator()\nattention_generator = AttentionGenerator(generator)\n\nprompt = "a portrait an anthropomorphic panda mage casting a spell, wearing mage robes, landscape in background, cute, dnd character art portrait, by jason felix and peter mohrbacher, cinematic lighting"\nattention_generator.generate(prompt, num_prompts=1)\n\n>> [\'a portrait an anthropomorphic panda mage casting a spell, wearing (mage robes:0.77), landscape in background, cute, dnd character art portrait, by jason felix and peter mohrbacher, cinematic lighting\']\n\n```\n\n<img src="images/emphasis.png">\n\nNote, AttentionGenerator is not installed by default as it needs additional libraries to run. Use this command to install it:\n\n`pip install "dynamicprompts[attentiongrabber]"`\n\nOne your first use it, a model will automatically be downloaded.\n\n## Jinja2 templates\nIf the standard template language is not sufficient for your needs, you can try the Jinja2 generator. Jinja2 templates have familiar programming constructs such as looping, conditionals, variables, etc. Youcan find a guide on using Jinja2 templates with Dynamic Prompts, [here](https://github.com/adieyal/sd-dynamic-prompts/blob/main/jinja2.md). Here is the minimal code you need to instantiate Jinja2 generator.\n\n```python\nfrom dynamicprompts.generators import JinjaGenerator\n\ngenerator = JinjaGenerator()\ngenerator.generate("I love {red|green|blue} roses", num_images=5)\n\ntemplate = """\n{% for colour in [\'red\', \'blue\', \'green\'] %}\n    {% prompt %}I love {{ colour }} roses{% endprompt %}\n{% endfor %}\n"""\n\ngenerator.generate(template)\n\n>> [\'I love red roses\', \'I love blue roses\', \'I love green roses\']\n```\n\n## Template syntax\n\nYou can find the complete syntax guide [here](https://github.com/adieyal/sd-dynamic-prompts/blob/main/docs/SYNTAX.md)\n\n### Syntax customisation\nTo address potential syntax clashes with other tools it is possible to change various tokens. Instead of `{red|green|blue}` you can configure the library to use the `<` `>` pair instead, e.g. `<red|green|blue>`. You can also change the `__` used in wildcards. So instead of `__colours__`, you can configure wildcards to use `**`, e.g. `**colours**`\n```python\n\nfrom dynamicprompts.generators import RandomPromptGenerator\nfrom dynamicprompts.parser.config import ParserConfig\n\nparser_config = ParserConfig(variant_start="<", variant_end=">", wildcard_wrap="**")\ngenerator = RandomPromptGenerator(parser_config=parser_config)\n\n```\n## Wildcard Collections\nYou can bootstrap your wildcard library by using our [pre-existing collections](https://github.com/adieyal/sd-dynamic-prompts/tree/main/collections). You\'ll find just under 80,000 wildcards divided into 1900 files. Feel free to pick and choose or take them in their entirety.\n\n## Dynamic Prompts in the wild.\nDynamic Prompts has been used in:\n1. [SD Dynamic Prompts](https://github.com/adieyal/sd-dynamic-prompts/edit/main/README.md) Auto1111 extension\n2. Deforum 0.7 [colab](https://colab.research.google.com/drive/1qtYHUwFl9ocLyzDRL1_MlpQluV32ndoT?usp=sharing)\n',
    'author': 'Adi Eyal',
    'author_email': 'adi@clearforest.io',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'https://github.com/adieyal/dynamicprompts',
    'package_dir': package_dir,
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'extras_require': extras_require,
    'python_requires': '>=3.7,<4.0',
}


setup(**setup_kwargs)
