|
|
import os
|
|
|
import subprocess
|
|
|
from PIL import Image
|
|
|
import gradio as gr
|
|
|
import cv2
|
|
|
|
|
|
|
|
|
|
|
|
def run_commands(description, aspect_ratio, enhance_check, model, style, upscale_check, task_type, img=None, is_extend=False, is_recreate=False):
|
|
|
try:
|
|
|
commands = []
|
|
|
|
|
|
if True:
|
|
|
|
|
|
if upscale_check:
|
|
|
commands.append('python /content/Vidu_Studio/vidu_credit.py --credit 4')
|
|
|
else:
|
|
|
commands.append('python /content/Vidu_Studio/vidu_credit.py --credit 0')
|
|
|
|
|
|
if task_type == "video_to_video":
|
|
|
commands.append('python /content/Vidu_Studio/utils/video_fragment.py')
|
|
|
print("File Uploader...")
|
|
|
commands.append('python /content/Vidu_Studio/upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
|
|
|
|
|
if task_type == "extend":
|
|
|
print("Last frame...")
|
|
|
commands.append('python /content/Vidu_Studio/utils/fragment.py')
|
|
|
|
|
|
if task_type == "reference_to_video" or task_type == "image_to_video" or task_type == "extend":
|
|
|
print("File Uploader...")
|
|
|
commands.append('python /content/Vidu_Studio/upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
|
|
|
|
|
if task_type == "reference_to_video":
|
|
|
print("Generating video with reference...")
|
|
|
commands.append(
|
|
|
f'python /content/Vidu_Studio/create_video_reference.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
|
|
)
|
|
|
elif task_type == "text_to_video":
|
|
|
print("Generating video: Text to Video...")
|
|
|
commands.append(
|
|
|
f'python /content/Vidu_Studio/create_text_to_video.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}" --style "{style}" --aspect_ratio "{aspect_ratio}"'
|
|
|
)
|
|
|
elif task_type == "image_to_video" or task_type == "extend":
|
|
|
print("Generating Video: Image to Video...")
|
|
|
commands.append(
|
|
|
f'python /content/Vidu_Studio/create_task.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
|
|
)
|
|
|
elif task_type == "video_to_video":
|
|
|
print("Generating Video: Video to Video...")
|
|
|
commands.append(
|
|
|
f'python /content/Vidu_Studio/create_task.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
|
|
)
|
|
|
else:
|
|
|
raise ValueError(f"Tipo de tarea no reconocido: {task_type}")
|
|
|
print("Video in progress...")
|
|
|
commands.append('python /content/Vidu_Studio/utils/process_task.py')
|
|
|
|
|
|
if upscale_check:
|
|
|
print("Generate Upscale...")
|
|
|
commands.append('python /content/Vidu_Studio/utils/upscale_task.py')
|
|
|
print("Upscale in progress...")
|
|
|
commands.append('python /content/Vidu_Studio/utils/process_task_upscale.py')
|
|
|
commands.append('python /content/Vidu_Studio/utils/delete_task.py')
|
|
|
commands.append('python /content/Vidu_Studio/utils/delete_task_upscale.py')
|
|
|
else:
|
|
|
commands.append('python /content/Vidu_Studio/utils/delete_task.py')
|
|
|
|
|
|
output = ""
|
|
|
for command in commands:
|
|
|
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
|
|
output += f"Exit:\n{result.stdout}\n"
|
|
|
print(result.stdout)
|
|
|
|
|
|
video_path = "/content/Vidu_Studio/video.mp4"
|
|
|
return output, video_path
|
|
|
except Exception as e:
|
|
|
return f"Excepci贸n: {str(e)}", None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_commands_dual(description, aspect_ratio, enhance_check, model, style, upscale_check, task_type, add_end_frame, img=None, is_extend=False, is_recreate=False):
|
|
|
try:
|
|
|
commands = []
|
|
|
|
|
|
if add_end_frame:
|
|
|
|
|
|
if upscale_check:
|
|
|
commands.append('python /content/Vidu_Studio/vidu_credit.py --credit 4')
|
|
|
else:
|
|
|
commands.append('python /content/Vidu_Studio/vidu_credit.py --credit 0')
|
|
|
|
|
|
print("File Uploader...")
|
|
|
commands.append('python /content/Vidu_Studio/upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
|
|
commands.append('python /content/Vidu_Studio/upload/file_uploader.py --file_info "file_info2" --image "img_fragmento2"')
|
|
|
|
|
|
if task_type == "headtailimg2video":
|
|
|
print("Generating video with headtailimg2video...")
|
|
|
commands.append(
|
|
|
f'python /content/Vidu_Studio/headtailimg2video.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
|
|
)
|
|
|
print("Video in progress...")
|
|
|
commands.append('python /content/Vidu_Studio/utils/process_task.py')
|
|
|
|
|
|
if upscale_check:
|
|
|
print("Generate Upscale...")
|
|
|
commands.append('python /content/Vidu_Studio/utils/upscale_task.py')
|
|
|
print("Upscale in progress...")
|
|
|
commands.append('python /content/Vidu_Studio/utils/process_task_upscale.py')
|
|
|
commands.append('python /content/Vidu_Studio/utils/delete_task.py')
|
|
|
commands.append('python /content/Vidu_Studio/utils/delete_task_upscale.py')
|
|
|
else:
|
|
|
commands.append('python /content/Vidu_Studio/utils/delete_task.py')
|
|
|
else:
|
|
|
|
|
|
if upscale_check:
|
|
|
commands.append('python /content/Vidu_Studio/vidu_credit.py --credit 4')
|
|
|
else:
|
|
|
commands.append('python /content/Vidu_Studio/vidu_credit.py --credit 0')
|
|
|
|
|
|
print("File Uploader...")
|
|
|
commands.append('python /content/Vidu_Studio/upload/file_uploader.py --file_info "file_info" --image "img_fragmento"')
|
|
|
|
|
|
if task_type == "headtailimg2video":
|
|
|
print("Generating video with Image to Video...")
|
|
|
commands.append(
|
|
|
f'python /content/Vidu_Studio/create_task.py --prompt "{description}" --enhance {str(enhance_check).lower()} --model "{model}"'
|
|
|
)
|
|
|
|
|
|
print("Video in progress...")
|
|
|
commands.append('python /content/Vidu_Studio/utils/process_task.py')
|
|
|
|
|
|
if upscale_check:
|
|
|
print("Generate Upscale...")
|
|
|
commands.append('python /content/Vidu_Studio/utils/upscale_task.py')
|
|
|
print("Upscale in progress...")
|
|
|
commands.append('python /content/Vidu_Studio/utils/process_task_upscale.py')
|
|
|
commands.append('python /content/Vidu_Studio/utils/delete_task.py')
|
|
|
commands.append('python /content/Vidu_Studio/utils/delete_task_upscale.py')
|
|
|
else:
|
|
|
commands.append('python /content/Vidu_Studio/utils/delete_task.py')
|
|
|
|
|
|
|
|
|
output = ""
|
|
|
for command in commands:
|
|
|
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
|
|
output += f"Exit:\n{result.stdout}\n"
|
|
|
print(result.stdout)
|
|
|
|
|
|
video_path = "/content/Vidu_Studio/video.mp4"
|
|
|
return output, video_path
|
|
|
except Exception as e:
|
|
|
return f"Excepci贸n: {str(e)}", None
|
|
|
|
|
|
|
|
|
def process_and_save_image(image, coordinates_file_path="/tmp/coordinates.txt"):
|
|
|
jpg_path = "/tmp/img_fragmento.jpg"
|
|
|
|
|
|
try:
|
|
|
if image.format != "JPEG":
|
|
|
image = image.convert("RGB")
|
|
|
image.save(jpg_path, "JPEG", quality=100)
|
|
|
if os.path.exists(jpg_path):
|
|
|
print(f"Imagen guardada correctamente")
|
|
|
|
|
|
|
|
|
width, height = image.size
|
|
|
|
|
|
|
|
|
with open(coordinates_file_path, "w") as file:
|
|
|
file.write(f"X: {width}\n")
|
|
|
file.write(f"Y: {height}\n")
|
|
|
|
|
|
print(f"Coordenadas guardadas correctamente")
|
|
|
|
|
|
return None
|
|
|
except Exception as e:
|
|
|
print(f"Error al procesar la imagen: {str(e)}")
|
|
|
return None
|
|
|
|
|
|
|
|
|
def process_and_save_image1(image, coordinates_file_path="/tmp/coordinates.txt"):
|
|
|
jpg_path = "/tmp/img_fragmento.jpg"
|
|
|
|
|
|
try:
|
|
|
if image.format != "JPEG":
|
|
|
image = image.convert("RGB")
|
|
|
image.save(jpg_path, "JPEG", quality=100)
|
|
|
if os.path.exists(jpg_path):
|
|
|
print(f"Imagen guardada correctamente")
|
|
|
|
|
|
|
|
|
width, height = image.size
|
|
|
|
|
|
|
|
|
with open(coordinates_file_path, "w") as file:
|
|
|
file.write(f"X: {width}\n")
|
|
|
file.write(f"Y: {height}\n")
|
|
|
|
|
|
print(f"Coordenadas guardadas correctamente")
|
|
|
|
|
|
return None
|
|
|
except Exception as e:
|
|
|
print(f"Error al procesar la imagen: {str(e)}")
|
|
|
return None
|
|
|
|
|
|
|
|
|
def process_and_save_image2(image, coordinates_file_path="/tmp/coordinates2.txt"):
|
|
|
jpg_path = "/tmp/img_fragmento2.jpg"
|
|
|
|
|
|
try:
|
|
|
if image.format != "JPEG":
|
|
|
image = image.convert("RGB")
|
|
|
image.save(jpg_path, "JPEG", quality=100)
|
|
|
if os.path.exists(jpg_path):
|
|
|
print(f"Imagen guardada correctamente")
|
|
|
|
|
|
|
|
|
width, height = image.size
|
|
|
|
|
|
|
|
|
with open(coordinates_file_path, "w") as file:
|
|
|
file.write(f"X: {width}\n")
|
|
|
file.write(f"Y: {height}\n")
|
|
|
|
|
|
print(f"Coordenadas guardadas correctamente")
|
|
|
|
|
|
except Exception as e:
|
|
|
print(f"Error al procesar la imagen: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_last_frame(video_path):
|
|
|
try:
|
|
|
cap = cv2.VideoCapture(video_path)
|
|
|
frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
|
|
|
cap.set(cv2.CAP_PROP_POS_FRAMES, frame_count - 1)
|
|
|
ret, frame = cap.read()
|
|
|
cap.release()
|
|
|
|
|
|
if ret:
|
|
|
return Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
|
|
|
else:
|
|
|
print(f"Error al leer el 煤ltimo frame del video: {video_path}")
|
|
|
return None
|
|
|
except Exception as e:
|
|
|
print(f"Excepci贸n al obtener el 煤ltimo frame: {str(e)}")
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def run_save_commands():
|
|
|
try:
|
|
|
print("Rendering video...")
|
|
|
commands = [
|
|
|
"python /content/Vidu_Studio/utils/fragment.py",
|
|
|
"python /content/Vidu_Studio/utils/union.py"
|
|
|
]
|
|
|
output = ""
|
|
|
for command in commands:
|
|
|
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
|
|
output += f"Exit:\n{result.stdout}\n"
|
|
|
print(result.stdout)
|
|
|
video_path = "/content/Vidu_Studio/video.mp4"
|
|
|
return output, video_path
|
|
|
except Exception as e:
|
|
|
return f"Excepci贸n al guardar: {str(e)}", None
|
|
|
|
|
|
|
|
|
def activar_end_frame(activar):
|
|
|
return gr.update(visible=activar)
|
|
|
|
|
|
|
|
|
with gr.Blocks() as demo:
|
|
|
|
|
|
gr.HTML(f"<h1 style='text-align: center; font-size: 3em;'>VIDU STUDIO 3.0 - AUTOMATIC</p>Created by:<a href='https://www.youtube.com/@IA.Sistema.de.Interes' target='_blank'>IA(Sistema de Inter茅s)</a></p>")
|
|
|
with gr.Tabs():
|
|
|
|
|
|
with gr.Tab("Image to Video"):
|
|
|
with gr.Row():
|
|
|
with gr.Column():
|
|
|
add_end_frame = gr.Checkbox(label="Add End Frame", value=False)
|
|
|
|
|
|
|
|
|
with gr.Row():
|
|
|
|
|
|
img1 = gr.Image(type="pil", label="Drag image here or select image", interactive=True,
|
|
|
elem_id="img1", width=200, height=200)
|
|
|
|
|
|
|
|
|
img2 = gr.Image(type="pil", label="Upload the last frame image", interactive=True,
|
|
|
elem_id="img2", visible=False, width=200, height=200)
|
|
|
|
|
|
description_input = gr.Textbox(label="Prompt",
|
|
|
placeholder="Aqu铆 va una caja de texto editable para el prompt",
|
|
|
elem_id="description_input")
|
|
|
enhance_checkbox = gr.Checkbox(label="Enhance prompt", value=False, elem_id="enhance_checkbox")
|
|
|
model_dropdown = gr.Dropdown(
|
|
|
choices=["vidu-1", "vidu-high-performance"],
|
|
|
label="Model",
|
|
|
value="vidu-1",
|
|
|
elem_id="model_dropdown"
|
|
|
)
|
|
|
upscale_checkbox = gr.Checkbox(label="Upscale", value=False, elem_id="upscale_checkbox")
|
|
|
create_button = gr.Button("Create", elem_id="create_button")
|
|
|
extend_button = gr.Button("Extend", elem_id="extend_button")
|
|
|
recreate_button = gr.Button("Re-create", elem_id="recreate_button")
|
|
|
save_button = gr.Button("Save", elem_id="save_button")
|
|
|
|
|
|
with gr.Column():
|
|
|
video_output = gr.Video(label="Video Output Image to Video", height=400, elem_id="video_output_image_to_video")
|
|
|
output_textbox = gr.Textbox(label="Output", interactive=False, elem_id="output_textbox")
|
|
|
|
|
|
|
|
|
|
|
|
add_end_frame.change(activar_end_frame, add_end_frame, img2)
|
|
|
|
|
|
|
|
|
img1.change(
|
|
|
fn=process_and_save_image1,
|
|
|
inputs=img1,
|
|
|
outputs=[]
|
|
|
)
|
|
|
|
|
|
img2.change(
|
|
|
fn=process_and_save_image2,
|
|
|
inputs=img2,
|
|
|
outputs=[]
|
|
|
)
|
|
|
|
|
|
|
|
|
create_button.click(
|
|
|
fn=lambda desc, enhance, model, upscale, img, add_end: run_commands_dual(desc, "16:9", enhance, model, "general", upscale, task_type="headtailimg2video", img=img, add_end_frame=add_end),
|
|
|
inputs=[description_input, enhance_checkbox, model_dropdown, upscale_checkbox, img1, add_end_frame],
|
|
|
outputs=[output_textbox, video_output]
|
|
|
)
|
|
|
|
|
|
|
|
|
extend_button.click(
|
|
|
fn=lambda desc, enhance, model, upscale, img: run_commands(desc, "16:9", enhance, model, "general", upscale, task_type="extend", img=img, is_extend=True),
|
|
|
inputs=[description_input, enhance_checkbox, model_dropdown, upscale_checkbox, img1],
|
|
|
outputs=[output_textbox, video_output]
|
|
|
)
|
|
|
|
|
|
|
|
|
recreate_button.click(
|
|
|
fn=lambda desc, enhance, model, upscale, img: run_commands(desc, "16:9", enhance, model, "general", upscale, task_type="image_to_video", img=img, is_recreate=True),
|
|
|
inputs=[description_input, enhance_checkbox, model_dropdown, upscale_checkbox, img1],
|
|
|
outputs=[output_textbox, video_output]
|
|
|
)
|
|
|
|
|
|
|
|
|
save_button.click(
|
|
|
fn=run_save_commands,
|
|
|
inputs=[],
|
|
|
outputs=[output_textbox, video_output]
|
|
|
)
|
|
|
|
|
|
|
|
|
with gr.Tab("Reference to Video"):
|
|
|
with gr.Row():
|
|
|
with gr.Column():
|
|
|
image_input2 = gr.Image(type="pil", label="Drag image here or select image", interactive=True,
|
|
|
elem_id="image_input2")
|
|
|
description_input2 = gr.Textbox(label="Prompt",
|
|
|
placeholder="Enter text to begin creating a video that aligns with the subject of the image",
|
|
|
elem_id="description_input2")
|
|
|
enhance_checkbox2 = gr.Checkbox(label="Enhance prompt", value=False, elem_id="enhance_checkbox2")
|
|
|
model_dropdown2 = gr.Dropdown(
|
|
|
choices=["vidu-1", "vidu-high-performance"],
|
|
|
label="Model",
|
|
|
value="vidu-1",
|
|
|
elem_id="model_dropdown2"
|
|
|
)
|
|
|
upscale_checkbox2 = gr.Checkbox(label="Upscale", value=False, elem_id="upscale_checkbox2")
|
|
|
create_button2 = gr.Button("Create", elem_id="create_button2")
|
|
|
extend_button2 = gr.Button("Extend", elem_id="extend_button2")
|
|
|
recreate_button2 = gr.Button("Re-create", elem_id="recreate_button2")
|
|
|
save_button2 = gr.Button("Save", elem_id="save_button2")
|
|
|
|
|
|
with gr.Column():
|
|
|
video_output2 = gr.Video(label="Video Output Reference to Video", height=400, elem_id="video_output_reference_to_video")
|
|
|
output_textbox2 = gr.Textbox(label="Output", interactive=False, elem_id="output_textbox2")
|
|
|
|
|
|
|
|
|
image_input2.change(
|
|
|
fn=process_and_save_image,
|
|
|
inputs=image_input2,
|
|
|
outputs=[]
|
|
|
)
|
|
|
|
|
|
|
|
|
create_button2.click(
|
|
|
fn=lambda desc, enhance, model, upscale, img: run_commands(desc, "16:9", enhance, model, "general", upscale, task_type="reference_to_video", img=img),
|
|
|
inputs=[description_input2, enhance_checkbox2, model_dropdown2, upscale_checkbox2, image_input2],
|
|
|
outputs=[output_textbox2, video_output2]
|
|
|
)
|
|
|
|
|
|
|
|
|
extend_button2.click(
|
|
|
fn=lambda desc, enhance, model, upscale, img: run_commands(desc, "16:9", enhance, model, "general", upscale, task_type="extend", img=img, is_extend=True),
|
|
|
inputs=[description_input2, enhance_checkbox2, model_dropdown2, upscale_checkbox2, image_input2],
|
|
|
outputs=[output_textbox2, video_output2]
|
|
|
)
|
|
|
|
|
|
|
|
|
recreate_button2.click(
|
|
|
fn=lambda desc, enhance, model, upscale, img: run_commands(desc, "16:9", enhance, model, "general", upscale, task_type="reference_to_video", img=img, is_recreate=True),
|
|
|
inputs=[description_input2, enhance_checkbox2, model_dropdown2, upscale_checkbox2, image_input2],
|
|
|
outputs=[output_textbox2, video_output2]
|
|
|
)
|
|
|
|
|
|
|
|
|
save_button2.click(
|
|
|
fn=run_save_commands,
|
|
|
inputs=[],
|
|
|
outputs=[output_textbox2, video_output2]
|
|
|
)
|
|
|
|
|
|
|
|
|
with gr.Tab("Text to Video"):
|
|
|
with gr.Row():
|
|
|
with gr.Column():
|
|
|
description_input3 = gr.Textbox(label="Prompt",
|
|
|
placeholder="Enter text to begin creating a video",
|
|
|
elem_id="description_input3")
|
|
|
aspect_ratio_dropdown = gr.Dropdown(
|
|
|
choices=["16:9", "9:16", "4:3", "1:1"],
|
|
|
label="Aspect Ratio",
|
|
|
value="16:9",
|
|
|
elem_id="aspect_ratio_dropdown"
|
|
|
)
|
|
|
enhance_checkbox3 = gr.Checkbox(label="Enhance prompt", value=False, elem_id="enhance_checkbox3")
|
|
|
model_dropdown3 = gr.Dropdown(
|
|
|
choices=["vidu-1", "vidu-high-performance"],
|
|
|
label="Model",
|
|
|
value="vidu-1",
|
|
|
elem_id="model_dropdown3"
|
|
|
)
|
|
|
style_dropdown3 = gr.Dropdown(
|
|
|
choices=["general", "anime"],
|
|
|
label="Style",
|
|
|
value="general",
|
|
|
elem_id="style_dropdown3"
|
|
|
)
|
|
|
upscale_checkbox3 = gr.Checkbox(label="Upscale", value=False, elem_id="upscale_checkbox3")
|
|
|
create_button3 = gr.Button("Create", elem_id="create_button3")
|
|
|
extend_button3 = gr.Button("Extend", elem_id="extend_button3")
|
|
|
recreate_button3 = gr.Button("Re-create", elem_id="recreate_button3")
|
|
|
save_button3 = gr.Button("Save", elem_id="save_button3")
|
|
|
|
|
|
with gr.Column():
|
|
|
video_output3 = gr.Video(label="Video Output Text to Video", height=400, elem_id="video_output_text_to_video")
|
|
|
output_textbox3 = gr.Textbox(label="Output", interactive=False, elem_id="output_textbox3")
|
|
|
|
|
|
|
|
|
create_button3.click(
|
|
|
fn=lambda desc, ratio, enhance, model, style, upscale: run_commands(desc, ratio, enhance, model, style,
|
|
|
upscale, task_type="text_to_video"),
|
|
|
inputs=[description_input3, aspect_ratio_dropdown, enhance_checkbox3, model_dropdown3, style_dropdown3,
|
|
|
upscale_checkbox3],
|
|
|
outputs=[output_textbox3, video_output3]
|
|
|
)
|
|
|
|
|
|
|
|
|
extend_button3.click(
|
|
|
fn=lambda desc, enhance, model, upscale: run_commands(desc, "16:9", enhance, model, "general", upscale, task_type="extend", is_extend=True),
|
|
|
inputs=[description_input3, enhance_checkbox3, model_dropdown3, upscale_checkbox3],
|
|
|
outputs=[output_textbox3, video_output3]
|
|
|
)
|
|
|
|
|
|
|
|
|
recreate_button3.click(
|
|
|
fn=lambda desc, ratio, enhance, model, style, upscale: run_commands(desc, ratio, enhance, model, style,
|
|
|
upscale, task_type="text_to_video", is_recreate=True),
|
|
|
inputs=[description_input3, aspect_ratio_dropdown, enhance_checkbox3, model_dropdown3, style_dropdown3,
|
|
|
upscale_checkbox3],
|
|
|
outputs=[output_textbox3, video_output3]
|
|
|
)
|
|
|
|
|
|
|
|
|
save_button3.click(
|
|
|
fn=run_save_commands,
|
|
|
inputs=[],
|
|
|
outputs=[output_textbox3, video_output3]
|
|
|
)
|
|
|
|
|
|
|
|
|
with gr.Tab("Video to Video"):
|
|
|
with gr.Row():
|
|
|
with gr.Column():
|
|
|
video_input4 = gr.Video(label="Input Video", height=400, interactive=True)
|
|
|
description_input4 = gr.Textbox(label="Prompt",
|
|
|
placeholder="Enter text to begin creating a video",
|
|
|
elem_id="description_input4")
|
|
|
enhance_checkbox4 = gr.Checkbox(label="Enhance prompt", value=False, elem_id="enhance_checkbox4")
|
|
|
model_dropdown4 = gr.Dropdown(
|
|
|
choices=["vidu-1", "vidu-high-performance"],
|
|
|
label="Model",
|
|
|
value="vidu-1",
|
|
|
elem_id="model_dropdown4"
|
|
|
)
|
|
|
upscale_checkbox4 = gr.Checkbox(label="Upscale", value=False, elem_id="upscale_checkbox4")
|
|
|
create_button4 = gr.Button("Create", elem_id="create_button4")
|
|
|
extend_button4 = gr.Button("Extend", elem_id="extend_button4")
|
|
|
recreate_button4 = gr.Button("Re-create", elem_id="recreate_button4")
|
|
|
save_button4 = gr.Button("Save", elem_id="save_button4")
|
|
|
|
|
|
with gr.Column():
|
|
|
video_output4 = gr.Video(label="Video Output Video to Video", height=400, elem_id="video_output_video_to_video")
|
|
|
output_textbox4 = gr.Textbox(label="Output", interactive=False, elem_id="output_textbox4")
|
|
|
|
|
|
|
|
|
def save_uploaded_video(video):
|
|
|
if video is not None:
|
|
|
video_path = video
|
|
|
result = subprocess.run(f"cp '{video_path}' /content/Vidu_Studio/videotovideo.mp4", shell=True)
|
|
|
print(f"Video guardado en /content/Vidu_Studio/videotovideo.mp4")
|
|
|
print(result.stdout)
|
|
|
|
|
|
|
|
|
video_input4.upload(
|
|
|
fn=save_uploaded_video,
|
|
|
inputs=video_input4,
|
|
|
outputs=None
|
|
|
)
|
|
|
|
|
|
|
|
|
create_button4.click(
|
|
|
fn=lambda desc, enhance, model, upscale: run_commands(desc, "16:9", enhance, model, "general", upscale, task_type="video_to_video"),
|
|
|
inputs=[description_input4, enhance_checkbox4, model_dropdown4, upscale_checkbox4],
|
|
|
outputs=[output_textbox4, video_output4]
|
|
|
)
|
|
|
|
|
|
|
|
|
extend_button4.click(
|
|
|
fn=lambda desc, enhance, model, upscale: run_commands(desc, "16:9", enhance, model, "general", upscale, task_type="extend", is_extend=True),
|
|
|
inputs=[description_input4, enhance_checkbox4, model_dropdown4, upscale_checkbox4],
|
|
|
outputs=[output_textbox4, video_output4]
|
|
|
)
|
|
|
|
|
|
|
|
|
recreate_button4.click(
|
|
|
fn=lambda desc, enhance, model, upscale: run_commands(desc, "16:9", enhance, model, "general", upscale, task_type="video_to_video", is_recreate=True),
|
|
|
inputs=[description_input4, enhance_checkbox4, model_dropdown4, upscale_checkbox4],
|
|
|
outputs=[output_textbox4, video_output4]
|
|
|
)
|
|
|
|
|
|
|
|
|
save_button4.click(
|
|
|
fn=run_save_commands,
|
|
|
inputs=[],
|
|
|
outputs=[output_textbox4, video_output4]
|
|
|
)
|
|
|
|
|
|
|
|
|
demo.launch(inline=False, debug=True, share=True) |