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] image_urls = [img.img_url for img in result_images]
logger.info(f"[image_tagging] START - task_id: {task_id}") 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}") logger.info(f"[image_tagging] Done - task_id: {task_id}")
total_time = time.perf_counter() - request_start total_time = time.perf_counter() - request_start
@ -771,9 +771,8 @@ async def upload_images_blob(
) )
async def tagging_images( async def tag_images_if_not_exist(
image_urls : list[str], image_urls : list[str]
clear_old_tags : bool = False
) -> None: ) -> None:
# 1. 조회 # 1. 조회
async with AsyncSessionLocal() as session: async with AsyncSessionLocal() as session:
@ -785,24 +784,21 @@ async def tagging_images(
image_tags_query_results = await session.execute(stmt) image_tags_query_results = await session.execute(stmt)
image_tags = image_tags_query_results.scalars().all() image_tags = image_tags_query_results.scalars().all()
existing_urls = {tag.img_url for tag in image_tags} existing_urls = {tag.img_url for tag in image_tags}
new_imt = [ new_tags = [
ImageTag(img_url=url, img_tag=None) ImageTag(img_url=url, img_tag=None)
for url in image_urls for url in image_urls
if url not in existing_urls if url not in existing_urls
] ]
if clear_old_tags: session.add_all(new_tags)
for tag in image_tags:
tag.img_tag = None null_tags = [tag for tag in image_tags if tag.img_tag is None] + new_tags
session.add_all(new_imt)
null_imts = [imt for imt in image_tags if imt.img_tag is None] + new_imt if null_tags:
await session.commit() tag_datas = await autotag_images([img.img_url for img in null_tags])
if null_imts:
tag_datas = await autotag_images([img.img_url for img in null_imts])
print(tag_datas) print(tag_datas)
async with AsyncSessionLocal() as session: for tag, tag_data in zip(null_tags, tag_datas):
for tag, tag_data in zip(null_imts, tag_datas):
tag.img_tag = tag_data.model_dump(mode="json") 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 os
import time import time
import re
from typing import Any, Optional, Type from typing import Any, Optional, Type
from sqlalchemy import select from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
def normalize_location(name: str) -> str:
return re.sub(r'(특별시|광역시|특별자치시|특별자치도|시|군|구|도)$', '', name)
def _generate_uuid7_string() -> str: def _generate_uuid7_string() -> str:
"""UUID7 문자열을 생성합니다. """UUID7 문자열을 생성합니다.

View File

@ -38,8 +38,6 @@ import httpx
from app.utils.logger import get_logger from app.utils.logger import get_logger
from app.utils.prompts.schemas.image import SpaceType,Subject,Camera,MotionRecommended,NarrativePhase 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 from config import apikey_settings, creatomate_settings, recovery_settings
# 로거 설정 # 로거 설정
@ -868,19 +866,3 @@ class CreatomateService:
logger.error("this template does not have same amount of keyword and subtitle.") logger.error("this template does not have same amount of keyword and subtitle.")
pitching_list = keyword_list + subtitle_list pitching_list = keyword_list + subtitle_list
return pitching_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

View File

@ -230,21 +230,12 @@ async def generate_video(
) )
project_id = project.id project_id = project.id
store_address = project.detail_region_info store_address = project.detail_region_info
brand_name = project.store_name # customer_name = project.store_name
region = project.region
marketing_result = await session.execute( marketing_result = await session.execute(
select(MarketingIntel).where(MarketingIntel.id == project.marketing_intelligence) select(MarketingIntel).where(MarketingIntel.id == project.marketing_intelligence)
) )
marketing_intelligence : MarketingIntel = marketing_result.scalar_one_or_none() marketing_intelligence = 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"]
# ===== 결과 처리: Lyric ===== # ===== 결과 처리: Lyric =====
lyric = lyric_result.scalar_one_or_none() lyric = lyric_result.scalar_one_or_none()
@ -377,17 +368,6 @@ async def generate_video(
subtitle_modifications = marketing_intelligence.subtitle subtitle_modifications = marketing_intelligence.subtitle
modifications.update(subtitle_modifications) 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 수정 # 6-3. elements 수정
new_elements = creatomate_service.modify_element( new_elements = creatomate_service.modify_element(
template["source"]["elements"], template["source"]["elements"],