auto-save 2026-05-13 14:49 (~5)
This commit is contained in:
45
api/main.py
45
api/main.py
@@ -63,6 +63,16 @@ class GeneratedImage(BaseModel):
|
||||
created_at: float = 0.0
|
||||
|
||||
|
||||
class StoryboardScene(BaseModel):
|
||||
"""分镜头编排:每个 selected 分镜对应一个 scene 描述"""
|
||||
subject: str = "" # 主体(如:戴头带的骨架人)
|
||||
product: str = "" # 产品(如:Goli 营养软糖)
|
||||
scene: str = "" # 场景(如:药店柜台)
|
||||
action: str = "" # 在干什么(如:递给顾客一瓶软糖)
|
||||
duration: float = 0 # 视频片段时长(秒)
|
||||
reference_ids: list[str] = [] # 参考图:选用该分镜里已提取的 element ids 作 reference
|
||||
|
||||
|
||||
class KeyElement(BaseModel):
|
||||
"""关键帧里识别 / 用户提取的元素 · 多次提取累积多张图,让用户挑选满意的"""
|
||||
id: str # uuid hex 8
|
||||
@@ -87,6 +97,7 @@ class KeyFrame(BaseModel):
|
||||
cleaned_url: str | None = None # 清洗后干净版(待应用)→ /jobs/{id}/frames/{idx}/cleaned.jpg
|
||||
cleaned_applied: bool = False # 是否已用清洗版替换原图(替换后 cleaned_url=null)
|
||||
elements: list[KeyElement] = [] # 提取的元素清单(持久化)
|
||||
storyboard: StoryboardScene | None = None # 分镜头编排字段
|
||||
generated_images: list[GeneratedImage] = []
|
||||
|
||||
|
||||
@@ -1389,6 +1400,40 @@ def delete_cutout(job_id: str, idx: int, element_id: str, cutout_id: str) -> Job
|
||||
return job
|
||||
|
||||
|
||||
class UpdateStoryboardReq(BaseModel):
|
||||
subject: str = ""
|
||||
product: str = ""
|
||||
scene: str = ""
|
||||
action: str = ""
|
||||
duration: float = 0
|
||||
reference_ids: list[str] = []
|
||||
|
||||
|
||||
@app.put("/jobs/{job_id}/frames/{idx}/storyboard", response_model=Job)
|
||||
def update_storyboard(job_id: str, idx: int, req: UpdateStoryboardReq) -> Job:
|
||||
"""更新分镜的编排字段(subject / product / scene / action / duration / reference_ids)"""
|
||||
job = JOBS.get(job_id)
|
||||
if not job:
|
||||
raise HTTPException(404, "job not found")
|
||||
frame = next((f for f in job.frames if f.index == idx), None)
|
||||
if not frame:
|
||||
raise HTTPException(404, "frame not found")
|
||||
new_frames = []
|
||||
for f in job.frames:
|
||||
if f.index == idx:
|
||||
f.storyboard = StoryboardScene(
|
||||
subject=req.subject.strip(),
|
||||
product=req.product.strip(),
|
||||
scene=req.scene.strip(),
|
||||
action=req.action.strip(),
|
||||
duration=max(0.0, float(req.duration)),
|
||||
reference_ids=list(req.reference_ids),
|
||||
)
|
||||
new_frames.append(f)
|
||||
update(job, frames=new_frames, message=f"分镜 {idx + 1} 编排已更新")
|
||||
return job
|
||||
|
||||
|
||||
@app.get("/jobs/{job_id}/frames/{idx}/elements/{element_id}/cutouts/{cutout_id}.jpg")
|
||||
def get_cutout_versioned(job_id: str, idx: int, element_id: str, cutout_id: str):
|
||||
p = job_dir(job_id) / "elements" / f"{idx:03d}_{element_id}_{cutout_id}.jpg"
|
||||
|
||||
Reference in New Issue
Block a user