이미지 부족 시 duplicate 기능 추가

image-tagging
Ubuntu 2026-04-03 15:35:49 +09:00
parent 7b00d21a34
commit 24534ccb3e
2 changed files with 21 additions and 1 deletions

View File

@ -436,6 +436,20 @@ class CreatomateService:
return tag_list
def counting_component(
self,
template : dict,
target_template_type : str
) -> list:
source_elements = template["source"]["elements"]
template_component_data = self.parse_template_component_name(source_elements)
count = 0
for _, (_, template_type) in enumerate(template_component_data.items()):
if template_type == target_template_type:
count += 1
return count
def template_matching_taged_image(
self,
template : dict,

View File

@ -350,12 +350,18 @@ async def generate_video(
# music_url=music_url,
# address=store_address
taged_image_list = await get_image_tags_by_task_id(task_id)
min_image_num = creatomate_service.counting_component(
template = template,
target_template_type = "image"
)
duplicate = bool(len(taged_image_list) < min_image_num)
logger.info(f"[generate_video] Duplicate : {duplicate} | length of taged_image {len(taged_image_list)}, min_len {min_image_num},- task_id: {task_id}")
modifications = creatomate_service.template_matching_taged_image(
template = template,
taged_image_list = taged_image_list,
music_url = music_url,
address = store_address,
duplicate = False,
duplicate = duplicate,
)
logger.debug(f"[generate_video] Modifications created - task_id: {task_id}")