Download app.py from arisegu/image-qa: direct link, hf CLI and curl.
- Browser
- Download file 795 Bytes
-
https://huggingface.co/spaces/arisegu/image-qa/resolve/main/app.py
- Command line
-
hf download hf://spaces/arisegu/image-qa/app.py
-
curl -L -o app.py https://huggingface.co/spaces/arisegu/image-qa/resolve/main/app.py
795 Bytes
| import streamlit as st | |
| import torch | |
| from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler | |
| from diffusers.utils import export_to_video | |
| # Explicitly set the device to CPU | |
| device = torch.device("cpu") | |
| # Load the model onto the CPU | |
| pipe = DiffusionPipeline.from_pretrained( | |
| "damo-vilab/text-to-video-ms-1.7b", | |
| torch_dtype=torch.float32 # Use float32 for CPU | |
| ).to(device) | |
| # Initialize the scheduler from the pipeline's configuration, no need to move it to the CPU | |
| pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config) | |
| prompt = "Pop international experimental music" | |
| # Generate the video frames on the CPU | |
| video_frames = pipe(prompt, num_inference_steps=25).frames | |
| # Export the frames to a video file | |
| video_path = export_to_video(video_frames) | |