Compare commits

..

No commits in common. "1e3da98c6a375903fb830d1d14a8ca1a2adcbf8f" and "6492d23bc1a891bbcc1c87fae59d102f7d5b92be" have entirely different histories.

5 changed files with 18 additions and 66 deletions

View File

@ -276,5 +276,3 @@ fastapi run main.py
│◀───────────────│ │ │
│ │ │ │
```
testAc

View File

@ -751,7 +751,7 @@ async def upload_images_blob(
image_urls = [img.img_url for img in result_images]
logger.info(f"[image_tagging] START - task_id: {task_id}")
await tagging_images(image_urls, clear_old_tags=True)
await tag_images_if_not_exist(image_urls)
logger.info(f"[image_tagging] Done - task_id: {task_id}")
total_time = time.perf_counter() - request_start
@ -771,9 +771,8 @@ async def upload_images_blob(
)
async def tagging_images(
image_urls : list[str],
clear_old_tags : bool = False
async def tag_images_if_not_exist(
image_urls : list[str]
) -> None:
# 1. 조회
async with AsyncSessionLocal() as session:
@ -785,24 +784,21 @@ async def tagging_images(
image_tags_query_results = await session.execute(stmt)
image_tags = image_tags_query_results.scalars().all()
existing_urls = {tag.img_url for tag in image_tags}
new_imt = [
new_tags = [
ImageTag(img_url=url, img_tag=None)
for url in image_urls
if url not in existing_urls
]
if clear_old_tags:
for tag in image_tags:
tag.img_tag = None
session.add_all(new_imt)
null_imts = [imt for imt in image_tags if imt.img_tag is None] + new_imt
await session.commit()
if null_imts:
tag_datas = await autotag_images([img.img_url for img in null_imts])
print(tag_datas)
session.add_all(new_tags)
async with AsyncSessionLocal() as session:
for tag, tag_data in zip(null_imts, tag_datas):
null_tags = [tag for tag in image_tags if tag.img_tag is None] + new_tags
if null_tags:
tag_datas = await autotag_images([img.img_url for img in null_tags])
print(tag_datas)
for tag, tag_data in zip(null_tags, tag_datas):
tag.img_tag = tag_data.model_dump(mode="json")
session.add(tag)
await session.commit()
await session.commit()

View File

@ -19,16 +19,12 @@ Note:
import os
import time
import re
from typing import Any, Optional, Type
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
def normalize_location(name: str) -> str:
return re.sub(r'(특별시|광역시|특별자치시|특별자치도|시|군|구|도)$', '', name)
def _generate_uuid7_string() -> str:
"""UUID7 문자열을 생성합니다.

View File

@ -38,8 +38,6 @@ import httpx
from app.utils.logger import get_logger
from app.utils.prompts.schemas.image import SpaceType,Subject,Camera,MotionRecommended,NarrativePhase
from app.utils.common import normalize_location
from config import apikey_settings, creatomate_settings, recovery_settings
# 로거 설정
@ -867,20 +865,4 @@ class CreatomateService:
except Exception as E:
logger.error("this template does not have same amount of keyword and subtitle.")
pitching_list = keyword_list + subtitle_list
return pitching_list
def make_thumbnail_modification(self, brand_name : str, region : str, brand_concept : str, category_definition : str, target_keywords : list[str]):
len_keywords = len(target_keywords) if len(target_keywords) < 3 else 3
hashtaged_target_keywords = [f"#{tk}" for tk in target_keywords[len_keywords]]
mod_dict = {
"thumb-hashtag-primary" : ' '.join(hashtaged_target_keywords),
"thumb-brand-wordmark" : brand_name,
"thumb-subheadline-selling_point" : f"{brand_name} · {normalize_location(region)}",
"thumb-headline-hook_claim-aspirational" : brand_concept,
"thumb-badge-category" : category_definition,
}
return mod_dict
return pitching_list

View File

@ -230,21 +230,12 @@ async def generate_video(
)
project_id = project.id
store_address = project.detail_region_info
brand_name = project.store_name
region = project.region
# customer_name = project.store_name
marketing_result = await session.execute(
select(MarketingIntel).where(MarketingIntel.id == project.marketing_intelligence)
)
marketing_intelligence : MarketingIntel = marketing_result.scalar_one_or_none()
category_definition= marketing_intelligence.intel_result["market_positioning"]["category_definition"]
target_keywords=marketing_intelligence.intel_result["target_keywords"]
brand_concept = ""
for sp in marketing_intelligence.intel_result["selling_points"]:
if "concept" in sp["english_category"].lower():
brand_concept = sp["description"]
marketing_intelligence = marketing_result.scalar_one_or_none()
# ===== 결과 처리: Lyric =====
lyric = lyric_result.scalar_one_or_none()
@ -377,17 +368,6 @@ async def generate_video(
subtitle_modifications = marketing_intelligence.subtitle
modifications.update(subtitle_modifications)
# revert thumbnail scene
# thumbnail_modifications = creatomate_service.make_thumbnail_modification(
# brand_name =brand_name,
# region = region,
# brand_concept = brand_concept,
# category_definition= category_definition,
# target_keywords=target_keywords)
# modifications.update(thumbnail_modifications)
# 6-3. elements 수정
new_elements = creatomate_service.modify_element(
template["source"]["elements"],