jgillix commited on
Commit
9c1d88f
·
verified ·
1 Parent(s): 1e4bcd5

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ lazy-pony-prompter/images/ef-showcase.jpg filter=lfs diff=lfs merge=lfs -text
37
+ lazy-pony-prompter/images/lulu.png filter=lfs diff=lfs merge=lfs -text
38
+ lazy-pony-prompter/images/pdv6xl-showcase.webp filter=lfs diff=lfs merge=lfs -text
lazy-pony-prompter/.github/workflows/publish.yml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Publish to Comfy registry
2
+ on:
3
+ workflow_dispatch:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - "pyproject.toml"
9
+
10
+ permissions:
11
+ issues: write
12
+
13
+ jobs:
14
+ publish-node:
15
+ name: Publish Custom Node to registry
16
+ runs-on: ubuntu-latest
17
+ if: ${{ github.repository_owner == 'Siberpone' }}
18
+ steps:
19
+ - name: Check out code
20
+ uses: actions/checkout@v4
21
+ - name: Publish Custom Node
22
+ uses: Comfy-Org/publish-node-action@v1
23
+ with:
24
+ ## Add your own personal access token to your Github Repository secrets and reference it here.
25
+ personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
lazy-pony-prompter/.gitignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ .nvimrc
2
+ modules
3
+ api_key
4
+ __pycache__
5
+ my_*.json
6
+ auth/*
7
+ cache*.json
8
+ *.dat
9
+ venv
lazy-pony-prompter/CHANGELOG.md ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### 2024-11-04
2
+
3
+ * Added support for [NoobAI v1.0](https://civitai.com/models/833294/noobai-xl-nai-xl) model
4
+
5
+ ### 2024-10-29
6
+
7
+ **1.1.0** release
8
+ * Added [Danbooru](https://danbooru.donmai.us) as tag source
9
+ * Added support for [SeaArt Furry XL V1](https://civitai.com/models/391781/seaart-furry-xl-10) model
10
+ * Import/Export functions for prompts and filters
11
+ * Prompt info panel is now more compact and readable
12
+ * Minor ComfyUI nodes improvements (notably: updater dummy is no longer needed)
13
+ * Tons of refactoring and behind-the-scene improvements
14
+
15
+ ### 2024-07-03
16
+
17
+ **1.0.0 release**
18
+ * Overhauled UI
19
+ * New tag filtering system with filter management and pattern substitutions
20
+ * Filter prompts by content rating (Safe/Questionable/Explicit)
21
+ * Increased maximum prompts limit to 1500
22
+ * Improved status reporting and logging
23
+
24
+ ### 2024-01-17
25
+
26
+ * Added custom prompt templates support
27
+ * Added some basic settings ui
28
+ * Added automatic prompt formatter selection
29
+ * Sources can now fetch tags from image URL
30
+ * Minor UI improvements
31
+ * Improved error handling
32
+
33
+ ### 2023-10-23
34
+
35
+ * Added experimental ComfyUI support
36
+ * Prompts cache is now stored in binary which should reduce size and load time
37
+ * Lots of code refactoring and reorganising
38
+
39
+ ### 2023-10-19
40
+
41
+ * Removed legacy cache format updater. Hopefully everyone updated at this point :)
42
+
43
+ ### 2023-10-13
44
+
45
+ * Small UI fixes and improvements
46
+ * e621 formatters improvements
47
+ * Improved formatting for EasyFluff
48
+ * Added PDV5 formatter for e621
49
+
50
+ ### 2023-10-02
51
+
52
+ * Added simple globbing support to tag filter
53
+
54
+ ### 2023-10-01
55
+
56
+ * Added different tag sources and prompt formats support
57
+ * Added support for e621.net as tag source
58
+ * Added basic support for EasyFluff model
59
+ * Added support for standard [A1111 styles feature](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#styles)
60
+ * Removed Prefix and Suffix textboxes since A1111 styles can be used for the same purpose
61
+
62
+ ### 2023-08-04
63
+
64
+ * Renamed "Saving & Loading" to "Prompts Manager"
65
+ * Refined Prompts Manager UI
66
+ * Added confirmation dialog for deleting/overwriting prompt collections
67
+ * Added option to autofill Suffix, Prefix and Tag Filter when loading prompts
68
+
69
+ ### 2023-08-03
70
+
71
+ * Refined UI layout
72
+
73
+ ### 2023-08-02
74
+
75
+ * Renamed append/prepend to prefix/suffix respectively. **NOTE :** this affects `a1111_ui.json` config options. Rename manually if you created a custom `my_a1111_ui.json` config
76
+ * Prefix, Suffix and User Tag Filters are now applied dynamically on each generation
77
+ * Previously saved prompts can now be deleted from cache via `Delete` button
78
+ * Added extra metadata to saved prompts (query, filter and sorting type). Could be useful if you want to rerun a query
79
+ * Parentheses are now only escaped in the core prompt (you can now properly use attention syntax in prefix and suffix)
80
+
81
+ ### 2023-07-26
82
+
83
+ * Refined and expanded tag filtering
84
+
85
+ ### 2023-07-22
86
+
87
+ * Refined config system
88
+ * Added user-defined configs
89
+
90
+ ### 2023-07-21
91
+
92
+ * Added custom Prepending/Appending text to prompts
93
+ * Added extra tag filter
94
+ * Refined UI layout
95
+
96
+ ### 2023-07-20
97
+
98
+ * Hid save/load into accordion
99
+ * Added UI config
lazy-pony-prompter/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Siberpone
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
lazy-pony-prompter/README.md ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Lazy Pony Prompter
2
+
3
+ A booru API powered prompt generator for [AUTOMATIC1111's Stable Diffusion Web UI](https://github.com/AUTOMATIC1111/stable-diffusion-webui) / [Forge](https://github.com/lllyasviel/stable-diffusion-webui-forge) and [ComfyUI](https://github.com/comfyanonymous/ComfyUI) with flexible tag filtering system and customizable prompt templates.
4
+
5
+ Supported boorus/websites:
6
+ * [Derpibooru](https://derpibooru.org)
7
+ * [E621](https://e621.net)
8
+ * [Danbooru](https://danbooru.donmai.us)
9
+ * More coming soon™ (or not ;))
10
+
11
+ > [!IMPORTANT]
12
+ >
13
+ > **1.1.0 release highlights:**
14
+ > * Added [Danbooru](https://danbooru.donmai.us) as tag source
15
+ > * Added support for [SeaArt Furry XL V1](https://civitai.com/models/391781/seaart-furry-xl-10) model
16
+ > * Import/Export functions for prompts and filters
17
+ > * Prompt info panel is now more compact and readable
18
+ > * Minor ComfyUI nodes improvements (notably: updater dummy is no longer needed)
19
+ > * Tons of refactoring and behind-the-scene improvements
20
+
21
+ Derpibooru + [Pony Diffusion V6 XL](https://civitai.com/models/257749?modelVersionId=290640) + [PD Styles Collection](https://github.com/Siberpone/pd-styles) (which I highly recommend you also check out) samples:
22
+
23
+ ![PDV6 XL Showcase](images/pdv6xl-showcase.webp)
24
+
25
+ E621 + [EasyFluff](https://civitai.com/models/129996/easyfluff) samples:
26
+
27
+ ![EasyFluff Showcase](images/ef-showcase.jpg)
28
+
29
+ *\* images generated with EasyFluff V11.2 from query `my_little_pony solo -anthro -meme order:score -animated -text rating:safe -multiple_images`*
30
+
31
+ # Installation
32
+
33
+ ### ❗Requirements
34
+ * [AUTOMATIC1111's Stable Diffusion Web UI](https://github.com/AUTOMATIC1111/stable-diffusion-webui) / [Forge](https://github.com/lllyasviel/stable-diffusion-webui-forge) or [ComfyUI](https://github.com/comfyanonymous/ComfyUI);
35
+ * One of recommended models (these are the "officially" supported models, but LPP should work well for other tag-based models as long as their "native" booru is used as tag source):
36
+ * [Pony Diffusion V6 XL](https://civitai.com/models/257749?modelVersionId=290640);
37
+ * [Pony Diffusion V5(.5)](https://civitai.com/models/95367/pony-diffusion-v5);
38
+ * [NoobAI v1.0](https://civitai.com/models/833294/noobai-xl-nai-xl)
39
+ * [EasyFluff](https://civitai.com/models/129996/easyfluff);
40
+ * [SeaArt Furry XL V1](https://civitai.com/models/391781/seaart-furry-xl-10);
41
+ * [AutismMix](https://civitai.com/models/288584);
42
+ * Active internet connection for communication with boorus;
43
+ * *(optional)* [Derpibooru](https://derpibooru.org) account for extra functionality.
44
+
45
+ ### 🖵 A1111 WebUI
46
+
47
+ Open the "Extensions" tab and then the "Install from URL" tab. Paste this repository link into the "URL" field:
48
+ ```
49
+ https://github.com/Siberpone/lazy-pony-prompter
50
+ ```
51
+
52
+ Click "Install" and after it's finished installing, restart the server. You should now see the "Lazy Pony Prompter" accordion on txt2img tab.
53
+
54
+ ### 🛏 ComfyUI
55
+
56
+ You can install LPP via [ComfyUI Manager](https://github.com/ltdrdata/ComfyUI-Manager) or manually by cloning this repository to `.../ComfyUI/custom_nodes`
57
+
58
+ ### 🙌 Manual
59
+ Clone this repository with:
60
+ ```
61
+ git clone https://github.com/Siberpone/lazy-pony-prompter
62
+ ```
63
+ Or click the "code" button in the top right, then click "Download ZIP". Unzip the downloaded archive anywhere on your file system. After that move the newly created repository folder to `.../stable-diffusion-webui/extentions` for A1111 WebUI or to `.../ComfyUI/custom_nodes` for ComfyUI.
64
+
65
+ # Usage
66
+ LPP operates by making a prompt list from a search query to one of the supported booru sites and then generating images using that list. Basically, it fetches tag data from a specified number of images in the query and converts it into "sensible" model-specific prompts (useless meta tags are pruned; "important" tags, like character name, are pushed closer to the beginning of the prompt, and so on...) and then randomly picks them to generate images.
67
+
68
+ ## A1111 WebUI
69
+
70
+ ### Prompts Manager
71
+ Now, lets take a closer look at the interface:
72
+
73
+ ![LPP interface](images/prompts_manager.jpg)
74
+
75
+ Firstly, note the title bar of the extension: `🗹`checkbox on the left side is the main toggle for LPP - it controls whether the extension is active or not; and on the right side you'll find the status indicator that shows some basic information about the currently loaded prompts collection.
76
+
77
+ Next, we move down to the "Prompts Manager" tab where you'll find the main controls for LPP:
78
+ * **Prompts Collection Name** is used for selecting existing prompt collections or for saving currently loaded ones. Note the four buttons to the right:
79
+ * 📋 toggles the selected collection extra info display underneath the `Prompts Collection Name`;
80
+ * 💾 saves the currently loaded collection under the name provided in the `Prompts Collection Name`;
81
+ * 📤 loads the collection selected in the `Prompts Collection Name`;
82
+ * ❌ deletes the collection selected in the `Prompts Collection Name`.
83
+ * **Prompts Format** is used to select model-specific prompt formatting. Normally, you don't need to worry about it and can just keep in on `Auto` at all times.
84
+ * **Autoload Filters** indicates whether the `Filters` input should automatically be populated when loading a prompt collection (whenever you save a prompt collection, the information about currently active filters is written along with it).
85
+
86
+ #### 💬 Get prompts from Booru
87
+
88
+ > [!NOTE]
89
+ >
90
+ > Look of this panel may vary slightly, depending on the selected tag source.
91
+
92
+ ![Query Panel](images/derpi_query.jpg)
93
+
94
+ On this panel you can pull tag data from selected booru site by typing in or pasting your query into the query textbox (the syntax is exactly the same as on the actual website). Use the `Tag Source` toggle at the top to select the desired booru. If you just want tags from a particular image, you can paste its URL into the query textbox or simply type in its ID number on the respective booru. You can also set a number of additional options:
95
+
96
+ * **Number of prompts to load** - will attempt to fetch tag data from this number of images in the query;
97
+ * **Derpibooru specific:**
98
+ * *Derpibooru Filter* - will apply this [Derpibooru filter](https://derpibooru.org/filters) to the query. Only system filters are available by default. If you want to use your personal filters, you must provide an [API key](#-api-key);
99
+ * *Sort by* - type of sorting to apply to the query. Wilson Score is the default.
100
+ * **E621 and Danbooru specific:**
101
+ * *Rating* - will append selected rating tag to the query.
102
+ * *Sort by* - will append selected sorting type tag to the query.
103
+
104
+ Once you're happy with the settings, it's finally time to click the `Send` button. This will prompt LPP to send the search query to the site and generate prompts from the returned tag data. If all goes well, you'll see the "Successfully fetched tags from *\<site\>*" message pop up. This means that LPP is now ready to poni and all you have to do is tick the `☑` checkbox at the very top and hit the `Generate` button.
105
+
106
+ #### 🏷 Filtering System
107
+
108
+ On the right side of the "Prompts Manager" panel you'll find the tags and prompts filtering controls that will help you customize and refine the composition of LPP-generated prompts. The filtering system allows you to filter out unwanted tags or substitute them with custom text. You can specify patterns that you wish to filter out or substitute in two ways:
109
+
110
+ 1. by creating a filter in the [Filter Editor](#filter-editor) and selecting it in the `Filters` input;
111
+ 2. by typing comma-separated patterns into the `Quick Filter` input.
112
+
113
+ Note that pattern syntax supports simple [globbing](https://en.wikipedia.org/wiki/Glob_(programming)) and optional substitutions:
114
+
115
+ * `*` matches anything;
116
+ * `?` matches any single character;
117
+ * `[xyz]` matches specified characters;
118
+ * `[A-Z]` matches a range of characters;
119
+ * `||` is used to provide a substitution for a pattern. For example, `horn||wings` will substitute "horn" with "wings".
120
+
121
+ > [!TIP]
122
+ > Use `Quick Filter` only for on-the-spot one-shot filtering needs. If you find yourself typing in the same things into it over and over, consider creating a persistent filter in the Filter Editor - it'll save you a lot of time! Over time you'll build up your "filter library" and if you put a bit of effort into maintaining and expanding it, soon you'll be able to generate prompts with great flexibility and variety.
123
+
124
+ And last but not least for the filtering system is the `Rating Filter`. It allows LPP to only sample prompts with selected content ratings from currently loaded prompts. The ratings are determined from the meta data returned by the boorus.
125
+
126
+ > [!WARNING]
127
+ > If the currently loaded collection doesn't have any prompts with selected ratings, the generation will fail. Use the 📋 extra info panel to see what kind of ratings any given prompt collection contains.
128
+
129
+ ### Filter Editor
130
+
131
+ ![Filter Editor](images/filters_editor.jpg)
132
+
133
+ This tab is used to manage and edit your persistent filters that can then be applied to LPP-generated prompts via selecting them in the `Filters` input on the "Prompts Manager" tab. On the left you'll find the `Create or delete a filter` input that is used to manage your filters: type in a new name for a filter and click the ✨ to create a new filter or select an existing filter form a drop-down list and click the ❌ to delete it.
134
+
135
+ Below, you'll find the file drop area for importing and exporting your locally saved prompts and filters. You can export them by clicking the "Export Prompts and Filters" button and then downloading the json file from file drop area. You can import prompts and filters data by dragging the previously exported json file onto the file drop area. If there is a naming conflict between already existing items and items that are being imported, the existing items take precedence.
136
+
137
+ Next you'll find a number of identical filter editors that are used to edit the filters. You can adjust the number of editors in the LPP's section of A1111 settings. To load up a filter, simply choose it from a drop-down in any of the editors (hit the 🗘 button if the desired filter doesn't appear on the list) and start editing the filter patterns. The syntax is exactly the same as described in the [Filtering System](#-filtering-system), but patterns are separated with new lines. Click the 💾 button to save changes to the filter.
138
+
139
+ > [!TIP]
140
+ > Changes to the filters are applied "on the fly". So, if you have a filter activated in the "Prompts Manager" and you add changes to it in the editor, the changes will apply on next generation
141
+
142
+ #### Examples
143
+
144
+ **Rule 63**
145
+ ```
146
+ mare||stallion
147
+ female||male
148
+ male||female
149
+ stallion||mare
150
+ ```
151
+
152
+ **Style Altering Tags**
153
+ ```
154
+ anime
155
+ grayscale
156
+ monochrome
157
+ black and white
158
+ show accurate*
159
+ vector
160
+ sketch
161
+ traditional art
162
+ * drawing
163
+ * painting
164
+ pixelated
165
+ pixel art
166
+ 3d
167
+ source filmmaker
168
+ etc...
169
+ ```
170
+
171
+ **Text**
172
+ ```
173
+ holding sign
174
+ dialogue
175
+ speech bubble
176
+ ```
177
+
178
+
179
+ ### ✨ Prompts Styling
180
+
181
+ > [!TIP]
182
+ > Check out my [PD Styles Collection](https://github.com/Siberpone/pd-styles). It works great in conjunction with LPP!
183
+
184
+ You can customize LPP-generated prompts by placing special tokens into the standard A1111 prompt textbox. When LPP is enabled, it basically serves as a template. LPP groups tags into certain categories which can then be referenced through tokens. LPP currently recognizes 7 tokens: `{character}`, `{species}`, `{rating}`, `{artist}`, `{general}`, `{meta}` and `{prompt}`. Lets take a look at some examples:
185
+
186
+ * *V6 XL prompt with special quality tags*: `score_9, score_8_up, score_7_up, score_6_up, score_5_up, score_4_up, {prompt}`
187
+ * *"fancy" V6 XL prompt:* `score_9, score_8_up, score_7_up, score_6_up, score_5_up, score_4_up, {rating}, a beautiful digital drawing of a {character} in the form of {species}, {general}`
188
+ * *EasyFluff*: `{character}, {species}, {artist}, {general}, {meta}, masterpiece, best quality, good quality`
189
+
190
+ When no template is provided, a sensible default one will be used. If user template doesn't contain any special tokens, its content will simply be appended to the default template. Note that `{prompt}` token is special and it should not be used in conjunction with other tokens. If it is present in the user template, the default template will be pasted in its place, and all other tokens will be pruned.
191
+
192
+ > [!NOTE]
193
+ > Don't worry about the cases when some tokens may end up empty (a poorly tagged image, for example). LPP will properly clean up multiple/leading/trailing spaces and commas.
194
+
195
+ LPP also fully supports [A1111 styles feature](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#styles). Any styles you select in the style box will be correctly applied to LPP-generated prompts.
196
+
197
+ #### Pony Diffusion V6 XL Recommendations
198
+
199
+ Both e621 and Derpibooru work fine as tag sources, but Derpi is preferred. As usual with Pony Diffusion models, preface your prompts with special quality tags: `score_9, score_8_up, score_7_up, score_6_up, score_5_up, score_4_up` (yes, it has to be exactly like this due to mistake in training process). `blurry` in the negative is highly recommended to avoid random "depth of field" spots.
200
+
201
+ #### EasyFluff Recommendations
202
+
203
+ EF works best with e621 as tags source, but will produce good results from Derpibooru tags as well.
204
+
205
+ #### Pony Diffusion V5 Recommendations
206
+
207
+ Derpibooru as tags source is highly recommended, however, e621 is also supported. It is also highly beneficial to, at least, include special model-specific `score_9` tag somewhere in the prompt. "Standard" negative prompt also improves generations quality: `lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, jpeg artifacts, signature, watermark, username, blurry`.
208
+
209
+ ## ComfyUI
210
+
211
+ > [!NOTE]
212
+ >
213
+ > These are somewhat experimental and may have some bugs. Also, due to some ComfyUI interface limitations some UX compromises had to be made ;)
214
+
215
+ LPP nodes are available under `LPP` group. The interface and functionality are kept as closely as possible to A1111 extension. Drag this Princess Luna picture to your ComfyUI to load a demo with notes on every available node and a very basic workflow example:
216
+
217
+ ![Cute Lulu](images/lulu.png)
218
+
219
+ ## 🔑 API Key
220
+
221
+ To further personalize your queries you can provide LPP with your personal Derpibooru API key (requires Derpibooru account). This will enable LPP to use your personal [Derpibooru filters](https://derpibooru.org/filters) and access images from your watch list by including `my:watched` into your queries. To provide an API key, go to `Settings -> Lazy Pony Prompter` and paste the key into the respective textbox. Then click "Apply settings" and reload UI. You can obtain an API key from your Derpibooru account info page (hover over your user icon -> Account).
222
+
223
+ # Pro Tips & Fun Facts
224
+ * 🐞 Found a bug? Create an [issue](https://github.com/Siberpone/lazy-pony-prompter/issues).
225
+ * 💬 Want to request a feature or have suggestions on how to improve the extension? Open up a [discussion](https://github.com/Siberpone/lazy-pony-prompter/discussions).
226
+ * You can see the latest additions to LPP in the [Changelog](CHANGELOG.md).
227
+ * You can use A1111's "Defaults" feature to customize LPP UI default values (Settings -> Defaults).
228
+ * LPP works best with images with high upvote/score count as those tend to be the most fully and properly tagged.
229
+ * LPP overrides webui prompts processing completely and, thus, not compatible with dynamic prompting extensions (you don't have to uninstall them or anything, just don't run them simultaneously with LPP).
230
+ * LPP is very light on traffic since it uses the website's API and only pulls necessary text data and not the actual webpages or images.
231
+ * Use Export prompts and filters feature to create backups of your locally stored data or share it with friends!
232
+ * Useful links:
233
+ * [CivitAI](https://civitai.com/) - *the* AI art website. And [small magical horses themed art](https://civitai.com/user/Siberpone/posts) by yours truly on the aforementioned website ;)
234
+ * [purplesmart.ai](https://purplesmart.ai) aka PSAI - Pony Diffusion creators website with gallery and prompt examples.
235
+ * [PSAI Discord server](http://discord.gg/94KqBcE) - poni AI discussion, help, tech support and free V6 bot.
236
+ * [EasyFluff](https://civitai.com/models/129996/easyfluff)
237
+ * 🐎 Please, poni responsibly 🐴🦄🪶.
lazy-pony-prompter/__init__.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .lpp.ui.comfy import ComfyDerpibooru, LPPLoaderDerpibooru
2
+ from .lpp.ui.comfy import ComfyE621, LPPLoaderE621
3
+ from .lpp.ui.comfy import ComfyDanbooru, LPPLoaderDanbooru
4
+ from .lpp.ui.comfy import LPPSaver, LPPDeleter
5
+
6
+
7
+ NODE_CLASS_MAPPINGS = {
8
+ "LPP_Derpibooru": ComfyDerpibooru,
9
+ "LPP_E621": ComfyE621,
10
+ "LPP_Danbooru": ComfyDanbooru,
11
+ "LPP_Saver": LPPSaver,
12
+ "LPP_Loader_Derpibooru": LPPLoaderDerpibooru,
13
+ "LPP_Loader_E621": LPPLoaderE621,
14
+ "LPP_Loader_Danbooru": LPPLoaderDanbooru,
15
+ "LPP_Deleter": LPPDeleter
16
+ }
17
+
18
+ NODE_DISPLAY_NAME_MAPPINGS = {
19
+ "LPP_Derpibooru": "Derpibooru",
20
+ "LPP_E621": "E621",
21
+ "LPP_Danbooru": "Danbooru",
22
+ "LPP_Saver": "Tag Data Saver",
23
+ "LPP_Loader_Derpibooru": "Tag Data Loader (Derpibooru)",
24
+ "LPP_Loader_E621": "Tag Data Loader (E621)",
25
+ "LPP_Loader_Danbooru": "Tag Data Loader (Danbooru)",
26
+ "LPP_Deleter": "Tag Data Deleter"
27
+ }
28
+
29
+ __all__ = [NODE_CLASS_MAPPINGS]
lazy-pony-prompter/config/danbooru.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "ratings": {
3
+ "lookup": {
4
+ "None": "",
5
+ "General": "rating:g",
6
+ "Sensitive": "rating:s",
7
+ "Questionable": "rating:q",
8
+ "Explicit": "rating:e"
9
+ },
10
+ "pdv5": {
11
+ "g": "rating_safe",
12
+ "s": "rating_questionable",
13
+ "q": "rating_questionable",
14
+ "e": "rating_explicit"
15
+ },
16
+ "lpp": {
17
+ "g": "Safe",
18
+ "s": "Questionable",
19
+ "q": "Questionable",
20
+ "e": "Explicit"
21
+ }
22
+ },
23
+ "sort_params": {
24
+ "None": "",
25
+ "Chronological": "order:id_desc",
26
+ "Score": "order:score",
27
+ "Faves": "order:favcount",
28
+ "Comments": "oreder:comment",
29
+ "Rank": "order:rank"
30
+ },
31
+ "filtered_tags": {
32
+ "general": [
33
+
34
+ ],
35
+ "character": [
36
+
37
+ ],
38
+ "copyright": [
39
+
40
+ ],
41
+ "artist": [
42
+
43
+ ],
44
+ "meta": [
45
+
46
+ ]
47
+ }
48
+ }
lazy-pony-prompter/config/derpibooru.json ADDED
@@ -0,0 +1,1377 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "ratings": {
3
+ "pdv5": {
4
+ "safe": "rating_safe",
5
+ "suggestive": "rating_questionable",
6
+ "questionable": "rating_questionable",
7
+ "explicit": "rating_explicit",
8
+ "semi-grimdark": "rating_questionable, semi-grimdark",
9
+ "grimdark": "rating_explicit, grimdark",
10
+ "grotesque": "rating_explicit, grotesque"
11
+ },
12
+ "lpp": {
13
+ "safe": "Safe",
14
+ "suggestive": "Questionable",
15
+ "questionable": "Questionable",
16
+ "explicit": "Explicit",
17
+ "semi-grimdark": "Questionable",
18
+ "grimdark": "Explicit",
19
+ "grotesque": "Explicit"
20
+ }
21
+ },
22
+ "filter_ids": {
23
+ "Default (System)": 100073,
24
+ "Everything (System)": 56027
25
+ },
26
+ "sort_params": {
27
+ "Wilson Score": "wilson_score",
28
+ "Score": "score",
29
+ "Upvotes": "upvotes",
30
+ "Fave Count": "faves",
31
+ "Upload Date": "first_seen_at",
32
+ "Tag Count": "tag_count"
33
+ },
34
+ "character_tags": [
35
+ "raripunk",
36
+ "s5 starlight",
37
+ "twilight sparkle",
38
+ "rainbow dash",
39
+ "fluttershy",
40
+ "pinkie pie",
41
+ "rarity",
42
+ "applejack",
43
+ "princess luna",
44
+ "princess celestia",
45
+ "spike",
46
+ "trixie",
47
+ "sunset shimmer",
48
+ "apple bloom",
49
+ "starlight glimmer",
50
+ "scootaloo",
51
+ "derpy hooves",
52
+ "sweetie belle",
53
+ "queen chrysalis",
54
+ "princess cadance",
55
+ "discord",
56
+ "lyra heartstrings",
57
+ "vinyl scratch",
58
+ "dj pon-3",
59
+ "big macintosh",
60
+ "sci-twi",
61
+ "octavia melody",
62
+ "shining armor",
63
+ "nightmare moon",
64
+ "tempest shadow",
65
+ "sweetie drops",
66
+ "bon bon",
67
+ "izzy moonbow",
68
+ "king sombra",
69
+ "sunny starscout",
70
+ "sonata dusk",
71
+ "soarin'",
72
+ "adagio dazzle",
73
+ "pipp petals",
74
+ "spitfire",
75
+ "flash sentry",
76
+ "maud pie",
77
+ "zipp storm",
78
+ "doctor whooves",
79
+ "time turner",
80
+ "aria blaze",
81
+ "diamond tiara",
82
+ "angel bunny",
83
+ "cheerilee",
84
+ "gilda",
85
+ "zecora",
86
+ "smolder",
87
+ "hitch trailblazer",
88
+ "fizzlepop berrytwist",
89
+ "cozy glow",
90
+ "princess flurry heart",
91
+ "gallus",
92
+ "sunburst",
93
+ "princess ember",
94
+ "marble pie",
95
+ "silverstream",
96
+ "berry punch",
97
+ "berryshine",
98
+ "silver spoon",
99
+ "daring do",
100
+ "coco pommel",
101
+ "braeburn",
102
+ "sandbar",
103
+ "minuette",
104
+ "ocellus",
105
+ "yona",
106
+ "babs seed",
107
+ "glitter drops",
108
+ "lord tirek",
109
+ "carrot top",
110
+ "golden harvest",
111
+ "granny smith",
112
+ "limestone pie",
113
+ "roseluck",
114
+ "moondancer",
115
+ "snails",
116
+ "spring rain",
117
+ "gummy",
118
+ "thorax",
119
+ "twilight velvet",
120
+ "lightning dust",
121
+ "autumn blaze",
122
+ "cup cake",
123
+ "thunderlane",
124
+ "button mash",
125
+ "dinky hooves",
126
+ "cheese sandwich",
127
+ "snips",
128
+ "prince blueblood",
129
+ "rumble",
130
+ "fleur-de-lis",
131
+ "principal celestia",
132
+ "cloudchaser",
133
+ "nurse redheart",
134
+ "sour sweet",
135
+ "bulk biceps",
136
+ "sugarcoat",
137
+ "daybreaker",
138
+ "mayor mare",
139
+ "sugar belle",
140
+ "pear butter",
141
+ "lemon zest",
142
+ "misty brightdawn",
143
+ "coloratura",
144
+ "tree hugger",
145
+ "nightmare rarity",
146
+ "flitter",
147
+ "lotus blossom",
148
+ "spike the regular dog",
149
+ "vice principal luna",
150
+ "pipsqueak",
151
+ "twist",
152
+ "surprise",
153
+ "sunny flare",
154
+ "tank",
155
+ "aloe",
156
+ "gabby",
157
+ "photo finish",
158
+ "amethyst star",
159
+ "pound cake",
160
+ "daisy",
161
+ "flower wishes",
162
+ "zephyr breeze",
163
+ "indigo zap",
164
+ "caramel",
165
+ "sparkler",
166
+ "night light",
167
+ "wallflower blush",
168
+ "winona",
169
+ "ms. harshwhinny",
170
+ "sunshower raindrops",
171
+ "pumpkin cake",
172
+ "twinkleshine",
173
+ "windy whistles",
174
+ "fleetfoot",
175
+ "lemon hearts",
176
+ "flim",
177
+ "cherry berry",
178
+ "princess skystar",
179
+ "flam",
180
+ "carrot cake",
181
+ "somnambula",
182
+ "cloud kicker",
183
+ "opalescence",
184
+ "fancypants",
185
+ "lily",
186
+ "lily valley",
187
+ "sprout cloverleaf",
188
+ "star swirl the bearded",
189
+ "sparky sparkeroni",
190
+ "owlowiscious",
191
+ "timber spruce",
192
+ "garble",
193
+ "luster dawn",
194
+ "gloriosa daisy",
195
+ "shoeshine",
196
+ "firefly",
197
+ "velvet (tfh)",
198
+ "sea swirl",
199
+ "seafoam",
200
+ "linky",
201
+ "double diamond",
202
+ "saffron masala",
203
+ "mane-iac",
204
+ "queen novo",
205
+ "capper dapperpaws",
206
+ "oleander (tfh)",
207
+ "quibble pants",
208
+ "posey shy",
209
+ "party favor",
210
+ "arizona (tfh)",
211
+ "opaline arcana",
212
+ "juniper montage",
213
+ "cloudy quartz",
214
+ "bright mac",
215
+ "screwball",
216
+ "blossomforth",
217
+ "stellar flare",
218
+ "pokey pierce",
219
+ "smarty pants",
220
+ "microchips",
221
+ "minty",
222
+ "night glider",
223
+ "dean cadance",
224
+ "boulder (g4)",
225
+ "ruby pinch",
226
+ "iron will",
227
+ "paprika (tfh)",
228
+ "songbird serenade",
229
+ "sprinkle medley",
230
+ "spring melody",
231
+ "suri polomare",
232
+ "spoiled rich",
233
+ "featherweight",
234
+ "queen haven",
235
+ "storm king",
236
+ "captain celaeno",
237
+ "grogar",
238
+ "rockhoof",
239
+ "trouble shoes",
240
+ "orange swirl",
241
+ "dizzy twister",
242
+ "filthy rich",
243
+ "cookie crumbles",
244
+ "pharynx",
245
+ "sandalwood",
246
+ "bow hothoof",
247
+ "sassy saddles",
248
+ "vapor trail",
249
+ "cherry jubilee",
250
+ "rainbowshine",
251
+ "cranky doodle donkey",
252
+ "philomena",
253
+ "rainbow dash (g3)",
254
+ "principal abacus cinch",
255
+ "the sphinx",
256
+ "megan williams",
257
+ "blues",
258
+ "noteworthy",
259
+ "white lightning",
260
+ "lightning bolt",
261
+ "sassaflash",
262
+ "summer flare",
263
+ "cinder glow",
264
+ "pom (tfh)",
265
+ "sapphire shores",
266
+ "watermelody",
267
+ "hoity toity",
268
+ "rover",
269
+ "posey bloom",
270
+ "mare do well",
271
+ "tianhuo (tfh)",
272
+ "pinkie pie (g3)",
273
+ "igneous rock pie",
274
+ "mystery mint",
275
+ "neon lights",
276
+ "rising star",
277
+ "normal norman",
278
+ "meadowbrook",
279
+ "vignette valencia",
280
+ "flash magnus",
281
+ "trenderhoof",
282
+ "masked matter-horn",
283
+ "comet tail",
284
+ "stygian",
285
+ "fili-second",
286
+ "terramar",
287
+ "mudbriar",
288
+ "wild fire",
289
+ "mean twilight sparkle",
290
+ "saddle rager",
291
+ "raven",
292
+ "jazz hooves",
293
+ "ms. peachbottom",
294
+ "chickadee",
295
+ "radiance",
296
+ "merry may",
297
+ "tom",
298
+ "grubber",
299
+ "zapp",
300
+ "ahuizotl",
301
+ "mistmane",
302
+ "little strongheart",
303
+ "doctor caballeron",
304
+ "chancellor neighsay",
305
+ "apple fritter",
306
+ "toola roola",
307
+ "prince rutherford",
308
+ "blueberry cake",
309
+ "lavender lace",
310
+ "donut joe",
311
+ "posey",
312
+ "fuchsia blush",
313
+ "drama letter",
314
+ "fizzy",
315
+ "paisley",
316
+ "mistress marevelous",
317
+ "tender taps",
318
+ "nightmare star",
319
+ "starlight",
320
+ "snowfall frost",
321
+ "starshine",
322
+ "tree of harmony",
323
+ "alphabittle blossomforth",
324
+ "parasol",
325
+ "noi",
326
+ "curly winds",
327
+ "spike (g1)",
328
+ "rose heart",
329
+ "some blue guy",
330
+ "wiz kid",
331
+ "coco crusoe",
332
+ "applejack (g1)",
333
+ "captain planet",
334
+ "alula",
335
+ "twilight",
336
+ "sir colton vines iii",
337
+ "pluto",
338
+ "goldengrape",
339
+ "thunderbass",
340
+ "upper crust",
341
+ "cherry crash",
342
+ "radiant hope",
343
+ "shimmy shake",
344
+ "golden hazel",
345
+ "princess platinum",
346
+ "tootsie flute",
347
+ "lucky clover",
348
+ "liza doolots",
349
+ "petunia",
350
+ "meadow song",
351
+ "lighthoof",
352
+ "li'l cheese",
353
+ "kerfuffle",
354
+ "smooze",
355
+ "dumbbell",
356
+ "gusty",
357
+ "fizzle",
358
+ "wind sprint",
359
+ "misty fly",
360
+ "aqua blossom",
361
+ "november rain",
362
+ "hondo flanks",
363
+ "cherry fizzy",
364
+ "sweet leaf",
365
+ "gaea everfree",
366
+ "scribble dee",
367
+ "inky rose",
368
+ "feather bangs",
369
+ "doctor fauna",
370
+ "steven magnet",
371
+ "velvet sky",
372
+ "cosmos",
373
+ "rain shine",
374
+ "hoo'far",
375
+ "sky stinger",
376
+ "tennis match",
377
+ "harry",
378
+ "fido",
379
+ "screw loose",
380
+ "allie way",
381
+ "tantabus",
382
+ "wind whistler",
383
+ "cherry cola",
384
+ "valhallen",
385
+ "pony of shadows",
386
+ "matilda",
387
+ "indigo wreath",
388
+ "seabreeze",
389
+ "berry bliss",
390
+ "peppermint goldylinks",
391
+ "berry blend",
392
+ "star tracker",
393
+ "thunder flap",
394
+ "nightshade",
395
+ "humdrum",
396
+ "clear sky",
397
+ "rainbow blaze",
398
+ "dahlia",
399
+ "ditzy doo",
400
+ "spot",
401
+ "moonlight raven",
402
+ "firelight",
403
+ "jet set",
404
+ "nolan north",
405
+ "cheerilee (g3)",
406
+ "sophisticata",
407
+ "cotton cloudy",
408
+ "fiddlesticks",
409
+ "gentle breeze",
410
+ "boneless",
411
+ "kiwi lollipop",
412
+ "pacific glow",
413
+ "oc:*"
414
+ ],
415
+ "filtered_tags": [
416
+ "spoiler:*",
417
+ "leak",
418
+ "*prompter*",
419
+ "generator:*",
420
+ "editor*",
421
+ "photographer:*",
422
+ "colorist:*",
423
+ "commissioner:*",
424
+ "anonymous *",
425
+ "art pack:*",
426
+ "this will end*",
427
+ "implied*",
428
+ "20*",
429
+ "*is trying to murder us",
430
+ "*in the comments",
431
+ "edit",
432
+ "* edit",
433
+ "*needed",
434
+ "backwards cutie mark",
435
+ "ai *",
436
+ "fifteen.ai",
437
+ "hundreds of users filter this tag",
438
+ "featured image",
439
+ "edited screencap",
440
+ "text",
441
+ "signature",
442
+ "*watermark*",
443
+ "patreon*",
444
+ "*logo",
445
+ "*advertisement*",
446
+ "dead source",
447
+ "useless source url",
448
+ "blatant lies",
449
+ "comission",
450
+ "30 minute art challenge finished after",
451
+ "explicit source",
452
+ "motivational description",
453
+ "this is gonna suck",
454
+ "gif",
455
+ "webm",
456
+ "animated",
457
+ "commission",
458
+ "i never asked for this",
459
+ "that was fast",
460
+ "derpibooru*",
461
+ "one word",
462
+ "updated",
463
+ "* in the description",
464
+ "* in the comments",
465
+ "bad end",
466
+ "bronycon*",
467
+ "uk ponycon*",
468
+ "galacon*",
469
+ "trotcon*",
470
+ "*my little pony fair",
471
+ "atg*",
472
+ "*community collab",
473
+ "* anniversary"
474
+ ],
475
+ "species_tags": [
476
+ "mare",
477
+ "female",
478
+ "solo",
479
+ "solo female",
480
+ "stallion",
481
+ "male",
482
+ "equestria girls",
483
+ "pony",
484
+ "unicorn",
485
+ "pegasus",
486
+ "earth pony",
487
+ "alicorn",
488
+ "human",
489
+ "dragon",
490
+ "bat pony",
491
+ "changeling",
492
+ "griffon",
493
+ "original species",
494
+ "hybrid",
495
+ "changeling queen",
496
+ "zebra",
497
+ "draconequus",
498
+ "kirin",
499
+ "hippogriff",
500
+ "dog",
501
+ "bird",
502
+ "changedling",
503
+ "robot",
504
+ "butterfly",
505
+ "deer",
506
+ "dracony",
507
+ "cat",
508
+ "rabbit",
509
+ "fluffy pony",
510
+ "seapony (g4)",
511
+ "classical hippogriff",
512
+ "yak",
513
+ "robot pony",
514
+ "crystal pony",
515
+ "vampire",
516
+ "satyr",
517
+ "classical unicorn",
518
+ "cyborg",
519
+ "undead",
520
+ "demon",
521
+ "monster pony",
522
+ "centaur",
523
+ "cow",
524
+ "horse",
525
+ "diamond dog",
526
+ "snake",
527
+ "ghost",
528
+ "fish",
529
+ "shark",
530
+ "insect",
531
+ "shark pony",
532
+ "bat pony alicorn",
533
+ "reindeer",
534
+ "merpony",
535
+ "lamia",
536
+ "zombie",
537
+ "mermaid",
538
+ "wolf",
539
+ "breezie",
540
+ "donkey",
541
+ "fox",
542
+ "sphinx",
543
+ "siren",
544
+ "vampony",
545
+ "sheep",
546
+ "bat",
547
+ "goo",
548
+ "spider",
549
+ "parasprite",
550
+ "goo pony",
551
+ "sea pony",
552
+ "demon pony",
553
+ "bear",
554
+ "phoenix",
555
+ "succubus",
556
+ "deer pony",
557
+ "plane pony",
558
+ "genie",
559
+ "goat",
560
+ "chicken",
561
+ "tatzlpony",
562
+ "alien",
563
+ "timber wolf",
564
+ "kaiju",
565
+ "owl",
566
+ "alligator",
567
+ "mouse",
568
+ "abyssinian",
569
+ "changepony",
570
+ "zony",
571
+ "food pony",
572
+ "alpaca",
573
+ "umbrum",
574
+ "duck",
575
+ "angel",
576
+ "big cat",
577
+ "bee",
578
+ "fairy",
579
+ "crab",
580
+ "squirrel",
581
+ "minotaur",
582
+ "dinosaur",
583
+ "longma",
584
+ "raccoon",
585
+ "moth",
586
+ "firefly (insect)",
587
+ "mothpony",
588
+ "zombie pony",
589
+ "tortoise",
590
+ "inflatable pony",
591
+ "buffalo",
592
+ "giraffe",
593
+ "werewolf",
594
+ "gem (race)",
595
+ "pikachu",
596
+ "pig",
597
+ "object pony",
598
+ "snake pony",
599
+ "ghost pony",
600
+ "frog",
601
+ "umbra pony",
602
+ "cat pony",
603
+ "kelpie",
604
+ "bat pony unicorn",
605
+ "lamb",
606
+ "hedgehog",
607
+ "twinkle eyed pony",
608
+ "saddle arabian",
609
+ "skunk",
610
+ "plant pony",
611
+ "timber pony",
612
+ "nymph",
613
+ "android",
614
+ "windigo",
615
+ "ladybug",
616
+ "fox pony",
617
+ "balloon pony",
618
+ "ursa minor",
619
+ "nirik",
620
+ "lion",
621
+ "parrot",
622
+ "spiderpony",
623
+ "manticore",
624
+ "blue jay",
625
+ "snail",
626
+ "chimera",
627
+ "flutter pony",
628
+ "octopus",
629
+ "cockatrice",
630
+ "cow pony",
631
+ "ghoul",
632
+ "eevee",
633
+ "devil",
634
+ "turtle",
635
+ "worm",
636
+ "hydra",
637
+ "hengstwolf",
638
+ "tiger",
639
+ "kitsune",
640
+ "pond pony",
641
+ "parrot pirates",
642
+ "zebracorn",
643
+ "orca pony",
644
+ "ursa",
645
+ "lizard",
646
+ "seagull"
647
+ ],
648
+ "meta_tags": [
649
+ "official",
650
+ "my little pony*",
651
+ "g[0-9]",
652
+ "g[0-9].[0-9]",
653
+ "season [0-9]*",
654
+ "equestria girls*",
655
+ "fanfic:*",
656
+ "series:*",
657
+ "comic:*",
658
+ "ask *",
659
+ "tumblr*",
660
+ "cyoa:*",
661
+ "fallout equestria*",
662
+ "screencap",
663
+ "alternate version",
664
+ "part of a set",
665
+ "idw",
666
+ "alternate character",
667
+ "gameloft",
668
+ "official comic",
669
+ "kotobukiya",
670
+ "enterplay",
671
+ "alternate angle",
672
+ "composite screencap",
673
+ "seven seas",
674
+ "budge studios",
675
+ "boulder media",
676
+ "egmont",
677
+ "dhx media",
678
+ "playdate digital",
679
+ "ruckus media group",
680
+ "faceapp",
681
+ "ponygen wallpapers",
682
+ "symbiote studios",
683
+ "red frog digital limited",
684
+ "backflip studios",
685
+ "trefl",
686
+ "eaglemoss",
687
+ "e-dantès",
688
+ "big balloon",
689
+ "turkuvaz radyo tv haberlesme ve yayincilik a.s.",
690
+ "them's fightin' herds",
691
+ "pony town",
692
+ "rcf community",
693
+ "pony creator",
694
+ "princess molestia",
695
+ "gamer luna",
696
+ "colt quest",
697
+ "equestria at war mod",
698
+ "equestria daily",
699
+ ".mov",
700
+ "moonstuck",
701
+ "kilalaverse",
702
+ "fighting is magic",
703
+ "the sunjackers",
704
+ "lunadoodle",
705
+ "friendship is witchcraft",
706
+ "kindverse",
707
+ "cold blooded twilight",
708
+ "banned from equestria daily",
709
+ "horse wife",
710
+ "legends of equestria",
711
+ "fall of equestria",
712
+ "icey-verse",
713
+ "lil-miss rarity",
714
+ "royal sketchbook",
715
+ "pony-berserker's twitter sketches",
716
+ "smile hd",
717
+ "ponylumen",
718
+ "story of the blanks",
719
+ "elements of insanity",
720
+ "shed.mov",
721
+ "vylet pony",
722
+ "pony comic generator",
723
+ "vocational death cruise",
724
+ "pony pov series",
725
+ "spiders and magic: rise of spider-mane",
726
+ "the count of monte rainbow",
727
+ "flurry heart's story",
728
+ "luna-afterdark",
729
+ "lovestruck derpy",
730
+ "twilight sparkle's secret shipfic folder",
731
+ "futaverse",
732
+ "daily dose of friends",
733
+ "five nights at aj's",
734
+ "ashes town",
735
+ "ain't never had friends like us",
736
+ "hugtastic pinkie pie",
737
+ "ponibooru film night",
738
+ "double rainboom",
739
+ "two best sisters play",
740
+ "loony luna",
741
+ "rainbow dash presents",
742
+ "button's adventures",
743
+ "twilight unbound",
744
+ "totally legit recap",
745
+ "full service playing cards",
746
+ "raindropsanswers",
747
+ "apple bloomers",
748
+ "aeroverse",
749
+ "turnabout storm",
750
+ "kirindos",
751
+ "cutiemarks (and the things that bind us)",
752
+ "two sided posters",
753
+ "adventures of flair",
754
+ "daily apple pony",
755
+ "cinemare sins",
756
+ "guardians of pondonia",
757
+ "rarijack daily",
758
+ "bubbleverse",
759
+ "ponyfinder",
760
+ "antonymph",
761
+ "b.u.c.k.",
762
+ "lateverse",
763
+ "don't mine at night",
764
+ "ponyar fusion",
765
+ "trixie is magic",
766
+ "saddle up 2: creature comforts",
767
+ "saddle up!",
768
+ "daily pinkie pie",
769
+ "luna game",
770
+ "ultimare universe",
771
+ "post-crusade",
772
+ "mentally advanced series",
773
+ "other royal book",
774
+ "tabun art-battle",
775
+ "hoofbeat 2",
776
+ "pony-berserker's twitter sketches (2023)",
777
+ "lullaby for a princess",
778
+ "descended twilight",
779
+ "after the fact",
780
+ "equestria untamed",
781
+ "the grand galloping 20s",
782
+ "elements of justice",
783
+ "ponies: the anthology 3",
784
+ "crisis equestria",
785
+ "the clone that got away",
786
+ "pandoraverse",
787
+ "hearth's warming con",
788
+ "children of the night",
789
+ "offensive ponies",
790
+ "new lunar millennium",
791
+ "firestarter spitfire",
792
+ "my little porno: friendship with benefits",
793
+ "cupcakes hd",
794
+ "matchstickman's apple brawn series",
795
+ "swag.mov",
796
+ "pink fluffy unicorns dancing on rainbows",
797
+ "kanashiipandaverse",
798
+ "season 8 doodles",
799
+ "freeny's hidden dissectibles",
800
+ "star trek: sunset shimmer",
801
+ "milkmare of trottingham",
802
+ "pantsu.html",
803
+ "tantamount time turner",
804
+ "steamquestria",
805
+ "auraverse",
806
+ "secret horse files",
807
+ "scootalootheadventurer",
808
+ "buck legacy",
809
+ "11-54",
810
+ "octavia in the underworld's cello",
811
+ "project seaponycon",
812
+ "equestria project humanized",
813
+ "abandon all hope",
814
+ "futa folio",
815
+ "ziragshabdarverse",
816
+ "discorderlyconduct",
817
+ "miss pie's monsters",
818
+ "mylittleheadcanon",
819
+ "ponies after people",
820
+ "slice of pony life",
821
+ "mlp x jojo",
822
+ "big book of fetishes",
823
+ "msponyadventures",
824
+ "winningverse",
825
+ "hunted luna",
826
+ "pinkiepieskitchen",
827
+ "friendship is manly",
828
+ "apple.mov",
829
+ "clockwise whooves",
830
+ "fall of the crystal empire",
831
+ "twijack weekly",
832
+ "sparkles! the wonder horse!",
833
+ "northern excursion",
834
+ "sweetie bot project",
835
+ "open pony",
836
+ "equestria divided",
837
+ "au:friendship is kindness",
838
+ "journey of the spark",
839
+ "rise and fall",
840
+ "party.mov",
841
+ "fearcomesnaturally",
842
+ "doctor whooves and assistant",
843
+ "cupidite",
844
+ "parcly taxel in japan",
845
+ "pony-berserker's twitter sketches (2022)",
846
+ "equestria trainers society",
847
+ "from the desk of mayor mare",
848
+ "moonsetmlp",
849
+ "pinkamena party",
850
+ "adventuring is magic",
851
+ "equis universe",
852
+ "dusk's dawn",
853
+ "gypsy bard",
854
+ "my little porny",
855
+ "daily life of spike",
856
+ "shooting stars cyoa",
857
+ "snowdrop (animation)",
858
+ "moody mark crusaders",
859
+ "survivor shy",
860
+ "let's start the game",
861
+ "tf2 analysis anarchy",
862
+ "madmax silly comic shop",
863
+ "tiny sapient ungulates",
864
+ "my little mages",
865
+ "game:ergosphere",
866
+ "first contact war",
867
+ "roan rpg",
868
+ "dancerverse",
869
+ "ponies the anthology v",
870
+ "my little brony risovach",
871
+ "moon-fall",
872
+ "magic.mov",
873
+ "harwick's sun/moon portraits",
874
+ "naughty luna",
875
+ "dress.mov",
876
+ "epic rage time",
877
+ "hooves & holly",
878
+ "how applejack won the war",
879
+ "time for two",
880
+ "littlepartycomics",
881
+ "picture perfect pony",
882
+ "epic wub time",
883
+ "ponies the anthology vi",
884
+ "the tiny apprentice",
885
+ "choose your wings",
886
+ "dtiys emoflat",
887
+ "ponyvania",
888
+ "villains of equestria collab",
889
+ "princessponk",
890
+ "bronies react",
891
+ "zelc-face's swimsuits",
892
+ "foal quest",
893
+ "pinkie's brew",
894
+ "bone pone funnies",
895
+ "rhythm is magic",
896
+ "screwingwithsfmverse",
897
+ "mare fair",
898
+ "pony couple generator",
899
+ "fall from grace",
900
+ "x point (comic series)",
901
+ "let's switch bodies",
902
+ "kilalaverse ii",
903
+ "ponies at dawn",
904
+ "the moon rises",
905
+ "collaboration:choose your starlight",
906
+ "once upon a time in canterlot",
907
+ "cmc 10k",
908
+ "derpin daily",
909
+ "the mayors journey(vore series)",
910
+ "eternal night au (janegumball)",
911
+ "p.f.f.",
912
+ "my little portal",
913
+ "miracleverse",
914
+ "emw:mmmm",
915
+ "fish whisperer",
916
+ "fizzleverse (徐詩珮)",
917
+ "my little investigations",
918
+ "minty fresh adventure",
919
+ "ambient.prologue",
920
+ "buy me",
921
+ "headmare of the school",
922
+ "rainbowdashsmailbag",
923
+ "40kponyguy's the staff of aurelian",
924
+ "honeycrisp tales",
925
+ "eris void",
926
+ "z-book universe",
927
+ "under a paper moon",
928
+ "fighting is magic aurora",
929
+ "cyber-questria",
930
+ "my tiny pony",
931
+ "drawing (shitty) porn of every episode",
932
+ "collaboration:too many twilight",
933
+ "discord (eurobeat brony)",
934
+ "raycord legends",
935
+ "super lesbian horse rpg",
936
+ "b.u.c.k. 2016",
937
+ "here comes berry punch",
938
+ "celestilee",
939
+ "smile virus",
940
+ "dream of alicornication",
941
+ "zefiros codex",
942
+ "amaryllisverse",
943
+ "biporarity",
944
+ "round trip's mlp season 8 in a nutshell",
945
+ "hoofstuck",
946
+ "equestria rises still (equestria at war submod)",
947
+ "ponyville's incident",
948
+ "crossed: equestria",
949
+ "equestria changed",
950
+ "nomad au",
951
+ "vanillaswirl6's state ponies",
952
+ "rise of reason",
953
+ "equestibooru girls",
954
+ "collaboration:meet the best showpony",
955
+ "man versus ponies",
956
+ "sunset's fantastic fishing",
957
+ "good morning celestia",
958
+ "pony girl",
959
+ "dimensional shift",
960
+ "eqqverse",
961
+ "g4 mega collab",
962
+ "hallowverse",
963
+ "squeezin' it",
964
+ "i am octavia",
965
+ "ponies the anthology vii",
966
+ "your little pets",
967
+ "au:equuis",
968
+ "a tale of one shadow",
969
+ "fighting is magic - roots",
970
+ "super ponybeat",
971
+ "daily sleeping spike",
972
+ "oh dat cheerilee",
973
+ "good morning baltimare",
974
+ "four string samurai",
975
+ "apple a day",
976
+ "trinity: rebirth",
977
+ "ponies: the anthology",
978
+ "fighting is magic - mega",
979
+ "ponies: the anthology 2",
980
+ "redd's great war universe",
981
+ "game:element of justice",
982
+ "princess celestia being deep",
983
+ "scootertrix the abridged",
984
+ "derpy's and carrot top's journey",
985
+ "tesiii:mlp",
986
+ "a devious plot",
987
+ "ponyvania: order of equestria",
988
+ "rarilightbomb",
989
+ "give me your wings",
990
+ "dark star au",
991
+ "skywar sword: las cronicas del caballero de fuego",
992
+ "equestria gardens",
993
+ "cartoon horse program",
994
+ "tales of the sugarcube corner",
995
+ "p<3nies",
996
+ "carousel (an examination of the shadow creekflow and its life as an afterthought)",
997
+ "samurai rarity au",
998
+ "a tropical octav3",
999
+ "rain siblings",
1000
+ "buy me 2.0",
1001
+ "poorly drawn encouragement ponies",
1002
+ "midair pony fair",
1003
+ "queen of misfits",
1004
+ "my little pony: form your friendship",
1005
+ "let's go and meet the bronies",
1006
+ "the nuclear holocaust but everyones a horse so its okay",
1007
+ "change your reality",
1008
+ "season 9 retirement party",
1009
+ "your little cat 3",
1010
+ "friendship is gic",
1011
+ "eaw redux",
1012
+ "megaspell (game)",
1013
+ "the princess of evil",
1014
+ "just relax and read",
1015
+ "fluffle puff tales",
1016
+ "the tale of two sisters",
1017
+ "midnight mares",
1018
+ "how to be a princess",
1019
+ "strangers",
1020
+ "magic lessons",
1021
+ "equestriabound",
1022
+ "fillycon",
1023
+ "collaboration:nightmare night event (2022)",
1024
+ "the most evil q&a ever",
1025
+ "dusty's trails",
1026
+ "my little dungeon",
1027
+ "saga of the metapony",
1028
+ "guardian (web video)",
1029
+ "friendship is violence",
1030
+ "super pony world",
1031
+ "things britannia is not allowed to do",
1032
+ "the cutie remark prequel",
1033
+ "everypony is strange",
1034
+ "game:filly astray",
1035
+ "beyond her garden",
1036
+ "apple thief (animation)",
1037
+ "brony polka",
1038
+ "pony and magical artifact",
1039
+ "balloon party",
1040
+ "the folly of celestia",
1041
+ "my roommate is a vampire",
1042
+ "game:the super speedy cider squeezy 6000",
1043
+ "draw this twi by jsunlight",
1044
+ "horse heresy",
1045
+ "the flutterby effect",
1046
+ "dazzlings' memories",
1047
+ "weird ponyville",
1048
+ "project goliathon",
1049
+ "collaboration:bestiary of fluttershy",
1050
+ "the fall of sunset shimmer: animated film",
1051
+ "nonexistent meet-cute [idlyam]",
1052
+ "the sweet shy & stacked super star squad",
1053
+ "appleshybomb",
1054
+ "snootverse",
1055
+ "equestria girls hearts and strings",
1056
+ "pinkie pie replies",
1057
+ "cloverly ponies",
1058
+ "applejack and the beanstalk",
1059
+ "fluffurama",
1060
+ "game:to the moon",
1061
+ "springtrapped",
1062
+ "starlight's world",
1063
+ "lesbian ponies with weapons",
1064
+ "you must remember",
1065
+ "wallflower's week",
1066
+ "spitfire's day off",
1067
+ "the stars will aid in her escape",
1068
+ "innocence.mov",
1069
+ "lulamoon sonata",
1070
+ "pony fantasy vi",
1071
+ "la da dee",
1072
+ "banned forever",
1073
+ "rainbow wake",
1074
+ "faithful farmer",
1075
+ "ultra fast pony",
1076
+ "hearth's warming con 2020",
1077
+ "in your dream",
1078
+ "bar buddies",
1079
+ "old equestria",
1080
+ "deep in the hive",
1081
+ "must be better",
1082
+ "round trip's mlp season 9 in a nutshell",
1083
+ "project decadence",
1084
+ "it started with a hug",
1085
+ "academy of booty",
1086
+ "the walking hugs",
1087
+ "the little clop shop of horrors",
1088
+ "the last summer",
1089
+ "make new friends",
1090
+ "different view of reality",
1091
+ "princesses don't sleep",
1092
+ "horse game",
1093
+ "it's picnic time",
1094
+ "new pony worlds",
1095
+ "flight of the valkyrie",
1096
+ "tales of adventurers",
1097
+ "your little cat 4",
1098
+ "when you're a filly",
1099
+ "seven days in sunny june",
1100
+ "everypony plays sports games",
1101
+ "know your castle",
1102
+ "honda dash",
1103
+ "magic the traveling",
1104
+ "zebra wife",
1105
+ "make it a surprise",
1106
+ "something about the princesses",
1107
+ "the rock farmer's daughters",
1108
+ "daring do and the sonic rainboom",
1109
+ "frostpony",
1110
+ "just another luna blog",
1111
+ "love me cheerilee",
1112
+ "starship ponyville",
1113
+ "cupcakes manga",
1114
+ "storm princess",
1115
+ "where are you?",
1116
+ "empty darkness",
1117
+ "i was the loner of paradise valley",
1118
+ "most sweet apple",
1119
+ "au:chaoticverse",
1120
+ "animation:the god of ponies",
1121
+ "b.u.c.k. 2014",
1122
+ "dreamwalker-luna",
1123
+ "matchmakers inc",
1124
+ "starlight wants your cutie mark",
1125
+ "my little worms",
1126
+ "pinkie pie's intimacy institute",
1127
+ "explore ponyville",
1128
+ "the secret life of fleur dis lee",
1129
+ "lumineko's nuzzling princesses",
1130
+ "no morality",
1131
+ "soul bond au",
1132
+ "astralverse",
1133
+ "mlponline",
1134
+ "no excuse for the heart",
1135
+ "saddle up 3: full of pride",
1136
+ "destiny of equestria",
1137
+ "false shining au",
1138
+ "abhiyaan seaponycon",
1139
+ "elements of cringe",
1140
+ "rartwi",
1141
+ "equestria at war (sensko)",
1142
+ "ponies the anthology 7.05",
1143
+ "your little cat",
1144
+ "rainblood and vomit",
1145
+ "everyone loves princess luna",
1146
+ "mad this time",
1147
+ "rise of the clockwork stallions",
1148
+ "pony driland",
1149
+ "friendship is gic: pinkie pie tlt uolliac",
1150
+ "wishbone heroes: friends forever",
1151
+ "plains au",
1152
+ "dinky's destiny",
1153
+ "letters to the moon",
1154
+ "oopsverse",
1155
+ "friendship is musical",
1156
+ "celestia is best princess (animation)",
1157
+ "how ponies made the season 4",
1158
+ "the garden",
1159
+ "starlight vs mane 6",
1160
+ "mane 6 cartoons",
1161
+ "human daily apple jack and fluttershy",
1162
+ "a world apart",
1163
+ "a different perspective",
1164
+ "romance reports",
1165
+ "the vinyl scratch tapes",
1166
+ "lords of ponykeep",
1167
+ "game:doom equestria",
1168
+ "spike.mov",
1169
+ "heartverse",
1170
+ "the first starlight",
1171
+ "my little supernatural",
1172
+ "after the fact:slice of life",
1173
+ "rarity wallpaper",
1174
+ "weird maretime bay",
1175
+ "a colt classic",
1176
+ "post season 9 story prompt",
1177
+ "cloudyglowverse",
1178
+ "game:spike's quest",
1179
+ "pink fluffy handcuffs are perfect for bondage",
1180
+ "bodyguard au",
1181
+ "chip of discord",
1182
+ "this is our miracle",
1183
+ "champion au",
1184
+ "the little magician",
1185
+ "friendship is magnets",
1186
+ "alive",
1187
+ "after the fact:it ain't easy being breezies",
1188
+ "mystic acoustics (album)",
1189
+ "pink tac toe",
1190
+ "fun fun fun (album)",
1191
+ "after the fact:the lost treasure of griffonstone",
1192
+ "a jessi-ka story",
1193
+ "after the fact:sparkle's seven",
1194
+ "twilight the unicorn",
1195
+ "i don't need to be fixed",
1196
+ "after the fact:inspiration manifestation",
1197
+ "we're going for a ride",
1198
+ "my little pony: hide-and-seek",
1199
+ "a little incident (animation)",
1200
+ "lincolnbrewsterfan's movie cutie smiles",
1201
+ "rainbow dash's precious book",
1202
+ "after the fact:pinkie pride",
1203
+ "the death of princess luna",
1204
+ "mlp vector club",
1205
+ "aplflu",
1206
+ "hearth's warming con 2016",
1207
+ "scootertrix the abridged: the movie",
1208
+ "rainbow dash and the fat pony thread",
1209
+ "flutterwonder",
1210
+ "game:foul sorcery",
1211
+ "starlight and the strange castle",
1212
+ "celestia abc",
1213
+ "luna (eurobeat brony)",
1214
+ "the story of pinkie pie",
1215
+ "my little pony: friendship makes its mark",
1216
+ "bit of a monster",
1217
+ "love nwantiti",
1218
+ "friendship is gic 3: revenge of the first one",
1219
+ "best princesses ever",
1220
+ "snow castle",
1221
+ "pinkie promise (animation)",
1222
+ "rainbow factory (song)",
1223
+ "slaughter horse 2",
1224
+ "after the fact:testing testing 1 2 3",
1225
+ "luna's determination",
1226
+ "m ",
1227
+ "winter's fucked up",
1228
+ "lyra's gift",
1229
+ "artifacts of equestria",
1230
+ "thinking with portals (series)",
1231
+ "rarity's little problem",
1232
+ "ice angel's moonlight au",
1233
+ "lessons in quirks",
1234
+ "redeemable trixie",
1235
+ "no matter what",
1236
+ "duskverse",
1237
+ "echo's fruit rampage",
1238
+ "the nutritious chronicles of celeryjack",
1239
+ "brohoof (vylet pony)",
1240
+ "cycles of autumn",
1241
+ "twilight and the strange castle",
1242
+ "the freeport venture",
1243
+ "round trip's mlp equestria girls in a nutshell",
1244
+ "solar eclipse (au)",
1245
+ "pony rock anthem",
1246
+ "three tribes",
1247
+ "magic bitch",
1248
+ "bonnie (vylet pony)",
1249
+ "round trip's mlp movie in a nutshell",
1250
+ "dio's bizarre pony adventure",
1251
+ "after the fact:pinkie apple pie",
1252
+ "pwny-verse",
1253
+ "after the fact:appleoosa's most wanted",
1254
+ "diamond's birthday buffet",
1255
+ "sweet-apple-secrets",
1256
+ "everybody hates pinkie pie",
1257
+ "missing out",
1258
+ "the mare who became queen",
1259
+ "mlp g5 leaked",
1260
+ "everybody hates ponies",
1261
+ "medley of visions",
1262
+ "after the fact:amending fences",
1263
+ "the carrion child",
1264
+ "girls who are wizards",
1265
+ "spies among us",
1266
+ "raripiebomb",
1267
+ "bad night",
1268
+ "wayfarer",
1269
+ "have fun together",
1270
+ "the return of snowdrop",
1271
+ "king and lionheart",
1272
+ "amityverse",
1273
+ "game:spike's time off",
1274
+ "wild fire's road rage",
1275
+ "badverse",
1276
+ "the forests of autumn",
1277
+ "princessverse",
1278
+ "sunshine and celery stalks",
1279
+ "after the fact:griffs galore!",
1280
+ "after the fact:party pooped",
1281
+ "slaughter horse",
1282
+ "love letters: colourless",
1283
+ "stale cupcakes au",
1284
+ "friendship is gic: what a story mark crusaders",
1285
+ "after the fact:flight to the finish",
1286
+ "celestia's favorite question",
1287
+ "after the fact:crusaders of the lost mark",
1288
+ "after the fact:keep calm and flutter on",
1289
+ "my little pony: equestrian friends",
1290
+ "hearth's warming con 2015",
1291
+ "after the fact:fantastic fluttershy",
1292
+ "twilight's apple",
1293
+ "after the fact:bloom and gloom",
1294
+ "trixie's grand adventure",
1295
+ "arranged marriage au",
1296
+ "a beautiful day in equestria",
1297
+ "after the fact:rarity investigates!",
1298
+ "friendship is not available in your country",
1299
+ "homeward (album)",
1300
+ "quantum seaponycon",
1301
+ "rainbow mother earth",
1302
+ "hearth's warming con 2018",
1303
+ "derpy's toy",
1304
+ "somewhere only we know",
1305
+ "exclusive royal canterlot wedding playset",
1306
+ "swayback mountain",
1307
+ "morning twilight sparkle",
1308
+ "the difference between us",
1309
+ "blue / flightcamp",
1310
+ "forgetful twilight",
1311
+ "ebony verse",
1312
+ "look in the past (animation)",
1313
+ "the brony community",
1314
+ "metal gear friendship",
1315
+ "needle pusher",
1316
+ "after the fact:tanks for the memories",
1317
+ "i don't know how to tell you you're my best friend (and i love you)",
1318
+ "isometrica",
1319
+ "ember (vylet pony)",
1320
+ "ponies the anthology",
1321
+ "after the fact:maud pie",
1322
+ "after the fact:rah! rah! rainbow!",
1323
+ "fluffle puff tales: \"nightmare night\"",
1324
+ "after the fact:twilight's tribute",
1325
+ "after the fact:spike's special",
1326
+ "control freaks pt. 1",
1327
+ "love letters (vylet pony)",
1328
+ "creature city",
1329
+ "where are we",
1330
+ "kindness's reward",
1331
+ "wrong apple tree",
1332
+ "gloryverse",
1333
+ "after the fact:castle sweet castle",
1334
+ "after the fact:twilight's kingdom",
1335
+ "moonyverse",
1336
+ "everything glimmer",
1337
+ "after the fact:the cutie map",
1338
+ "harper",
1339
+ "life with wings",
1340
+ "nightmare night (song)",
1341
+ "after the fact:celestia centerpoints",
1342
+ "ponies the anthology iv",
1343
+ "feeding the bat pony",
1344
+ "autistic six",
1345
+ "after the fact:for whom the sweetie belle toils",
1346
+ "awoken (song)",
1347
+ "hush!",
1348
+ "the adventures of pouniewoop",
1349
+ "after the fact:twilight time",
1350
+ "venus-quest",
1351
+ "cast away (stormxf3)",
1352
+ "† (i believe in you)",
1353
+ "the queen is back",
1354
+ "i want to feel like a little dragon",
1355
+ "after the fact:power ponies",
1356
+ "alive (song)",
1357
+ "after the fact:celestia celebration",
1358
+ "fuck marry kill (vylet pony)",
1359
+ "cupcakes (futret)",
1360
+ "after the fact:the point of no return",
1361
+ "artwork of twilight (animation)",
1362
+ "wish list (song)",
1363
+ "rarpin",
1364
+ "out of the frying pan",
1365
+ "at the crown of eternal sunlight",
1366
+ "wrecked elements",
1367
+ "pony songs",
1368
+ "the incredibly expensive one of a kind crochet wool sweater song",
1369
+ "mare-y nyxmas",
1370
+ "something sweet to bite",
1371
+ "the seapony orchestra",
1372
+ "the seapony orchestra presents adieu",
1373
+ "fluffy au",
1374
+ "chubby bunny challenge",
1375
+ "game:beyond equestria"
1376
+ ]
1377
+ }
lazy-pony-prompter/config/e621.json ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "ratings": {
3
+ "lookup": {
4
+ "None": "",
5
+ "Safe": "rating:safe",
6
+ "Questionable": "rating:questionable",
7
+ "Explicit": "rating:explicit"
8
+ },
9
+ "pdv5": {
10
+ "s": "rating_safe",
11
+ "q": "rating_questionable",
12
+ "e": "rating_explicit"
13
+ },
14
+ "lpp": {
15
+ "s": "Safe",
16
+ "q": "Questionable",
17
+ "e": "Explicit"
18
+ }
19
+ },
20
+ "sort_params": {
21
+ "None": "",
22
+ "Chronological": "order:id",
23
+ "Score": "order:score",
24
+ "Faves": "order:favcount",
25
+ "Tag Count": "order:tagcount",
26
+ "Comments": "order:comment_count"
27
+ },
28
+ "filtered_tags": {
29
+ "meta": [
30
+ "webm",
31
+ "gif",
32
+ "animated",
33
+ "*animation",
34
+ "*_playtime",
35
+ "*_framerate",
36
+ "sound",
37
+ "no_sound",
38
+ "widescreen",
39
+ "*_filesize",
40
+ "voice_acted",
41
+ "loop",
42
+ "*signature",
43
+ "*watermark",
44
+ "artist_name",
45
+ "alpha_channel",
46
+ "1?:?",
47
+ "?:?",
48
+ "??:??",
49
+ "?:1?",
50
+ "20*",
51
+ "source_request",
52
+ "lol_comments",
53
+ "collaboration"
54
+ ],
55
+ "copyright": [
56
+ ],
57
+ "artist": [
58
+ "conditional_dnp",
59
+ "avoid_posting",
60
+ "unknown_artist",
61
+ "third-party_edit"
62
+ ],
63
+ "general": [
64
+ "transparent_background"
65
+ ]
66
+ }
67
+ }
lazy-pony-prompter/images/derpi_query.jpg ADDED
lazy-pony-prompter/images/ef-showcase.jpg ADDED

Git LFS Details

  • SHA256: 721ef59e74b4cee12a56ed697500b921f251a27f9d5d99f0b74a91207462aa0c
  • Pointer size: 132 Bytes
  • Size of remote file: 1.08 MB
lazy-pony-prompter/images/filters_editor.jpg ADDED
lazy-pony-prompter/images/lulu.png ADDED

Git LFS Details

  • SHA256: 297cc65877bc6ad5c17b5838ca6fa7cb6e6fb27b870bf1e0ca9ecde1ece3b160
  • Pointer size: 131 Bytes
  • Size of remote file: 981 kB
lazy-pony-prompter/images/pdv6xl-showcase.webp ADDED

Git LFS Details

  • SHA256: a15e3cea26517e6e32060803209c7672a5d18e38590cdef66d6bccaf9fdc43e7
  • Pointer size: 131 Bytes
  • Size of remote file: 616 kB
lazy-pony-prompter/images/prompts_manager.jpg ADDED
lazy-pony-prompter/install.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import launch
2
+ import os
3
+
4
+ req_file = os.path.join(
5
+ os.path.dirname(os.path.realpath(__file__)), "requirements.txt"
6
+ )
7
+
8
+ if __name__ == "__main__":
9
+ with open(req_file) as f:
10
+ for package in f:
11
+ try:
12
+ package = package.strip()
13
+ if not launch.is_installed(package):
14
+ launch.run_pip(
15
+ f"install {package}", f"lazy-pony-prompter: {package}"
16
+ )
17
+ except Exception as e:
18
+ print(e)
19
+ print(
20
+ f'Warning: Failed to install {package}.'
21
+ )
lazy-pony-prompter/lpp/data.py ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from abc import ABC, abstractmethod
2
+ from copy import deepcopy
3
+ from dataclasses import dataclass, fields, asdict
4
+ from lpp.log import get_logger
5
+ from os import path
6
+ import enum
7
+ import fnmatch
8
+ import pickle
9
+
10
+ logger = get_logger()
11
+
12
+
13
+ @dataclass
14
+ class TagData:
15
+ source: str
16
+ query: str
17
+ raw_tags: list
18
+ other_params: dict
19
+
20
+
21
+ @dataclass
22
+ class TagGroups:
23
+ character: list[str]
24
+ species: list[str]
25
+ rating: list[str]
26
+ artist: list[str]
27
+ general: list[str]
28
+ meta: list[str]
29
+
30
+ @classmethod
31
+ def get_categories(cls) -> list[str]:
32
+ return [x.name for x in fields(cls)]
33
+
34
+
35
+ class Models(enum.Enum):
36
+ PDV56 = "Pony Diffusion V5(.5)/V6"
37
+ EF = "EasyFluff"
38
+ SEAART = "SeaArt Furry v1.0"
39
+ ANIME = "Generic Anime"
40
+ NOOBAI = "NoobAI XL v1.0"
41
+
42
+ def get_default_template(model: str) -> str:
43
+ if model == Models.SEAART.value:
44
+ return "{species}, {character}, {artist}, {general}, {meta}"
45
+ if model == Models.ANIME.value:
46
+ return "{character}, {general}, {artist}, {meta}"
47
+ if model == Models.NOOBAI.value:
48
+ return "{character}, {meta}, {artist}, {species}, {general}"
49
+ return "{rating}, {character}, {species}, {artist}, {general}, {meta}"
50
+
51
+
52
+ class Ratings(enum.Enum):
53
+ SAFE = "Safe"
54
+ QUESTIONABLE = "Questionable"
55
+ EXPLICIT = "Explicit"
56
+
57
+
58
+ @dataclass
59
+ class FilterData:
60
+ substitutions: dict[str:str]
61
+ __patterns: dict[str:None] # ordered set emulation
62
+
63
+ @property
64
+ def patterns(self) -> list[str]:
65
+ return self.__patterns.keys()
66
+
67
+ @patterns.setter
68
+ def patterns(self, value: str) -> None:
69
+ self.__patterns = dict.fromkeys(value)
70
+
71
+ def __post_init__(self) -> None:
72
+ if self.__patterns is not dict:
73
+ self.__patterns = dict.fromkeys(self.__patterns)
74
+
75
+ def __str__(self) -> str:
76
+ s = [f"{k}||{v}" for k, v in self.substitutions.items()]
77
+ return "\n".join(s + list(self.patterns))
78
+
79
+ @staticmethod
80
+ def from_string(filter_string: str, sep: str = None):
81
+ lines = {l.strip() for l in filter_string.split(sep) if l}\
82
+ if sep else filter_string.splitlines()
83
+ return FilterData.from_list(lines)
84
+
85
+ @staticmethod
86
+ def from_list(filter_patterns: list[str]):
87
+ substitutions = {}
88
+ patterns = []
89
+ for p in filter_patterns:
90
+ if "||" in p:
91
+ pattern, substitution = p.split("||")[slice(2)]
92
+ substitutions[pattern] = substitution
93
+ else:
94
+ patterns.append(p)
95
+ return FilterData(substitutions, patterns)
96
+
97
+ @staticmethod
98
+ def merge(*filters):
99
+ substitutions = {}
100
+ patterns = []
101
+ for filter in filters:
102
+ substitutions = {**substitutions, **filter.substitutions}
103
+ patterns += filter.patterns
104
+ return FilterData(substitutions, patterns)
105
+
106
+ @staticmethod
107
+ def glob_match(term: str, *patterns: str) -> bool:
108
+ return any([fnmatch.fnmatch(term, x) for x in patterns])
109
+
110
+ def match_subst(self, term: str) -> str:
111
+ for pattern, substitution in self.substitutions.items():
112
+ if FilterData.glob_match(term, pattern):
113
+ return substitution
114
+ return None
115
+
116
+ def match(self, term: str) -> bool:
117
+ return FilterData.glob_match(term, *self.patterns)
118
+
119
+
120
+ # HACK: Since "TagData" and "FilterData" were moved to a new module, they won't
121
+ # be deserializable from old pickle files, so we need a workaround.
122
+ class RenameUnpickler(pickle.Unpickler):
123
+ def find_class(self, module, name):
124
+ renamed_module = module
125
+ if module == "lpp.utils" and (name == "TagData" or name == "FilterData"):
126
+ renamed_module = "lpp.data"
127
+
128
+ return super(RenameUnpickler, self).find_class(renamed_module, name)
129
+
130
+
131
+ class LppDataManager(ABC):
132
+ def __init__(self, cache_file: str, work_dir: str = "."):
133
+ self._cache_file = cache_file
134
+ self._work_dir: str = work_dir
135
+ self._data: dict[str:object] = self._load_cache()
136
+
137
+ def __getitem__(self, name: str) -> object:
138
+ if name not in self._data:
139
+ raise KeyError(f"No name '{name}' in cache")
140
+ return deepcopy(self._data[name])
141
+
142
+ def _load_cache(self) -> dict[str:object]:
143
+ cache_file = path.join(self._work_dir, self._cache_file)
144
+ if not path.exists(cache_file):
145
+ return {}
146
+
147
+ with open(cache_file, "rb") as f:
148
+ try:
149
+ return RenameUnpickler(f).load()
150
+ except Exception:
151
+ logger.exception(
152
+ "Failed to unpickle cache file", exc_info=True
153
+ )
154
+ return {}
155
+
156
+ def _dump_cache(self) -> None:
157
+ cache_file = path.join(self._work_dir, self._cache_file)
158
+ with open(cache_file, "wb") as f:
159
+ pickle.dump(self._data, f)
160
+
161
+ @abstractmethod
162
+ def save_item(self, name: str, data: object, *args) -> None:
163
+ pass
164
+
165
+ @abstractmethod
166
+ def export_data(self) -> dict[str:object]:
167
+ pass
168
+
169
+ @abstractmethod
170
+ def import_data(self, data: dict[str:object]) -> int:
171
+ pass
172
+
173
+ def get_item_names(self, selector: callable = None) -> list[str]:
174
+ if selector:
175
+ return [k for k, v in self._data.items() if selector(k, v)]
176
+ return list(self._data.keys())
177
+
178
+ def delete_item(self, name: str) -> None:
179
+ if name not in self._data:
180
+ raise KeyError(f"No name '{name}' in cache")
181
+ del self._data[name]
182
+ self._dump_cache()
183
+
184
+
185
+ class CacheManager(LppDataManager):
186
+ def __init__(self, work_dir: str = "."):
187
+ super().__init__("tag_cache.dat", work_dir)
188
+
189
+ def save_item(self,
190
+ name: str,
191
+ data: TagData,
192
+ filters: list[str] = None) -> None:
193
+ if not name:
194
+ raise ValueError("Empty \"name\" parameter")
195
+ new_item = deepcopy(data)
196
+ new_item.other_params["filters"] = deepcopy(filters) if filters else []
197
+
198
+ self._data[name] = new_item
199
+ self._dump_cache()
200
+
201
+ def export_data(self) -> dict[str:dict[str:object]]:
202
+ return {k: asdict(v) for k, v in self._data.items()}
203
+
204
+ def import_data(self, data: dict[str:dict[str:object]]) -> int:
205
+ success_count = 0
206
+ for name, item in data.items():
207
+ if name not in self._data:
208
+ self.save_item(name, TagData(**item))
209
+ success_count += 1
210
+ return success_count
211
+
212
+
213
+ class FiltersManager(LppDataManager):
214
+ def __init__(self, work_dir: str = "."):
215
+ super().__init__("filters.dat", work_dir)
216
+
217
+ def save_item(self, name: str, data: FilterData):
218
+ if not name:
219
+ raise ValueError("Empty \"name\" parameter")
220
+ new_item = deepcopy(data)
221
+ self._data[name] = new_item
222
+ self._dump_cache()
223
+
224
+ def export_data(self) -> dict[str:str]:
225
+ return {k: str(v) for k, v in self._data.items()}
226
+
227
+ def import_data(self, data: dict[str:str]) -> int:
228
+ success_count = 0
229
+ for name, item in data.items():
230
+ if name not in self._data:
231
+ self.save_item(name, FilterData.from_string(item))
232
+ success_count += 1
233
+ return success_count
lazy-pony-prompter/lpp/log.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from abc import ABC, abstractmethod
2
+ import logging
3
+
4
+ __logger = None
5
+
6
+
7
+ def __init_logger(level: int = logging.WARNING,
8
+ name: str = 'lpp') -> logging.Logger:
9
+ formatter = logging.Formatter(
10
+ "[LPP] %(levelname)s (%(module)s): %(message)s"
11
+ )
12
+
13
+ handler = logging.StreamHandler()
14
+ handler.setFormatter(formatter)
15
+
16
+ logger = logging.getLogger(name)
17
+ logger.addHandler(handler)
18
+ logger.setLevel(level)
19
+ logger.propagate = False
20
+ return logger
21
+
22
+
23
+ def get_logger() -> logging.Logger:
24
+ global __logger
25
+
26
+ if __logger:
27
+ return __logger
28
+ else:
29
+ __logger = __init_logger()
30
+ return __logger
31
+
32
+
33
+ class LppMessageService(ABC):
34
+ @abstractmethod
35
+ def info(self, message: str): pass
36
+
37
+ @abstractmethod
38
+ def warning(self, message: str): pass
39
+
40
+ @abstractmethod
41
+ def error(self, message: str): pass
42
+
43
+
44
+ class DefaultLppMessageService(LppMessageService):
45
+ logger = get_logger()
46
+
47
+ def info(self, message: str) -> None:
48
+ self.logger.info(message)
49
+
50
+ def warning(self, message: str) -> None:
51
+ self.logger.warning(message)
52
+
53
+ def error(self, message: str) -> None:
54
+ self.logger.error(message)
lazy-pony-prompter/lpp/prompts.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from lpp.sources.common import TagSourceBase, Tags
2
+ from lpp.sources.utils import get_sources
3
+ from lpp.data import TagData, Models, Ratings
4
+ from random import sample
5
+ import re
6
+
7
+
8
+ class Prompts:
9
+ def __init__(self, chosen_prompts: list[object], source: TagSourceBase):
10
+ self.__prompts = chosen_prompts
11
+ self.__source = source
12
+ self.__processed_tags = []
13
+ self.__processed_prompts = []
14
+
15
+ def apply_formatting(self, model: str):
16
+ source = self.__source
17
+ format_func = source.formatters[model]\
18
+ if model in source.supported_models\
19
+ else source.default_formatter
20
+ for raw_tags in self.__prompts:
21
+ self.__processed_tags.append(
22
+ Tags(format_func(raw_tags))
23
+ )
24
+ return self
25
+
26
+ def extra_tag_formatting(self, format_func: callable):
27
+ self.__processed_tags = [format_func(x) for x in self.__processed_tags]
28
+ return self
29
+
30
+ def __replace_tokens(self,
31
+ flat_groups: dict[str:str],
32
+ template: str) -> str:
33
+ result = template
34
+ for token, prompt_fragment in flat_groups.items():
35
+ result = result.replace(f"{{{token}}}", prompt_fragment)
36
+ return result
37
+
38
+ def apply_template(self, model: str, template: str = None, sep: str = ", "):
39
+ default_template = Models.get_default_template(model)
40
+ for flat_groups in [x.as_flat_groups() for x in self.__processed_tags]:
41
+ tokens = set(flat_groups.keys())
42
+ prompt = ""
43
+ if template:
44
+ if "{prompt}" in template:
45
+ for token in tokens:
46
+ template = template.replace(f"{{{token}}}", "")
47
+ template = template.replace("{prompt}", default_template)
48
+ prompt = self.__replace_tokens(flat_groups, template)
49
+ elif any(f"{{{x}}}" in template for x in tokens):
50
+ for token in tokens:
51
+ prompt = self.__replace_tokens(flat_groups, template)
52
+ else:
53
+ prompt = self.__replace_tokens(
54
+ flat_groups, sep.join([default_template, template])
55
+ )
56
+ else:
57
+ prompt = self.__replace_tokens(flat_groups, default_template)
58
+ self.__processed_prompts.append(prompt)
59
+ return self
60
+
61
+ def sanitize(self, rules: dict[str:str] = None):
62
+ if not rules:
63
+ rules = {
64
+ " +": " ",
65
+ r"(, )\1+": r"\1",
66
+ "^, +": "",
67
+ ", +$": ""
68
+ }
69
+ sanitized_prompts = []
70
+ for prompt in self.__processed_prompts:
71
+ for re_pattern, replacement in rules.items():
72
+ prompt = re.sub(re_pattern, replacement, prompt)
73
+ sanitized_prompts.append(prompt)
74
+ self.__processed_prompts = sanitized_prompts
75
+ return self
76
+
77
+ def as_list(self) -> list[str]:
78
+ return self.__processed_prompts
79
+
80
+ def first(self) -> str:
81
+ return self.__processed_prompts[0]
82
+
83
+
84
+ class PromptPool:
85
+ def __init__(self, tag_data: TagData, work_dir: str = "."):
86
+ self.__source = get_sources(work_dir)[tag_data.source]
87
+ self.tag_data = tag_data
88
+
89
+ def choose_prompts(self,
90
+ n: int = 1,
91
+ allowed_ratings: list[str] = None
92
+ ) -> Prompts:
93
+ if not self.tag_data:
94
+ raise ValueError("No prompts are currently loaded.")
95
+
96
+ raw_tags = self.tag_data.raw_tags
97
+ source = self.__source
98
+
99
+ if allowed_ratings and len(allowed_ratings) < len(Ratings):
100
+ raw_tags = [
101
+ x for x in raw_tags if (source.get_lpp_rating(x) in allowed_ratings)
102
+ ]
103
+ if len(raw_tags) == 0:
104
+ raise ValueError(
105
+ "Current collection doesn't seem to have prompts with selected rating(s)."
106
+ )
107
+
108
+ # manually handle requests for more images than we have tags
109
+ # because random.sample would raise a ValueError
110
+ if n > len(raw_tags):
111
+ factor = n // len(raw_tags) + 1 # +1 because // rounds down
112
+ raw_tags = raw_tags * factor
113
+ return Prompts(sample(raw_tags, k=n), self.__source)
114
+
115
+ @property
116
+ def prompts_count(self) -> int:
117
+ return len(self.tag_data.raw_tags)
lazy-pony-prompter/lpp/sources/__init__.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from os import listdir
2
+ from os.path import dirname, basename
3
+
4
+ __all__ = [
5
+ basename(f)[:-3] for f in listdir(dirname(__file__))
6
+ if f[-3:] == ".py"
7
+ and not f.endswith("__init__.py")
8
+ and f != "utils.py"
9
+ ]
lazy-pony-prompter/lpp/sources/common.py ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from lpp.log import get_logger
2
+ from abc import ABC, abstractmethod
3
+ from lpp.data import TagData, TagGroups, FilterData
4
+ from dataclasses import asdict
5
+ import requests
6
+ import os
7
+ import json
8
+
9
+
10
+ def formatter(model_name: str) -> callable:
11
+ def inner(func: callable) -> callable:
12
+ func.is_formatter = True
13
+ func.model_name = model_name
14
+ return func
15
+ return inner
16
+
17
+
18
+ def default_formatter(model_name: str) -> callable:
19
+ def inner(func: callable) -> callable:
20
+ func = formatter(model_name)(func)
21
+ func.is_default_formatter = True
22
+ return func
23
+ return inner
24
+
25
+
26
+ def attach_query_param(name: str, display_name: str) -> callable:
27
+ def inner(func: callable) -> callable:
28
+ func.attached_param = name
29
+ func.display_name = display_name
30
+ return func
31
+ return inner
32
+
33
+
34
+ class TagSourceBase(ABC):
35
+ def __init__(self,
36
+ syntax_help_url: str = "",
37
+ query_hint: str = "",
38
+ work_dir: str = "."):
39
+ self._work_dir: str = work_dir
40
+ self._logger = get_logger()
41
+ self.syntax_help_url = syntax_help_url
42
+ self.query_hint = query_hint
43
+ self.formatters: dict[str:callable] = {}
44
+ self.default_formatter: callable = None
45
+ self.extra_query_params: dict[str:callable] = {}
46
+ for attr in [x for x in dir(self) if not x.startswith("_")]:
47
+ obj = getattr(self, attr)
48
+ if hasattr(obj, "is_formatter"):
49
+ self.formatters[obj.model_name] = obj
50
+ if hasattr(obj, "is_default_formatter"):
51
+ self.default_formatter = obj
52
+ if hasattr(obj, "attached_param"):
53
+ self.extra_query_params[obj.attached_param] = obj
54
+
55
+ def _send_api_request(
56
+ self, endpoint: str, query_params: dict[str:str],
57
+ user_agent: str = "lazy-pony-prompter (by user Siberpone)/v1.1.x"
58
+ ) -> dict[str:object]:
59
+ TIMEOUTS = (9.1, 15.1)
60
+ req = requests.get(
61
+ endpoint,
62
+ query_params,
63
+ timeout=TIMEOUTS,
64
+ headers={"User-Agent": user_agent}
65
+ )
66
+ req.raise_for_status()
67
+ return req.json()
68
+
69
+ def _get_config(self) -> dict[str:object]:
70
+ name = self.__class__.__name__.lower()
71
+ config_file = os.path.join(self._work_dir, "config", f"{name}.json")
72
+ with open(config_file, encoding="utf-8") as f:
73
+ config_entry = json.load(f)
74
+ return config_entry
75
+
76
+ @property
77
+ def supported_models(self) -> list[str]:
78
+ return list(self.formatters.keys())
79
+
80
+ @abstractmethod
81
+ def get_lpp_rating(self, tag_data: TagData):
82
+ pass
83
+
84
+ @abstractmethod
85
+ def request_tags(self, query: str, count: int, *params: object) -> TagData:
86
+ pass
87
+
88
+ @abstractmethod
89
+ def _convert_raw_tags(self, raw_tags: list[object]) -> TagGroups:
90
+ pass
91
+
92
+
93
+ class Tags:
94
+ def __init__(self, tag_groups: TagGroups):
95
+ self.__tag_groups: dict[str:list[str]] = asdict(tag_groups)
96
+
97
+ def select(self, *groups: str):
98
+ self.__tag_groups = {
99
+ k: v if k in groups else [] for k, v in self.__tag_groups.items()
100
+ }
101
+ return self
102
+
103
+ def modify(self, modifier: callable, *groups: str):
104
+ if not groups:
105
+ groups = set(self.__tag_groups.keys())
106
+ for group in groups:
107
+ self.__tag_groups[group] = [
108
+ modifier(tag) for tag in self.__tag_groups[group]
109
+ ]
110
+ return self
111
+
112
+ def replace_underscores(self, replace: bool = True, exclude: list[str] = []):
113
+ if not replace:
114
+ return self
115
+ self.__tag_groups = {
116
+ k: [
117
+ x.replace("_", " ") if k not in exclude else x for x in v
118
+ ] for k, v in self.__tag_groups.items()
119
+ }
120
+ return self
121
+
122
+ def escape_parentheses(self, escape: bool = True):
123
+ if not escape:
124
+ return self
125
+ self.__tag_groups = {
126
+ k: [
127
+ x.replace("(", "\\(").replace(")", "\\)") for x in v
128
+ ] for k, v in self.__tag_groups.items()
129
+ }
130
+ return self
131
+
132
+ def filter(self, *filters: FilterData):
133
+ if not filters:
134
+ return self
135
+
136
+ filtered_tags = {}
137
+ joint_filter = FilterData.merge(*filters)
138
+ for group, tags in self.__tag_groups.items():
139
+ filtered_tags[group] = []
140
+ for tag in tags:
141
+ subst = joint_filter.match_subst(tag)
142
+ if subst:
143
+ filtered_tags[group].append(subst)
144
+ continue
145
+ if not joint_filter.match(tag):
146
+ filtered_tags[group].append(tag)
147
+ self.__tag_groups = filtered_tags
148
+ return self
149
+
150
+ def as_tag_groups(self):
151
+ return TagGroups(**self.__tag_groups)
152
+
153
+ def as_flat_groups(self, sep: str = ", "):
154
+ return {k: sep.join(v) for k, v in self.__tag_groups.items()}
lazy-pony-prompter/lpp/sources/danbooru.py ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from lpp.sources.common import TagSourceBase, Tags, formatter, default_formatter, attach_query_param
2
+ from lpp.data import TagData, TagGroups, Models, FilterData
3
+ from tqdm import trange
4
+ import re
5
+ import time
6
+
7
+
8
+ class Danbooru(TagSourceBase):
9
+ def __init__(self, work_dir: str = "."):
10
+ TagSourceBase.__init__(self,
11
+ "https://danbooru.donmai.us/wiki_pages/help%3Acheatsheet",
12
+ "Danbooru query or image URL",
13
+ work_dir)
14
+ config: dict[str:object] = self._get_config()
15
+ self.__ratings: dict[str:str] = config["ratings"]
16
+ self.__sort_params: dict[str:str] = config["sort_params"]
17
+ self.filter: FilterData = FilterData.from_list(
18
+ [x for cat in config["filtered_tags"].values() for x in cat]
19
+ )
20
+
21
+ @attach_query_param("rating", "Rating")
22
+ def get_ratings(self) -> list[str]:
23
+ return list(self.__ratings["lookup"].keys())
24
+
25
+ @attach_query_param("sort_type", "Sort by")
26
+ def get_sort_options(self) -> list[str]:
27
+ return list(self.__sort_params.keys())
28
+
29
+ def get_lpp_rating(self, raw_tags: dict[str:list[str]]) -> str:
30
+ return self.__ratings["lpp"][raw_tags["rating"]]
31
+
32
+ def request_tags(
33
+ self, query: str, count: int,
34
+ rating: str = None, sort_type: str = None
35
+ ) -> TagData:
36
+ ENDPOINT = "https://danbooru.donmai.us/posts.json"
37
+ PER_PAGE_MAX = 200
38
+ QUERY_DELAY = 0.1
39
+
40
+ image_id = re.search(
41
+ r"/^(?:https?:\/\/)?(?:danbooru\.donmai\.us\/posts\/)?(\d+)(\?.*)?$", query
42
+ )
43
+ if image_id:
44
+ query = f"id:{image_id.groups(0)[0]}"
45
+
46
+ p_rating = self.__ratings["lookup"][rating] if rating \
47
+ and rating in self.__ratings["lookup"] else None
48
+ p_sort = self.__sort_params[sort_type] if sort_type \
49
+ and sort_type in self.__sort_params else None
50
+ p_query = " ".join(x for x in [query, p_rating, p_sort] if x)
51
+ query_params = {
52
+ "tags": p_query,
53
+ "limit": count if count < PER_PAGE_MAX else PER_PAGE_MAX
54
+ }
55
+
56
+ posts = []
57
+ pages_to_load = (count // PER_PAGE_MAX) + \
58
+ (1 if count % PER_PAGE_MAX > 0 else 0)
59
+
60
+ for p in trange(1, pages_to_load + 1, desc="[LPP] Fetching tags"):
61
+ time.sleep(QUERY_DELAY)
62
+ query_params["page"] = p
63
+ json_response = self._send_api_request(ENDPOINT, query_params)
64
+ posts += json_response
65
+ if len(json_response) < PER_PAGE_MAX:
66
+ break
67
+
68
+ processed_response = []
69
+ for post in posts:
70
+ post_tags = {
71
+ "general": post["tag_string_general"].split(" "),
72
+ "artist": post["tag_string_artist"].split(" "),
73
+ "rating": post["rating"],
74
+ "character": post["tag_string_character"].split(" "),
75
+ "meta": post["tag_string_meta"].split(" ")
76
+ + post["tag_string_copyright"].split(" ")
77
+ }
78
+ processed_response.append(post_tags)
79
+ return TagData(
80
+ self.__class__.__name__,
81
+ p_query,
82
+ processed_response[:count],
83
+ {}
84
+ )
85
+
86
+ def _convert_raw_tags(self, raw_tags: dict[str:object]) -> TagGroups:
87
+ return TagGroups(species=[], **raw_tags)
88
+
89
+ @default_formatter(Models.ANIME.value)
90
+ def anime_format(self, raw_image_tags: dict[str:list[str]]) -> TagGroups:
91
+ return Tags(self._convert_raw_tags(raw_image_tags))\
92
+ .select("character", "artist", "general", "meta")\
93
+ .filter(self.filter)\
94
+ .replace_underscores()\
95
+ .as_tag_groups()
96
+
97
+ @formatter(f"{Models.ANIME.value} (keep underscores)")
98
+ def anime_underscores_format(self, raw_image_tags: dict[str:list[str]]) -> TagGroups:
99
+ return Tags(self._convert_raw_tags(raw_image_tags))\
100
+ .select("character", "artist", "general", "meta")\
101
+ .filter(self.filter)\
102
+ .as_tag_groups()
103
+
104
+ @formatter(Models.PDV56.value)
105
+ def pdv5_format(self, raw_image_tags: dict[str:list[str]]) -> TagGroups:
106
+ return Tags(self._convert_raw_tags(raw_image_tags))\
107
+ .select("character", "rating", "general", "meta")\
108
+ .modify(lambda x: self.__ratings["pdv5"][x], "rating")\
109
+ .filter(self.filter)\
110
+ .replace_underscores(exclude=["rating"])\
111
+ .as_tag_groups()
112
+
113
+ @formatter(Models.NOOBAI.value)
114
+ def noobai_fomat(self, raw_image_tags: dict[str:list[str]]) -> TagGroups:
115
+ return Tags(self._convert_raw_tags(raw_image_tags))\
116
+ .select("character", "general", "artist", "meta")\
117
+ .filter(self.filter)\
118
+ .replace_underscores()\
119
+ .as_tag_groups()
lazy-pony-prompter/lpp/sources/derpibooru.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from lpp.sources.common import TagSourceBase, Tags, formatter, default_formatter, attach_query_param
2
+ from lpp.data import TagData, TagGroups, Models, FilterData
3
+ from requests.exceptions import HTTPError, Timeout, ConnectionError, TooManyRedirects
4
+ from tqdm import trange
5
+ import time
6
+ import re
7
+
8
+
9
+ class Derpibooru(TagSourceBase):
10
+ def __init__(self, work_dir: str = "."):
11
+ TagSourceBase.__init__(self,
12
+ "https://derpibooru.org/pages/search_syntax",
13
+ "Derpibooru query or image URL",
14
+ work_dir)
15
+ self.__api_key = None
16
+ config = self._get_config()
17
+ self.__filter_ids = config["filter_ids"]
18
+ self.__sort_params = config["sort_params"]
19
+ self.__ratings = config["ratings"]
20
+ self.__character_tags = set(config["character_tags"])
21
+ self.__species_tags = set(config["species_tags"])
22
+ self.__meta_tags = set()
23
+ self.__meta_tags_glob = set()
24
+ for pattern in config["meta_tags"]:
25
+ if any(x in pattern for x in ["*", "[", "?"]):
26
+ self.__meta_tags_glob.add(pattern)
27
+ else:
28
+ self.__meta_tags.add(pattern)
29
+ self.filter = FilterData.from_list(config["filtered_tags"])
30
+
31
+ @attach_query_param("filter_type", "Derpibooru Filter")
32
+ def get_filters(self) -> list[str]:
33
+ return list(self.__filter_ids.keys())
34
+
35
+ @attach_query_param("sort_type", "Sort by")
36
+ def get_sort_options(self) -> list[str]:
37
+ return list(self.__sort_params.keys())
38
+
39
+ def get_lpp_rating(self, raw_tags: list[str]) -> str:
40
+ for tag in raw_tags:
41
+ if tag in self.__ratings["lpp"].keys():
42
+ return self.__ratings["lpp"][tag]
43
+ return "Unknown"
44
+
45
+ def request_tags(self,
46
+ query: str,
47
+ count: int,
48
+ filter_type: str = None,
49
+ sort_type: str = None) -> TagData:
50
+ ENDPOINT = "https://derpibooru.org/api/v1/json/search/images"
51
+ PER_PAGE_MAX = 50
52
+ QUERY_DELAY = 0.5
53
+
54
+ image_id = re.search(
55
+ r"^(?:https?:\/\/)?(?:derpibooru\.org\/images\/)?(\d+)(\?.*)?$", query
56
+ )
57
+ if image_id:
58
+ query = f"id:{image_id.groups(0)[0]}"
59
+
60
+ query_params = {
61
+ "q": query,
62
+ "per_page": PER_PAGE_MAX
63
+ }
64
+ if self.__api_key is not None:
65
+ query_params["key"] = self.__api_key
66
+ if filter_type is not None and filter_type in self.__filter_ids.keys():
67
+ query_params["filter_id"] = self.__filter_ids[filter_type]
68
+ if sort_type is not None and sort_type in self.__sort_params.keys():
69
+ query_params["sf"] = self.__sort_params[sort_type]
70
+
71
+ json_response = self._send_api_request(ENDPOINT, query_params)
72
+ response_total = json_response["total"]
73
+ items_total = count if count < response_total else response_total
74
+ pages_to_load = (items_total // PER_PAGE_MAX) + \
75
+ (1 if items_total % PER_PAGE_MAX > 0 else 0)
76
+
77
+ raw_tags = []
78
+ for p in trange(1, pages_to_load + 1, desc="[LPP] Fetching tags"):
79
+ time.sleep(QUERY_DELAY)
80
+ query_params["page"] = p
81
+ json_response = self._send_api_request(ENDPOINT, query_params)
82
+ raw_tags += [x["tags"] for x in json_response["images"]]
83
+
84
+ return TagData(
85
+ self.__class__.__name__,
86
+ query,
87
+ raw_tags[:items_total],
88
+ {
89
+ "filter_type": filter_type,
90
+ "sort_type": sort_type,
91
+ }
92
+ )
93
+
94
+ def _convert_raw_tags(self, raw_tags: list[str]) -> TagGroups:
95
+ sorted_tags = {k: [] for k in TagGroups.get_categories()}
96
+ for tag in raw_tags:
97
+ if tag in self.__ratings["pdv5"]:
98
+ sorted_tags["rating"].append(self.__ratings["pdv5"][tag])
99
+ continue
100
+ if tag in self.__character_tags or tag.startswith("oc:"):
101
+ sorted_tags["character"].append(tag)
102
+ continue
103
+ if tag in self.__species_tags:
104
+ sorted_tags["species"].append(tag)
105
+ continue
106
+ if (tag in self.__meta_tags
107
+ or FilterData.glob_match(tag, *self.__meta_tags_glob)):
108
+ sorted_tags["meta"].append(tag)
109
+ continue
110
+ if tag.startswith("artist:"):
111
+ sorted_tags["artist"].append(tag[7:])
112
+ continue
113
+ sorted_tags["general"].append(tag)
114
+ return TagGroups(**sorted_tags)
115
+
116
+ def set_api_key(self, key: str):
117
+ if not key:
118
+ return
119
+ self.__api_key = key
120
+ self.__fetch_user_filters()
121
+
122
+ def __fetch_user_filters(self) -> None:
123
+ self._logger.info("Attempting to fetch Derpibooru user filters...")
124
+ try:
125
+ json_response = self._send_api_request(
126
+ "https://derpibooru.org/api/v1/json/filters/user",
127
+ {"key": self.__api_key}
128
+ )
129
+
130
+ for filter in json_response["filters"]:
131
+ self.__filter_ids[filter["name"]] = filter["id"]
132
+ self._logger.info("Successfully fetched Derpibooru user filters.")
133
+ except (HTTPError, ConnectionError, TooManyRedirects):
134
+ self._logger.warning(
135
+ "Failed to fetch Derpibooru user filters due to connection issues."
136
+ )
137
+ except Timeout:
138
+ self._logger.warning(
139
+ "Failed to fetch Derpibooru filters due to connection timeout."
140
+ )
141
+ except Exception as e:
142
+ self._logger.debug(
143
+ f"Failed to fetch Derpibooru user filters ({e:=})"
144
+ )
145
+
146
+ @default_formatter(Models.PDV56.value)
147
+ def pdv5_format(self, raw_image_tags: list[str]) -> TagGroups:
148
+ return Tags(self._convert_raw_tags(raw_image_tags))\
149
+ .select("character", "species", "rating", "general", "meta")\
150
+ .filter(self.filter)\
151
+ .as_tag_groups()
152
+
153
+ @formatter(Models.EF.value)
154
+ def easyfluff_format(self, raw_image_tags: list[str]) -> TagGroups:
155
+ return Tags(self._convert_raw_tags(raw_image_tags))\
156
+ .select("character", "species", "artist", "general", "meta")\
157
+ .modify(lambda x: f"by {x}", "artist")\
158
+ .filter(self.filter)\
159
+ .as_tag_groups()
160
+
161
+ @formatter(f"{Models.EF.value} (no artist names)")
162
+ def easyfluff_no_artists_format(
163
+ self, raw_image_tags: list[str]
164
+ ) -> TagGroups:
165
+ return Tags(self._convert_raw_tags(raw_image_tags))\
166
+ .select("character", "species", "general", "meta")\
167
+ .filter(self.filter)\
168
+ .as_tag_groups()
lazy-pony-prompter/lpp/sources/e621.py ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from lpp.sources.common import TagSourceBase, Tags, formatter, default_formatter, attach_query_param
2
+ from lpp.data import TagData, TagGroups, Models, FilterData
3
+ from tqdm import trange
4
+ import re
5
+ import time
6
+
7
+
8
+ class E621(TagSourceBase):
9
+ def __init__(self, work_dir: str = "."):
10
+ TagSourceBase.__init__(self,
11
+ "https://e621.net/help/cheatsheet",
12
+ "E621 query or image URL",
13
+ work_dir)
14
+ config: dict[str:object] = self._get_config()
15
+ self.__ratings: dict[str:str] = config["ratings"]
16
+ self.__sort_params: dict[str:str] = config["sort_params"]
17
+ self.filter: FilterData = FilterData.from_list(
18
+ [x for cat in config["filtered_tags"].values() for x in cat]
19
+ )
20
+
21
+ @attach_query_param("rating", "Rating")
22
+ def get_ratings(self) -> list[str]:
23
+ return list(self.__ratings["lookup"].keys())
24
+
25
+ @attach_query_param("sort_type", "Sort by")
26
+ def get_sort_options(self) -> list[str]:
27
+ return list(self.__sort_params.keys())
28
+
29
+ def get_lpp_rating(self, raw_tags: dict[str:list[str]]) -> str:
30
+ return self.__ratings["lpp"][raw_tags["rating"]]
31
+
32
+ def request_tags(
33
+ self, query: str, count: int,
34
+ rating: str = None, sort_type: str = None
35
+ ) -> TagData:
36
+ ENDPOINT = "https://e621.net/posts.json"
37
+ PER_PAGE_MAX = 320
38
+ QUERY_DELAY = 1
39
+
40
+ image_id = re.search(
41
+ r"^(?:https?:\/\/)?(?:e621\.net\/posts\/)?(\d+)(\?.*)?$", query
42
+ )
43
+ if image_id:
44
+ query = f"id:{image_id.groups(0)[0]}"
45
+
46
+ p_rating = self.__ratings["lookup"][rating] if rating \
47
+ and rating in self.__ratings["lookup"] else None
48
+ p_sort = self.__sort_params[sort_type] if sort_type \
49
+ and sort_type in self.__sort_params else None
50
+ p_query = " ".join(x for x in [query, p_rating, p_sort] if x)
51
+ query_params = {
52
+ "tags": p_query,
53
+ "limit": count if count < PER_PAGE_MAX else PER_PAGE_MAX
54
+ }
55
+
56
+ raw_tags = []
57
+ pages_to_load = (count // PER_PAGE_MAX) + \
58
+ (1 if count % PER_PAGE_MAX > 0 else 0)
59
+
60
+ for p in trange(1, pages_to_load + 1, desc="[LPP] Fetching tags"):
61
+ time.sleep(QUERY_DELAY)
62
+ query_params["page"] = p
63
+ json_response = self._send_api_request(ENDPOINT, query_params)
64
+ posts = json_response["posts"]
65
+ for post in posts:
66
+ post["tags"]["rating"] = post["rating"]
67
+ raw_tags += posts
68
+ if len(posts) < PER_PAGE_MAX:
69
+ break
70
+
71
+ raw_tags = [x["tags"] for x in raw_tags]
72
+ return TagData(
73
+ self.__class__.__name__,
74
+ p_query,
75
+ raw_tags[:count],
76
+ {}
77
+ )
78
+
79
+ def _convert_raw_tags(self, raw_tags: dict[str:object]) -> TagGroups:
80
+ return TagGroups(
81
+ raw_tags["character"],
82
+ raw_tags["species"],
83
+ raw_tags["rating"],
84
+ raw_tags["artist"],
85
+ raw_tags["general"],
86
+ raw_tags["copyright"] + raw_tags["meta"]
87
+ )
88
+
89
+ @formatter(Models.PDV56.value)
90
+ def pdv5_format(self, raw_image_tags: dict[str:list[str]]) -> TagGroups:
91
+ return Tags(self._convert_raw_tags(raw_image_tags))\
92
+ .select("character", "rating", "species", "general", "meta")\
93
+ .modify(lambda x: self.__ratings["pdv5"][x], "rating")\
94
+ .filter(self.filter)\
95
+ .replace_underscores(exclude=["rating"])\
96
+ .as_tag_groups()
97
+
98
+ @default_formatter(Models.EF.value)
99
+ def easyfluff_format(
100
+ self, raw_image_tags: dict[str:list[str]]
101
+ ) -> TagGroups:
102
+ return Tags(self._convert_raw_tags(raw_image_tags))\
103
+ .select("character", "species", "general", "artist", "meta")\
104
+ .modify(lambda x: f"by {x}", "artist")\
105
+ .filter(self.filter)\
106
+ .replace_underscores()\
107
+ .as_tag_groups()
108
+
109
+ @formatter(f"{Models.EF.value} (no artist names)")
110
+ def easyfluff_no_artist_format(
111
+ self, raw_image_tags: dict[str:list[str]]
112
+ ) -> TagGroups:
113
+ return Tags(self._convert_raw_tags(raw_image_tags))\
114
+ .select("character", "species", "general", "meta")\
115
+ .filter(self.filter)\
116
+ .replace_underscores()\
117
+ .as_tag_groups()
118
+
119
+ @formatter(Models.SEAART.value)
120
+ def seaart_format(self, raw_image_tags: dict[str:list[str]]) -> TagGroups:
121
+ return Tags(self._convert_raw_tags(raw_image_tags))\
122
+ .select("character", "species", "general", "artist", "meta")\
123
+ .filter(self.filter)\
124
+ .as_tag_groups()
125
+
126
+ @formatter(Models.NOOBAI.value)
127
+ def noobai_fomat(self, raw_image_tags: dict[str:list[str]]) -> TagGroups:
128
+ return Tags(self._convert_raw_tags(raw_image_tags))\
129
+ .select("character", "species", "general", "artist", "meta")\
130
+ .filter(self.filter)\
131
+ .replace_underscores()\
132
+ .as_tag_groups()
lazy-pony-prompter/lpp/sources/utils.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from lpp.sources.common import TagSourceBase
2
+ from lpp.sources import *
3
+
4
+
5
+ def get_sources(work_dir: str = ".") -> dict[str:TagSourceBase]:
6
+ return {x.__name__: x(work_dir) for x in TagSourceBase.__subclasses__()}
lazy-pony-prompter/lpp/ui/a1111.py ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from lpp.prompts import PromptPool, Prompts
2
+ from lpp.data import TagData, FilterData, Ratings, CacheManager, FiltersManager
3
+ from lpp.log import get_logger, LppMessageService, DefaultLppMessageService
4
+ from lpp.sources.common import TagSourceBase
5
+ from lpp.sources.utils import get_sources
6
+ import json
7
+ import tempfile
8
+
9
+ logger = get_logger()
10
+
11
+
12
+ class LPP_A1111:
13
+ def __init__(self, work_dir: str = ".",
14
+ derpi_api_key: str = None,
15
+ logging_level: object = None,
16
+ messenger: LppMessageService = DefaultLppMessageService()):
17
+ self.__work_dir: str = work_dir
18
+ if logging_level:
19
+ logger.setLevel(logging_level)
20
+ self.__sources: dict[str:TagSourceBase] = get_sources(self.__work_dir)
21
+
22
+ # TODO: need better way of handling this
23
+ if "Derpibooru" in self.__sources.keys():
24
+ self.__sources["Derpibooru"].set_api_key(derpi_api_key)
25
+
26
+ self.__prompt_pool = None
27
+ self.__cache_manager: CacheManager = CacheManager(self.__work_dir)
28
+ self.__filters_manager: FiltersManager = FiltersManager(self.__work_dir)
29
+
30
+ self.__messenger = messenger
31
+ self.__collection_name = ""
32
+
33
+ @property
34
+ def source_names(self) -> list[str]:
35
+ return list(self.__sources.keys())
36
+
37
+ @property
38
+ def sources(self) -> dict[str:TagSourceBase]:
39
+ return self.__sources
40
+
41
+ @property
42
+ def tag_data(self) -> TagData:
43
+ return self.__prompt_pool.tag_data if self.__prompt_pool else None
44
+
45
+ @tag_data.setter
46
+ def tag_data(self, value: TagData) -> None:
47
+ self.__prompt_pool = PromptPool(value, self.__work_dir)
48
+
49
+ @property
50
+ def prompt_collections(self) -> list[str]:
51
+ return self.__cache_manager.get_item_names()
52
+
53
+ @property
54
+ def filters(self) -> list[str]:
55
+ return self.__filters_manager.get_item_names()
56
+
57
+ @property
58
+ def status(self) -> str:
59
+ n_prompts = self.__prompt_pool.prompts_count\
60
+ if self.__prompt_pool else 0
61
+ return f"\"{self.__collection_name}\" <b>[{n_prompts}]</b> ✅" \
62
+ if n_prompts > 0 \
63
+ else "No prompts loaded 🛑"
64
+
65
+ def __try_exec_command(
66
+ self, lpp_method: callable, success_msg: str,
67
+ failure_msg: str, *args: object
68
+ ) -> None:
69
+ try:
70
+ lpp_method(*args)
71
+ self.__messenger.info(success_msg)
72
+ except Exception as e:
73
+ self.__messenger.warning(
74
+ f"{failure_msg} {str(e)} ({type(e).__name__})"
75
+ )
76
+
77
+ def try_save_prompts(self, name: str, filters: list[str]) -> None:
78
+ self.__try_exec_command(
79
+ self.__cache_manager.save_item,
80
+ f"Successfully saved \"{name}\"",
81
+ f"Failed to save \"{name}\":",
82
+ name, self.tag_data, filters
83
+ )
84
+
85
+ def try_load_prompts(self, name: str) -> None:
86
+ def load_new_tag_data(name: str) -> None:
87
+ self.tag_data = self.__cache_manager[name]
88
+ self.__collection_name = name
89
+ self.__try_exec_command(
90
+ load_new_tag_data,
91
+ f"Successfully loaded \"{name}\"",
92
+ f"Failed to load \"{name}\":",
93
+ name
94
+ )
95
+
96
+ def try_delete_prompts(self, name: str) -> None:
97
+ self.__try_exec_command(
98
+ self.__cache_manager.delete_item,
99
+ f"Successfully deleted \"{name}\"",
100
+ f"Failed to delete \"{name}\":",
101
+ name
102
+ )
103
+
104
+ def try_save_filter(self, name: str, lpp_filter: FilterData) -> None:
105
+ self.__try_exec_command(
106
+ self.__filters_manager.save_item,
107
+ f"Successfully saved filter \"{name}\"",
108
+ f"Filed to save filter \"{name}\":",
109
+ name, lpp_filter
110
+ )
111
+
112
+ def try_load_filter(self, name: str) -> FilterData:
113
+ try:
114
+ f = self.__filters_manager[name]
115
+ self.__messenger.info(f"Successfully loaded filter \"{name}\"")
116
+ return f
117
+ except KeyError:
118
+ self.__messenger.warning(f"Failed to load filter \"{name}\":")
119
+ return None
120
+
121
+ def try_delete_filter(self, name: str) -> None:
122
+ self.__try_exec_command(
123
+ self.__filters_manager.delete_item,
124
+ f"Successfully deleted filter \"{name}\"",
125
+ f"Failed to delete filter \"{name}\":",
126
+ name
127
+ )
128
+
129
+ def get_filters(self, filter_names: str):
130
+ if not filter_names:
131
+ return []
132
+
133
+ filters = []
134
+ failed_filters = []
135
+ for f in filter_names:
136
+ if f in self.filters:
137
+ filters.append(self.__filters_manager[f])
138
+ else:
139
+ failed_filters.append(f)
140
+ if failed_filters:
141
+ self.__messenger.warning(f"Filed to load filters: {', '.join(failed_filters)}")
142
+ return filters
143
+
144
+ def try_send_request(self, source: str, *args: object) -> None:
145
+ def load_new_tag_data(*args: object) -> None:
146
+ self.tag_data = self.__sources[source].request_tags(*args)
147
+ self.__collection_name = "from query"
148
+ self.__try_exec_command(
149
+ load_new_tag_data,
150
+ f"Successfully fetched tags from \"{source}\"",
151
+ f"Failed to fetch tags from \"{source}\":",
152
+ *args
153
+ )
154
+
155
+ def try_get_tag_data_markdown(self, name: str) -> str:
156
+ try:
157
+ target = self.__cache_manager[name]
158
+ ratings = {
159
+ Ratings.SAFE.value: 0,
160
+ Ratings.QUESTIONABLE.value: 0,
161
+ Ratings.EXPLICIT.value: 0
162
+ }
163
+ source = self.__sources[target.source]
164
+ for item in target.raw_tags:
165
+ ratings[source.get_lpp_rating(item)] += 1
166
+ filter_str = "Filters: " +\
167
+ " ".join([f"`{x}`" for x in target.other_params["filters"]])
168
+ other_params = ", ".join(
169
+ [f"{k}: **{v}**" for k, v in target.other_params.items()
170
+ if k not in ["filters", "tag_filter"]]
171
+ )
172
+ main_info =\
173
+ f"""Source: **{target.source}** *({len(target.raw_tags)} total prompts)*
174
+
175
+ Safe: **{ratings[Ratings.SAFE.value]}** | Questionable: **{ratings[Ratings.QUESTIONABLE.value]}** | Explicit: **{ratings[Ratings.EXPLICIT.value]}**
176
+
177
+ ```
178
+ {target.query}
179
+ ```
180
+ """
181
+ return main_info + filter_str + "\n" + other_params
182
+ except KeyError:
183
+ return "no collection selected"
184
+
185
+ def try_choose_prompts(self,
186
+ n: int = 1,
187
+ allowed_ratings: list[str] = None,
188
+ ) -> Prompts:
189
+ try:
190
+ return self.__prompt_pool.choose_prompts(n, allowed_ratings)
191
+ # HACK: these should really be errors and not warnings, but effing
192
+ # A1111 or Gradio just refuses to display them. It is important to
193
+ # explicitly alert the user about these problems, so for now I'll
194
+ # leave it as is. Revisit this issue when A1111 updates.
195
+ except ValueError as e:
196
+ self.__messenger.warning(repr(e))
197
+ except Exception:
198
+ logger.exception("An error occured when trying to choose prompts.")
199
+
200
+ def try_export_json(self):
201
+ try:
202
+ payload = {
203
+ "version": "1.1.x",
204
+ "prompts": self.__cache_manager.export_data(),
205
+ "filters": self.__filters_manager.export_data()
206
+ }
207
+
208
+ with tempfile.NamedTemporaryFile(
209
+ "w+t", delete=False, suffix=".json"
210
+ ) as tmp:
211
+ json.dump(payload, tmp)
212
+ return tmp.name
213
+ except Exception:
214
+ logger.exception("An error occured when trying to export prompts.")
215
+
216
+ def try_import_json(self, temp_file_obj: str) -> None:
217
+ try:
218
+ with open(temp_file_obj.name, "r") as f:
219
+ data = json.load(f)
220
+ total_prompts = len(data["prompts"])
221
+ total_filters = len(data["filters"])
222
+ imported_prompts = self.__cache_manager.import_data(data["prompts"])
223
+ imported_filters = self.__filters_manager.import_data(data["filters"])
224
+ hint = " (some prompts/filters may have failed to import due to naming conflicts)"\
225
+ if total_prompts != imported_prompts or total_filters != imported_filters\
226
+ else ""
227
+ self.__messenger.info(
228
+ f"Imported {imported_prompts}/{total_prompts} prompts and {imported_filters}/{total_filters} filters{hint}"
229
+ )
230
+ return True
231
+
232
+ except Exception:
233
+ logger.exception("An error occured when trying to import prompts.")
234
+ return False
lazy-pony-prompter/lpp/ui/comfy.py ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import os.path as path
3
+ from copy import deepcopy
4
+
5
+ LPP_ROOT_DIR = path.join(path.dirname(__file__), "..", "..")
6
+ sys.path.append(LPP_ROOT_DIR)
7
+
8
+ from lpp.sources.common import TagSourceBase
9
+ from lpp.sources.derpibooru import Derpibooru
10
+ from lpp.sources.e621 import E621
11
+ from lpp.sources.danbooru import Danbooru
12
+ from lpp.sources.utils import get_sources
13
+ from lpp.prompts import PromptPool
14
+ from lpp.data import FilterData, CacheManager
15
+
16
+ lpp_sources = get_sources(LPP_ROOT_DIR)
17
+ cm = CacheManager(LPP_ROOT_DIR)
18
+
19
+
20
+ class ComfyTagSourceBase:
21
+ def __init__(self, source: TagSourceBase):
22
+ self._source: TagSourceBase = source
23
+ self._prompt_pool: PromptPool = None
24
+
25
+ SOURCE_NAME = ""
26
+
27
+ tag_source_input_types_base = {
28
+ "required": {
29
+ "query": ("STRING", {
30
+ "multiline": True
31
+ }),
32
+ "tag_filter": ("STRING", {
33
+ "multiline": False
34
+ }),
35
+ "count": ("INT", {
36
+ "default": 100,
37
+ "min": 5,
38
+ "max": 1500,
39
+ "step": 5,
40
+ "display": "slider"
41
+ }),
42
+ "send_request": ("BOOLEAN", {
43
+ "default": False
44
+ })
45
+ },
46
+ "optional": {
47
+ "prompt_template": ("STRING", {
48
+ "multiline": False
49
+ })
50
+ }
51
+ }
52
+
53
+ RETURN_TYPES = ("STRING", "LPP_TAG_DATA")
54
+ RETURN_NAMES = ("Prompt", "LPP Tag Data")
55
+ CATEGORY = "LPP/sources"
56
+ FUNCTION = "get_prompt"
57
+
58
+ def get_prompt(self,
59
+ format,
60
+ tag_filter,
61
+ send_request,
62
+ tag_data=None,
63
+ prompt_template="",
64
+ **query_args):
65
+ if tag_data:
66
+ self._prompt_pool = PromptPool(tag_data, LPP_ROOT_DIR)
67
+ elif not self._prompt_pool or send_request:
68
+ self._prompt_pool = PromptPool(
69
+ self._source.request_tags(**query_args),
70
+ LPP_ROOT_DIR
71
+ )
72
+ tf = FilterData.from_string(tag_filter, ",")
73
+ chosen_prompts = self._prompt_pool.choose_prompts(1, None)
74
+ prompt = chosen_prompts\
75
+ .apply_formatting(format)\
76
+ .extra_tag_formatting(
77
+ lambda x: x.filter(tf).escape_parentheses()
78
+ )\
79
+ .apply_template(format, prompt_template)\
80
+ .sanitize()\
81
+ .first()
82
+ return (prompt, (self._prompt_pool.tag_data, tf))
83
+
84
+ @classmethod
85
+ def IS_CHANGED(self, *args, **kwargs):
86
+ return float("NaN")
87
+
88
+ @classmethod
89
+ def INPUT_TYPES(cls):
90
+ types = deepcopy(cls.tag_source_input_types_base)
91
+ s = lpp_sources[cls.SOURCE_NAME]
92
+
93
+ for p, get_values_func in s.extra_query_params.items():
94
+ types["required"][p] = (get_values_func(),)
95
+ types["required"]["format"] = (s.supported_models,)
96
+ types["optional"]["tag_data"] = (f"LPP_TAG_DATA_{cls.SOURCE_NAME.upper()}",)
97
+ return types
98
+
99
+
100
+ class ComfyDerpibooru(ComfyTagSourceBase):
101
+ SOURCE_NAME = Derpibooru.__name__
102
+
103
+ def __init__(self):
104
+ ComfyTagSourceBase.__init__(self, Derpibooru(LPP_ROOT_DIR))
105
+
106
+
107
+ class ComfyE621(ComfyTagSourceBase):
108
+ SOURCE_NAME = E621.__name__
109
+
110
+ def __init__(self):
111
+ ComfyTagSourceBase.__init__(self, E621(LPP_ROOT_DIR))
112
+
113
+
114
+ class ComfyDanbooru(ComfyTagSourceBase):
115
+ SOURCE_NAME = Danbooru.__name__
116
+
117
+ def __init__(self):
118
+ ComfyTagSourceBase.__init__(self, Danbooru(LPP_ROOT_DIR))
119
+
120
+
121
+ class LPPSaver:
122
+ @classmethod
123
+ def INPUT_TYPES(self):
124
+ return {
125
+ "required": {
126
+ "tag_data": ("LPP_TAG_DATA",),
127
+ "name": ("STRING", {
128
+ "multiline": False,
129
+ }),
130
+ "overwrite": ("BOOLEAN", {
131
+ "default": False
132
+ })
133
+ }
134
+ }
135
+ RETURN_TYPES = ()
136
+ CATEGORY = "LPP"
137
+ FUNCTION = "save_tag_data"
138
+ OUTPUT_NODE = True
139
+
140
+ def save_tag_data(self, tag_data, name, overwrite):
141
+ existing_names = cm.get_item_names()
142
+ if (name in existing_names and overwrite) \
143
+ or name not in existing_names:
144
+ cm.save_item(name, tag_data[0])
145
+ return {}
146
+
147
+
148
+ class LPPLoaderBase:
149
+ SOURCE_NAME = ""
150
+
151
+ @classmethod
152
+ def INPUT_TYPES(cls):
153
+ return {
154
+ "required": {
155
+ "collection_name": (
156
+ cm.get_item_names(lambda k, v: (v.source == cls.SOURCE_NAME)),
157
+ )
158
+ }
159
+ }
160
+ RETURN_NAMES = ("tag data",)
161
+ CATEGORY = "LPP/loaders"
162
+ FUNCTION = "load_tag_data"
163
+
164
+ def load_tag_data(self, collection_name):
165
+ return (cm[collection_name],)
166
+
167
+
168
+ class LPPLoaderDerpibooru(LPPLoaderBase):
169
+ SOURCE_NAME = Derpibooru.__name__
170
+ RETURN_TYPES = (f"LPP_TAG_DATA_{SOURCE_NAME.upper()}",)
171
+
172
+
173
+ class LPPLoaderE621(LPPLoaderBase):
174
+ SOURCE_NAME = E621.__name__
175
+ RETURN_TYPES = (f"LPP_TAG_DATA_{SOURCE_NAME.upper()}",)
176
+
177
+
178
+ class LPPLoaderDanbooru(LPPLoaderBase):
179
+ SOURCE_NAME = Danbooru.__name__
180
+ RETURN_TYPES = (f"LPP_TAG_DATA_{SOURCE_NAME.upper()}",)
181
+
182
+
183
+ class LPPDeleter:
184
+ @classmethod
185
+ def INPUT_TYPES(self):
186
+ return {
187
+ "required": {
188
+ "collection_name": (cm.get_item_names(),)
189
+ }
190
+ }
191
+ RETURN_TYPES = ()
192
+ CATEGORY = "LPP"
193
+ FUNCTION = "delete_tag_data"
194
+ OUTPUT_NODE = True
195
+
196
+ def delete_tag_data(self, collection_name):
197
+ cm.delete_item(collection_name)
198
+ return {}
lazy-pony-prompter/pyproject.toml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "lazy-pony-prompter"
3
+ description = "A booru API powered prompt generator for A1111 and ComfyUI with flexible tag filtering system and customizable prompt templates."
4
+ version = "1.1.2"
5
+ license = { file = "LICENSE" }
6
+ dependencies = ["tqdm", "requests"]
7
+
8
+ [project.urls]
9
+ Repository = "https://github.com/Siberpone/lazy-pony-prompter"
10
+ # Used by Comfy Registry https://comfyregistry.org
11
+
12
+ [tool.comfy]
13
+ PublisherId = "siberpone"
14
+ DisplayName = "lazy-pony-prompter"
15
+ Icon = ""
lazy-pony-prompter/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ tqdm
2
+ requests
lazy-pony-prompter/scripts/lpp_extension.py ADDED
@@ -0,0 +1,681 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from lpp.ui.a1111 import LPP_A1111
2
+ from lpp.data import Models, FilterData, Ratings
3
+ from lpp.log import DefaultLppMessageService
4
+ from dataclasses import dataclass
5
+ from modules import scripts
6
+ from modules import shared
7
+ from modules import script_callbacks
8
+ from modules.ui_components import InputAccordion, FormRow, FormColumn, FormGroup, ToolButton
9
+ import gradio as gr
10
+ import logging
11
+
12
+ base_dir = scripts.basedir()
13
+
14
+
15
+ def set_no_config(*args: object) -> None:
16
+ for control in args:
17
+ setattr(control, "do_not_save_to_config", True)
18
+
19
+
20
+ def get_opt(option, default):
21
+ return getattr(shared.opts, option, default)
22
+
23
+
24
+ saved_prompt_collections = []
25
+
26
+
27
+ def refresh_saved_collections():
28
+ global saved_prompt_collections
29
+ saved_prompt_collections = ["None"] + lpp.prompt_collections
30
+
31
+
32
+ def on_ui_settings():
33
+ LPP_SECTION = ("lpp", "Lazy Pony Prompter")
34
+
35
+ lpp_options = {
36
+ "lpp_default_collection":
37
+ # TODO: try to fix this later.
38
+ # "allow_custom_value" bugs out UI, so had to go with a constant
39
+ # value indicating not to load anything on startup
40
+ shared.OptionInfo(
41
+ "None",
42
+ "Load this collection on startup",
43
+ gr.Dropdown,
44
+ lambda: {"choices": ["None"] + lpp.prompt_collections},
45
+ refresh=refresh_saved_collections
46
+ ),
47
+ "lpp_logging_level":
48
+ shared.OptionInfo(
49
+ logging.WARNING,
50
+ "Console nagging level",
51
+ gr.Radio,
52
+ {"choices": [
53
+ ("Error", logging.ERROR),
54
+ ("Warning", logging.WARNING),
55
+ ("Info", logging.INFO),
56
+ ("Debug", logging.DEBUG)]
57
+ }
58
+ ).needs_reload_ui(),
59
+ "lpp_derpibooru_api_key":
60
+ shared.OptionInfo("",
61
+ "Derpibooru API Key",
62
+ gr.Textbox,
63
+ {"interactive": True, "type": "password"}
64
+ ).needs_reload_ui(),
65
+ "lpp_editors_count":
66
+ shared.OptionInfo(3,
67
+ "Number of filter editor panels",
68
+ gr.Number,
69
+ {"precision": 0, "minimum": 1, "maximum": 8}
70
+ ).needs_reload_ui()
71
+ }
72
+
73
+ for key, opt in lpp_options.items():
74
+ opt.section = LPP_SECTION
75
+ shared.opts.add_option(key, opt)
76
+
77
+
78
+ script_callbacks.on_ui_settings(on_ui_settings)
79
+
80
+
81
+ class A1111LppMessageService(DefaultLppMessageService):
82
+ def __init__(self):
83
+ def modal_decorator(func, modal_func):
84
+ def inner(message):
85
+ func(self, message)
86
+ modal_func(f"[LPP] {message}")
87
+ return inner
88
+ self.info = modal_decorator(super().info.__func__, gr.Info)
89
+ self.warning = modal_decorator(super().warning.__func__, gr.Warning)
90
+ self.error = modal_decorator(super().error.__func__, gr.Error)
91
+
92
+
93
+ lpp: LPP_A1111 = LPP_A1111(
94
+ base_dir,
95
+ get_opt("lpp_derpibooru_api_key", None),
96
+ get_opt("lpp_logging_level", None),
97
+ A1111LppMessageService()
98
+ )
99
+
100
+
101
+ class ConfirmationDialog:
102
+ def __init__(self, gradio_upd_func, gradio_outputs):
103
+ def action_decorator(func):
104
+ def inner():
105
+ self.__action()
106
+ ret = func(*self.__gradio_upd_func_args)
107
+ return (*ret, gr.update(visible=False))
108
+ return inner
109
+ self.__gradio_upd_func = action_decorator(gradio_upd_func)
110
+ self.__gradio_outputs = gradio_outputs
111
+
112
+ def set_action(self, action, *args):
113
+ self.__action = action
114
+ self.__gradio_upd_func_args = args
115
+
116
+ def ui(self):
117
+ with FormRow(variant="panel", visible=False) as dialog:
118
+ self.dialog = dialog
119
+ with FormColumn():
120
+ with FormRow():
121
+ self.msg = gr.Markdown()
122
+ with FormRow():
123
+ self.confirm_btn = gr.Button("Confirm", variant="stop")
124
+ self.cancel_btn = gr.Button("Cancel")
125
+ self.confirm_btn.click(
126
+ self.__gradio_upd_func,
127
+ None,
128
+ self.__gradio_outputs + [self.dialog],
129
+ show_progress="hidden"
130
+ )
131
+ self.cancel_btn.click(
132
+ lambda: gr.update(visible=False),
133
+ None,
134
+ [self.dialog],
135
+ show_progress="hidden"
136
+ )
137
+ return self.dialog, self.msg
138
+
139
+
140
+ class FilterEditor:
141
+ external_inputs = [] # ui components to update when saving a filter
142
+
143
+ def __init__(self):
144
+ self.current_text = ""
145
+
146
+ def ui(self):
147
+ with FormColumn(variant="panel", scale=1, min_width=300):
148
+ with FormRow():
149
+ self.filter_name = gr.Dropdown(
150
+ label="Choose a filter to edit:",
151
+ choices=lpp.filters
152
+ )
153
+ self.save_btn = ToolButton("💾")
154
+ self.refresh_btn = ToolButton("🗘")
155
+ with FormRow():
156
+ self.patterns_textarea = gr.Textbox(
157
+ label="Filter Patterns",
158
+ interactive=True,
159
+ lines=7,
160
+ max_lines=15
161
+ )
162
+
163
+ set_no_config(self.filter_name, self.patterns_textarea)
164
+
165
+ def filter_name_change(name):
166
+ filter_text = str(lpp.try_load_filter(name))
167
+ self.current_text = filter_text
168
+ return gr.update(value=filter_text)
169
+
170
+ self.filter_name.change(
171
+ filter_name_change,
172
+ [self.filter_name],
173
+ [self.patterns_textarea],
174
+ show_progress="hidden"
175
+ )
176
+
177
+ self.patterns_textarea.change(
178
+ lambda p: gr.update(label="Filter Patterns *(unsaved)")
179
+ if self.current_text != p else gr.update(label="Filter Patterns"),
180
+ [self.patterns_textarea],
181
+ [self.patterns_textarea],
182
+ show_progress="hidden"
183
+ )
184
+
185
+ def save_btn_click(name, patterns):
186
+ self.current_text = patterns
187
+ lpp.try_save_filter(name, FilterData.from_string(patterns))
188
+ return [gr.update(label="Filter Patterns")]\
189
+ + [gr.update(choices=lpp.filters)]\
190
+ * len(FilterEditor.external_inputs)
191
+
192
+ self.save_btn.click(
193
+ save_btn_click,
194
+ [self.filter_name, self.patterns_textarea],
195
+ [self.patterns_textarea, *FilterEditor.external_inputs],
196
+ show_progress="hidden"
197
+ )
198
+
199
+ self.refresh_btn.click(
200
+ lambda: gr.update(choices=lpp.filters),
201
+ [],
202
+ [self.filter_name],
203
+ show_progress="hidden"
204
+ )
205
+
206
+
207
+ @dataclass
208
+ class QueryPanel:
209
+ panel: gr.Group
210
+ send_btn: gr.Button
211
+ params: list[object]
212
+
213
+
214
+ def get_query_panels(active_panel_name: str):
215
+ panels = {}
216
+ for name, source in lpp.sources.items():
217
+ with FormGroup(
218
+ visible=(active_panel_name == name)
219
+ ) as panel:
220
+ gr.Markdown(
221
+ f"[🔗 {name} Syntax Help]({source.syntax_help_url})")
222
+ with FormRow():
223
+ query = gr.Textbox(
224
+ placeholder=source.query_hint,
225
+ show_label=False
226
+ )
227
+ with FormRow():
228
+ with FormColumn():
229
+ prompts_count = gr.Slider(
230
+ label="Number of Prompts to Load",
231
+ minimum=5,
232
+ maximum=1500,
233
+ step=5,
234
+ value=100
235
+ )
236
+ with FormColumn():
237
+ with FormRow():
238
+ extra_controls = []
239
+ for p, get_values_func in source.extra_query_params.items():
240
+ control = gr.Dropdown(
241
+ label=get_values_func.display_name,
242
+ choices=get_values_func(),
243
+ value=get_values_func()[0]
244
+ )
245
+ extra_controls.append(control)
246
+ with FormRow():
247
+ send_btn = gr.Button(value="Send")
248
+ controls = [query, prompts_count] + extra_controls
249
+ set_no_config(*controls)
250
+ panels[name] = QueryPanel(panel, send_btn, controls)
251
+ return panels
252
+
253
+
254
+ class Scripts(scripts.Script):
255
+ def __init__(self):
256
+ self.query_panels = {}
257
+ self.prompt_info_visible = False
258
+
259
+ startup_collection = get_opt("lpp_default_collection", "None")
260
+ if startup_collection != "None":
261
+ lpp.try_load_prompts(startup_collection)
262
+
263
+ def title(self):
264
+ return "Lazy Pony Prompter"
265
+
266
+ def show(self, is_img2img):
267
+ return scripts.AlwaysVisible
268
+
269
+ def ui(self, is_img2img):
270
+ with InputAccordion(
271
+ value=False,
272
+ label="💤 Lazy Pony Prompter",) as lpp_enable:
273
+ with lpp_enable.extra():
274
+ status_bar = gr.HTML(lpp.status, elem_id="lpp-status-bar")
275
+
276
+ # Prompts Manager #################################################
277
+ with gr.Tab("Prompts Manager"):
278
+ with FormRow():
279
+ # Prompt Collections Management Panel ---------------------
280
+ with FormColumn():
281
+ with FormRow():
282
+ prompts_manager_input = gr.Dropdown(
283
+ label="Prompts Collection Name",
284
+ choices=lpp.prompt_collections,
285
+ allow_custom_value=True
286
+ )
287
+ prompts_info_btn = ToolButton("📋")
288
+ save_prompts_btn = ToolButton("💾")
289
+ load_prompts_btn = ToolButton("📤")
290
+ delete_prompts_btn = ToolButton("❌")
291
+
292
+ prompts_manager_metadata = gr.Markdown(
293
+ label="Prompts Info",
294
+ show_label=True,
295
+ render=False
296
+ )
297
+ pm_dialog = ConfirmationDialog(
298
+ lambda name: [
299
+ gr.Dropdown.update(
300
+ choices=lpp.prompt_collections,
301
+ value=name
302
+ ),
303
+ gr.update(
304
+ value=lpp.try_get_tag_data_markdown(name)
305
+ )
306
+ ],
307
+ [prompts_manager_input, prompts_manager_metadata]
308
+ )
309
+ pm_dialog_panel, pm_dialog_msg = pm_dialog.ui()
310
+
311
+ with FormRow(visible=False, variant="panel") as prompts_info_panel:
312
+ prompts_manager_metadata.render()
313
+ with FormRow():
314
+ models = ["Auto"]
315
+ if lpp.tag_data:
316
+ source = lpp.sources[lpp.tag_data.source]
317
+ models += source.supported_models
318
+
319
+ prompts_format = gr.Dropdown(
320
+ label="Prompts Format",
321
+ choices=models,
322
+ value="Auto",
323
+ scale=8
324
+ )
325
+ autofill_tags_filter = gr.Checkbox(
326
+ label="Autoload Filters",
327
+ value=True,
328
+ elem_id="lpp-autofill-filter-chbox",
329
+ scale=2,
330
+ min_width=120
331
+ )
332
+ # Booru Query & Promts Info Panels --------------------
333
+ with FormRow(variant="panel", elem_id="lpp-query-panel"):
334
+ with gr.Accordion(
335
+ label="💬 Get prompts from Booru",
336
+ open=False
337
+ ):
338
+ source = gr.Radio(
339
+ label="Tags Source",
340
+ choices=lpp.source_names,
341
+ value=lambda: lpp.source_names[0],
342
+ elem_id="lpp-chbox-group"
343
+ )
344
+ self.query_panels = get_query_panels(source.value)
345
+
346
+ # Filtering Options Panel ---------------------------------
347
+ with FormColumn():
348
+ with FormRow():
349
+ quick_filter = gr.Textbox(
350
+ label="Quick Filter",
351
+ lines=1,
352
+ max_lines=1,
353
+ interactive=True,
354
+ placeholder="Type in comma-separated patterns here to filter them out"
355
+ )
356
+ clear_qfilter_btn = ToolButton("🧹")
357
+ with FormRow():
358
+ filters = gr.Dropdown(
359
+ label="Filters",
360
+ choices=lpp.filters,
361
+ multiselect=True
362
+ )
363
+ with FormRow():
364
+ rating_filter = gr.CheckboxGroup(
365
+ label="Rating Filter",
366
+ choices=[x.value for x in Ratings],
367
+ value="Safe",
368
+ elem_id="lpp-chbox-group"
369
+ )
370
+
371
+ # Filter Editor ###################################################
372
+ with gr.Tab("Filter Editor"):
373
+ with FormRow():
374
+ # Filter Managment Panel ----------------------------------
375
+ with FormColumn(scale=1, min_width=300):
376
+ with FormRow():
377
+ fe_filter_name = gr.Dropdown(
378
+ label="Create or delete a filter:",
379
+ choices=lpp.filters,
380
+ allow_custom_value=True
381
+ )
382
+ fe_save_btn = ToolButton("✨")
383
+ fe_delete_btn = ToolButton("❌", visible=False)
384
+ fe_dialog = ConfirmationDialog(
385
+ lambda name: [
386
+ gr.Dropdown.update(choices=lpp.filters),
387
+ gr.Dropdown.update(
388
+ value=name, choices=lpp.filters
389
+ ),
390
+ gr.Button.update(visible=True),
391
+ gr.Button.update(visible=False)
392
+ ],
393
+ [filters, fe_filter_name, fe_save_btn, fe_delete_btn]
394
+ )
395
+ fe_dialog_panel, fe_dialog_msg = fe_dialog.ui()
396
+ with FormRow():
397
+ import_export_panel = gr.File(
398
+ label="Prompts & filters import/export",
399
+ file_count="single",
400
+ file_types=[".json"],
401
+ interactive=True,
402
+ )
403
+
404
+ with FormRow():
405
+ export_btn = gr.Button(
406
+ value="Export Prompts and Filters"
407
+ )
408
+ with FormRow():
409
+ with gr.Accordion("cheatsheet", open=False):
410
+ gr.Markdown(r"""
411
+ * patterns are separated with new lines
412
+ * patterns support simple globbing
413
+ * `*` matches anything
414
+ * `?` matches any single character
415
+ * `[xyz]` matches specified characters
416
+ * `[A-Z]` matches a range of characters
417
+ * you can specify a substitution for a pattern with `||`, for example:
418
+ `horn||wings` will substitute "horn" with "wings"
419
+ """)
420
+
421
+ # Filter Editors ------------------------------------------
422
+ FilterEditor.external_inputs += [filters, fe_filter_name]
423
+ filter_editors = []
424
+ for i in range(get_opt("lpp_editors_count", 3)):
425
+ filter_editors.append(FilterEditor())
426
+ filter_editors[i].ui()
427
+
428
+ # A1111 will cache ui control values in ui_config.json and "freeze"
429
+ # them without this attribute.
430
+ set_no_config(source, prompts_format, prompts_manager_input,
431
+ filters, fe_filter_name)
432
+
433
+ # Prompt Manager Event Handlers ###################################
434
+ # Send Query Buttons
435
+ def send_request_click(source, prompts_format, *params):
436
+ models = ["Auto"] + lpp.sources[source].supported_models
437
+ lpp.try_send_request(source, *params)
438
+ return (
439
+ lpp.status,
440
+ gr.update(
441
+ choices=models,
442
+ value=prompts_format if prompts_format in models
443
+ else models[0]
444
+ )
445
+ )
446
+
447
+ for panel in self.query_panels.values():
448
+ panel.send_btn.click(
449
+ send_request_click,
450
+ [source, prompts_format, *panel.params],
451
+ [status_bar, prompts_format],
452
+ show_progress="full"
453
+ )
454
+
455
+ # Source Radio Change
456
+ source.change(
457
+ lambda s: [
458
+ gr.update(
459
+ visible=(s == x)
460
+ ) for x in self.query_panels.keys()
461
+ ],
462
+ [source],
463
+ [x.panel for x in self.query_panels.values()],
464
+ show_progress="hidden"
465
+ )
466
+
467
+ # Prompts Info Button Click
468
+ def prompts_info_click():
469
+ self.prompt_info_visible = not self.prompt_info_visible
470
+ variant = "primary" if self.prompt_info_visible else "secondary"
471
+ return (
472
+ gr.update(visible=self.prompt_info_visible),
473
+ gr.update(variant=variant)
474
+ )
475
+
476
+ prompts_info_btn.click(
477
+ prompts_info_click,
478
+ [],
479
+ [prompts_info_panel, prompts_info_btn],
480
+ show_progress="hidden"
481
+ )
482
+
483
+ # Save Button Click
484
+ def save_prompts_click(name, filters):
485
+ pm_dialog.set_action(
486
+ lambda: lpp.try_save_prompts(name, filters),
487
+ name
488
+ )
489
+ if name in lpp.prompt_collections:
490
+ return (
491
+ gr.update(),
492
+ gr.update(),
493
+ f"Are you sure you want to overwrite \"{name}\"?",
494
+ gr.update(visible=True)
495
+ )
496
+ else:
497
+ lpp.try_save_prompts(name, filters)
498
+ return (
499
+ gr.Dropdown.update(
500
+ choices=lpp.prompt_collections
501
+ ),
502
+ gr.update(value=lpp.try_get_tag_data_markdown(name)),
503
+ "", gr.update(visible=False)
504
+ )
505
+
506
+ save_prompts_btn.click(
507
+ save_prompts_click,
508
+ [prompts_manager_input, filters],
509
+ [prompts_manager_input, prompts_manager_metadata,
510
+ pm_dialog_msg, pm_dialog_panel],
511
+ show_progress="hidden"
512
+ )
513
+
514
+ # Load Button Click
515
+ def load_prompts_click(name, autofill_tags_filter, current_model):
516
+ lpp.try_load_prompts(name)
517
+ filters_update = gr.update()
518
+ if lpp.tag_data:
519
+ source = lpp.tag_data.source
520
+ models = ["Auto"] + lpp.sources[source].supported_models
521
+ models_update = gr.update(
522
+ choices=models,
523
+ value=current_model if current_model in models
524
+ else models[0]
525
+ )
526
+
527
+ params = lpp.tag_data.other_params
528
+ if "filters" in params and params["filters"] and autofill_tags_filter:
529
+ filters_update = gr.update(value=params["filters"])
530
+ else:
531
+ models_update = gr.update()
532
+
533
+ return (
534
+ lpp.status,
535
+ filters_update,
536
+ models_update
537
+ )
538
+ load_prompts_btn.click(
539
+ load_prompts_click,
540
+ [prompts_manager_input, autofill_tags_filter, prompts_format],
541
+ [status_bar, filters, prompts_format],
542
+ show_progress="hidden"
543
+ )
544
+
545
+ # Delete Button Click
546
+ def delete_click(name):
547
+ pm_dialog.set_action(lambda: lpp.try_delete_prompts(name), "")
548
+ return (f"Are you sure you want to delete \"{name}\"?",
549
+ gr.update(visible=True))
550
+
551
+ delete_prompts_btn.click(
552
+ delete_click,
553
+ [prompts_manager_input],
554
+ [pm_dialog_msg, pm_dialog_panel],
555
+ show_progress="hidden"
556
+ )
557
+
558
+ # Load Prompts Dropdown Change
559
+ prompts_manager_input.change(
560
+ lambda n: lpp.try_get_tag_data_markdown(n),
561
+ [prompts_manager_input],
562
+ [prompts_manager_metadata],
563
+ show_progress="hidden"
564
+ )
565
+
566
+ # Quick Filter Button
567
+ clear_qfilter_btn.click(
568
+ lambda: gr.update(value=""),
569
+ [],
570
+ [quick_filter],
571
+ show_progress="hidden"
572
+ )
573
+
574
+ # Filters Editor Event Handlers ###################################
575
+ # Filter Name Dropdown Change -------------------------------------
576
+ fe_filter_name.change(
577
+ lambda n: (gr.update(visible=False), gr.update(visible=True))
578
+ if n in lpp.filters
579
+ else (gr.update(visible=True), gr.update(visible=False)),
580
+ [fe_filter_name],
581
+ [fe_save_btn, fe_delete_btn]
582
+ )
583
+
584
+ # Save Button -----------------------------------------------------
585
+ def fe_save_click(name: str):
586
+ lpp.try_save_filter(name, FilterData.from_string(""))
587
+ return (
588
+ gr.update(choices=lpp.filters),
589
+ gr.update(choices=lpp.filters),
590
+ gr.update(visible=False),
591
+ gr.update(visible=True)
592
+ )
593
+
594
+ fe_save_btn.click(
595
+ fe_save_click,
596
+ [fe_filter_name],
597
+ [filters, fe_filter_name, fe_save_btn, fe_delete_btn],
598
+ show_progress="hidden"
599
+ )
600
+
601
+ # Delete Button ---------------------------------------------------
602
+ def fe_delete_click(name: str):
603
+ fe_dialog.set_action(lambda: lpp.try_delete_filter(name), "")
604
+ return (gr.update(visible=True),
605
+ f"Are you sure you want ot delete \"{name}\"?")
606
+
607
+ fe_delete_btn.click(
608
+ fe_delete_click,
609
+ [fe_filter_name],
610
+ [fe_dialog_panel, fe_dialog_msg],
611
+ show_progress="hidden"
612
+ )
613
+
614
+ # Import Export Panel ---------------------------------------------
615
+ export_btn.click(
616
+ lpp.try_export_json,
617
+ [],
618
+ [import_export_panel]
619
+ )
620
+
621
+ def import_export_upload(temp_file_obj):
622
+ if lpp.try_import_json(temp_file_obj):
623
+ return (
624
+ gr.update(choices=lpp.prompt_collections),
625
+ gr.update(choices=lpp.filters),
626
+ gr.update(choices=lpp.filters)
627
+ )
628
+ else:
629
+ return (gr.update() * 3)
630
+
631
+ import_export_panel.upload(
632
+ import_export_upload,
633
+ [import_export_panel],
634
+ [prompts_manager_input, filters, fe_filter_name]
635
+ )
636
+ return [lpp_enable, prompts_format, rating_filter, quick_filter, filters]
637
+
638
+ def process(self, p, enabled, prompts_format, allowed_ratings,
639
+ quick_filter, filter_names):
640
+ if not enabled:
641
+ return p
642
+
643
+ if prompts_format == "Auto":
644
+ model_hashes = {
645
+ "67ab2fd8ec": Models.PDV56.value, # PD V6 XL
646
+ "6fdb703d7d": Models.PDV56.value, # PD V5.5
647
+ "51e44370f4": Models.PDV56.value, # PD V5
648
+ "821628644e": Models.EF.value, # EasyFluff V11.2
649
+ "461c3bbd5c": Models.SEAART.value, # SeaArt Furry v1.0
650
+ "821aa5537f": Models.PDV56.value, # AutismMix_pony
651
+ "ac006fdd7e": Models.PDV56.value, # AutismMix_confetti
652
+ "ff827fc345": Models.NOOBAI.value # NoobAI XL v1.0
653
+ }
654
+ if p.sd_model_hash not in model_hashes:
655
+ prompts_format = Models.PDV56.value
656
+ else:
657
+ prompts_format = model_hashes[p.sd_model_hash]
658
+
659
+ n_images = p.batch_size * p.n_iter
660
+ filters = lpp.get_filters(filter_names)
661
+ if quick_filter:
662
+ filters += [FilterData.from_string(quick_filter, ",")]
663
+
664
+ chosen_prompts = lpp.try_choose_prompts(n_images, allowed_ratings)
665
+ p.all_prompts = chosen_prompts\
666
+ .apply_formatting(prompts_format)\
667
+ .extra_tag_formatting(
668
+ lambda x: x.filter(*filters).escape_parentheses()
669
+ )\
670
+ .apply_template(prompts_format, p.prompt)\
671
+ .sanitize()\
672
+ .as_list()
673
+
674
+ p.all_prompts = [
675
+ shared.prompt_styles.apply_styles_to_prompt(x, p.styles)
676
+ for x in p.all_prompts
677
+ ]
678
+
679
+ if p.enable_hr:
680
+ p.all_hr_prompts = p.all_prompts
681
+ p.all_hr_negative_prompts = [p.negative_prompt] * n_images
lazy-pony-prompter/style.css ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #lpp-query-panel {
2
+ padding: 0;
3
+ }
4
+
5
+ #lpp-status-bar p {
6
+ margin: 0;
7
+ }
8
+
9
+ #lpp-status-bar svg {
10
+ display: none !important;
11
+ }
12
+
13
+ #lpp-chbox-group span {
14
+ margin-bottom: 0;
15
+ }
16
+
17
+ #lpp-autofill-filter-chbox {
18
+ margin-top: 2.1em;
19
+ margin-right: 43px;
20
+ }