Обновлена модель генерации аниме.
This commit is contained in:
parent
1d6fd6f612
commit
25992ef772
1 changed files with 6 additions and 3 deletions
|
|
@ -29,7 +29,7 @@ PRIVATE_CHAT_MAX_MESSAGES = 40
|
|||
MAX_OUTPUT_TOKENS = 500
|
||||
|
||||
FAL_MODEL = "fal-ai/bytedance/seedream/v4.5/text-to-image"
|
||||
REPLICATE_MODEL = "ultracoderru/nova-anime-xl-il-140:83a9531bdd7eab282e68d16a80d7b25502df827e43d286360299fe6321d81d06"
|
||||
REPLICATE_MODEL = "ultracoderru/nova-anime-xl-14:1a8ded85309ffeb41780db667102ea935e4140b1a15f4a0f669a60a104b722db"
|
||||
|
||||
|
||||
@dataclass()
|
||||
|
|
@ -286,12 +286,13 @@ class AiAgent:
|
|||
"height": height,
|
||||
"guidance_scale": 4.5,
|
||||
"num_inference_steps": 20,
|
||||
"hires_enable": True,
|
||||
"disable_safety_checker": True
|
||||
}
|
||||
|
||||
try:
|
||||
outputs = await self.replicate_client.async_run(REPLICATE_MODEL, input=arguments)
|
||||
image = _convert_image_to_jpeg(await outputs[0].aread())
|
||||
image = _convert_image_to_jpeg(await outputs[0].aread(), (width, height))
|
||||
return Ok(image)
|
||||
except Exception as e:
|
||||
print(f"Ошибка генерации изображения: {e}")
|
||||
|
|
@ -407,8 +408,10 @@ def _get_resolution_for_aspect_ratio(aspect_ratio: str) -> Tuple[int, int]:
|
|||
return aspect_ratio_resolution_map.get(aspect_ratio, (1280, 1024))
|
||||
|
||||
|
||||
def _convert_image_to_jpeg(image: bytes) -> bytes:
|
||||
def _convert_image_to_jpeg(image: bytes, size: Optional[tuple[int, int]] = None) -> bytes:
|
||||
img = Image.open(BytesIO(image)).convert("RGB")
|
||||
if size is not None:
|
||||
img = img.resize(size=size, resample=Image.Resampling.BILINEAR)
|
||||
output = BytesIO()
|
||||
img.save(output, format='JPEG', quality=87, optimize=True)
|
||||
return output.getvalue()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue