Spaces:
Runtime error
Runtime error
Janailsonk
commited on
Commit
•
e91a011
1
Parent(s):
701725b
app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,53 @@
|
|
1 |
import gradio as gr
|
2 |
-
import torch
|
3 |
-
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
4 |
-
from generate_video import generate as generate_video
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
# Essa função recebe os parâmetros da entrada e usa o módulo generate_video para gerar o vídeo com o áudio correspondente.
|
13 |
-
result = generate_video(prompt, tokenizer, model, seed, duration)
|
14 |
-
return result
|
15 |
|
16 |
-
|
17 |
-
fn=generate_video_online,
|
18 |
-
inputs=[
|
19 |
-
gr.inputs.Textbox(lines=7, placeholder="Insira seu texto aqui"),
|
20 |
-
gr.inputs.Radio(['modelscope', 'zeroscope'], label="Selecione o modelo a ser usado"),
|
21 |
-
gr.inputs.Slider(minimum=0, maximum=100000, step=1, label="Seed"),
|
22 |
-
gr.inputs.Slider(minimum=2, maximum=60, step=1, label="Duração em segundos")
|
23 |
-
],
|
24 |
-
outputs="video",
|
25 |
-
title="Text to Video with Audio",
|
26 |
-
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
+
def generate_videos(prompt, models, seed, video_duration):
|
4 |
+
"""
|
5 |
+
This function generates videos with audio from Audioldm using the Hugging Face website space and Gradio.
|
6 |
+
|
7 |
+
Parameters:
|
8 |
+
prompt (str): The text prompt for generating the videos.
|
9 |
+
models (list): The list of models to choose from (e.g., ["MODELSCOPE", "ZEROSCOPE"]).
|
10 |
+
seed (int): The seed number for generating different videos.
|
11 |
+
video_duration (int): The time duration of the video in seconds (between 2 and 60).
|
12 |
+
|
13 |
+
Returns:
|
14 |
+
str: The generated video with audio from Audioldm.
|
15 |
+
"""
|
16 |
+
try:
|
17 |
+
# Check if prompt is provided
|
18 |
+
if not prompt:
|
19 |
+
raise ValueError("Prompt is required")
|
20 |
+
|
21 |
+
# Check if models are provided
|
22 |
+
if not models:
|
23 |
+
raise ValueError("Models are required")
|
24 |
+
|
25 |
+
# Check if seed is within the valid range
|
26 |
+
if seed < -1 or seed > 1000000:
|
27 |
+
raise ValueError("Seed must be between -1 and 1000000")
|
28 |
+
|
29 |
+
# Check if video duration is within the valid range
|
30 |
+
if video_duration < 2 or video_duration > 60:
|
31 |
+
raise ValueError("Video duration must be between 2 and 60 seconds")
|
32 |
+
|
33 |
+
# Generate the videos using the provided inputs
|
34 |
+
# Add your code here
|
35 |
+
|
36 |
+
return "Generated video with audio from Audioldm"
|
37 |
+
|
38 |
+
except ValueError as e:
|
39 |
+
# Log the error
|
40 |
+
print(f"Error: {e}")
|
41 |
+
return ""
|
42 |
+
|
43 |
+
# Create the Gradio interface
|
44 |
+
inputs = [
|
45 |
+
gr.inputs.Textbox(label="Prompt"),
|
46 |
+
gr.inputs.CheckboxGroup(["MODELSCOPE", "ZEROSCOPE"], label="Models"),
|
47 |
+
gr.inputs.Number(label="Seed", min_value=-1, max_value=1000000),
|
48 |
+
gr.inputs.Number(label="Video Duration", min_value=2, max_value=60)
|
49 |
+
]
|
50 |
|
51 |
+
output = gr.outputs.Textbox(label="Generated Video")
|
|
|
|
|
|
|
52 |
|
53 |
+
gr.Interface(fn=generate_videos, inputs=inputs, outputs=output).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|