cmvr-visual/inference/llm_services/reference_profiles.py
zhanghao 88cf14d794 feat: consolidate story studio and editable automatic production
Restructure backend and frontend modules; add story, library, and editor schema migrations.

Support editable automatic production, manual confirmation modes, account and user lifecycle management, compact container scrolling, consistent forms, and per-task result previews.

Update inference and TTS scheduling, deployment guidance, and regression coverage; remove obsolete standalone pages and temporary acceptance artifacts.
2026-11-14 14:07:26 +08:00

74 lines
2.6 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.

"""固定版本的Edit协议;不根据文件是否存在偷偷切换模型。"""
from dataclasses import dataclass
@dataclass(frozen=True)
class ReferenceProfile:
name: str
repo: str
revision: str
directory: str
max_images: int = 3
memory_gib: int = 112
max_sequence_length: int = 1024
DEFAULT_PROFILE = "qwen-image-edit-2511-v1"
PROFILES = {
DEFAULT_PROFILE: ReferenceProfile(
DEFAULT_PROFILE,
"Qwen/Qwen-Image-Edit-2511",
"6f3ccc0b56e431dc6a0c2b2039706d7d26f22cb9",
"/workspace/models/qwen-image-edit-2511",
),
"qwen-image-edit-2509-v1": ReferenceProfile(
"qwen-image-edit-2509-v1",
"Qwen/Qwen-Image-Edit-2509",
"d3968ef930e841f4c73640fb8afa3b306a78167e",
"/workspace/models/qwen-image-edit-2509",
),
"qwen-image-edit-2511-experimental-4-v1": ReferenceProfile(
"qwen-image-edit-2511-experimental-4-v1",
"Qwen/Qwen-Image-Edit-2511",
"6f3ccc0b56e431dc6a0c2b2039706d7d26f22cb9",
"/workspace/models/qwen-image-edit-2511",
max_images=4,
memory_gib=128,
),
}
def get_profile(name):
if not isinstance(name, str) or name not in PROFILES:
raise ValueError("Unknown reference generation profile; no implicit model fallback")
return PROFILES[name]
def capabilities(settings):
profile = get_profile(settings.reference_generation_profile)
enabled = settings.reference_generation_enabled
return {
"available": enabled,
"task_type": "image.reference.generate",
"profile": profile.name,
"model": profile.repo,
"revision": profile.revision,
"max_reference_images": min(profile.max_images, settings.reference_max_images),
"reason": None
if enabled
else "Reference generation is not certified/enabled on this deployment",
"experimental": profile.max_images == 4,
"max_sequence_length": profile.max_sequence_length,
}
def validate_submission(settings, inputs, parameters):
if not (settings.reference_generation_enabled or settings.reference_generation_poc_enabled):
raise ValueError("Reference generation is not certified/enabled on this deployment")
if parameters.get("profile") != settings.reference_generation_profile:
raise ValueError("Reference generation profile differs from deployment certification")
paths = inputs.get("image_paths")
if not isinstance(paths, list) or not 1 <= len(paths) <= settings.reference_max_images:
raise ValueError("Reference image count exceeds deployment profile")