From 6ac2a3c12ad461008edc2606c1a07fc265448015 Mon Sep 17 00:00:00 2001 From: BCC168 Date: Sat, 14 Dec 2024 02:32:58 +0800 Subject: [PATCH] docs:add Tagger API example --- README.md | 10 ++++++++++ webuiapi/webuiapi.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d3d2bc5..05c5174 100644 --- a/README.md +++ b/README.md @@ -506,6 +506,16 @@ semantic_seg_result = segment.sam_and_semantic_seg_with_cat_id( ) ``` +### Extension support - Tagger (contributed by C-BP) + +```python +# https://github.com/Akegarasu/sd-webui-wd14-tagger + +tagger = webuiapi.TaggerInterface(api) +result = tagger.tagger_interrogate(image) +print(result) +# {"caption": {"additionalProp1":0.9,"additionalProp2": 0.8,"additionalProp3": 0.7}} +``` ### Extension support - ADetailer (contributed by tomj2ee and davidmartinrius) #### txt2img with ADetailer ``` diff --git a/webuiapi/webuiapi.py b/webuiapi/webuiapi.py index 308d4d9..0500eed 100644 --- a/webuiapi/webuiapi.py +++ b/webuiapi/webuiapi.py @@ -2009,14 +2009,14 @@ class TaggerInterface: def __init__(self, webuiapi: WebUIApi): self.api = webuiapi - def tagger_interrogate(self, image, model="wd14-vit-v2-git", threshold=0.0, use_async=False): + def tagger_interrogate(self, image, model="wd14-vit-v2-git", threshold=0.3, use_async=False): """ Interrogates the tagger model with the provided image and parameters. Args: image (Image.Image or str): The image to be interrogated. Can be a PIL Image object or a base64 encoded string. model (str, optional): The model to use for interrogation. Defaults to "wd14-vit-v2-git". - threshold (float, optional): The threshold value for the model. Defaults to 0. + threshold (float, optional): The threshold value for the model. Defaults to 0.3 use_async (bool, optional): Whether to use asynchronous processing. Defaults to False. Returns: