bfs for wildcard
This commit is contained in:
parent
f1e1d2f7d7
commit
ff8d649cac
@ -1 +1 @@
|
||||
version = '2.1.715'
|
||||
version = '2.1.716'
|
||||
|
@ -116,9 +116,6 @@ def worker():
|
||||
skip_prompt_processing = False
|
||||
refiner_swap_method = advanced_parameters.refiner_swap_method
|
||||
|
||||
raw_prompt = prompt
|
||||
raw_negative_prompt = negative_prompt
|
||||
|
||||
inpaint_image = None
|
||||
inpaint_mask = None
|
||||
inpaint_head_model_path = None
|
||||
@ -231,10 +228,12 @@ def worker():
|
||||
tasks = []
|
||||
for i in range(image_number):
|
||||
task_seed = seed + i
|
||||
task_prompt = apply_wildcards(prompt, task_seed)
|
||||
task_negative_prompt = apply_wildcards(negative_prompt, task_seed + 1)
|
||||
task_extra_positive_prompts = [apply_wildcards(pmt, task_seed) for pmt in extra_positive_prompts]
|
||||
task_extra_negative_prompts = [apply_wildcards(pmt, task_seed) for pmt in extra_negative_prompts]
|
||||
task_rng = random.Random(task_seed) # may bind to inpaint noise in the future
|
||||
|
||||
task_prompt = apply_wildcards(prompt, task_rng)
|
||||
task_negative_prompt = apply_wildcards(negative_prompt, task_rng)
|
||||
task_extra_positive_prompts = [apply_wildcards(pmt, task_rng) for pmt in extra_positive_prompts]
|
||||
task_extra_negative_prompts = [apply_wildcards(pmt, task_rng) for pmt in extra_negative_prompts]
|
||||
|
||||
positive_basic_workloads = []
|
||||
negative_basic_workloads = []
|
||||
|
@ -1,6 +1,5 @@
|
||||
import os
|
||||
import re
|
||||
import random
|
||||
import json
|
||||
|
||||
from modules.util import get_files_from_folder
|
||||
@ -9,6 +8,7 @@ from modules.util import get_files_from_folder
|
||||
# cannot use modules.path - validators causing circular imports
|
||||
styles_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../sdxl_styles/'))
|
||||
wildcards_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../wildcards/'))
|
||||
wildcards_max_bfs_depth = 64
|
||||
|
||||
|
||||
def normalize_key(k):
|
||||
@ -98,21 +98,21 @@ def apply_style(style, positive):
|
||||
return p.replace('{prompt}', positive), n
|
||||
|
||||
|
||||
def apply_wildcards(wildcard_text, seed=None, directory=wildcards_path):
|
||||
placeholders = re.findall(r'__(\w+)__', wildcard_text)
|
||||
if len(placeholders) == 0:
|
||||
return wildcard_text
|
||||
def apply_wildcards(wildcard_text, rng, directory=wildcards_path):
|
||||
for _ in range(wildcards_max_bfs_depth):
|
||||
placeholders = re.findall(r'__(\w+)__', wildcard_text)
|
||||
if len(placeholders) == 0:
|
||||
return wildcard_text
|
||||
|
||||
print(f'[Fooocus Wildcards] input: {wildcard_text}')
|
||||
rng = random.Random(seed)
|
||||
for placeholder in placeholders:
|
||||
try:
|
||||
words = open(os.path.join(directory, f'{placeholder}.txt'), encoding='utf-8').read().splitlines()
|
||||
words = [x for x in words if x != '']
|
||||
wildcard_text = wildcard_text.replace(f'__{placeholder}__', rng.choice(words), 1)
|
||||
except IOError:
|
||||
print(f'Error: could not open wildcard file {placeholder}.txt, using as normal word.')
|
||||
wildcard_text = wildcard_text.replace(f'__{placeholder}__', placeholder)
|
||||
print(f'[Fooocus Wildcards] output: {wildcard_text}')
|
||||
|
||||
return wildcard_text
|
||||
print(f'[Wildcards] processing: {wildcard_text}')
|
||||
for placeholder in placeholders:
|
||||
try:
|
||||
words = open(os.path.join(directory, f'{placeholder}.txt'), encoding='utf-8').read().splitlines()
|
||||
words = [x for x in words if x != '']
|
||||
assert len(words) > 0
|
||||
wildcard_text = wildcard_text.replace(f'__{placeholder}__', rng.choice(words), 1)
|
||||
except:
|
||||
print(f'[Wildcards] Warning: {placeholder}.txt missing or empty. '
|
||||
f'Using "{placeholder}" as a normal word.')
|
||||
wildcard_text = wildcard_text.replace(f'__{placeholder}__', placeholder)
|
||||
print(f'[Wildcards] {wildcard_text}')
|
||||
|
1
wildcards/color_flower.txt
Normal file
1
wildcards/color_flower.txt
Normal file
@ -0,0 +1 @@
|
||||
__color__ __flower__
|
250
wildcards/flower.txt
Normal file
250
wildcards/flower.txt
Normal file
@ -0,0 +1,250 @@
|
||||
Acacia
|
||||
Achillea
|
||||
Adam's-needle
|
||||
African Boxwood
|
||||
African Lily
|
||||
Agapanthus
|
||||
Ageratum
|
||||
Ageratum houstonim
|
||||
Allium
|
||||
Alpina
|
||||
Alstroemeria
|
||||
Amaranthus hypochondriacus
|
||||
Amaryllis
|
||||
Ammi majus
|
||||
Anconitum
|
||||
Anemone
|
||||
Anigozanthus
|
||||
Annual Delphinium
|
||||
Anthurium
|
||||
Antirrhinum majus
|
||||
Artichoke thistle
|
||||
Asparagus
|
||||
Aster
|
||||
Astilbe
|
||||
Baby's Breath
|
||||
Bachelor's Button
|
||||
Banksia
|
||||
Bellflower
|
||||
Big Flax
|
||||
Bighead Knapweed
|
||||
Billy Buttons
|
||||
Bird of Paradise
|
||||
Blazing Star
|
||||
Blue Lace Flower
|
||||
Boronia
|
||||
Bouvardia
|
||||
Boxwood African
|
||||
Diosma
|
||||
Buckthorn Variegated
|
||||
Buddleia
|
||||
Bupleurum
|
||||
Butterfly Bush
|
||||
Butterfly Orchid
|
||||
Calla Lily
|
||||
Campanula
|
||||
Candytuft
|
||||
Canterbury Bells
|
||||
Carnation
|
||||
Carthamus
|
||||
Casa Blanca
|
||||
Caspia
|
||||
Cattleya
|
||||
Celosia
|
||||
Celosia argenta
|
||||
Centaurea cyanus
|
||||
Chamelaucium
|
||||
Chimney Bells
|
||||
Chrysanthemum
|
||||
Chrysanthemum x morifolium
|
||||
Clarkia
|
||||
Cockscomb Crested
|
||||
Coffee Bean Berry
|
||||
Common Myrtle
|
||||
Common Yarrow
|
||||
Cone Flower
|
||||
Consolida ambigua
|
||||
Convallaria
|
||||
Cordyline
|
||||
Cosmos
|
||||
Cornflower
|
||||
Craspedia
|
||||
Curly Willow
|
||||
Cymbidium
|
||||
Cymbidium Orchid
|
||||
Daffodil
|
||||
Dahlia
|
||||
Daisy Mums
|
||||
Delphinium Belladonna
|
||||
Delphinium Pacific Giant
|
||||
Dendrobium
|
||||
Dendrobium Orchid
|
||||
Dianthus barbatus
|
||||
Dianthus caryophyllus
|
||||
Dianthus caryophyllus nana
|
||||
Erica spp
|
||||
Eucalyptus seeded
|
||||
Eucalyptus silver dollar
|
||||
Eustoma grandiflorum
|
||||
False Bird of Paradise
|
||||
False Spirea
|
||||
Farewell-To-Spring
|
||||
Fernleaf Yarrow
|
||||
Feverfew
|
||||
Flamingo Flower
|
||||
Flax New Zealand
|
||||
Floss Flower
|
||||
Foxtail Fern
|
||||
Freesia
|
||||
Freesia x hybrida
|
||||
Fuji Mums
|
||||
Gardenia
|
||||
Gay Feather
|
||||
Genista
|
||||
Gerbera
|
||||
Gerbera Ruby Red
|
||||
Ginger
|
||||
Gladiolus
|
||||
Gladiolus hybrid nanus
|
||||
Goat's Beard
|
||||
Godetia
|
||||
Golden Rod
|
||||
Guersney Lily
|
||||
Gyp
|
||||
Gypsophila paniculata
|
||||
Hanging Helicona
|
||||
Heath
|
||||
Heather
|
||||
Helianthus annuus
|
||||
Heliconia spp.
|
||||
Hippeastrum
|
||||
Hydrangea
|
||||
Iberis amara
|
||||
Inca Lily
|
||||
Iris
|
||||
Japhette Orchid
|
||||
Jonquil
|
||||
Knapweed
|
||||
Lace fern
|
||||
Larkspur
|
||||
Lathyrus odoratus
|
||||
Lavandula
|
||||
Lavender
|
||||
Liatris
|
||||
Lilac
|
||||
Lily
|
||||
Lilly-of-the-Valley
|
||||
Lily Casa Blanca
|
||||
Lily of the Field
|
||||
Lily of the Nile
|
||||
Lily Stargazer
|
||||
Limonium
|
||||
Lisianthus
|
||||
Marguerite daisy
|
||||
Mattholia incana
|
||||
Melaleuca
|
||||
Memosa
|
||||
Misty Blue Limonium
|
||||
Moluccella laevis
|
||||
Monkshood
|
||||
Montbretia
|
||||
Monte Cassino
|
||||
Moon orchid
|
||||
Musa
|
||||
Myrsine
|
||||
Myrtle
|
||||
Myrtus
|
||||
Nephrolepis
|
||||
Nerine
|
||||
Nerine Lily
|
||||
Nigella
|
||||
Ornithogalum
|
||||
Paeonia
|
||||
Painted Tongue
|
||||
Paper Reed
|
||||
Papyrus lion's head
|
||||
Peony
|
||||
Peruvian Lily
|
||||
Phalaenopsis
|
||||
Philodendron
|
||||
Phlox
|
||||
Pincushion Flower
|
||||
Pink Mink
|
||||
Pitt
|
||||
Pittosporum
|
||||
Pixie Carnation
|
||||
Polianthes tuberosa
|
||||
Pompon Chrysanthemum
|
||||
Poppy Anemone
|
||||
Porium
|
||||
Pussy Willow
|
||||
Queen Anne's Lace
|
||||
Ranunculus
|
||||
Red Ribbons
|
||||
Rice flower
|
||||
Rose
|
||||
Rose Bridal Pink
|
||||
Rose Bridal White
|
||||
Rose Champagne
|
||||
Rose Diadem
|
||||
Rose Emblem
|
||||
Rose Kardinal
|
||||
Rose Lady Liberty
|
||||
Rose Lavanda
|
||||
Rose Osiana
|
||||
Rose Royalty
|
||||
Safari Sunset
|
||||
Safflower
|
||||
Sage Perennial
|
||||
Salix
|
||||
Salmon Reagan
|
||||
Sansevieria
|
||||
Saponaria
|
||||
Satin Flowers
|
||||
Saxicola
|
||||
Scabiosa
|
||||
Schinus
|
||||
Sea lavender
|
||||
Shell Flowers
|
||||
Snake Plant
|
||||
Snapdragon
|
||||
Solidago
|
||||
Solidaster
|
||||
Speedwell
|
||||
Spider Lily
|
||||
Spider Mums
|
||||
Spray Carnation
|
||||
Sprengeri Fern
|
||||
Star of Bethlehem
|
||||
Statice
|
||||
Stenamezon
|
||||
Stephanotis
|
||||
Strawberry banksia
|
||||
Strawflower
|
||||
Summer poinsettia
|
||||
Summer's Darling
|
||||
Sunflower
|
||||
Sweet Pea
|
||||
Sweet William
|
||||
Sword Fern
|
||||
Syringa vulgaris
|
||||
Tailflowers
|
||||
Tassel flower
|
||||
Thouroughwax
|
||||
Throatwort
|
||||
Tracelium
|
||||
Tree Fern
|
||||
Trumpet Lily
|
||||
Tuberose
|
||||
Tulip
|
||||
Tulipa
|
||||
Veronica
|
||||
Wattle
|
||||
Waxflower
|
||||
Wild Plantain
|
||||
Willow curly
|
||||
Windflower
|
||||
Wolfsbane
|
||||
Zantedeschia
|
||||
Zinna
|
||||
Zinnia elegans
|
Loading…
Reference in New Issue
Block a user