diff --git a/playground/static_refer_banner.png b/playground/static_refer_banner.png new file mode 100644 index 0000000..7857c3f Binary files /dev/null and b/playground/static_refer_banner.png differ diff --git a/playground/vibe.py b/playground/vibe.py index 0c07063..8b613a2 100644 --- a/playground/vibe.py +++ b/playground/vibe.py @@ -13,7 +13,7 @@ async def generate( prompt="1girl, year 2023, dynamic angle, best quality, amazing quality, very aesthetic, absurdres", - image_path="static_refer.png" + image_path="static_refer_banner.png" ): jwt = os.getenv("NOVELAI_JWT", None) if jwt is None: @@ -36,7 +36,7 @@ async def generate( action=Action.GENERATE, sampler=Sampler.K_DPMPP_SDE, reference_image=image, - reference_strength=0.6, + reference_strength=0.9, reference_information_extracted=1, add_original_image=True, # This Not affect the vibe generation qualityToggle=True, diff --git a/pyproject.toml b/pyproject.toml index 2564560..393aa0f 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "novelai-python" -version = "0.3.7" +version = "0.3.8" description = "Novelai Python Binding With Pydantic" authors = [ { name = "sudoskys", email = "coldlando@hotmail.com" }, diff --git a/src/novelai_python/sdk/ai/generate_image/__init__.py b/src/novelai_python/sdk/ai/generate_image/__init__.py index 412a907..7afbc43 100755 --- a/src/novelai_python/sdk/ai/generate_image/__init__.py +++ b/src/novelai_python/sdk/ai/generate_image/__init__.py @@ -148,7 +148,7 @@ def resize_image(image: Union[str, bytes], width: int, height: int): @staticmethod def add_image_to_black_background(image: Union[str, bytes], width: int = 448, height: int = 448): """ - 将图像缩放到一个指定的黑背景上,使其最大,比例不变。 + 缩放图像到指定的黑色透明背景上,使其尽可能大且保持比例。 :param image: 图像 :param width: 宽 :param height: 高 @@ -157,7 +157,7 @@ def add_image_to_black_background(image: Union[str, bytes], width: int = 448, he if isinstance(image, str): image = base64.b64decode(image) - open_image = Image.open(BytesIO(image)) + open_image = Image.open(BytesIO(image)).convert("RGBA") # 如果尺寸相同,直接返回 if open_image.width == width and open_image.height == height: return base64.b64encode(image).decode("utf-8") @@ -170,8 +170,8 @@ def add_image_to_black_background(image: Union[str, bytes], width: int = 448, he new_image_size = (int(open_image.width * ratio), int(open_image.height * ratio)) open_image = open_image.resize(new_image_size, Image.Resampling.BICUBIC) - # 创建一个黑色背景的新图像 - new_image = Image.new("RGB", (width, height), (0, 0, 0)) + # 创建一个黑色透明背景的新图像,颜色深度32位 + new_image = Image.new("RGBA", (width, height), (0, 0, 0, 0)) # 计算居中位置 position = ((width - open_image.width) // 2, (height - open_image.height) // 2)