-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
Some of my generated images are good enough to be fed back into the training data, I'd love to have an option to automatically read the positive prompt and use it as a caption.
It would be great to also have it automatically remove parentheses, weights and extra networks like Loras from the caption data.
I'd love to implement it myself but a quick look wasn't enough to fully understand the code. Sadly I don't have experience with gradio.
with gr.Column():
self.cb_load_recursive = gr.Checkbox(value=cfg_general.load_recursive, label='Load from subdirectories')
self.cb_load_caption_from_filename = gr.Checkbox(value=cfg_general.load_caption_from_filename, label='Load caption from filename if no text file exists')
self.cb_replace_new_line_with_comma = gr.Checkbox(value=cfg_general.replace_new_line, label='Replace new-line character with comma')
Something like this would work for the cleanup:
import re
example = "((1girl), solo:1.4),(masterpiece:1.3:), best quality, (ultra-detailed), illustration, perfect lighting, (beautiful 8K CG:1.2),(realistic:1.3), (full-body view:1.4), (high updo hairstyle:1.4), <lora:style:0.5:MIDD>"
text = re.sub(r"\(|\)", "", example)
text = re.sub(r"<.*?>", "", text)
result = re.sub(r"(:[^,]+)(,?)", r"\g<2>", text)
print(result)
Result:
1girl, solo,masterpiece, best quality, ultra-detailed, illustration, perfect lighting, beautiful 8K CG,realistic, full-body view, high updo hairstyle,
toshiaki1729, NEXTAltair and CommieDogtoshiaki1729
Metadata
Metadata
Assignees
Labels
No labels
