生图模型可选(火山/gpt-image)+ 模特上身图提示词强化 + 多会话等改动

本轮(生图模型选择 + 火山接入):
- 工作室新增「生图模型」选择器(模特上身图/平台套图头部 chip + 图片创作底部 Pill),
  默认火山 Seedream,可切 gpt-image-2;选择写入 localStorage,下次进页面读回
- 后端 resolve_image_model 解析所选模型;enqueue_standalone_images 接 image_model
- worker 按模型能力分流:有 image_edit(gpt-image)走多图编辑;无(火山)走
  image_generation(image=参考图);新增 _ratio_to_volcano_size 让火山按比例出图
  → 内衣等敏感品类用火山可绕开 gpt-image 的 sexual 内容审核

模特上身图提示词:
- 穿戴/非穿戴分流、按 index 变化动作场景镜头、负面词尾接、多图参考序号自适应
- _product_reference_urls:商品参考真实上传图优先、排除 AI 生成图、可多张

其他(并入此前各会话未提交改动):
- 图片创作多会话(ImageConversation + migration 0019)、任务中心按类型过滤
- accounts/projects/assets/team/auth 等零散调整、相关测试
- 测试脚本(tryon_*.py)、测试清单(core/bug/*.xlsx)
This commit is contained in:
zyc
2026-06-27 14:00:28 +08:00
parent 0a519ca892
commit ce7eaefe1d
21 changed files with 1279 additions and 158 deletions
+53 -5
View File
@@ -3,7 +3,7 @@ from pathlib import Path
import uuid
from django.db import transaction
from django.db.models import Count
from django.db.models import Count, Q
from django.http import HttpResponse, JsonResponse, StreamingHttpResponse
from rest_framework import status
from rest_framework.decorators import action
@@ -105,6 +105,39 @@ def _store_uploaded_asset(*, team, user, upload, asset_type: str, category: str,
return asset
def _clone_asset_into_team(src: Asset, *, team, user) -> Asset:
"""把跨团队可见的「官方模特」形象图克隆一份进目标团队:共享同一份 TOS 对象(只新建 Asset/AssetFile DB 行,
不重新上传),使其成为本团队真实资产 —— 可被基础资产组采用、在「我的演员」里列出,不再因 team 隔离报 asset not found。
去掉 metadata 里的 kind=model 标记,让克隆体作为普通「我的演员」person 资产,而不是被误判成模特库预设。"""
src_meta = {k: v for k, v in (src.metadata or {}).items() if k != "kind"}
clone = Asset.objects.create(
team=team,
created_by=user,
name=src.name,
asset_type=src.asset_type,
source=src.source,
category=src.category,
description=src.description,
metadata={**src_meta, "cloned_from_asset": str(src.id), "from_official_model": True},
in_library=src.in_library,
)
for f in src.files.all():
AssetFile.objects.create(
asset=clone,
object_key=f.object_key,
bucket=f.bucket,
content_type=f.content_type,
size_bytes=f.size_bytes,
checksum=f.checksum,
width=f.width,
height=f.height,
duration_ms=f.duration_ms,
preview_url=f.preview_url,
is_primary=f.is_primary,
)
return clone
def promote_base_asset_stage_if_ready(project: Project) -> bool:
adopted_kind_count = (
project.base_asset_groups.filter(adopted_asset__isnull=False).values("kind").distinct().count()
@@ -492,8 +525,26 @@ class ProjectViewSet(TeamScopedViewSetMixin, ModelViewSet):
@transaction.atomic
def attach_base_asset(self, request, pk=None):
"""流程步骤4 · 用演员库现有资产替换某基础资产卡:把团队内现有 Asset 挂为该组候选并采用。
seed 占位卡还没有 group,此时不传 group_id,改传 kind+label:按 label 命中同实体组,没有则据 label 建组再挂(不出图)。"""
seed 占位卡还没有 group,此时不传 group_id,改传 kind+label:按 label 命中同实体组,没有则据 label 建组再挂(不出图)。
所选资产可能是「官方模特」形象图(跨团队可见但不属本团队)→ 克隆一份进本团队再挂:避免 team 隔离导致
明明选了官方模特却报 asset not found、替换失败。"""
project = self.get_object()
# 先把要挂的资产定下来(本团队资产,或官方模特形象图克隆),拿不到立即 404 —— 必须在建/找组「之前」,
# 否则会留下一个采用资产为空的幽灵角色组(旧版本在 404 return 前就 create 了组,且 @atomic 正常 return 仍会提交)。
asset_id = request.data.get("asset_id")
asset = Asset.objects.filter(team=project.team, id=asset_id).first()
if asset is None and asset_id:
# 跨团队可见的官方模特形象图 / 三视图 → 克隆进本团队再挂
official = (
Asset.objects.filter(id=asset_id, is_deleted=False)
.filter(Q(model_as_portrait__is_official=True) | Q(model_as_triview__is_official=True))
.first()
)
if official is not None:
asset = _clone_asset_into_team(official, team=project.team, user=request.user)
if asset is None:
return Response({"detail": "asset not found"}, status=status.HTTP_404_NOT_FOUND)
group = None
group_id = request.data.get("group_id")
if group_id:
@@ -517,9 +568,6 @@ class ProjectViewSet(TeamScopedViewSetMixin, ModelViewSet):
group_meta = {"label": label} if label else {}
group = BaseAssetGroup.objects.create(project=project, kind=kind, metadata=group_meta)
group = BaseAssetGroup.objects.select_for_update().get(id=group.id)
asset = Asset.objects.filter(team=project.team, id=request.data.get("asset_id")).first()
if asset is None:
return Response({"detail": "asset not found"}, status=status.HTTP_404_NOT_FOUND)
group.candidate_assets.add(asset)
group.adopted_asset_id = asset.id
group.save(update_fields=["adopted_asset", "updated_at"])