From 3c564ef916ad8e3bda63a73dc89358c4e399a1e0 Mon Sep 17 00:00:00 2001 From: ahgsql <35695543+ahgsql@users.noreply.github.com> Date: Fri, 28 Jul 2023 00:47:42 +0300 Subject: [PATCH] Fix --- .gitignore | 2 + .history/README_20230709123111.md | 38 ---- .history/README_20230728003913.md | 106 ----------- .history/README_20230728004004.md | 26 --- .history/README_20230728004120.md | 27 --- .history/README_20230728004134.md | 27 --- .../scripts/SendtoTextImg_20230709123111.py | 65 ------- .../scripts/SendtoTextImg_20230727230227.py | 65 ------- .../scripts/SendtoTextImg_20230727230407.py | 64 ------- .../scripts/SendtoTextImg_20230727230414.py | 64 ------- .../scripts/SendtoTextImg_20230727230903.py | 64 ------- .../scripts/StyleSelectorXL_20230727230902.py | 64 ------- .../scripts/StyleSelectorXL_20230727231505.py | 64 ------- .../scripts/StyleSelectorXL_20230727231535.py | 150 ---------------- .../scripts/StyleSelectorXL_20230727231708.py | 118 ------------ .../scripts/StyleSelectorXL_20230727231728.py | 114 ------------ .../scripts/StyleSelectorXL_20230727231803.py | 79 -------- .../scripts/StyleSelectorXL_20230727231809.py | 79 -------- .../scripts/StyleSelectorXL_20230727231918.py | 79 -------- .../scripts/StyleSelectorXL_20230727232247.py | 90 ---------- .../scripts/StyleSelectorXL_20230727232356.py | 107 ----------- .../scripts/StyleSelectorXL_20230727232544.py | 118 ------------ .../scripts/StyleSelectorXL_20230727232637.py | 122 ------------- .../scripts/StyleSelectorXL_20230727232827.py | 119 ------------- .../scripts/StyleSelectorXL_20230727232832.py | 119 ------------- .../scripts/StyleSelectorXL_20230727232939.py | 115 ------------ .../scripts/StyleSelectorXL_20230727233047.py | 117 ------------ .../scripts/StyleSelectorXL_20230727233056.py | 118 ------------ .../scripts/StyleSelectorXL_20230727233110.py | 120 ------------- .../scripts/StyleSelectorXL_20230727233114.py | 119 ------------- .../scripts/StyleSelectorXL_20230727233237.py | 124 ------------- .../scripts/StyleSelectorXL_20230727233428.py | 109 ------------ .../scripts/StyleSelectorXL_20230727233450.py | 109 ------------ .../scripts/StyleSelectorXL_20230727233452.py | 109 ------------ .../scripts/StyleSelectorXL_20230727233502.py | 107 ----------- .../scripts/StyleSelectorXL_20230727233525.py | 107 ----------- .../scripts/StyleSelectorXL_20230727233536.py | 106 ----------- .../scripts/StyleSelectorXL_20230727233754.py | 122 ------------- .../scripts/StyleSelectorXL_20230727234105.py | 122 ------------- .../scripts/StyleSelectorXL_20230727234108.py | 122 ------------- .../scripts/StyleSelectorXL_20230727234115.py | 121 ------------- .../scripts/StyleSelectorXL_20230727234120.py | 119 ------------- .../scripts/StyleSelectorXL_20230727234140.py | 106 ----------- .../scripts/StyleSelectorXL_20230727234218.py | 106 ----------- .../scripts/StyleSelectorXL_20230727234223.py | 106 ----------- .../scripts/StyleSelectorXL_20230727234231.py | 106 ----------- .../scripts/StyleSelectorXL_20230727234254.py | 106 ----------- .../scripts/StyleSelectorXL_20230727234317.py | 107 ----------- .../scripts/StyleSelectorXL_20230727234622.py | 106 ----------- .../scripts/StyleSelectorXL_20230727234653.py | 106 ----------- .../scripts/StyleSelectorXL_20230727234853.py | 105 ----------- .../scripts/StyleSelectorXL_20230727234911.py | 106 ----------- .../scripts/StyleSelectorXL_20230727235044.py | 105 ----------- .../scripts/StyleSelectorXL_20230727235049.py | 106 ----------- .../scripts/StyleSelectorXL_20230727235105.py | 106 ----------- .../scripts/StyleSelectorXL_20230727235234.py | 105 ----------- .../scripts/StyleSelectorXL_20230727235237.py | 106 ----------- .../scripts/StyleSelectorXL_20230727235322.py | 105 ----------- .../scripts/StyleSelectorXL_20230727235435.py | 105 ----------- .../scripts/StyleSelectorXL_20230727235527.py | 105 ----------- .../scripts/StyleSelectorXL_20230727235806.py | 105 ----------- .../scripts/StyleSelectorXL_20230727235810.py | 104 ----------- .../scripts/StyleSelectorXL_20230727235847.py | 110 ------------ .../scripts/StyleSelectorXL_20230727235855.py | 111 ------------ .../scripts/StyleSelectorXL_20230728000356.py | 143 --------------- .../scripts/StyleSelectorXL_20230728000429.py | 145 --------------- .../scripts/StyleSelectorXL_20230728000535.py | 145 --------------- .../scripts/StyleSelectorXL_20230728000619.py | 145 --------------- .../scripts/StyleSelectorXL_20230728000820.py | 140 --------------- .../scripts/StyleSelectorXL_20230728000827.py | 140 --------------- .../scripts/StyleSelectorXL_20230728000935.py | 140 --------------- .../scripts/StyleSelectorXL_20230728001229.py | 134 -------------- .../scripts/StyleSelectorXL_20230728001411.py | 135 -------------- .../scripts/StyleSelectorXL_20230728001414.py | 134 -------------- .../scripts/StyleSelectorXL_20230728001524.py | 137 -------------- .../scripts/StyleSelectorXL_20230728001727.py | 138 -------------- .../scripts/StyleSelectorXL_20230728001742.py | 136 -------------- .../scripts/StyleSelectorXL_20230728001928.py | 137 -------------- .../scripts/StyleSelectorXL_20230728002038.py | 137 -------------- .../scripts/StyleSelectorXL_20230728002129.py | 137 -------------- .../scripts/StyleSelectorXL_20230728002356.py | 138 -------------- .../scripts/StyleSelectorXL_20230728002406.py | 139 --------------- .../scripts/StyleSelectorXL_20230728002539.py | 140 --------------- .../scripts/StyleSelectorXL_20230728002623.py | 139 --------------- .../scripts/StyleSelectorXL_20230728002626.py | 137 -------------- .../scripts/StyleSelectorXL_20230728002629.py | 136 -------------- .../scripts/StyleSelectorXL_20230728002725.py | 136 -------------- .../scripts/StyleSelectorXL_20230728002727.py | 136 -------------- .../scripts/StyleSelectorXL_20230728002906.py | 168 ------------------ .../scripts/StyleSelectorXL_20230728002912.py | 163 ----------------- .../scripts/StyleSelectorXL_20230728002915.py | 163 ----------------- .../scripts/StyleSelectorXL_20230728003009.py | 161 ----------------- .../scripts/StyleSelectorXL_20230728003012.py | 161 ----------------- .../scripts/StyleSelectorXL_20230728003059.py | 161 ----------------- .../scripts/StyleSelectorXL_20230728003121.py | 165 ----------------- .../scripts/StyleSelectorXL_20230728003231.py | 164 ----------------- .../scripts/StyleSelectorXL_20230728003315.py | 165 ----------------- .../scripts/StyleSelectorXL_20230728003359.py | 164 ----------------- .../scripts/StyleSelectorXL_20230728003403.py | 164 ----------------- .../scripts/StyleSelectorXL_20230728003424.py | 164 ----------------- .../scripts/StyleSelectorXL_20230728003757.py | 164 ----------------- .../scripts/StyleSelectorXL_20230728004143.py | 164 ----------------- .../__pycache__/SendtoTextImg.cpython-310.pyc | Bin 2032 -> 0 bytes .../StyleSelectorXL.cpython-310.pyc | Bin 4110 -> 0 bytes 104 files changed, 2 insertions(+), 11882 deletions(-) create mode 100644 .gitignore delete mode 100644 .history/README_20230709123111.md delete mode 100644 .history/README_20230728003913.md delete mode 100644 .history/README_20230728004004.md delete mode 100644 .history/README_20230728004120.md delete mode 100644 .history/README_20230728004134.md delete mode 100644 .history/scripts/SendtoTextImg_20230709123111.py delete mode 100644 .history/scripts/SendtoTextImg_20230727230227.py delete mode 100644 .history/scripts/SendtoTextImg_20230727230407.py delete mode 100644 .history/scripts/SendtoTextImg_20230727230414.py delete mode 100644 .history/scripts/SendtoTextImg_20230727230903.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727230902.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727231505.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727231535.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727231708.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727231728.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727231803.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727231809.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727231918.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727232247.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727232356.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727232544.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727232637.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727232827.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727232832.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727232939.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727233047.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727233056.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727233110.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727233114.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727233237.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727233428.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727233450.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727233452.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727233502.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727233525.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727233536.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727233754.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234105.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234108.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234115.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234120.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234140.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234218.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234223.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234231.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234254.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234317.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234622.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234653.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234853.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727234911.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727235044.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727235049.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727235105.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727235234.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727235237.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727235322.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727235435.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727235527.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727235806.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727235810.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727235847.py delete mode 100644 .history/scripts/StyleSelectorXL_20230727235855.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728000356.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728000429.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728000535.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728000619.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728000820.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728000827.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728000935.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728001229.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728001411.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728001414.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728001524.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728001727.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728001742.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728001928.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002038.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002129.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002356.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002406.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002539.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002623.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002626.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002629.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002725.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002727.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002906.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002912.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728002915.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728003009.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728003012.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728003059.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728003121.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728003231.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728003315.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728003359.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728003403.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728003424.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728003757.py delete mode 100644 .history/scripts/StyleSelectorXL_20230728004143.py delete mode 100644 scripts/__pycache__/SendtoTextImg.cpython-310.pyc delete mode 100644 scripts/__pycache__/StyleSelectorXL.cpython-310.pyc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..22402c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.history +__pycache__ \ No newline at end of file diff --git a/.history/README_20230709123111.md b/.history/README_20230709123111.md deleted file mode 100644 index bed5d0e..0000000 --- a/.history/README_20230709123111.md +++ /dev/null @@ -1,38 +0,0 @@ -# ExampleSendText -## what is this? -This is an extension for https://github.com/AUTOMATIC1111/stable-diffusion-webui - -## Goal -It's goal is to show extension developers how to send text to the textprompt textbox, -The code is contains comments to clarify some aspects. Feel free to play around with it!! - -## How to use it? - -locate Send centrum -![example](text_to_be_sent.png) - -Afterwards, input your text and click on send text. -The result will be as follows -> ![example](full_text.png) - - - -## credits -Making this extension required going through different extensions and -inspecting their code,which provide vital clues without this, the extension wouldn't exist. - - - https://github.com/Zyin055/Config-Presets - - https://github.com/anime-webui-colab/ext-aspect-ratio-preset - - - - - - - - - - - - - diff --git a/.history/README_20230728003913.md b/.history/README_20230728003913.md deleted file mode 100644 index 320d79a..0000000 --- a/.history/README_20230728003913.md +++ /dev/null @@ -1,106 +0,0 @@ -## Style Selector for SDXL 1.0 - -This repository contains a Automatic1111 Extension allows users to select and apply different styles to their inputs using SDXL 1.0. - -### Styles - -Released positive and negative templates are used to generate stylized prompts. Just install extension, then SDXL Styles will appear in the panel. - -### Installation - -Enter this repo's URL in Automatic1111's extension tab "Install from Url": - -https://github.com/ahgsql/StyleSelectorXL.git - -### Usage - -1. Import the required libraries and modules: - -```python -import contextlib -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os -``` - -2. Define a function to read JSON content from a file: - -```python -def get_json_content(file_path): - # ... - return json_data -``` - -3. Define a function to extract style names from the JSON data: - -```python -def read_sdxl_styles(json_data): - # ... - return names -``` - -4. Define a function to get the available styles: - -```python -def getStyles(): - # ... - return styles -``` - -5. Define functions to create positive and negative prompts based on the selected style: - -```python -def createPositive(style, positive): - # ... - return positive - -def createNegative(style, negative): - # ... - return negative -``` - -6. Create a class `StyleSelectorXL` that extends the `scripts.Script` class: - -```python -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - # ... (omitting other methods for brevity) - - def ui(self, is_img2img): - # ... - return [is_enabled, style] - - def process(self, p, is_enabled, style): - # ... -``` - -7. In the `__main__` section, create an instance of the `StyleSelectorXL` class and use the `gr.Interface` to expose the UI: - -```python -if __name__ == "__main__": - style_selector = StyleSelectorXL() - - iface = gr.Interface( - fn=style_selector, - inputs=["text" if is_img2img else gr.Image(), "checkbox", "radio"], - outputs=None, - title="Style Selector for SDXL 1.0", - description="Select a style to apply to the input.", - ) - - iface.launch() -``` - -Note: Make sure to replace "text" with "image" for the text-to-image scenario. - -### Example - -For a complete example on how to use the `StyleSelectorXL` class, refer to the provided code and integrate it with your existing project or application. - -### License - -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. diff --git a/.history/README_20230728004004.md b/.history/README_20230728004004.md deleted file mode 100644 index a9e648a..0000000 --- a/.history/README_20230728004004.md +++ /dev/null @@ -1,26 +0,0 @@ -## Style Selector for SDXL 1.0 - -This repository contains a Automatic1111 Extension allows users to select and apply different styles to their inputs using SDXL 1.0. - -### Styles - -Released positive and negative templates are used to generate stylized prompts. Just install extension, then SDXL Styles will appear in the panel. - -### Installation - -Enter this repo's URL in Automatic1111's extension tab "Install from Url": - -https://github.com/ahgsql/StyleSelectorXL.git - -### Usage - -Enable or Disable it On Extension's panel, Select Style then hit Generate! -The selected style will be applied to your current prompts. - -### Example - -For a complete example on how to use the `StyleSelectorXL` class, refer to the provided code and integrate it with your existing project or application. - -### License - -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. diff --git a/.history/README_20230728004120.md b/.history/README_20230728004120.md deleted file mode 100644 index 72b3942..0000000 --- a/.history/README_20230728004120.md +++ /dev/null @@ -1,27 +0,0 @@ -## Style Selector for SDXL 1.0 - -This repository contains a Automatic1111 Extension allows users to select and apply different styles to their inputs using SDXL 1.0. - -### Styles - -Released positive and negative templates are used to generate stylized prompts. Just install extension, then SDXL Styles will appear in the panel. - -### Installation - -Enter this repo's URL in Automatic1111's extension tab "Install from Url": - -https://github.com/ahgsql/StyleSelectorXL.git - -### Usage - -Enable or Disable it On Extension's panel, Write your subject into Prompt field, -Select Style then hit Generate! -The selected style will be applied to your current prompts. - -### Thanks - -Huge thanks for https://github.com/twri/sdxl_prompt_styler as i got style json file from his repo. - -### License - -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. diff --git a/.history/README_20230728004134.md b/.history/README_20230728004134.md deleted file mode 100644 index 0bf85fa..0000000 --- a/.history/README_20230728004134.md +++ /dev/null @@ -1,27 +0,0 @@ -## Style Selector for SDXL 1.0 - -This repository contains a Automatic1111 Extension allows users to select and apply different styles to their inputs using SDXL 1.0. - -### Styles - -Released positive and negative templates are used to generate stylized prompts. Just install extension, then SDXL Styles will appear in the panel. - -### Installation - -Enter this repo's URL in Automatic1111's extension tab "Install from Url": - -https://github.com/ahgsql/StyleSelectorXL.git - -### Usage - -Enable or Disable it On Extension's panel, Write your subject into Prompt field, -Select Style then hit Generate! -The selected style will be applied to your current prompts. - -### Thanks - -Huge thanks for https://github.com/twri/sdxl_prompt_styler as i got style json file's original structure from his repo. - -### License - -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. diff --git a/.history/scripts/SendtoTextImg_20230709123111.py b/.history/scripts/SendtoTextImg_20230709123111.py deleted file mode 100644 index 3ef71fc..0000000 --- a/.history/scripts/SendtoTextImg_20230709123111.py +++ /dev/null @@ -1,65 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - return old_text + " " + new_text # else join them together and send it to the textbox - -class ExampleScript(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Example" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Send centrum", open=False): - send_text_button = gr.Button(value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - with contextlib.suppress(AttributeError): # Ignore the error if the attribute is not present - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [text_to_be_sent, send_text_button] - - def after_component(self, component, **kwargs): - #https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": #postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": #postive prompt textbox - self.boxxIMG = component - - #this code below works aswell, you can send negative prompt text box,provided you change the code a little - #switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - #if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - #if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component - - - - - - - - diff --git a/.history/scripts/SendtoTextImg_20230727230227.py b/.history/scripts/SendtoTextImg_20230727230227.py deleted file mode 100644 index b3fb272..0000000 --- a/.history/scripts/SendtoTextImg_20230727230227.py +++ /dev/null @@ -1,65 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - return old_text + " " + new_text # else join them together and send it to the textbox - -class ExampleScript(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Send centrum", open=False): - send_text_button = gr.Button(value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - with contextlib.suppress(AttributeError): # Ignore the error if the attribute is not present - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [text_to_be_sent, send_text_button] - - def after_component(self, component, **kwargs): - #https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": #postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": #postive prompt textbox - self.boxxIMG = component - - #this code below works aswell, you can send negative prompt text box,provided you change the code a little - #switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - #if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - #if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component - - - - - - - - diff --git a/.history/scripts/SendtoTextImg_20230727230407.py b/.history/scripts/SendtoTextImg_20230727230407.py deleted file mode 100644 index 65033db..0000000 --- a/.history/scripts/SendtoTextImg_20230727230407.py +++ /dev/null @@ -1,64 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class ExampleScript(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Send centrum", open=False): - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [text_to_be_sent, send_text_button] - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/SendtoTextImg_20230727230414.py b/.history/scripts/SendtoTextImg_20230727230414.py deleted file mode 100644 index d1985df..0000000 --- a/.history/scripts/SendtoTextImg_20230727230414.py +++ /dev/null @@ -1,64 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class ExampleScript(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [text_to_be_sent, send_text_button] - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/SendtoTextImg_20230727230903.py b/.history/scripts/SendtoTextImg_20230727230903.py deleted file mode 100644 index d1985df..0000000 --- a/.history/scripts/SendtoTextImg_20230727230903.py +++ /dev/null @@ -1,64 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class ExampleScript(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [text_to_be_sent, send_text_button] - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727230902.py b/.history/scripts/StyleSelectorXL_20230727230902.py deleted file mode 100644 index d1985df..0000000 --- a/.history/scripts/StyleSelectorXL_20230727230902.py +++ /dev/null @@ -1,64 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class ExampleScript(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [text_to_be_sent, send_text_button] - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727231505.py b/.history/scripts/StyleSelectorXL_20230727231505.py deleted file mode 100644 index d3934ce..0000000 --- a/.history/scripts/StyleSelectorXL_20230727231505.py +++ /dev/null @@ -1,64 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [text_to_be_sent, send_text_button] - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727231535.py b/.history/scripts/StyleSelectorXL_20230727231535.py deleted file mode 100644 index e73cd6f..0000000 --- a/.history/scripts/StyleSelectorXL_20230727231535.py +++ /dev/null @@ -1,150 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [text_to_be_sent, send_text_button] - - def process(self, p, text_to_be_sent): - if not is_enabled: - return - - if use_main_seed: - declone_seed = p.all_seeds[0] - elif declone_seed == -1: - declone_seed = int(random.randrange(4294967294)) - else: - declone_seed = int(declone_seed) - - # original_prompt = p.all_prompts[0] - # settings = f"gender={gender}, beginning={insert_start}, declone_weight={declone_weight}, main_seed={use_main_seed}, " + \ - # f"declone_seed={declone_seed}, exclude_regions={exclude_regions}" - p.extra_generation_params["CloneCleaner enabled"] = True - p.extra_generation_params["CC_gender"] = gender - p.extra_generation_params["CC_insert_start"] = insert_start - p.extra_generation_params["CC_declone_weight"] = declone_weight - p.extra_generation_params["CC_use_main_seed"] = use_main_seed - p.extra_generation_params["CC_declone_seed"] = declone_seed - if exclude_regions: - p.extra_generation_params["CC_exclude_regions"] = ",".join(exclude_regions) - if exclude_hairlength: - p.extra_generation_params["CC_exclude_hairlength"] = ",".join(exclude_hairlength) - if exclude_haircolor: - p.extra_generation_params["CC_exclude_haircolor"] = ",".join(exclude_haircolor) - - countrytree = self.prompt_tree["country"] - hairtree = self.prompt_tree["hair"] - - regions = sorted_difference(countrytree.keys(), exclude_regions) - hairlengths = sorted_difference(hairtree["length"].keys(), exclude_hairlength) - haircolors = sorted_difference(hairtree["color"].keys(), exclude_haircolor) - - use_name = "name" in use_components - use_country = "country" in use_components - use_length = "hair length" in use_components - use_style = "hair style" in use_components - use_color = "hair color" in use_components - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - rng = random.Random() - seed = p.all_seeds[i] if use_main_seed else declone_seed + i - rng.seed(seed) - - region = rng.choice(regions) - countries = list(countrytree[region].keys()) - countryweights = [countrytree[region][cty]["weight"] for cty in countries] - country = rng.choices(countries, weights=countryweights)[0] - - countrydata = countrytree[region][country] - hairdata = countrydata.get("hair", hairtree["defaultweight"][region]) - maincolor = rng.choices(haircolors, weights=[hairdata[col] for col in haircolors])[0] - color = rng.choice(hairtree["color"][maincolor]) - mainlength = rng.choice(hairlengths) - length = rng.choice(hairtree["length"][mainlength]) - style = rng.choice(hairtree["style"][mainlength]) - name = rng.choice(countrydata["names"]) - - inserted_prompt = "" - - if use_name or use_country: - inserted_prompt += name if use_name else "person" - inserted_prompt += " from " + country if use_country else "" - - if use_length or use_style or use_color: - if inserted_prompt: - inserted_prompt += ", " - if use_length: - inserted_prompt += length + " " - if use_style: - inserted_prompt += style + " " - if use_color: - inserted_prompt += color + " " - inserted_prompt += "hair" - - if inserted_prompt: - if declone_weight != 1: - inserted_prompt = f"({inserted_prompt}:{declone_weight})" - - if insert_start: - p.all_prompts[i] = inserted_prompt + ", " + prompt - else: - p.all_prompts[i] = prompt + ", " + inserted_prompt - - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727231708.py b/.history/scripts/StyleSelectorXL_20230727231708.py deleted file mode 100644 index 9e60c4f..0000000 --- a/.history/scripts/StyleSelectorXL_20230727231708.py +++ /dev/null @@ -1,118 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - rng = random.Random() - seed = p.all_seeds[i] if use_main_seed else declone_seed + i - rng.seed(seed) - - region = rng.choice(regions) - countries = list(countrytree[region].keys()) - countryweights = [countrytree[region][cty]["weight"] - for cty in countries] - country = rng.choices(countries, weights=countryweights)[0] - - countrydata = countrytree[region][country] - hairdata = countrydata.get( - "hair", hairtree["defaultweight"][region]) - maincolor = rng.choices(haircolors, weights=[ - hairdata[col] for col in haircolors])[0] - color = rng.choice(hairtree["color"][maincolor]) - mainlength = rng.choice(hairlengths) - length = rng.choice(hairtree["length"][mainlength]) - style = rng.choice(hairtree["style"][mainlength]) - name = rng.choice(countrydata["names"]) - - inserted_prompt = "" - - if use_name or use_country: - inserted_prompt += name if use_name else "person" - inserted_prompt += " from " + country if use_country else "" - - if use_length or use_style or use_color: - if inserted_prompt: - inserted_prompt += ", " - if use_length: - inserted_prompt += length + " " - if use_style: - inserted_prompt += style + " " - if use_color: - inserted_prompt += color + " " - inserted_prompt += "hair" - - if inserted_prompt: - - if insert_start: - p.all_prompts[i] = inserted_prompt + ", " + prompt - else: - p.all_prompts[i] = prompt + ", " + inserted_prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727231728.py b/.history/scripts/StyleSelectorXL_20230727231728.py deleted file mode 100644 index acf3492..0000000 --- a/.history/scripts/StyleSelectorXL_20230727231728.py +++ /dev/null @@ -1,114 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - rng = random.Random() - seed = p.all_seeds[i] if use_main_seed else declone_seed + i - rng.seed(seed) - - region = rng.choice(regions) - countries = list(countrytree[region].keys()) - countryweights = [countrytree[region][cty]["weight"] - for cty in countries] - country = rng.choices(countries, weights=countryweights)[0] - - countrydata = countrytree[region][country] - hairdata = countrydata.get( - "hair", hairtree["defaultweight"][region]) - maincolor = rng.choices(haircolors, weights=[ - hairdata[col] for col in haircolors])[0] - color = rng.choice(hairtree["color"][maincolor]) - mainlength = rng.choice(hairlengths) - length = rng.choice(hairtree["length"][mainlength]) - style = rng.choice(hairtree["style"][mainlength]) - name = rng.choice(countrydata["names"]) - - inserted_prompt = "" - - if use_name or use_country: - inserted_prompt += name if use_name else "person" - inserted_prompt += " from " + country if use_country else "" - - if use_length or use_style or use_color: - if inserted_prompt: - inserted_prompt += ", " - if use_length: - inserted_prompt += length + " " - if use_style: - inserted_prompt += style + " " - if use_color: - inserted_prompt += color + " " - inserted_prompt += "hair" - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727231803.py b/.history/scripts/StyleSelectorXL_20230727231803.py deleted file mode 100644 index 2d3c5e0..0000000 --- a/.history/scripts/StyleSelectorXL_20230727231803.py +++ /dev/null @@ -1,79 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727231809.py b/.history/scripts/StyleSelectorXL_20230727231809.py deleted file mode 100644 index 6691b5f..0000000 --- a/.history/scripts/StyleSelectorXL_20230727231809.py +++ /dev/null @@ -1,79 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727231918.py b/.history/scripts/StyleSelectorXL_20230727231918.py deleted file mode 100644 index 9a32fa9..0000000 --- a/.history/scripts/StyleSelectorXL_20230727231918.py +++ /dev/null @@ -1,79 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727232247.py b/.history/scripts/StyleSelectorXL_20230727232247.py deleted file mode 100644 index 7b1c228..0000000 --- a/.history/scripts/StyleSelectorXL_20230727232247.py +++ /dev/null @@ -1,90 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -def read_json_file(file_path): - try: - # Open file, load JSON content into python dictionary, and return it. - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"An error occurred: {str(e)}") - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727232356.py b/.history/scripts/StyleSelectorXL_20230727232356.py deleted file mode 100644 index 07135d9..0000000 --- a/.history/scripts/StyleSelectorXL_20230727232356.py +++ /dev/null @@ -1,107 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -def read_json_file(file_path): - try: - # Open file, load JSON content into python dictionary, and return it. - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"An error occurred: {str(e)}") - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727232544.py b/.history/scripts/StyleSelectorXL_20230727232544.py deleted file mode 100644 index 6d14ba3..0000000 --- a/.history/scripts/StyleSelectorXL_20230727232544.py +++ /dev/null @@ -1,118 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -def read_json_file(file_path): - try: - # Open file, load JSON content into python dictionary, and return it. - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"An error occurred: {str(e)}") - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - path = os.path.dirname(os.path.realpath(__file__)) - # Construct 'sdxl_styles.json' path - file_path = os.path.join(path, 'sdxl_styles.json') - - # Read JSON from file - self.json_data = read_json_file(file_path) - # Retrieve styles from JSON data - styles = read_sdxl_styles(self.json_data) - print(styles) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727232637.py b/.history/scripts/StyleSelectorXL_20230727232637.py deleted file mode 100644 index f7624e7..0000000 --- a/.history/scripts/StyleSelectorXL_20230727232637.py +++ /dev/null @@ -1,122 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def read_json_file(file_path): - try: - # Open file, load JSON content into python dictionary, and return it. - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"An error occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - path = os.path.dirname(os.path.realpath(__file__)) - print(path) - # Construct 'sdxl_styles.json' path - file_path = os.path.join(path, 'sdxl_styles.json') - print(file_path) - - # Read JSON from file - self.json_data = read_json_file(file_path) - # Retrieve styles from JSON data - styles = read_sdxl_styles(self.json_data) - print(styles) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727232827.py b/.history/scripts/StyleSelectorXL_20230727232827.py deleted file mode 100644 index b70cb5e..0000000 --- a/.history/scripts/StyleSelectorXL_20230727232827.py +++ /dev/null @@ -1,119 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"An error occurred: {str(e)}") - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - path = os.path.dirname(os.path.realpath(__file__)) - print(path) - # Construct 'sdxl_styles.json' path - file_path = os.path.join(path, 'sdxl_styles.json') - print(file_path) - - # Read JSON from file - self.json_data = read_json_file(file_path) - # Retrieve styles from JSON data - styles = read_sdxl_styles(self.json_data) - print(styles) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727232832.py b/.history/scripts/StyleSelectorXL_20230727232832.py deleted file mode 100644 index 4f6799c..0000000 --- a/.history/scripts/StyleSelectorXL_20230727232832.py +++ /dev/null @@ -1,119 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - path = os.path.dirname(os.path.realpath(__file__)) - print(path) - # Construct 'sdxl_styles.json' path - file_path = os.path.join(path, 'sdxl_styles.json') - print(file_path) - - # Read JSON from file - self.json_data = read_json_file(file_path) - # Retrieve styles from JSON data - styles = read_sdxl_styles(self.json_data) - print(styles) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727232939.py b/.history/scripts/StyleSelectorXL_20230727232939.py deleted file mode 100644 index 515ce2e..0000000 --- a/.history/scripts/StyleSelectorXL_20230727232939.py +++ /dev/null @@ -1,115 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - json_path=os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(file_path) - - # Read JSON from file - self.json_data = read_json_file(file_path) - # Retrieve styles from JSON data - styles = read_sdxl_styles(self.json_data) - print(styles) - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727233047.py b/.history/scripts/StyleSelectorXL_20230727233047.py deleted file mode 100644 index 99a1b54..0000000 --- a/.history/scripts/StyleSelectorXL_20230727233047.py +++ /dev/null @@ -1,117 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - -def getStyles(): - json_path=os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - json_data = get_json_content(json_path) - styles = read_sdxl_styles(self.json_data) - print(styles) - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - - - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727233056.py b/.history/scripts/StyleSelectorXL_20230727233056.py deleted file mode 100644 index f101cb5..0000000 --- a/.history/scripts/StyleSelectorXL_20230727233056.py +++ /dev/null @@ -1,118 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - -def getStyles(): - json_path=os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - print(styles) - return styles - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - - - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727233110.py b/.history/scripts/StyleSelectorXL_20230727233110.py deleted file mode 100644 index 4aec456..0000000 --- a/.history/scripts/StyleSelectorXL_20230727233110.py +++ /dev/null @@ -1,120 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - -def getStyles(): - json_path=os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - print(styles) - return styles - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames=getStyles(); - print(styleNames) - - - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727233114.py b/.history/scripts/StyleSelectorXL_20230727233114.py deleted file mode 100644 index 5327aef..0000000 --- a/.history/scripts/StyleSelectorXL_20230727233114.py +++ /dev/null @@ -1,119 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - -def getStyles(): - json_path=os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - print(styles) - return styles - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames=getStyles(); - print(styleNames) - - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable CloneCleaner") - send_text_button = gr.Button( - value='send text', variant='primary') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727233237.py b/.history/scripts/StyleSelectorXL_20230727233237.py deleted file mode 100644 index ad5e380..0000000 --- a/.history/scripts/StyleSelectorXL_20230727233237.py +++ /dev/null @@ -1,124 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - print(styles) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - print(styleNames) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - send_text_button = gr.Button( - value='send text', variant='primary') - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727233428.py b/.history/scripts/StyleSelectorXL_20230727233428.py deleted file mode 100644 index 43d5592..0000000 --- a/.history/scripts/StyleSelectorXL_20230727233428.py +++ /dev/null @@ -1,109 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - print(styles) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - print(styleNames) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727233450.py b/.history/scripts/StyleSelectorXL_20230727233450.py deleted file mode 100644 index 1bf4d01..0000000 --- a/.history/scripts/StyleSelectorXL_20230727233450.py +++ /dev/null @@ -1,109 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - print(styles) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - print(styleNames) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + style - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727233452.py b/.history/scripts/StyleSelectorXL_20230727233452.py deleted file mode 100644 index dd4dfb5..0000000 --- a/.history/scripts/StyleSelectorXL_20230727233452.py +++ /dev/null @@ -1,109 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - print(styles) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - print(styleNames) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727233502.py b/.history/scripts/StyleSelectorXL_20230727233502.py deleted file mode 100644 index 03b33ad..0000000 --- a/.history/scripts/StyleSelectorXL_20230727233502.py +++ /dev/null @@ -1,107 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - print(styleNames) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727233525.py b/.history/scripts/StyleSelectorXL_20230727233525.py deleted file mode 100644 index 03b33ad..0000000 --- a/.history/scripts/StyleSelectorXL_20230727233525.py +++ /dev/null @@ -1,107 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - print(styleNames) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727233536.py b/.history/scripts/StyleSelectorXL_20230727233536.py deleted file mode 100644 index 383a85e..0000000 --- a/.history/scripts/StyleSelectorXL_20230727233536.py +++ /dev/null @@ -1,106 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - print(styleNames) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727233754.py b/.history/scripts/StyleSelectorXL_20230727233754.py deleted file mode 100644 index 862ea4c..0000000 --- a/.history/scripts/StyleSelectorXL_20230727233754.py +++ /dev/null @@ -1,122 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - print(styles) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - print(styleNames) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent, send_text_button] - - def process(self, p, is_enabled, text_to_be_sent, send_text_button): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234105.py b/.history/scripts/StyleSelectorXL_20230727234105.py deleted file mode 100644 index 9792074..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234105.py +++ /dev/null @@ -1,122 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - print(styles) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - print(styleNames) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent,] - - def process(self, p, is_enabled, text_to_be_sent): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234108.py b/.history/scripts/StyleSelectorXL_20230727234108.py deleted file mode 100644 index eff0cf6..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234108.py +++ /dev/null @@ -1,122 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - print(styles) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - print(styleNames) - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent] - - def process(self, p, is_enabled, text_to_be_sent): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234115.py b/.history/scripts/StyleSelectorXL_20230727234115.py deleted file mode 100644 index a3cb5e6..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234115.py +++ /dev/null @@ -1,121 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - print(styles) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent] - - def process(self, p, is_enabled, text_to_be_sent): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234120.py b/.history/scripts/StyleSelectorXL_20230727234120.py deleted file mode 100644 index 5c5c5e8..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234120.py +++ /dev/null @@ -1,119 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - with contextlib.suppress(AttributeError): - if is_img2img: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxxIMG (textbox) - # Outputs: self.boxxIMG (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxxIMG], outputs=[self.boxxIMG]) - else: - # Bind the click event of the button to the send_text_to_prompt function - # Inputs: text_to_be_sent (textbox), self.boxx (textbox) - # Outputs: self.boxx (textbox) - send_text_button.click(fn=send_text_to_prompt, inputs=[ - text_to_be_sent, self.boxx], outputs=[self.boxx]) - - return [is_enabled, text_to_be_sent] - - def process(self, p, is_enabled, text_to_be_sent): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234140.py b/.history/scripts/StyleSelectorXL_20230727234140.py deleted file mode 100644 index eb64676..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234140.py +++ /dev/null @@ -1,106 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent] - - def process(self, p, is_enabled, text_to_be_sent): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234218.py b/.history/scripts/StyleSelectorXL_20230727234218.py deleted file mode 100644 index 066c7d4..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234218.py +++ /dev/null @@ -1,106 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent,style] - - def process(self, p, is_enabled, text_to_be_sent): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234223.py b/.history/scripts/StyleSelectorXL_20230727234223.py deleted file mode 100644 index c0e6381..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234223.py +++ /dev/null @@ -1,106 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent,style] - - def process(self, p, is_enabled, text_to_be_sent,style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234231.py b/.history/scripts/StyleSelectorXL_20230727234231.py deleted file mode 100644 index ba2866f..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234231.py +++ /dev/null @@ -1,106 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent, style] - - def process(self, p, is_enabled, text_to_be_sent, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234254.py b/.history/scripts/StyleSelectorXL_20230727234254.py deleted file mode 100644 index bba8650..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234254.py +++ /dev/null @@ -1,106 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent, style] - - def process(self, p, is_enabled, text_to_be_sent, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234317.py b/.history/scripts/StyleSelectorXL_20230727234317.py deleted file mode 100644 index 5472662..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234317.py +++ /dev/null @@ -1,107 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent, style] - - def process(self, p, is_enabled, text_to_be_sent, style): - print(style) - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234622.py b/.history/scripts/StyleSelectorXL_20230727234622.py deleted file mode 100644 index eb64676..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234622.py +++ /dev/null @@ -1,106 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=False): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent] - - def process(self, p, is_enabled, text_to_be_sent): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234653.py b/.history/scripts/StyleSelectorXL_20230727234653.py deleted file mode 100644 index c346ef6..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234653.py +++ /dev/null @@ -1,106 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(self.styleNames, label="Location", - info="Where did they go?"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent] - - def process(self, p, is_enabled, text_to_be_sent): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234853.py b/.history/scripts/StyleSelectorXL_20230727234853.py deleted file mode 100644 index 1fa5bfe..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234853.py +++ /dev/null @@ -1,105 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style =gr.Radio(label = 'Style', choices = self.styleNames, info="Select Your Style"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent,style] - - def process(self, p, is_enabled, text_to_be_sent,style): - if not is_enabled: - return - print(style) - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727234911.py b/.history/scripts/StyleSelectorXL_20230727234911.py deleted file mode 100644 index 1f09832..0000000 --- a/.history/scripts/StyleSelectorXL_20230727234911.py +++ /dev/null @@ -1,106 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector"), - style = gr.Radio( - label='Style', choices=self.styleNames, info="Select Your Style"), - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent, style] - - def process(self, p, is_enabled, text_to_be_sent, style): - if not is_enabled: - return - print(style) - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727235044.py b/.history/scripts/StyleSelectorXL_20230727235044.py deleted file mode 100644 index f1d3631..0000000 --- a/.history/scripts/StyleSelectorXL_20230727235044.py +++ /dev/null @@ -1,105 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - codec = gr.Radio(label = 'Codec', choices = ['x264', 'x265', 'vpx-vp9', 'aom-av1', 'prores_ks'], value = 'x264') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent, style] - - def process(self, p, is_enabled, text_to_be_sent, style): - if not is_enabled: - return - print(style) - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727235049.py b/.history/scripts/StyleSelectorXL_20230727235049.py deleted file mode 100644 index 3b1c5f4..0000000 --- a/.history/scripts/StyleSelectorXL_20230727235049.py +++ /dev/null @@ -1,106 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - codec = gr.Radio(label='Codec', choices=[ - 'x264', 'x265', 'vpx-vp9', 'aom-av1', 'prores_ks'], value='x264') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent, codec] - - def process(self, p, is_enabled, text_to_be_sent, codec): - if not is_enabled: - return - print(style) - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727235105.py b/.history/scripts/StyleSelectorXL_20230727235105.py deleted file mode 100644 index 20d4ad7..0000000 --- a/.history/scripts/StyleSelectorXL_20230727235105.py +++ /dev/null @@ -1,106 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - codec = gr.Radio(label='Codec', choices=[ - 'x264', 'x265', 'vpx-vp9', 'aom-av1', 'prores_ks'], value='x264') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent, codec] - - def process(self, p, is_enabled, text_to_be_sent, codec): - if not is_enabled: - return - print(codec) - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727235234.py b/.history/scripts/StyleSelectorXL_20230727235234.py deleted file mode 100644 index efcf9fe..0000000 --- a/.history/scripts/StyleSelectorXL_20230727235234.py +++ /dev/null @@ -1,105 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio(label='Codec', choices=self.styleNames, value='sai-base') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent, style] - - def process(self, p, is_enabled, text_to_be_sent, style): - if not is_enabled: - return - print(stylecodec) - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727235237.py b/.history/scripts/StyleSelectorXL_20230727235237.py deleted file mode 100644 index c3e0829..0000000 --- a/.history/scripts/StyleSelectorXL_20230727235237.py +++ /dev/null @@ -1,106 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - text_to_be_sent = gr.Textbox(label="drop text") - - # Ignore the error if the attribute is not present - - return [is_enabled, text_to_be_sent, style] - - def process(self, p, is_enabled, text_to_be_sent, style): - if not is_enabled: - return - print(style) - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = "ALİ HAYDAR GÜLEÇ" + text_to_be_sent - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727235322.py b/.history/scripts/StyleSelectorXL_20230727235322.py deleted file mode 100644 index 1b28e91..0000000 --- a/.history/scripts/StyleSelectorXL_20230727235322.py +++ /dev/null @@ -1,105 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727235435.py b/.history/scripts/StyleSelectorXL_20230727235435.py deleted file mode 100644 index b0b5675..0000000 --- a/.history/scripts/StyleSelectorXL_20230727235435.py +++ /dev/null @@ -1,105 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - print(p.all_prompts[i]) - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727235527.py b/.history/scripts/StyleSelectorXL_20230727235527.py deleted file mode 100644 index d7b9af0..0000000 --- a/.history/scripts/StyleSelectorXL_20230727235527.py +++ /dev/null @@ -1,105 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - print(p.all_prompts) - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727235806.py b/.history/scripts/StyleSelectorXL_20230727235806.py deleted file mode 100644 index d7b9af0..0000000 --- a/.history/scripts/StyleSelectorXL_20230727235806.py +++ /dev/null @@ -1,105 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - print(p.all_prompts) - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727235810.py b/.history/scripts/StyleSelectorXL_20230727235810.py deleted file mode 100644 index 24c029f..0000000 --- a/.history/scripts/StyleSelectorXL_20230727235810.py +++ /dev/null @@ -1,104 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727235847.py b/.history/scripts/StyleSelectorXL_20230727235847.py deleted file mode 100644 index fc469e2..0000000 --- a/.history/scripts/StyleSelectorXL_20230727235847.py +++ /dev/null @@ -1,110 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - for i, prompt in enumerate(p.all_negative_prompts): # for each image in batch - - inserted_prompt = style - if inserted_prompt: - p.all_negative_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230727235855.py b/.history/scripts/StyleSelectorXL_20230727235855.py deleted file mode 100644 index 4aca11f..0000000 --- a/.history/scripts/StyleSelectorXL_20230727235855.py +++ /dev/null @@ -1,111 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - - inserted_prompt = style + " ve negatif" - if inserted_prompt: - p.all_negative_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728000356.py b/.history/scripts/StyleSelectorXL_20230728000356.py deleted file mode 100644 index 0b97a46..0000000 --- a/.history/scripts/StyleSelectorXL_20230728000356.py +++ /dev/null @@ -1,143 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - -def createprompts(style,positive,negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError("Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError("Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == template_name: - positive_prompt = template['prompt'].replace('{prompt}', positive_prompt) - - json_negative_prompt = template.get('negative_prompt', "") - if negative_prompt: - negative_prompt = f"{json_negative_prompt}, {negative_prompt}" if json_negative_prompt else negative_prompt - else: - negative_prompt = json_negative_prompt - - return positive_prompt, negative_prompt - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{template_name}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - - inserted_prompt = style + " ve negatif" - if inserted_prompt: - p.all_negative_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728000429.py b/.history/scripts/StyleSelectorXL_20230728000429.py deleted file mode 100644 index 703197b..0000000 --- a/.history/scripts/StyleSelectorXL_20230728000429.py +++ /dev/null @@ -1,145 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive_prompt = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative_prompt: - negative_prompt = f"{json_negative_prompt}, {negative_prompt}" if json_negative_prompt else negative_prompt - else: - negative_prompt = json_negative_prompt - - return positive_prompt, negative_prompt - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{template_name}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - - inserted_prompt = style + " ve negatif" - if inserted_prompt: - p.all_negative_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728000535.py b/.history/scripts/StyleSelectorXL_20230728000535.py deleted file mode 100644 index 3001ad6..0000000 --- a/.history/scripts/StyleSelectorXL_20230728000535.py +++ /dev/null @@ -1,145 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{template_name}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - - inserted_prompt = style + " ve negatif" - if inserted_prompt: - p.all_negative_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728000619.py b/.history/scripts/StyleSelectorXL_20230728000619.py deleted file mode 100644 index 156cd13..0000000 --- a/.history/scripts/StyleSelectorXL_20230728000619.py +++ /dev/null @@ -1,145 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - inserted_prompt = style - if inserted_prompt: - p.all_prompts[i] = inserted_prompt + ", " + prompt - - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - - inserted_prompt = style + " ve negatif" - if inserted_prompt: - p.all_negative_prompts[i] = inserted_prompt + ", " + prompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728000820.py b/.history/scripts/StyleSelectorXL_20230728000820.py deleted file mode 100644 index 42f87e2..0000000 --- a/.history/scripts/StyleSelectorXL_20230728000820.py +++ /dev/null @@ -1,140 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt) - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728000827.py b/.history/scripts/StyleSelectorXL_20230728000827.py deleted file mode 100644 index 42f87e2..0000000 --- a/.history/scripts/StyleSelectorXL_20230728000827.py +++ /dev/null @@ -1,140 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt) - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728000935.py b/.history/scripts/StyleSelectorXL_20230728000935.py deleted file mode 100644 index a165ad1..0000000 --- a/.history/scripts/StyleSelectorXL_20230728000935.py +++ /dev/null @@ -1,140 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def send_text_to_prompt(new_text, old_text): - if old_text == "": # if text on the textbox text2img or img2img is empty, return new text - return new_text - # else join them together and send it to the textbox - return old_text + " " + new_text - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt,"") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style,"", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728001229.py b/.history/scripts/StyleSelectorXL_20230728001229.py deleted file mode 100644 index 1f5577e..0000000 --- a/.history/scripts/StyleSelectorXL_20230728001229.py +++ /dev/null @@ -1,134 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt,"") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style,"", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728001411.py b/.history/scripts/StyleSelectorXL_20230728001411.py deleted file mode 100644 index 5148223..0000000 --- a/.history/scripts/StyleSelectorXL_20230728001411.py +++ /dev/null @@ -1,135 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - print(type(json_data)) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt,"") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style,"", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728001414.py b/.history/scripts/StyleSelectorXL_20230728001414.py deleted file mode 100644 index 416ca62..0000000 --- a/.history/scripts/StyleSelectorXL_20230728001414.py +++ /dev/null @@ -1,134 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - print(type(json_data)) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728001524.py b/.history/scripts/StyleSelectorXL_20230728001524.py deleted file mode 100644 index 6de9a17..0000000 --- a/.history/scripts/StyleSelectorXL_20230728001524.py +++ /dev/null @@ -1,137 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - - json_data = get_json_content(json_path) - print(json_data) - print(type(json_data)) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728001727.py b/.history/scripts/StyleSelectorXL_20230728001727.py deleted file mode 100644 index 8a66010..0000000 --- a/.history/scripts/StyleSelectorXL_20230728001727.py +++ /dev/null @@ -1,138 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - - json_data = get_json_content(json_path) - print(json_data) - print(type(json_data)) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728001742.py b/.history/scripts/StyleSelectorXL_20230728001742.py deleted file mode 100644 index ebdfd41..0000000 --- a/.history/scripts/StyleSelectorXL_20230728001742.py +++ /dev/null @@ -1,136 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - - json_data = get_json_content(json_path) - print(json_data) - print(type(json_data)) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = self.createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = self.createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728001928.py b/.history/scripts/StyleSelectorXL_20230728001928.py deleted file mode 100644 index b9ffd94..0000000 --- a/.history/scripts/StyleSelectorXL_20230728001928.py +++ /dev/null @@ -1,137 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - - json_data = get_json_content(json_path) - print(json_data) - print(type(json_data)) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - print(style, prompt, "") - positivePrompt = self.createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = self.createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002038.py b/.history/scripts/StyleSelectorXL_20230728002038.py deleted file mode 100644 index 49dda59..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002038.py +++ /dev/null @@ -1,137 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def createprompts(self, style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - - json_data = get_json_content(json_path) - print(json_data) - print(type(json_data)) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - print(style, prompt, "") - positivePrompt = self.createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = self.createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002129.py b/.history/scripts/StyleSelectorXL_20230728002129.py deleted file mode 100644 index 6de9a17..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002129.py +++ /dev/null @@ -1,137 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - - json_data = get_json_content(json_path) - print(json_data) - print(type(json_data)) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002356.py b/.history/scripts/StyleSelectorXL_20230728002356.py deleted file mode 100644 index e04ec33..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002356.py +++ /dev/null @@ -1,138 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath="" -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath=json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - print(json_path) - - json_data = get_json_content(json_path) - print(json_data) - print(type(json_data)) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002406.py b/.history/scripts/StyleSelectorXL_20230728002406.py deleted file mode 100644 index 0521552..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002406.py +++ /dev/null @@ -1,139 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - print(stylespath) - - json_data = get_json_content(stylespath) - print(json_data) - print(type(json_data)) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002539.py b/.history/scripts/StyleSelectorXL_20230728002539.py deleted file mode 100644 index 1acfc18..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002539.py +++ /dev/null @@ -1,140 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - print(stylespath) - - json_data = get_json_content(stylespath) - print(json_data) - print(type(json_data)) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002623.py b/.history/scripts/StyleSelectorXL_20230728002623.py deleted file mode 100644 index a926859..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002623.py +++ /dev/null @@ -1,139 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - print(stylespath) - - json_data = get_json_content(stylespath) - print(json_data) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002626.py b/.history/scripts/StyleSelectorXL_20230728002626.py deleted file mode 100644 index c4ff080..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002626.py +++ /dev/null @@ -1,137 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - print(stylespath) - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002629.py b/.history/scripts/StyleSelectorXL_20230728002629.py deleted file mode 100644 index 6234c33..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002629.py +++ /dev/null @@ -1,136 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002725.py b/.history/scripts/StyleSelectorXL_20230728002725.py deleted file mode 100644 index 5b41a09..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002725.py +++ /dev/null @@ -1,136 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - # positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = "positivePrompt" - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002727.py b/.history/scripts/StyleSelectorXL_20230728002727.py deleted file mode 100644 index 860d6f0..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002727.py +++ /dev/null @@ -1,136 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createprompts(style, positive, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - # positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = "positivePrompt" - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - # a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002906.py b/.history/scripts/StyleSelectorXL_20230728002906.py deleted file mode 100644 index 8e57aeb..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002906.py +++ /dev/null @@ -1,168 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - -def createNegative(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - # positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = "positivePrompt" - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - # a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002912.py b/.history/scripts/StyleSelectorXL_20230728002912.py deleted file mode 100644 index 5454007..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002912.py +++ /dev/null @@ -1,163 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - -def createNegative(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - # positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = "positivePrompt" - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - # a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728002915.py b/.history/scripts/StyleSelectorXL_20230728002915.py deleted file mode 100644 index 9005e95..0000000 --- a/.history/scripts/StyleSelectorXL_20230728002915.py +++ /dev/null @@ -1,163 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - -def createNegative(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - # positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = "positivePrompt" - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - # a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728003009.py b/.history/scripts/StyleSelectorXL_20230728003009.py deleted file mode 100644 index c58baf1..0000000 --- a/.history/scripts/StyleSelectorXL_20230728003009.py +++ /dev/null @@ -1,161 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - -def createNegative(style, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return positive, negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - # positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = "positivePrompt" - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - # a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728003012.py b/.history/scripts/StyleSelectorXL_20230728003012.py deleted file mode 100644 index 7c02dda..0000000 --- a/.history/scripts/StyleSelectorXL_20230728003012.py +++ /dev/null @@ -1,161 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - -def createNegative(style, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - # positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = "positivePrompt" - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - # a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728003059.py b/.history/scripts/StyleSelectorXL_20230728003059.py deleted file mode 100644 index 7c02dda..0000000 --- a/.history/scripts/StyleSelectorXL_20230728003059.py +++ /dev/null @@ -1,161 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - -def createNegative(style, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - # positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = "positivePrompt" - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - # a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728003121.py b/.history/scripts/StyleSelectorXL_20230728003121.py deleted file mode 100644 index 17c5964..0000000 --- a/.history/scripts/StyleSelectorXL_20230728003121.py +++ /dev/null @@ -1,165 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -def createNegative(style, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - print(createPositive(style, "alihaydar")) - # positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = "positivePrompt" - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - print(createNegative(style, "alihaydar")) - - # a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728003231.py b/.history/scripts/StyleSelectorXL_20230728003231.py deleted file mode 100644 index 4066bab..0000000 --- a/.history/scripts/StyleSelectorXL_20230728003231.py +++ /dev/null @@ -1,164 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -def createNegative(style, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - # positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = "positivePrompt" - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - - # a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728003315.py b/.history/scripts/StyleSelectorXL_20230728003315.py deleted file mode 100644 index 733843f..0000000 --- a/.history/scripts/StyleSelectorXL_20230728003315.py +++ /dev/null @@ -1,165 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -def createNegative(style, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - ali = createPositive(style, "alihaydar") - print(ali) - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - # positivePrompt = createprompts(style, prompt, "") - p.all_prompts[i] = "positivePrompt" - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - - # a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728003359.py b/.history/scripts/StyleSelectorXL_20230728003359.py deleted file mode 100644 index 7c59ef3..0000000 --- a/.history/scripts/StyleSelectorXL_20230728003359.py +++ /dev/null @@ -1,164 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -def createNegative(style, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - positivePrompt = createPositive(style, prompt) - p.all_prompts[i] = "positivePrompt" - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - - # a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728003403.py b/.history/scripts/StyleSelectorXL_20230728003403.py deleted file mode 100644 index 52fe23d..0000000 --- a/.history/scripts/StyleSelectorXL_20230728003403.py +++ /dev/null @@ -1,164 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -def createNegative(style, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - positivePrompt = createPositive(style, prompt) - p.all_prompts[i] =positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - - # a, negativePrompt = createprompts(style, "", prompt) - p.all_negative_prompts[i] = "negativePrompt" - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728003424.py b/.history/scripts/StyleSelectorXL_20230728003424.py deleted file mode 100644 index 80ab049..0000000 --- a/.history/scripts/StyleSelectorXL_20230728003424.py +++ /dev/null @@ -1,164 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -def createNegative(style, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("Select Style", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - positivePrompt = createPositive(style, prompt) - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - - negativePrompt = createNegative(style, prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728003757.py b/.history/scripts/StyleSelectorXL_20230728003757.py deleted file mode 100644 index 7d3d16f..0000000 --- a/.history/scripts/StyleSelectorXL_20230728003757.py +++ /dev/null @@ -1,164 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -def createNegative(style, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("SDXL Styles", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - positivePrompt = createPositive(style, prompt) - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - - negativePrompt = createNegative(style, prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/.history/scripts/StyleSelectorXL_20230728004143.py b/.history/scripts/StyleSelectorXL_20230728004143.py deleted file mode 100644 index 7d3d16f..0000000 --- a/.history/scripts/StyleSelectorXL_20230728004143.py +++ /dev/null @@ -1,164 +0,0 @@ -import contextlib - -import gradio as gr -from modules import scripts -from modules import script_callbacks -import json -import os - -stylespath = "" - - -def get_json_content(file_path): - try: - with open(file_path, 'r') as file: - json_data = json.load(file) - return json_data - except Exception as e: - print(f"A Problem occurred: {str(e)}") - - -def read_sdxl_styles(json_data): - # Check that data is a list - if not isinstance(json_data, list): - print("Error: input data must be a list") - return None - - names = [] - - # Iterate over each item in the data list - for item in json_data: - # Check that the item is a dictionary - if isinstance(item, dict): - # Check that 'name' is a key in the dictionary - if 'name' in item: - # Append the value of 'name' to the names list - names.append(item['name']) - - return names - - -def getStyles(): - global stylespath - json_path = os.path.join(scripts.basedir(), 'sdxl_styles.json') - stylespath = json_path - json_data = get_json_content(json_path) - styles = read_sdxl_styles(json_data) - return styles - - -def createPositive(style, positive): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - positive = template['prompt'].replace( - '{prompt}', positive) - - return positive - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -def createNegative(style, negative): - json_data = get_json_content(stylespath) - try: - # Check if json_data is a list - if not isinstance(json_data, list): - raise ValueError( - "Invalid JSON data. Expected a list of templates.") - - for template in json_data: - # Check if template contains 'name' and 'prompt' fields - if 'name' not in template or 'prompt' not in template: - raise ValueError( - "Invalid template. Missing 'name' or 'prompt' field.") - - # Replace {prompt} in the matching template - if template['name'] == style: - json_negative_prompt = template.get('negative_prompt', "") - if negative: - negative = f"{json_negative_prompt}, {negative}" if json_negative_prompt else negative - else: - negative = json_negative_prompt - - return negative - - # If function hasn't returned yet, no matching template was found - raise ValueError(f"No template found with name '{style}'.") - - except Exception as e: - print(f"An error occurred: {str(e)}") - - -class StyleSelectorXL(scripts.Script): - def __init__(self) -> None: - super().__init__() - - styleNames = getStyles() - - def title(self): - return "Style Selector for SDXL 1.0" - - def show(self, is_img2img): - return scripts.AlwaysVisible - - def ui(self, is_img2img): - with gr.Group(): - with gr.Accordion("SDXL Styles", open=True): - is_enabled = gr.Checkbox( - value=True, label="Enable Style Selector") - style = gr.Radio( - label='Codec', choices=self.styleNames, value='sai-base') - - # Ignore the error if the attribute is not present - - return [is_enabled, style] - - def process(self, p, is_enabled, style): - if not is_enabled: - return - - p.extra_generation_params["Style Selector Enabled"] = True - - for i, prompt in enumerate(p.all_prompts): # for each image in batch - - positivePrompt = createPositive(style, prompt) - p.all_prompts[i] = positivePrompt - # for each image in batch - for i, prompt in enumerate(p.all_negative_prompts): - - negativePrompt = createNegative(style, prompt) - p.all_negative_prompts[i] = negativePrompt - - def after_component(self, component, **kwargs): - # https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7456#issuecomment-1414465888 helpfull link - # Find the text2img textbox component - if kwargs.get("elem_id") == "txt2img_prompt": # postive prompt textbox - self.boxx = component - # Find the img2img textbox component - if kwargs.get("elem_id") == "img2img_prompt": # postive prompt textbox - self.boxxIMG = component - - # this code below works aswell, you can send negative prompt text box,provided you change the code a little - # switch self.boxx with self.neg_prompt_boxTXT and self.boxxIMG with self.neg_prompt_boxIMG - - # if kwargs.get("elem_id") == "txt2img_neg_prompt": - #self.neg_prompt_boxTXT = component - # if kwargs.get("elem_id") == "img2img_neg_prompt": - #self.neg_prompt_boxIMG = component diff --git a/scripts/__pycache__/SendtoTextImg.cpython-310.pyc b/scripts/__pycache__/SendtoTextImg.cpython-310.pyc deleted file mode 100644 index e53cda6cd246550102a1f71e7745bf47b5888ad4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2032 zcmZWqPmkL~6rUM8wv$cL(86vJMalsVMr_p<4hW%&0&P_RxdZ`?RR_bZhuh1U*B{*>B3(S=hS0q3xLd$#O?6TR~nm2Fe&71f9{`_2aIxPav&%ge{ zdmDuOhKsY04~tJ>=sQ3-;Z%}QJ<}0`HIv@VANdsbJm4Fn2Jk*_JSL;yF5v+W9}^x5 ze>Z&OjUrBmB#wTEyT~A>Hq@EQ=SBnDtJx$=r5vZ(p3WGaT0O|)_#B453}i_;-D4_P zk|FYJi!8|&@Ub_r=_CU0S|`37&p96ljF8AT9@uI=1DNM~~?hAzrBP{LHI7-ZDhs0s2ISr3Np0x{$f zc}AZTOzDukpaTeGLsxU5Y?LHqQ~xJcp$oQQ zawEkhV4V{_U0hms!pUDLvQrN*Q-H8G@VH}E`dq?c)8*U9n zfdz5I9x{-+qBx=tz3(7-KD>`SN{Z+@(eLb23Mr-JK8#nSADoq%#_yR9j6l=9{g-n?~2w&7$O)0OP34bWv%He9oNvIoAYv(``cZ`%kjhHf@Ik8bv@nY%SLNKD0>y?*$3n)QWs|}N zc`>hywqaQrWa74EQ)L@>Rawn#^H!FXibKcS;IqmYm_uysad}`{Sy`Z6nU8G*Juz28 zYumkLjLOHA5x12p;i63D*`8}~8-m)wy|3?DADP&9^`fvI0P#*i0(8;N1-u&(V=NL7 zn)9{9s{BpR)E@z9(H`K4PlMwwyYesl>B@0Cgq0sqb{x>?I0#O-)}K+A{oVQ}>h}JK zx{Ka={Z;u|^&t%4_!8}01F~e#pc9`%)dAeLmUKxHdb;Pq-lp4wf5FfJM(hu42(3Cx za&Eikz+h9XAkcPKO|n`;KD?OHWdVj!_s_fscf8Z-bWvo-PTH7G|0vhSs-4tD>bgx_MR1ciSEEYe^s0cMxRgwp zcRcU%Ea}QKf+$6v3_k@Z5Co7P4fIp=sh?q=iuS3WpsmnU{mt@Dk673{w zV>7R%;jGhXl{;Juc4+`0Ab|&*yC4$+_TX ztw)f*JC_qk?Do)GkusH6ytvmNWF8sC>kd@rtw&zqC9%r1(+j#$tE6kOihHn2FN|Pv zj7Wltc0?Rzx*YW35Ye(_gP0|nqqGxeQP)#TT(tmF<1TZU z!(AIK-r)Qrhs$R%5aKzy$Q%SzV~+2kky%>+W@hg@j{wz2d<63ZrL3G=dkmnhAT+xM7yR@n5G&tu#%;}|&$bKK$bQf>?TthHYfCB!fXRv0%?x@z5}xP-Yrw?yR& z#OB8gQCr@94^fLmg{Vae%G?|)PDQPA-x)_OS|)0%?SqSN_U;8qEWEc?f7v#OTJlzQ z`UrSS0>XZ0!!XIu>$lqy+uORqL)f*Lq$=s6U=ks)cLMK@~|@ zl!QuMdp}49kqHr9kr5OQBUzy?Yc~H^v(n(>RI!8!C%{t%;|M%|LgxrP z%U=VYAN*h7c`dgIIHC;TI60HA=8n9aI|P`VKwzW{)w%rN9HdGfm?vqwH{CLO6r` z2mk-GSv&IbE0_}EIdRcG=~6d9BCErMh5BOdQ)`0>TR5N8J9gykSsmjw)CuKr9Z?zA z5$?E-sE+H1+NVgWof+iFrk*qD>Z>D6mt~XR{Py)=XJ!_vmLQ)~$ zJ!b6|M`#TCk<_m5$Gtf7{l`o@DoQr+uKIqM1WNh-S79Mv#X3D&kXCN6;h8B_mL>~5 zp$e(9Of$(crUXK=f6h$zCR;&5klyMWAKdUREnO_W`eR5>$7U&uvm{cq7^&f~;i+jg zjKqo1BgrEjC=TgZTD9bl&}{MINSVEsYzMpQeVnAIF2KElK{{CdxV!l>o@q@Sbvxa@ z2O*7oPFVuHJ1i zNroGqTIo^sRdA1-M`*&qGKh333D%=TmzGlzg+o^b@dY}oQGEOy({&}hoyK9LwAULpmOnGMxHIqI^`&%QTidSFO7ZBZo8lm>eo^BUj0h zwznK3_W}hgD#3S$r;Tn$_Vx-d2w3nL)V(tBH=|x8k!?{u_X8Ppm99p;L6>-up20uG zI2kHQSxzqyXDUxBN!hIB7RYCP`8K*mu4S>w>$)*HMsJ#eKsP2!6#Z%QSCIJOZ1p=V zWU5HAe~r&0i`H2|oiB&aOxt}t>qO{KCZmURQWrsTzE2e;LIwp?Ek}9nqvRU%Z17GS z9{%g-*9B&D+PZ?uzw5_BH?p0KVtQ;8-5AICxDT|_C$s|y?x5HNee<2`;F_FJ4N(lG zJ^U)@@}2EKZmQ{h&jlMf|~&q!%H`x|zdHFyp6!|>enuBYZ816{_9cB@Vqno15XO~ESP!YuhyBCivnGf2Ki`7j-}Gdb4RpaSqkY-_lN&#Ou1eDJe?j3gmUAP*9nyD#>NC zLgYCjri7!PC{w2w`Vt-u@^pFC{0*B=95bm=&-|XaSBu4eM#)^!--m0tfKt7v*h$H% LyMX5#r_cQdG5yvB