feat: P2V 파이프라인 연동 및 좋아요·댓글·공유 지원
- 무빙 포스터(p2v_video)·롱컷(p2v_playreel) 파이프라인과 워커, 갤러리·내 콘텐츠 노출 - 좋아요·댓글: comment/video_reaction에 p2v_playreel_id 추가, 종류별 CHECK 확장 - P2V 소프트 삭제(is_deleted), queued/running 삭제 차단 - 공개 상세·공유 OG 페이지 추가 - 삭제된 부모 댓글이 목록에서 사라지던 has_live_reply 서브쿼리 버그 수정 - 마이그레이션: migration_2026-10-15_p2v_reactions.sql
This commit is contained in:
1 parent
bb1ea12958
commit
b16d4a8f1b
126 files changed
+6921
-62
No files matched your search
@@ -0,0 +1,57 @@
|
||||
"""스타일링 ② — 레퍼런스 이미지에서 화풍 명세를 뽑는다
|
||||
|
||||
번들 템플릿 빌드와 사용자 업로드가 같은 경로를 탄다.
|
||||
둘이 갈라지면 사용자 템플릿만 품질이 떨어지고 원인을 찾기 어려워진다.
|
||||
"""
|
||||
import io
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from app.p2v.answers.style_prompt_answer import StylePromptAnswer
|
||||
from app.p2v.schemas.styling import ReferenceVariants
|
||||
from config import apikey_settings
|
||||
from app.p2v.utils.common_llm import StructuredLLM
|
||||
from app.p2v.utils.image import to_data_uri
|
||||
from app.p2v.utils.prompt import load_prompt
|
||||
|
||||
REFERENCE_LONG_EDGE = 2400 # 붓질이 보이는 최소선
|
||||
THUMBNAIL_LONG_EDGE = 600 # 화면 카드
|
||||
VISION_SIZE = (1536, 1536)
|
||||
SMALL_REFERENCE_WARN = 600 # 이보다 작으면 결과가 나빠진다. 막지는 않는다
|
||||
|
||||
REFERENCE_QUALITY = 92
|
||||
THUMBNAIL_QUALITY = 88
|
||||
|
||||
STYLE_PROMPT_PROMPT = load_prompt("style_prompt")
|
||||
|
||||
style_llm = StructuredLLM("gpt-4o", apikey_settings.CHATGPT_API_KEY)
|
||||
|
||||
|
||||
def encode(image: Image.Image, quality: int) -> bytes:
|
||||
buffer = io.BytesIO()
|
||||
image.save(buffer, "JPEG", quality=quality, optimize=True)
|
||||
return buffer.getvalue()
|
||||
|
||||
|
||||
def build_variants(raw: bytes) -> ReferenceVariants:
|
||||
"""올린 바이트에서 전이용 고해상본과 카드용 썸네일을 만든다"""
|
||||
Image.MAX_IMAGE_PIXELS = None
|
||||
source = Image.open(io.BytesIO(raw)).convert("RGB")
|
||||
source.thumbnail((REFERENCE_LONG_EDGE, REFERENCE_LONG_EDGE), Image.LANCZOS)
|
||||
|
||||
thumbnail = source.copy()
|
||||
thumbnail.thumbnail((THUMBNAIL_LONG_EDGE, THUMBNAIL_LONG_EDGE), Image.LANCZOS)
|
||||
|
||||
return ReferenceVariants(reference=encode(source, REFERENCE_QUALITY),
|
||||
thumbnail=encode(thumbnail, THUMBNAIL_QUALITY),
|
||||
size=source.size)
|
||||
|
||||
|
||||
async def analyze_style(reference: bytes) -> str:
|
||||
Image.MAX_IMAGE_PIXELS = None
|
||||
image = Image.open(io.BytesIO(reference)).convert("RGB")
|
||||
|
||||
answer = await style_llm.ask_with_images(
|
||||
StylePromptAnswer, STYLE_PROMPT_PROMPT,
|
||||
[("레퍼런스", to_data_uri(image, VISION_SIZE))], temperature=0.2)
|
||||
return answer.style_prompt
|
||||
Reference in new issue
Block a user