Code Monkey home page Code Monkey logo

stable-diffusion-webui-wildcards's Introduction

Wildcards

An extension version of a script from https://github.com/jtkelm2/stable-diffusion-webui-1/blob/main/scripts/wildcards.py

Allows you to use __name__ syntax in your prompt to get a random line from a file named name.txt in the wildcards directory.

Install

To install from webui, go to Extensions -> Install from URL, paste https://github.com/AUTOMATIC1111/stable-diffusion-webui-wildcards.git into URL field, and press Install.

Install manually

Alternatively, to install by hand:

From your base stable-diffusion-webui directory, run the following command to install:

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui-wildcards extensions/stable-diffusion-webui-wildcards

Then restart the webui.

stable-diffusion-webui-wildcards's People

Contributors

automatic1111 avatar ryankhart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stable-diffusion-webui-wildcards's Issues

Add support to face editor

Hi, can support be added to face editor so that each face can have different expression in group picture? Thank you

[Feature Request] Add sequential order

Random order is great, but sometimes I want some control over the order, so can you add an option to allow sequential order, meaning it will allow reading from the rows from first to last, something like, __lora__ will pick a random row from lora.txt, ||lora||will pick from the first row to last in sequential order?

The reason I'm asking is that I want to do side by side comparison of several character loras. I have saved these loras in lora.txt, but since the row is randomly picked, sometimes I have trouble linking character to lora used. If there is an option of sequential order, it will be straightforward.

Feature request: "Add new wildcards file" from UI

It would be nice if it was possible to add a new file directly from the interface. Currently, you have to reuse existing files or search for the appropriate folder via SSH.

Changing the file name would also be very useful.

Suddenly stopped working

Yesterday the script worked just fine, and I was able to get random values from several different wildcard .txt files and all was right with the world, then last night, after I fired up stable diffusion/automatic1111 again, it just stopped working. I get an error of (color1 is just one of many files that worked fine before) in the cmd console:

WARNING:root:Could not find any wildcard files matching color1

The .txt files are in the proper \stable-diffusion-webui\extensions\stable-diffusion-webui-wildcards\wildcards directory. I have no idea what happened. Nothing changed as far as I know, I didn't install any other extensions in the time between when it worked and later when it didn't, and stable diffusion didn't update.

Deforum does not generate videos after the last update.

0
100%|████████████████████████████████████████████████████████████████████████████████| 110/110 [00:18<00:00, 5.85it/s]
2023-01-28 22:26:40,872 - root - INFO - Calibrating color correction. | 110/6666 [00:18<18:06, 6.03it/s]
Rendering animation frame 2 of 300
creating in between frame 0 tween:0.50
resized to 500x1000
creating in between frame 1 tween:1.00
resized to 500x1000
resized to 500x1000
Deforum progress: 2%|█ | 110/6666 [00:19<18:57, 5.76it/s]
Error completing request
Arguments: ('task(c4663zv6flaeiz1)', None, False, '', '3D', 300, 'wrap', '0:(0)', '0:(1.02+0.02sin(23.14*t/20))', '0:(0)', '0:(0)', '0:(1)', '0:(0)', '0:(0)', '0:(0)', False, '0:(0)', '0:(t%15)', '0:(0)', '0:(53)', '0: (0.02)', '0: (0.6)', '0: (1.0)', '0: (7)', False, '0: (25)', '0: (40)', '0: (200)', '0: (10000)', '0: (t%4294967293)', False, '0: ("Euler a")', '0: ("!({everywhere}^({init_mask}|{video_mask}) ) ")', False, '0: ("!({everywhere}^({init_mask}|{video_mask}) ) ")', False, '0: ("model1.ckpt"), 100: ("model2.ckpt")', '0: (5)', '0: (1.0)', '0: (0.1)', '0: (0.0)', True, 'Match Frame 0 LAB', 1.0, 2.0, 'perlin', 8.0, 8.0, 4, 0.5, True, 0.3, 200.0, 10000.0, 40.0, 'border', 'bicubic', False, '/content/video_in.mp4', 1, 0, -1, False, False, '/content/video_in.mp4', False, 4, False, '20220829210106', ong neck"\n}', 512, 1024, False, False, True, 0, 0, -1, 'Euler a', False, 1, 0.01, 0, 0, 110, 0.0, 1, False, 1, True, True, False, False, False, False, 'Deforum', '{timestring}{index}{prompt}.png', 'iter', 1, False, False, True, 0.6, 'https://user-images.githubusercontent.com/14872007/195867706-d067cdc6-28cd-450b-a61e-55e25bc67010.png', False, False, False, True, 'https://www.filterforge.com/wiki/images/archive/b/b7/20080927223728%21Polygonal_gradient_thumb.jpg', 1.0, 1.0, 5.0, 1, True, 4, 'reroll', False, 28.0, 'FFMPEG mp4', 'C:\stable-diffusion-webui\venv\lib\site-packages\imageio_ffmpeg\binaries\ffmpeg-win64-v4.2.2.exe', 17.0, 'veryslow', 'None', 'snowfall.mp3', False, False, 300.0, 'x0_pred', '/content/drive/MyDrive/AI/StableDiffusion/2022-09/20220903000939_%05d.png', '/content/drive/MyDrive/AI/StableDiffusion/content/drive/MyDrive/AI/StableDiffusion/2022-09/kabachuha/2022-09/20220903000939.mp4', False, 'RIFE v4.6', 'x3', 'x2', False, '', True, False, 'None', False, 'None', 'Farneback', False, 'None', False, 'None', False, False, '0:(1)', '0:(0.5)', '0:(1)', '0:(100)', '0:(0)', False, '{\n "0": "https://cdn.discordapp.com/attachments/1047760262637297664/1049851726200578058/a_dragon_flying_over_a_futuristic_city_dramatic_sky_cinematic_view_seed-1703716904ts-1670374556_idx-0.png",\n "50": "https://cdn.discordapp.com/attachments/1047760262637297664/1049901219004555274/a_digital_painting_of_a_fox_standing_in_the_grass_on_a_hill__trees_beh_t_outpaint_from-down_seed-1205071278ts-1670386356_idx-0.png",\n "100": "https://cdn.discordapp.com/attachments/745415989633482882/1048084925359857704/00024-2977479109-wings_hubble_images_jwst_images_6.png",\n "150": "https://cdn.discordapp.com/attachments/1011355905490694355/1047133257097031680/31_0031_31.jpg",\n "200": "https://cdn.discordapp.com/attachments/1047760262637297664/1049851726200578058/a_dragon_flying_over_a_futuristic_city_dramatic_sky_cinematic_view_seed-1703716904ts-1670374556_idx-0.png"\n}', '0:(.75)', '0:(.35)', '0:(.25)', '0:(20)', '0:(.075)', '

Deforum v0.5-webui-beta

', 'Made by deforum.github.io, port for AUTOMATIC1111's webui maintained by kabachuha', '\n If you liked this extension, please give it a star on GitHub! 😊', '', '', '', '', '

Import settings from file

', '

Animation settings

', '

Motion parameters:

', '

2D and 3D settings

', '

Prespective flip — Low VRAM pseudo-3D mode:

', '

Coherence:

', '

3D Depth Warping:

', '

Video Input:

', '

Interpolation (turned off atm)

', '

Resume animation:

', '

Prompts

', '

animation_mode: None batches on list of prompts. (Batch mode disabled atm, only animation_prompts are working)

', '

Important change from vanilla Deforum!

', '

This script uses the built-in webui weighting settings.

', '

So if you want to use math functions as prompt weights,

', '

keep the values above zero in both parts

', '

Negative prompt part can be specified with --neg

', '

Run settings

', '

Sampling settings

', '

3D Fov settings:

', '', '', '', '

Batch settings

', '

Init settings

', '

3D settings

', '

Steps scheduling:

', '

Video output settings

', '

To enable seed schedule select seed behavior — 'schedule'

', '\n Use an <a style='color:blue;' target='_blank' href='https://sd-parseq.web.app/deforum\'>sd-parseq manifest for your animation (leave blank to ignore).

\n

\n Note that parseq overrides:\n

    \n
  • Run: seed, subseed, subseed strength.
  • \n
  • Keyframes: generation settings (noise, strength, contrast, scale).
  • \n
  • Keyframes: motion parameters for 2D and 3D (angle, zoom, translation, rotation, perspective flip).
  • \n
\n

\n <p">\n Parseq does not override:\n
    \n
  • Run: Sampler, W, H, Restore faces, tiling, highres fix, resize seed.
  • \n
  • Keyframes: animation settings (animation mode, max_frames, border)
  • \n
  • Keyframes: coherence (color coherence & diffusion cadence)
  • \n
  • Keyframes: depth warping
  • \n
  • Video output settings: all settings (including fps and max frames)
  • \n
\n

\n ', '

Anti-blur settings

', '

Perlin noise params, if selected.

', '

Hybrid Video Compositing in 2D/3D Modeby reallybigname

', '
  • Composite video with previous frame init image in 2D or 3D animation_mode (not for Video Input mode)
  • Uses your Init settings for video_init_path, extract_nth_frame, overwrite_extracted_frames
  • In Keyframes tab, you can also set color_coherence = 'Video Input'
  • color_coherence_video_every_N_frames lets you only match every N frames
  • Color coherence may be used with hybrid composite off, to just use video color.
  • Hybrid motion may be used with hybrid composite off, to just use video motion.
Hybrid Video Schedules
  • The alpha schedule controls overall alpha for video mix, whether using a composite mask or not.
  • The hybrid_comp_mask_blend_alpha_schedule only affects the 'Blend' hybrid_comp_mask_type.
  • Mask contrast schedule is from 0-255. Normal is 1. Affects all masks.
  • Autocontrast low/high cutoff schedules 0-100. Low 0 High 100 is full range.
    (hybrid_comp_mask_auto_contrast must be enabled)
See main Deforum document for more details.', '

Hybrid Video Schedules

', '\n Use RIFE and other Video Frame Interpolation methods to smooth out, slow-mo (or both) your output videos.

\n

\n Supported engines:\n

    \n
  • RIFE v4.6, v4.3 and v4.0. Recommended for now: v4.6.
  • \n
  • RIFE v2.3 and other interpolation engines might come in the future.
  • \n
\n

\n

\n Important notes:\n

    \n
  • ffmpeg has to be installed for this feature to work properly. If you can't have it, make sure to check the "keep_imgs" tab so that your interpolated frames are saved into HD'\n
  • Frame Interpolation will not run if 'store_frames_in_ram' is enabled.
  • \n
  • Audio (if provided) will be transferred to the interpolated video even if Slow-Mo is enabled.
  • \n
  • Frame Interpolation will always save an .mp4 video even if you used GIF for the raw video.
  • \n
\n

\n ', 'Supports boolean operations (! - negation, & - and, | - or, ^ - xor, \ - difference, () - nested operations); default variables in \{\}, like \{init_mask\}, \{video_mask\}, \{everywhere\}; masks from files in [], like [mask1.png]; description-based word masks in <>, like <apple>, <hair>') {}
Traceback (most recent call last):
File "C:\stable-diffusion-webui\modules\call_queue.py", line 56, in f
res = list(func(*args, **kwargs))
File "C:\stable-diffusion-webui\modules\call_queue.py", line 37, in f
res = func(*args, **kwargs)
File "C:\stable-diffusion-webui\extensions\deforum-for-automatic1111-webui\scripts\deforum.py", line 85, in run_deforum
render_animation(args, anim_args, video_args, parseq_args, loop_args, root.animation_prompts, root)
File "C:\stable-diffusion-webui/extensions/deforum-for-automatic1111-webui/scripts\deforum_helpers\render.py", line 285, in render_animation
noised_image = add_noise(contrast_image, noise, args.seed, anim_args.noise_type,
File "C:\stable-diffusion-webui/extensions/deforum-for-automatic1111-webui/scripts\deforum_helpers\noise.py", line 62, in add_noise
sample = cv2.addWeighted(sample, 1-noise_amt, noise_to_add, noise_amt, 0)
cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\core\src\arithm.cpp:650: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'cv::arithm_op'

Wildcard weight doesn't modify LoRA weight

Hello, for a while I've had problems sometimes when using several wildcards with LoRAs at the same time despite lowering wildcard weights accordingly.
I have noticed that that only modifies the weight of trigger words but not of the LoRAs themselves.
I would like to ask if it would be possible to add that function.
EG: if lora:baccon:0.8 is in a wildcard file set in prompt to :0.5, then it should be lora:baccon:0.4 or lora:baccon:0.8:0,5 (idk if this last one would work).

Edit: I have just noticed that for wildcard lines with more than one word, the weight is only added to the last one. This limits greatly what can be done with the wildcard tool.
So what happens is (a, b, c)*0.4=a, b, c:0.4 instead of a:0.4, b:0.4, c:0.4

wildcards worked great, but not now.

1, if I put something in the prompt area, like cube, I get a message in the command window: cube.txt not found for the cube wildcard.

2, typing artists (for example) used to pop up an auto complete. But it doesn't anymore. Possibly related, the --deepdanbooru auto complete doesn't seem to come up either.

[Feature Request] Add support for inline wildcards

Add support for these kinds of prompts

a very cute ((__color__ __{cat;dog;monkey;fish}__))

This is meant to look for words in a file called color.txt ofcourse as it does by default, but also when it encounters a "chunk" surrounded by __{ and }__ it should directly pick a word from in-between those

Here is some basic code that allows for this, but it could definitely be improved

def is_inline_wilcard(self, text):
	return "}" in text and "}" in text

def replace_wildcard(self, text):
	if " " in text or len(text) == 0:
		return text
		
	# very basic but it works
	if self.is_inline_wilcard(text):
		choices = text.replace("{", "").replace("}", "").split(";")
		assert len(choices) > 0
		return random.choice(choices).replace("_", " ")
	else:
		file_dir = os.path.dirname(os.path.realpath("__file__"))
		replacement_file = os.path.join(file_dir, f"scripts\\wildcards\\{text}.txt")
		if os.path.exists(replacement_file):
			with open(replacement_file, encoding="utf8") as f:
				return random.choice(f.read().splitlines())
		else:
			if replacement_file not in warned_about_files:
				print(f"File {replacement_file} not found for the __{text}__ wildcard.", file=sys.stderr)
				warned_about_files[replacement_file] = 1

	return text

Not sure if Wildcards working or not

I cannot find a clear tutorial on this Wildcards thing, besides some cool stuffs people wrote about this feature at Reddit.

I did try all the steps:

  • dynamic prompting
  • wildcard manager set to parrotzone
  • actually use the blah in the prompt

For example:
"portrait of cute lady with marvelous color hair"
Screenshot 2022-12-22 at 11 57 14 pm

I activated "Write Prompts To File" as well, hoping I could get a list of all the prompts generated via wildcards modifier, however none seems to be working?
Screenshot 2022-12-22 at 11 58 04 pm

Using Wildcards in the Negative Prompt

I've looked everywhere & can't find a workaround. Is there any way you could update the extension to include the ability to use wildcards for negative prompts as well?

[Possible PR] Wildcards ported from outdated script

Looks like this script didn't bring over the updates I made to the existing wildcard script that handled image grid generation as a final step, fixed seed issues, and added wildcard prompt info to the PNG metadata.

If those aren't something to be handled by extensions anymore then perhaps this can be closed, but otherwise these two commits should be simple enough to port to the new script. Let me know if you'd prefer if I submitted as a PR, or if there was a reason the outdated script was used (these were previously already merged into the jtkelm2 script).

AUTOMATIC1111/stable-diffusion-webui@8969bb4
AUTOMATIC1111/stable-diffusion-webui@5a4a343
(note that the 2nd commit fixes a few issues noticed/mentioned when developing 1st commit)

Thanks,
Aphix

random function

I don’t know if there is a way to turn off the random function? Sometimes I want to test the prompt words in order.

Wildcards not populated in hires prompt when using hires fix

Hires prompts are not properly modified to remove __wildcard__ tokens. Stepping through the debugger in sample_hr_pass in processing.py in the main stable-diffusion repo, I see that a number of hires-related prompt variables do not have the wildcards properly replaced: at least self.all_hr_prompts, self.hr_prompts, and self.hr_prompt. Anecdotally, this explains why all of my generations look decent on the first txt2img pass, but become very same-y after the hires pass.

I have to assume this was broken a long time ago when the base repo introduced the ability to set a different prompt for the hires pass AUTOMATIC1111/stable-diffusion-webui@ff0e171

The dynamic prompts extension had to put in a fix for this, so I assume it's also needed here adieyal/sd-dynamic-prompts#474

Loras in wildcard prompts

I don't think it's correctly handling loras in wildcard prompts in a batch

I have a wildcard file of the following lines:

lora:TLOK_Asami_Sato_v4:0.6, TLOK_Asami_Sato, \green eyes, black hair, main_outfit
lora:YangXiaoLong:1, ((yellow hair)), yang xiao long, (prosthetic arm), smile, ahoge purple eyes, brown jacket, waist coat
lora:nora_valkyrie:0.6, nora_valkyrie, looking at viewer, smile, short hair, [[blue eyes]], gloves, jacket, pink skirt, pink belt, short sleeves, puffy sleeves, fingerless gloves, orange hair

They are character loras for Asami Sato from Legend of Korra, and Yang Xiao Long + Nora Valkyrie from RWBY, for visual reference. When I run this prompt using a batch size of 1 and batch count of 6, I get what I'd expect:

image

But when I generate with a batch size of 6 and batch count of 1, I think it's including the lora used for the first image in all the images generated.

Here's the one that starts with Nora:
grid-0007

Here's the one that starts with Yang:
grid-0008

Here's the one that starts with Asami:
grid-0009

Suddently stopped working, it keeps printing an utf-8 error

Till yesterday everything worked fine, but today, using the same wildcards and prompts it doesn't works and prints this in the terminal each time i start a generation that includes wildcards in it's prompt:

*** Error running process: D:\Red-AI\stable-diffusion-webui\extensions\stable-diffusion-webui-wildcards\scripts\wildcards.py
    Traceback (most recent call last):
      File "D:\Red-AI\stable-diffusion-webui\modules\scripts.py", line 718, in process
        script.process(p, *script_args)
      File "D:\Red-AI\stable-diffusion-webui\extensions\stable-diffusion-webui-wildcards\scripts\wildcards.py", line 49, in process
        p.all_prompts = self.replace_prompts(p.all_prompts, p.all_seeds)
      File "D:\Red-AI\stable-diffusion-webui\extensions\stable-diffusion-webui-wildcards\scripts\wildcards.py", line 42, in replace_prompts
        res.append("".join(self.replace_wildcard(chunk, gen) for chunk in text.split("__")))
      File "D:\Red-AI\stable-diffusion-webui\extensions\stable-diffusion-webui-wildcards\scripts\wildcards.py", line 42, in <genexpr>
        res.append("".join(self.replace_wildcard(chunk, gen) for chunk in text.split("__")))
      File "D:\Red-AI\stable-diffusion-webui\extensions\stable-diffusion-webui-wildcards\scripts\wildcards.py", line 27, in replace_wildcard
        return gen.choice(f.read().splitlines())
      File "C:\Users\enric\AppData\Local\Programs\Python\Python310\lib\codecs.py", line 322, in decode
        (result, consumed) = self._buffer_decode(data, self.errors, final)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 7: invalid continuation byte

"greyscale input: true" - how do I turn this off?

It is making my images black and white. I never asked this to happen. I don't see a setting to turn it off.

Edit: oops, wrong plugin-I was using the wildcards in dynamic prompts. Please delete this.

Wildcard characters cannot be used with random input problem

44_$A5NW9( B @{62S$SNMY

What is the reason for this?
I can't use the wildcard color to input random words in forward words, but I can use the wildcard color to input random words in reverse words.

There is only one case that can be used in the forward word, that is, only color without any words, and just adding a space or comma after color will not work for random input words.

image

Suggestion Click to add to prompt

suggestion -- use left click to add catagory and individual items to prompt rather than having to copy on paste each -- or control click shortcut to add just an idea to speed up things if it has not been suggested before

Wildcards location

Hi, I'm trying this plugin for the first time, I created the name.txt in the wildcards folder in the extensions but when I try and call the wildcard in the prompt I am met with the following error. I am using __name__ in my prompt as directed. I have tried different names for the wildcards also.

WARNING:root:Could not find any wildcard files matching name
INFO:dynamic_prompting.py:Prompt matrix will create 1 images in a total of 1 batches.

image generation is normal but without the wildcards of course.

I have tried placing the text file in various locations including the root directory and in a directory called wildcards in the root and could not figure it out.
Thanks so much

Request: add utf-8 support

I got following error when trying to use a list of names from this link (https://civitai.com/models/70708?modelVersionId=79565) and saved in a txt file in wildcards folder.
Error running process: D:\stable-diffusion\stable-diffusion-webui\extensions\stable-diffusion-webui-wildcards\scripts\wildcards.pys] Traceback (most recent call last): File "D:\stable-diffusion\stable-diffusion-webui\modules\scripts.py", line 418, in process script.process(p, *script_args) File "D:\stable-diffusion\stable-diffusion-webui\extensions\stable-diffusion-webui-wildcards\scripts\wildcards.py", line 41, in process prompt = "".join(self.replace_wildcard(chunk, gen) for chunk in prompt.split("__")) File "D:\stable-diffusion\stable-diffusion-webui\extensions\stable-diffusion-webui-wildcards\scripts\wildcards.py", line 41, in <genexpr> prompt = "".join(self.replace_wildcard(chunk, gen) for chunk in prompt.split("__")) File "D:\stable-diffusion\stable-diffusion-webui\extensions\stable-diffusion-webui-wildcards\scripts\wildcards.py", line 25, in replace_wildcard return gen.choice(f.read().splitlines()) File "C:\Users\Meng Lu\AppData\Local\Programs\Python\Python310\lib\codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 221: invalid continuation byte

error

having this error
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.