app.py
CHANGED
|
@@ -1,10 +1,44 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
with gr.Blocks(fill_height=True) as demo:
|
| 4 |
with gr.Sidebar():
|
| 5 |
-
gr.Markdown("#
|
| 6 |
gr.Markdown("This Space showcases the Wan-AI/Wan2.2-TI2V-5B model, served by the replicate API. Sign in with your Hugging Face account to use this API.")
|
| 7 |
button = gr.LoginButton("Sign in")
|
| 8 |
-
gr.load("models/Wan-AI/Wan2.2-TI2V-5B", accept_token=button, provider="replicate")
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
def generate_video(text_prompt, token):
|
| 4 |
+
"""Generate video from text using the Wan-AI/Wan2.2-TI2V-5B model"""
|
| 5 |
+
if not token:
|
| 6 |
+
return None, "Please sign in to use this feature."
|
| 7 |
+
|
| 8 |
+
try:
|
| 9 |
+
# Use Gradio's client to call the model
|
| 10 |
+
client = gr.Interface.load("models/Wan-AI/Wan2.2-TI2V-5B", hf_token=token)
|
| 11 |
+
result = client(text_prompt)
|
| 12 |
+
return result, "Video generated successfully!"
|
| 13 |
+
except Exception as e:
|
| 14 |
+
return None, f"Error generating video: {str(e)}"
|
| 15 |
+
|
| 16 |
with gr.Blocks(fill_height=True) as demo:
|
| 17 |
with gr.Sidebar():
|
| 18 |
+
gr.Markdown("# Text-to-Video Generator")
|
| 19 |
gr.Markdown("This Space showcases the Wan-AI/Wan2.2-TI2V-5B model, served by the replicate API. Sign in with your Hugging Face account to use this API.")
|
| 20 |
button = gr.LoginButton("Sign in")
|
|
|
|
| 21 |
|
| 22 |
+
with gr.Column():
|
| 23 |
+
gr.Markdown("## Generate Video from Text")
|
| 24 |
+
gr.Markdown("Enter a text description and generate a video using AI!")
|
| 25 |
+
|
| 26 |
+
text_input = gr.Textbox(
|
| 27 |
+
label="Text Prompt",
|
| 28 |
+
placeholder="Describe the video you want to generate...",
|
| 29 |
+
lines=3
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
generate_btn = gr.Button("Generate Video", variant="primary")
|
| 33 |
+
|
| 34 |
+
with gr.Row():
|
| 35 |
+
video_output = gr.Video(label="Generated Video")
|
| 36 |
+
status_output = gr.Textbox(label="Status", interactive=False)
|
| 37 |
+
|
| 38 |
+
generate_btn.click(
|
| 39 |
+
fn=generate_video,
|
| 40 |
+
inputs=[text_input, button],
|
| 41 |
+
outputs=[video_output, status_output]
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
demo.launch()
|