Compare commits

..

3 commits

6 changed files with 31 additions and 1 deletions

View file

@ -21,4 +21,7 @@ IMAGE_GENERATION_ENDPOINT="http://127.0.0.1:7860/sdapi/v1/txt2img"
IMAGE_GENERATION_BACKEND="sdwui" # openai or sdwui or localai IMAGE_GENERATION_BACKEND="sdwui" # openai or sdwui or localai
IMAGE_GENERATION_SIZE="512x512" IMAGE_GENERATION_SIZE="512x512"
IMAGE_FORMAT="webp" IMAGE_FORMAT="webp"
SDWUI_STEPS=20
SDWUI_SAMPLER_NAME="Euler a"
SDWUI_CFG_SCALE=7
TIMEOUT=120.0 TIMEOUT=120.0

View file

@ -1,4 +1,11 @@
# Changelog # Changelog
## 1.5.2
- Expose more stable diffusion webui api parameters
## 1.5.1
- fix: set timeout not work in image generation
## 1.5.0 ## 1.5.0
- Fix localai v2.0+ image generation - Fix localai v2.0+ image generation
- Fallback to gpt-3.5-turbo when caculate tokens using custom model - Fallback to gpt-3.5-turbo when caculate tokens using custom model

View file

@ -21,6 +21,9 @@
"image_generation_endpoint": "http://localai:8080/v1/images/generations", "image_generation_endpoint": "http://localai:8080/v1/images/generations",
"image_generation_backend": "localai", "image_generation_backend": "localai",
"image_generation_size": "512x512", "image_generation_size": "512x512",
"sdwui_steps": 20,
"sdwui_sampler_name": "Euler a",
"sdwui_cfg_scale": 7,
"image_format": "webp", "image_format": "webp",
"timeout": 120.0 "timeout": 120.0
} }

View file

@ -70,6 +70,9 @@ class Bot:
image_generation_backend: Optional[str] = None, image_generation_backend: Optional[str] = None,
image_generation_size: Optional[str] = None, image_generation_size: Optional[str] = None,
image_format: Optional[str] = None, image_format: Optional[str] = None,
sdwui_steps: Optional[int] = None,
sdwui_sampler_name: Optional[str] = None,
sdwui_cfg_scale: Optional[float] = None,
timeout: Union[float, None] = None, timeout: Union[float, None] = None,
): ):
if homeserver is None or user_id is None or device_id is None: if homeserver is None or user_id is None or device_id is None:
@ -138,6 +141,10 @@ class Bot:
self.image_generation_width = self.image_generation_size.split("x")[0] self.image_generation_width = self.image_generation_size.split("x")[0]
self.image_generation_height = self.image_generation_size.split("x")[1] self.image_generation_height = self.image_generation_size.split("x")[1]
self.sdwui_steps = sdwui_steps
self.sdwui_sampler_name = sdwui_sampler_name
self.sdwui_cfg_scale = sdwui_cfg_scale
self.timeout: float = timeout or 120.0 self.timeout: float = timeout or 120.0
self.base_path = Path(os.path.dirname(__file__)).parent self.base_path = Path(os.path.dirname(__file__)).parent
@ -1361,13 +1368,16 @@ class Bot:
self.image_generation_endpoint, self.image_generation_endpoint,
prompt, prompt,
self.image_generation_backend, self.image_generation_backend,
timeount=self.timeout, timeout=self.timeout,
api_key=self.openai_api_key, api_key=self.openai_api_key,
output_path=self.base_path / "images", output_path=self.base_path / "images",
n=1, n=1,
size=self.image_generation_size, size=self.image_generation_size,
width=self.image_generation_width, width=self.image_generation_width,
height=self.image_generation_height, height=self.image_generation_height,
steps=self.sdwui_steps,
sampler_name=self.sdwui_sampler_name,
cfg_scale=self.sdwui_cfg_scale,
image_format=self.image_format, image_format=self.image_format,
) )
# send image # send image

View file

@ -48,6 +48,7 @@ async def get_images(
json={ json={
"prompt": prompt, "prompt": prompt,
"sampler_name": kwargs.get("sampler_name", "Euler a"), "sampler_name": kwargs.get("sampler_name", "Euler a"),
"cfg_scale": kwargs.get("cfg_scale", 7),
"batch_size": kwargs.get("n", 1), "batch_size": kwargs.get("n", 1),
"steps": kwargs.get("steps", 20), "steps": kwargs.get("steps", 20),
"width": kwargs.get("width", 512), "width": kwargs.get("width", 512),

View file

@ -45,6 +45,9 @@ async def main():
image_generation_endpoint=config.get("image_generation_endpoint"), image_generation_endpoint=config.get("image_generation_endpoint"),
image_generation_backend=config.get("image_generation_backend"), image_generation_backend=config.get("image_generation_backend"),
image_generation_size=config.get("image_generation_size"), image_generation_size=config.get("image_generation_size"),
sdwui_steps=config.get("sdwui_steps"),
sdwui_sampler_name=config.get("sdwui_sampler_name"),
sdwui_cfg_scale=config.get("sdwui_cfg_scale"),
image_format=config.get("image_format"), image_format=config.get("image_format"),
timeout=config.get("timeout"), timeout=config.get("timeout"),
) )
@ -78,6 +81,9 @@ async def main():
image_generation_endpoint=os.environ.get("IMAGE_GENERATION_ENDPOINT"), image_generation_endpoint=os.environ.get("IMAGE_GENERATION_ENDPOINT"),
image_generation_backend=os.environ.get("IMAGE_GENERATION_BACKEND"), image_generation_backend=os.environ.get("IMAGE_GENERATION_BACKEND"),
image_generation_size=os.environ.get("IMAGE_GENERATION_SIZE"), image_generation_size=os.environ.get("IMAGE_GENERATION_SIZE"),
sdwui_steps=int(os.environ.get("SDWUI_STEPS", 20)),
sdwui_sampler_name=os.environ.get("SDWUI_SAMPLER_NAME"),
sdwui_cfg_scale=float(os.environ.get("SDWUI_CFG_SCALE", 7)),
image_format=os.environ.get("IMAGE_FORMAT"), image_format=os.environ.get("IMAGE_FORMAT"),
timeout=float(os.environ.get("TIMEOUT", 120.0)), timeout=float(os.environ.get("TIMEOUT", 120.0)),
) )