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

♻️ refactor(image_metadata): update typing in __init__.py #55

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion src/novelai_python/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ async def generator():
generator = agent.request(session=session)
async for data in generator:
data: LLMStreamResp
print(data) # 或者做其他需要的处理
yield data.text # Yield data for streaming response

return StreamingResponse(generator())
Expand Down
28 changes: 25 additions & 3 deletions src/novelai_python/tool/image_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json
from io import BytesIO
from pathlib import Path
from typing import Union
from typing import Union, Optional, List

import numpy as np
from PIL import Image
Expand Down Expand Up @@ -36,8 +36,10 @@ class CommentModel(BaseModel):
hide_debug_overlay: bool = None
noise_schedule: str = None
legacy_v3_extend: bool = None
reference_information_extracted: float = None
reference_strength: float = None
reference_information_extracted: Optional[float] = None
reference_strength: Optional[float] = None
reference_strength_multiple: Optional[List[float]] = None
reference_information_extracted_multiple: Optional[List[float]] = None
sampler: str = None
controlnet_strength: float = None
controlnet_model: Union[None, str] = None
Expand All @@ -58,6 +60,26 @@ class CommentModel(BaseModel):
def negative_prompt(self):
return self.uc

@property
def vibe_transfer_strength(self) -> List[float]:
"""
Get the vibe transfer strength totally
:return: List[float]
"""
if self.reference_strength:
return [self.reference_strength]
return self.reference_strength_multiple

@property
def vibe_transfer_information(self) -> List[float]:
"""
Get the vibe transfer information totally
:return: List[float]
"""
if self.reference_information_extracted:
return [self.reference_information_extracted]
return self.reference_information_extracted_multiple

Title: str = "AI generated image"
Software: str = "NovelAI"
Source: str = None
Expand Down
Loading