MCPcopy Create free account
hub / github.com/Vchitect/LaVie / predict

Method predict

predict.py:159–340  ·  view source on GitHub ↗

Run a single prediction on the model

(
        self,
        prompt: str = Input(
            description="Prompt for video generation.",
            default="a Corgi walking in the park at sunrise, oil painting style",
        ),
        sample_method: str = Input(
            description="Choose a scheduler for sampling base video output.",
            default="ddpm",
            choices=["ddim", "eulerdiscrete", "ddpm"],
        ),
        width: int = Input(description="Width of output video.", default=512),
        height: int = Input(description="Height of output video", default=320),
        num_inference_steps: int = Input(
            description="Number of denoising steps", default=50
        ),
        guidance_scale: float = Input(
            description="Scale for classifier-free guidance", default=7.0
        ),
        quality: int = Input(
            description="Quality of the output vide0", le=10, ge=0, default=9
        ),
        seed: int = Input(
            description="Random seed. Leave blank to randomize the seed", default=None
        ),
        interpolation: bool = Input(
            description="Default output has 16 frames. Set interpolation to True to get 61 frames output.",
            default=False,
        ),
        super_resolution: bool = Input(
            description="Super resolution 4x when set to True.", default=False
        ),
        video_fps: int = Input(
            description="Number of frames per second in the output video", default=8
        ),
    )

Source from the content-addressed store, hash-verified

157 self.sr_pipeline = self.sr_pipeline.to(self.device)
158
159 def predict(
160 self,
161 prompt: str = Input(
162 description="Prompt for video generation.",
163 default="a Corgi walking in the park at sunrise, oil painting style",
164 ),
165 sample_method: str = Input(
166 description="Choose a scheduler for sampling base video output.",
167 default="ddpm",
168 choices=["ddim", "eulerdiscrete", "ddpm"],
169 ),
170 width: int = Input(description="Width of output video.", default=512),
171 height: int = Input(description="Height of output video", default=320),
172 num_inference_steps: int = Input(
173 description="Number of denoising steps", default=50
174 ),
175 guidance_scale: float = Input(
176 description="Scale for classifier-free guidance", default=7.0
177 ),
178 quality: int = Input(
179 description="Quality of the output vide0", le=10, ge=0, default=9
180 ),
181 seed: int = Input(
182 description="Random seed. Leave blank to randomize the seed", default=None
183 ),
184 interpolation: bool = Input(
185 description="Default output has 16 frames. Set interpolation to True to get 61 frames output.",
186 default=False,
187 ),
188 super_resolution: bool = Input(
189 description="Super resolution 4x when set to True.", default=False
190 ),
191 video_fps: int = Input(
192 description="Number of frames per second in the output video", default=8
193 ),
194 ) -> Path:
195 """Run a single prediction on the model"""
196 if seed is None:
197 seed = int.from_bytes(os.urandom(2), "big")
198 print(f"Using seed: {seed}")
199
200 temp_output_dir = "temp_output"
201 if os.path.exists(temp_output_dir):
202 shutil.rmtree(temp_output_dir)
203 os.makedirs(temp_output_dir)
204
205 torch.manual_seed(seed)
206 torch.cuda.manual_seed(seed)
207 scheduler = self.schedulers[sample_method]
208
209 videogen_pipeline = VideoGenPipeline(
210 vae=self.vae,
211 text_encoder=self.text_encoder_one,
212 tokenizer=self.tokenizer_one,
213 scheduler=scheduler,
214 unet=self.unet,
215 ).to(self.device)
216 videogen_pipeline.enable_xformers_memory_efficient_attention()

Callers

nothing calls this directly

Calls 3

VideoGenPipelineClass · 0.90
get_inputFunction · 0.70

Tested by

no test coverage detected