Last active
March 7, 2025 22:43
-
-
Save XIT07/22cfec81e64578e7c9f36782ecefc40d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Step 1: Install required packages | |
| !pip install -U datasets modelscope gradio addict | |
| # Step 1.1: Install simplejson | |
| !pip install simplejson | |
| # Import dependencies | |
| from modelscope.pipelines import pipeline | |
| from modelscope.utils.constant import Tasks | |
| import gradio as gr | |
| # Load Wan2.1 model from ModelScope | |
| model_id = 'Wan-AI/Wan2.1-I2V-14B-720P' | |
| pipe = pipeline(task='text-to-video-generation', model=model_id) | |
| # Define prediction function | |
| def generate_video(prompt): | |
| output = pipe(prompt) | |
| video_path = output['output_video'] | |
| return video_path | |
| # Create Gradio interface | |
| iface = gr.Interface( | |
| fn=generate_video, | |
| inputs=gr.Textbox(label="Enter your prompt"), | |
| outputs=gr.Video(label="Generated Video"), | |
| title="Wan2.1 Text-to-Video Generator", | |
| description="Generate videos from text using the Wan2.1 model" | |
| ) | |
| # Launch the app (publicly accessible in Colab) | |
| iface.launch(share=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment