Download LTX2.3/patches/api_types.py from India2000/LTX2.3-Multifunctional: direct link, hf CLI and curl.
- Browser
- Download file 7.34 kB
-
https://huggingface.co/India2000/LTX2.3-Multifunctional/resolve/main/LTX2.3/patches/api_types.py
- Command line
-
hf download hf://India2000/LTX2.3-Multifunctional/LTX2.3/patches/api_types.py
-
curl -L -o api_types.py https://huggingface.co/India2000/LTX2.3-Multifunctional/resolve/main/LTX2.3/patches/api_types.py
7.34 kB
| """Pydantic request/response models and TypedDicts for ltx2_server.""" | |
| from __future__ import annotations | |
| from typing import Literal, NamedTuple, TypeAlias, TypedDict | |
| from typing import Annotated | |
| from pydantic import BaseModel, Field, StringConstraints | |
| NonEmptyPrompt = Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)] | |
| ModelFileType = Literal[ | |
| "checkpoint", | |
| "upsampler", | |
| "distilled_lora", | |
| "ic_lora", | |
| "depth_processor", | |
| "person_detector", | |
| "pose_processor", | |
| "text_encoder", | |
| "zit", | |
| ] | |
| class ImageConditioningInput(NamedTuple): | |
| """Image conditioning triplet used by all video pipelines.""" | |
| path: str | |
| frame_idx: int | |
| strength: float | |
| # ============================================================ | |
| # TypedDicts for module-level state globals | |
| # ============================================================ | |
| class GenerationState(TypedDict): | |
| id: str | None | |
| cancelled: bool | |
| result: str | list[str] | None | |
| error: str | None | |
| status: str # "idle" | "running" | "complete" | "cancelled" | "error" | |
| phase: str | |
| progress: int | |
| current_step: int | |
| total_steps: int | |
| JsonObject: TypeAlias = dict[str, object] | |
| VideoCameraMotion = Literal[ | |
| "none", | |
| "dolly_in", | |
| "dolly_out", | |
| "dolly_left", | |
| "dolly_right", | |
| "jib_up", | |
| "jib_down", | |
| "static", | |
| "focus_shift", | |
| ] | |
| # ============================================================ | |
| # Response Models | |
| # ============================================================ | |
| class ModelStatusItem(BaseModel): | |
| id: str | |
| name: str | |
| loaded: bool | |
| downloaded: bool | |
| class GpuTelemetry(BaseModel): | |
| name: str | |
| vram: int | |
| vramUsed: int | |
| class HealthResponse(BaseModel): | |
| status: str | |
| models_loaded: bool | |
| active_model: str | None | |
| gpu_info: GpuTelemetry | |
| sage_attention: bool | |
| models_status: list[ModelStatusItem] | |
| class GpuInfoResponse(BaseModel): | |
| cuda_available: bool | |
| mps_available: bool = False | |
| gpu_available: bool = False | |
| gpu_name: str | None | |
| vram_gb: int | None | |
| gpu_info: GpuTelemetry | |
| class RuntimePolicyResponse(BaseModel): | |
| force_api_generations: bool | |
| class GenerationProgressResponse(BaseModel): | |
| status: str | |
| phase: str | |
| progress: int | |
| currentStep: int | None | |
| totalSteps: int | None | |
| class ModelInfo(BaseModel): | |
| id: str | |
| name: str | |
| description: str | |
| class ModelFileStatus(BaseModel): | |
| id: ModelFileType | |
| name: str | |
| description: str | |
| downloaded: bool | |
| size: int | |
| expected_size: int | |
| required: bool = True | |
| is_folder: bool = False | |
| optional_reason: str | None = None | |
| class TextEncoderStatus(BaseModel): | |
| downloaded: bool | |
| size_bytes: int | |
| size_gb: float | |
| expected_size_gb: float | |
| class ModelsStatusResponse(BaseModel): | |
| models: list[ModelFileStatus] | |
| all_downloaded: bool | |
| total_size: int | |
| downloaded_size: int | |
| total_size_gb: float | |
| downloaded_size_gb: float | |
| models_path: str | |
| has_api_key: bool | |
| text_encoder_status: TextEncoderStatus | |
| use_local_text_encoder: bool | |
| class DownloadProgressResponse(BaseModel): | |
| status: str | |
| current_downloading_file: ModelFileType | None | |
| current_file_progress: int | |
| total_progress: int | |
| total_downloaded_bytes: int | |
| expected_total_bytes: int | |
| completed_files: set[ModelFileType] | |
| all_files: set[ModelFileType] | |
| error: str | None | |
| speed_mbps: int | |
| class SuggestGapPromptResponse(BaseModel): | |
| status: str = "success" | |
| suggested_prompt: str | |
| class GenerateVideoResponse(BaseModel): | |
| status: str | |
| video_path: str | None = None | |
| class GenerateImageResponse(BaseModel): | |
| status: str | |
| image_paths: list[str] | None = None | |
| class CancelResponse(BaseModel): | |
| status: str | |
| id: str | None = None | |
| class RetakeResponse(BaseModel): | |
| status: str | |
| video_path: str | None = None | |
| result: JsonObject | None = None | |
| class IcLoraExtractResponse(BaseModel): | |
| conditioning: str | |
| original: str | |
| conditioning_type: Literal["canny", "depth"] | |
| frame_time: float | |
| class IcLoraGenerateResponse(BaseModel): | |
| status: str | |
| video_path: str | None = None | |
| class ModelDownloadStartResponse(BaseModel): | |
| status: str | |
| message: str | None = None | |
| sessionId: str | None = None | |
| class TextEncoderDownloadResponse(BaseModel): | |
| status: str | |
| message: str | None = None | |
| sessionId: str | None = None | |
| class StatusResponse(BaseModel): | |
| status: str | |
| class ErrorResponse(BaseModel): | |
| error: str | |
| message: str | None = None | |
| # ============================================================ | |
| # Request Models | |
| # ============================================================ | |
| class GenerateVideoRequest(BaseModel): | |
| prompt: NonEmptyPrompt | |
| resolution: str = "512p" | |
| model: str = "fast" | |
| cameraMotion: VideoCameraMotion = "none" | |
| negativePrompt: str = "" | |
| duration: str = "2" | |
| fps: str = "24" | |
| audio: str = "false" | |
| imagePath: str | None = None | |
| audioPath: str | None = None | |
| startFramePath: str | None = None | |
| endFramePath: str | None = None | |
| # 多张图单次推理:latent 时间轴多锚点(Comfy LTXVAddGuideMulti 思路);≥2 路径时优先于首尾帧 | |
| keyframePaths: list[str] | None = None | |
| # 与 keyframePaths 等长、0.1–1.0;不传则按 Comfy 类工作流自动降低中间帧强度,减轻闪烁 | |
| keyframeStrengths: list[float] | None = None | |
| # 与 keyframePaths 等长,单位秒,落在 [0, 整段时长];全提供时按时间映射 latent,否则仍自动均分 | |
| keyframeTimes: list[float] | None = None | |
| aspectRatio: Literal["16:9", "9:16"] = "16:9" | |
| modelPath: str | None = None | |
| loraPath: str | None = None | |
| loraStrength: float = 1.0 | |
| class GenerateImageRequest(BaseModel): | |
| prompt: NonEmptyPrompt | |
| width: int = 1024 | |
| height: int = 1024 | |
| numSteps: int = 4 | |
| numImages: int = 1 | |
| def _default_model_types() -> set[ModelFileType]: | |
| return set() | |
| class ModelDownloadRequest(BaseModel): | |
| modelTypes: set[ModelFileType] = Field(default_factory=_default_model_types) | |
| class RequiredModelsResponse(BaseModel): | |
| modelTypes: list[ModelFileType] | |
| class SuggestGapPromptRequest(BaseModel): | |
| beforePrompt: str = "" | |
| afterPrompt: str = "" | |
| beforeFrame: str | None = None | |
| afterFrame: str | None = None | |
| gapDuration: float = 5 | |
| mode: str = "t2v" | |
| inputImage: str | None = None | |
| class RetakeRequest(BaseModel): | |
| video_path: str | |
| start_time: float = 0 | |
| duration: float = 0 | |
| prompt: str = "" | |
| mode: str = "replace_video_only" | |
| width: int | None = None | |
| height: int | None = None | |
| class IcLoraExtractRequest(BaseModel): | |
| video_path: str | |
| conditioning_type: Literal["canny", "depth"] = "canny" | |
| frame_time: float = 0 | |
| class IcLoraImageInput(BaseModel): | |
| path: str | |
| frame: int = 0 | |
| strength: float = 1.0 | |
| def _default_ic_lora_images() -> list[IcLoraImageInput]: | |
| return [] | |
| class IcLoraGenerateRequest(BaseModel): | |
| video_path: str | |
| conditioning_type: Literal["canny", "depth"] | |
| prompt: NonEmptyPrompt | |
| conditioning_strength: float = 1.0 | |
| num_inference_steps: int = 30 | |
| cfg_guidance_scale: float = 1.0 | |
| negative_prompt: str = "" | |
| images: list[IcLoraImageInput] = Field(default_factory=_default_ic_lora_images) | |