script that runs the interrogator before processing each image
- Batch interrogation for img2img with multiple model support
- Plugin/API capability - Other extensions can integrate with this interrogator
- Multiple interrogation models - CLIP (Native/EXT), Deepbooru, WD14 Tagger
- Advanced filtering - Remove duplicates, custom filters, find & replace
- Keep Tags functionality - Override confidence thresholds for specific tags
- Experimental tools - Debug mode, reverse mode, punctuation filtering, and more
For the script to run, make sure that script checkbox is checked and a interrogator is selected.
[Interrogation Model(s)
]: The interrogators will run in the order of user selection.
[CLIP (EXT)
]: If user does not have a installed, and enabled version of clip-interrogator-ext
, then CLIP (EXT)
will not appear in the interrogator selection dropdown menu.
[WD (EXT)
]: If user does not have a installed, and enabled version of stable-diffusion-webui-wd14-tagger
, then WD (EXT)
will not appear in the interrogator selection dropdown menu.
[Interrogator results position
]: User can determine if the interrogation result is positioned at the beginning or end of the prompt.
This menu will only appear if CLIP (EXT)
is selected.
[CLIP Extension Model(s)
]: Users may select multiple interrogation models, interrogators will run in the order of user selection.
[CLIP Extension Mode
]: User may select what mode the CLIP extention interrogator will run in: best
, fast
, classic
, or negative
[Unload CLIP Interrogator After Use
]: User has the option to keep interrogators loaded or have interrogators unloaded at the end of each interrogation.
- It is advisable to unload models because of memory usage, however, keeping model loaded will be faster
[Unload All CLIP Interrogators
]: User has the ability to unload all CLIP interrogation models by pressing the Unload All CLIP Interrogators
button.
- User can also unload CLIP interrogators from the CLIP interrogator extention tab.
This menu will only appear if WD (EXT)
is selected.
[WD Extension Model(s)
]: Users may select multiple tagger models, taggers will run in the order of user selection.
[Tag Sensitivity Threshold
]: Tagger models will use threshold
to determine if a suspected tag should be applied. Tags that do not meet the threshold will not be applied.
[Remove Underscores from Tags
]: User has the option to remove underscores from tags. The models inherently have underscores between words instead of spaces, this option replaces underscores with spaces.
- To ensure that this option does not mutilate text emojis, underscores are compared against a list of underscore emojis to determine if replacement is nessassary.
[Append Interpreted Rating(s)
]: User has the option to append the rating to each interrogation.
- [
Rating(s) Sensitivity Threshold
]: IfAppend Interpreted Rating(s)
is disabled this slider will be hidden. - Note, setting the rating sensitivity to zero will result in all ratings being appended.
[Unload Tagger After Use
]: User has the option to keep taggers loaded or have taggers unloaded at the end of each interrogation.
- It is advisable to unload models because of memory usage, however, keeping model loaded will be faster
[Unload All Tagger Models
]: User has the ability to unload all tagger models by pressing the Unload All Tagger Models
button.
- User can also unload CLIP interrogators from the CLIP interrogator extention tab.
Users have the ability to filter content out of the interrogation prompts.
- [
Filter Duplicate Positive Prompt Entries from Interrogation
]: Users can remove content from interrogations that was already added by the user in the prompt, this prevents exageration of prompt entries. - [
Filter Duplicate Negative Prompt Entries from Interrogation
]: Users can remove content from interrogations that is in the negative prompt, this prevents contradicting the negative prompt. - [
Filter Custom Prompt Entries from Interrogation
]: Users can create their own custom filter to remove content from interrogations without modifying the prompt or negative prompt.
-
Note, if
Filter Custom Prompt Entries from Interrogation
is not enabled, options associated with it will be hidden -
[
Custom Filter Prompt
]: Users can add their custom filter to the provided textbox. Please note, any attention syntax will be ignored, as any entry matching added entries are filtered. -
[
Optimize Custom FIlter
]: User can optimize custom filter, optimize will remove duplicate entries, extra spaces, and empty entries. -
[
Load Custom Filter
]: User can load custom filter from the previous save -
[
Save Custom Filter
]: User can scae custom filter for future use WARNING: Saving the custom filter will overwrite previous custom filter save. -
[
Find & Replace User Defined Pairs in the Interrogation
]: Users can create their own custom find and replace lists to replace words and phrases in the interrogations without modifying the prompt or negative prompt.
- Note, if
Find & Replace User Defined Pairs in the Interrogation
is not enabled, options associated with it will be hidden - [
Find
]: Users can add their custom phrases and words, seperated by comma, to find in the provided textbox. - [
Replace
]: Users can add their custom phrases and words replacements, seperated by comma, in the provided textbox. Leaving an entry blank will result in deleting the word from the interrogation prompt. - [
Parsed Pairs Visualizer
]: These two lists of find phrases and words will be paired with their replace counterparts. Pairing is based on order in the lists. - [
Load Custom Replace
]: User can load custom replace from the previous save - [
Save Custom Replace
]: User can scae custom replace for future use WARNING: Saving the custom replace lists will overwrite previous custom replace lists save.
A bunch of tools that were added that are helpful with understanding the script, or offer greater variety with interrogation output.
- [
Enable Debug Mode
]: DEBUG statements will be printed to console log. - [
Enable Reverse Mode
]: Interrogation will be added to the negative prompt. - [
Enable No Puncuation Mode
]: Interrogation will be filtered of all puncuations (except for a variety of emoji art). - [
Enable Exaggeration Mode
]: Interrogators will be permitted to add depulicate responses. - [
Enable Interrogator Prompt Weight
]: Use attention syntax on interrogation.- [
Interrogator Prompt Weight
]: This slider will specify the attention weight.- This option is hidden if
Enable Interrogator Prompt Weight
is not enabled.
- This option is hidden if
- [
- [
Enable Prompt Output
]: Prompt statements will be printed to console log after every interrogation.
The extension now automatically saves interrogation results and model information to the generation parameters, making it easy to track what models and settings were used for each image.
Other extensions can import a global interrogation_processor
instance and call
its process_batch
method. This makes it possible to run interrogation logic on
images without showing the UI.
from extensions.sd_Img2img_batch_interrogator.scripts.sd_tag_batch import interrogation_processor
# p is a StableDiffusionProcessingImg2Img object
result_prompt = interrogation_processor.process_batch(
p=p,
tag_batch_enabled=True,
model_selection=["WD (EXT)", "CLIP (Native)"],
# any additional parameters from the UI can be passed here
prompt_override="custom prompt", # optional
image_override=custom_image, # optional PIL.Image
update_p=False # when False, p remains unchanged
)
print("Interrogation result:", result_prompt)
p
: theStableDiffusionProcessingImg2Img
instance to operate ontag_batch_enabled
: enable or disable interrogation processingmodel_selection
: ordered list of interrogators to runprompt_override
: optional text to use instead ofp.prompt
image_override
: optional image to interrogate instead ofp.init_images[0]
update_p
: ifFalse
, restore the originalp
after interrogation and return only the resulting prompt
The return value is the prompt string including the interrogation results.
You can reuse the script's UI components inside another extension:
import gradio as gr
from extensions.sd_Img2img_batch_interrogator.scripts.sd_tag_batch import interrogation_processor
with gr.Tab("Batch Interrogator"):
ui_elems = interrogation_processor.ui(is_img2img=True, skip_check=True)
Passing skip_check=True
allows the UI to be displayed outside of the default
img2img tab.