creuthecat's picture
download
raw
1.9 kB
from dataclasses import dataclass
from pathlib import Path
from typing import Optional, Sequence
from PIL import Image
@dataclass
class GenerationConfig:
prompt: str
negative_prompt: str = ""
width: int = 1280
height: int = 720
frames: int = 120
fps: int = 24
seed: int = 42
guidance_scale: float = 5.0
motion_strength: float = 0.5
camera: str = "static"
class OpenSoraV21Pipeline:
"""
Main Open-Sora-v2.1 pipeline.
The model backend is intentionally separated from the public API so
the underlying video transformer can be replaced without changing
user-facing generation code.
"""
def __init__(
self,
model_id: str = "creuthecat/Open-Sora-v2.1",
device: str = "cuda",
dtype: str = "bf16",
):
self.model_id = model_id
self.device = device
self.dtype = dtype
self.video_model = None
self.reference_encoder = None
self.audio_generator = None
def load(self):
"""
Load model components.
TODO:
Replace this with the actual Open-Sora-v2.1 model loading code.
"""
print(f"Loading {self.model_id}...")
print(f"Device: {self.device}")
print(f"Dtype: {self.dtype}")
return self
def generate(
self,
config: GenerationConfig,
image: Optional[Image.Image] = None,
references: Optional[Sequence[Image.Image]] = None,
generate_sfx: bool = True,
generate_ambient: bool = True,
) -> Path:
if self.video_model is None:
raise RuntimeError(
"Video backend is not loaded yet. "
"Implement/load the model backend before generation."
)
raise NotImplementedError(
"Video generation backend will be implemented in the next stage."
)

Xet Storage Details

Size:
1.9 kB
·
Xet hash:
880ed8481d8c1bf9c41922d0ff71a6ee2375d9892e80acff70425bfe64630f20

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.