|
| 1 | +from typing import Optional, Union |
| 2 | + |
| 3 | +from pydantic import BaseModel, Field |
| 4 | + |
| 5 | + |
| 6 | +class ImageEnhanceRequest(BaseModel): |
| 7 | + model: str = Field("Reimagine") |
| 8 | + output_format: str = Field("jpeg") |
| 9 | + subject_detection: str = Field("All") |
| 10 | + face_enhancement: bool = Field(True) |
| 11 | + face_enhancement_creativity: float = Field(0, description="Is ignored if face_enhancement is false") |
| 12 | + face_enhancement_strength: float = Field(0.8, description="Is ignored if face_enhancement is false") |
| 13 | + source_url: str = Field(...) |
| 14 | + output_width: Optional[int] = Field(None) |
| 15 | + output_height: Optional[int] = Field(None) |
| 16 | + crop_to_fill: bool = Field(False) |
| 17 | + prompt: Optional[str] = Field(None, description="Text prompt for creative upscaling guidance") |
| 18 | + creativity: int = Field(3, description="Creativity settings range from 1 to 9") |
| 19 | + face_preservation: str = Field("true", description="To preserve the identity of characters") |
| 20 | + color_preservation: str = Field("true", description="To preserve the original color") |
| 21 | + |
| 22 | + |
| 23 | +class ImageAsyncTaskResponse(BaseModel): |
| 24 | + process_id: str = Field(...) |
| 25 | + |
| 26 | + |
| 27 | +class ImageStatusResponse(BaseModel): |
| 28 | + process_id: str = Field(...) |
| 29 | + status: str = Field(...) |
| 30 | + progress: Optional[int] = Field(None) |
| 31 | + credits: int = Field(...) |
| 32 | + |
| 33 | + |
| 34 | +class ImageDownloadResponse(BaseModel): |
| 35 | + download_url: str = Field(...) |
| 36 | + expiry: int = Field(...) |
| 37 | + |
| 38 | + |
| 39 | +class Resolution(BaseModel): |
| 40 | + width: int = Field(...) |
| 41 | + height: int = Field(...) |
| 42 | + |
| 43 | + |
| 44 | +class CreateCreateVideoRequestSource(BaseModel): |
| 45 | + container: str = Field(...) |
| 46 | + size: int = Field(..., description="Size of the video file in bytes") |
| 47 | + duration: int = Field(..., description="Duration of the video file in seconds") |
| 48 | + frameCount: int = Field(..., description="Total number of frames in the video") |
| 49 | + frameRate: int = Field(...) |
| 50 | + resolution: Resolution = Field(...) |
| 51 | + |
| 52 | + |
| 53 | +class VideoFrameInterpolationFilter(BaseModel): |
| 54 | + model: str = Field(...) |
| 55 | + slowmo: Optional[int] = Field(None) |
| 56 | + fps: int = Field(...) |
| 57 | + duplicate: bool = Field(...) |
| 58 | + duplicate_threshold: float = Field(...) |
| 59 | + |
| 60 | + |
| 61 | +class VideoEnhancementFilter(BaseModel): |
| 62 | + model: str = Field(...) |
| 63 | + auto: Optional[str] = Field(None, description="Auto, Manual, Relative") |
| 64 | + focusFixLevel: Optional[str] = Field(None, description="Downscales video input for correction of blurred subjects") |
| 65 | + compression: Optional[float] = Field(None, description="Strength of compression recovery") |
| 66 | + details: Optional[float] = Field(None, description="Amount of detail reconstruction") |
| 67 | + prenoise: Optional[float] = Field(None, description="Amount of noise to add to input to reduce over-smoothing") |
| 68 | + noise: Optional[float] = Field(None, description="Amount of noise reduction") |
| 69 | + halo: Optional[float] = Field(None, description="Amount of halo reduction") |
| 70 | + preblur: Optional[float] = Field(None, description="Anti-aliasing and deblurring strength") |
| 71 | + blur: Optional[float] = Field(None, description="Amount of sharpness applied") |
| 72 | + grain: Optional[float] = Field(None, description="Grain after AI model processing") |
| 73 | + grainSize: Optional[float] = Field(None, description="Size of generated grain") |
| 74 | + recoverOriginalDetailValue: Optional[float] = Field(None, description="Source details into the output video") |
| 75 | + creativity: Optional[str] = Field(None, description="Creativity level(high, low) for slc-1 only") |
| 76 | + isOptimizedMode: Optional[bool] = Field(None, description="Set to true for Starlight Creative (slc-1) only") |
| 77 | + |
| 78 | + |
| 79 | +class OutputInformationVideo(BaseModel): |
| 80 | + resolution: Resolution = Field(...) |
| 81 | + frameRate: int = Field(...) |
| 82 | + audioCodec: Optional[str] = Field(..., description="Required if audioTransfer is Copy or Convert") |
| 83 | + audioTransfer: str = Field(..., description="Copy, Convert, None") |
| 84 | + dynamicCompressionLevel: str = Field(..., description="Low, Mid, High") |
| 85 | + |
| 86 | + |
| 87 | +class Overrides(BaseModel): |
| 88 | + isPaidDiffusion: bool = Field(True) |
| 89 | + |
| 90 | + |
| 91 | +class CreateVideoRequest(BaseModel): |
| 92 | + source: CreateCreateVideoRequestSource = Field(...) |
| 93 | + filters: list[Union[VideoFrameInterpolationFilter, VideoEnhancementFilter]] = Field(...) |
| 94 | + output: OutputInformationVideo = Field(...) |
| 95 | + overrides: Overrides = Field(Overrides(isPaidDiffusion=True)) |
| 96 | + |
| 97 | + |
| 98 | +class CreateVideoResponse(BaseModel): |
| 99 | + requestId: str = Field(...) |
| 100 | + |
| 101 | + |
| 102 | +class VideoAcceptResponse(BaseModel): |
| 103 | + uploadId: str = Field(...) |
| 104 | + urls: list[str] = Field(...) |
| 105 | + |
| 106 | + |
| 107 | +class VideoCompleteUploadRequestPart(BaseModel): |
| 108 | + partNum: int = Field(...) |
| 109 | + eTag: str = Field(...) |
| 110 | + |
| 111 | + |
| 112 | +class VideoCompleteUploadRequest(BaseModel): |
| 113 | + uploadResults: list[VideoCompleteUploadRequestPart] = Field(...) |
| 114 | + |
| 115 | + |
| 116 | +class VideoCompleteUploadResponse(BaseModel): |
| 117 | + message: str = Field(..., description="Confirmation message") |
| 118 | + |
| 119 | + |
| 120 | +class VideoStatusResponseEstimates(BaseModel): |
| 121 | + cost: list[int] = Field(...) |
| 122 | + |
| 123 | + |
| 124 | +class VideoStatusResponseDownloadUrl(BaseModel): |
| 125 | + url: str = Field(...) |
| 126 | + |
| 127 | + |
| 128 | +class VideoStatusResponse(BaseModel): |
| 129 | + status: str = Field(...) |
| 130 | + estimates: Optional[VideoStatusResponseEstimates] = Field(None) |
| 131 | + progress: Optional[float] = Field(None) |
| 132 | + message: Optional[str] = Field("") |
| 133 | + download: Optional[VideoStatusResponseDownloadUrl] = Field(None) |
0 commit comments