Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WD14 image reverse inference prompt words #170

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add WD14 image reverse inference prompt words
  • Loading branch information
zdoek001 committed Jun 13, 2024
commit 689a60c4b9ee06ee0fe0e4ff5b66ef79e6d8407d
22 changes: 22 additions & 0 deletions webuiapi/webuiapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def __init__(
host="127.0.0.1",
port=7860,
baseurl=None,
taggerurl=None,
sampler="Euler a",
scheduler="automatic",
steps=20,
Expand All @@ -413,8 +414,15 @@ def __init__(
baseurl = f"https://{host}:{port}/sdapi/v1"
else:
baseurl = f"http://{host}:{port}/sdapi/v1"

if taggerurl is None:
if use_https:
taggerurl = f"https://{host}:{port}/tagger/v1"
else:
taggerurl = f"http://{host}:{port}/tagger/v1"

self.baseurl = baseurl
self.taggerurl = taggerurl
self.default_sampler = sampler
self.default_scheduler = scheduler
self.default_steps = steps
Expand Down Expand Up @@ -948,6 +956,20 @@ def interrogate(self, image, model="clip"):

response = self.session.post(url=f"{self.baseurl}/interrogate", json=payload)
return self._to_api_result(response)

def WD14_interrogate(self, image, model="wd14-vit-v2-git",threshold=0.35):
payload = {
"image": b64_img(image) if isinstance(image, Image.Image) else image,
"model": model,
'threshold':threshold,
}

response = self.session.post(url=f"{self.taggerurl}/interrogate", json=payload)
return self._to_api_result(response)

def WD14_interrogators(self):
response = self.session.get(url=f"{self.taggerurl}/interrogators")
return response.json()

def list_prompt_gen_models(self):
r = self.custom_get("promptgen/list_models")
Expand Down