|
|
| import torch |
| from diffusers import LTXVideoPipeline, DPMSolverMultistepScheduler |
| from diffusers.utils import export_to_video |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
|
|
| class ShivAI_Pro: |
| def __init__(self): |
| self.device = "cuda" if torch.cuda.is_available() else "cpu" |
| print("--- Loading Shiv AI Pro Engine (Owner: Shri Ram Nag) ---") |
|
|
| |
| self.pipe = LTXVideoPipeline.from_pretrained( |
| "Shriramnag/Shiv-AI-Video-Generator", |
| torch_dtype=torch.float16 |
| ).to(self.device) |
|
|
| |
| self.pipe.scheduler = DPMSolverMultistepScheduler.from_config(self.pipe.scheduler.config) |
|
|
| |
| self.pipe.enable_model_cpu_offload() |
|
|
| def generate_pro_video(self, prompt, audio_path=None): |
| |
| negative_prompt = "low quality, blurry, distorted face, bad anatomy, static" |
|
|
| print(f"--- Shiv AI: Generating Pro Video for: {prompt} ---") |
|
|
| video_frames = self.pipe( |
| prompt=prompt, |
| negative_prompt=negative_prompt, |
| num_inference_steps=25, |
| num_frames=32, |
| guidance_scale=7.5, |
| ).frames[0] |
|
|
| output_path = "shiv_ai_pro_output.mp4" |
| export_to_video(video_frames, output_path, fps=12) |
|
|
| |
| if audio_path: |
| print("--- Applying Perfect Lip-Sync with Audio ---") |
| |
|
|
| return output_path |
|
|
| if __name__ == "__main__": |
| ai = ShivAI_Pro() |
| ai.generate_pro_video("An Indian man speaking to the camera, cinematic lighting, 4k") |
|
|