Skip to content

Commit

Permalink
Merge pull request #33 from LlmKira/dev
Browse files Browse the repository at this point in the history
fix(logic): vibe
  • Loading branch information
sudoskys authored Mar 9, 2024
2 parents c98c665 + 9c4b7de commit 282c96d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion playground/generate_image_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# @File : generate_image_img2img.py
# @Software: PyCharm
import asyncio
import base64
import os
import pathlib
from dotenv import load_dotenv
Expand Down Expand Up @@ -35,7 +36,9 @@ async def generate(
if not os.path.exists(image_path):
raise ValueError(f"Image not found: {image_path}")
with open(image_path, "rb") as f:
image = f.read()
# Base64 encode the image
image = base64.b64encode(f.read()).decode()
# image = f.read() # Or you can use the raw bytes
agent = GenerateImageInfer.build(
prompt=prompt,
action=Action.IMG2IMG,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "novelai-python"
version = "0.3.6"
version = "0.3.7"
description = "Novelai Python Binding With Pydantic"
authors = [
{ name = "sudoskys", email = "[email protected]" },
Expand Down
4 changes: 2 additions & 2 deletions src/novelai_python/sdk/ai/generate_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def resize_image(image: Union[str, bytes], width: int, height: int):
return base64.b64encode(buffered.getvalue()).decode("utf-8")

@staticmethod
def add_image_to_black_background(image: Union[str, bytes], width: int, height: int):
def add_image_to_black_background(image: Union[str, bytes], width: int = 448, height: int = 448):
"""
将图像缩放到一个指定的黑背景上,使其最大,比例不变。
:param image: 图像
Expand Down Expand Up @@ -201,7 +201,7 @@ def image_validator(self):
if self.image is not None:
self.image = self.resize_image(self.image, self.width, self.height)
if self.reference_image is not None:
self.reference_image = self.add_image_to_black_background(self.reference_image, self.width, self.height)
self.reference_image = self.add_image_to_black_background(self.reference_image, width=448, height=448)
return self

@field_validator('width')
Expand Down

0 comments on commit 282c96d

Please sign in to comment.