Files
pod_trend_agent/graph/backends/base.py
T
3218485270 f493bde8a9 POD 趋势感知 Agent:缓存热点模式 + 三图合成 + 热点去重/风格去重 + review 兜底
- 缓存热点批量流程(有采集缓存不触发 Google)
- 简报不足直接从采集缓存生成(轻量补齐)
- 三图合成(模特/印花/底图)+ 底图压缩 <2MB
- 热点去重→风格去重自动切换 + 不适合类目 review 兜底
- 透明背景(background=transparent)+ 提示词清洗(敏感词/背景描述)
- 任务前 basemap 校验 + 模板国家校验 + 模特任务级分配
2026-08-22 14:14:01 +08:00

29 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""图像后端抽象接口(可插拔)。
- print(prompt, base_image, out_path, negative, extra_images)
以 base_image 为底图(+ extra_images 多参考图,按顺序追加)按 prompt 生成成品图。
product 流水线用法:
* 纯印花设计稿 → generate()
* 平铺服装图(底图+印花)→ print(base=底图, extra=[设计稿])
* 三图模特合成 → print(base=模特图, extra=[设计稿, 底图])(图1=模特, 图2=印花, 图3=底图)
- generate(prompt, out_path, negative):纯文生图(无参考图),用于生成白底纯印花设计稿。
"""
from abc import ABC, abstractmethod
from typing import Optional, Sequence
class ImageBackend(ABC):
name: str = "base"
@abstractmethod
def print(self, prompt: str, base_image: str, out_path: str, negative: str = "",
extra_images: Optional[Sequence[str]] = None, size: str = "") -> str:
"""返回生成的成品图路径。实现内部应处理调用失败/超时并抛异常由调用方兜底。
size: 显式尺寸覆盖(如 "1504x2000");留空则用后端配置的 size。"""
raise NotImplementedError
def generate(self, prompt: str, out_path: str, negative: str = "", size: str = "") -> str:
"""纯文生图(无参考图),默认退化为 print 不支持则抛异常。
size: 显式尺寸覆盖;留空则用后端配置的 size。"""
raise NotImplementedError(f"{self.name} 后端不支持纯文生图(generate")