EcoVidGenerator / app.py
doanxem99's picture
Upload app.py
174bec6 verified
Raw
History Blame Contribute Delete
1.62 kB
import os
os.system("git clone https://github.com/Begineer17/Short-Video-Generator.git")
os.chdir("Short-Video-Generator")
os.system("pip install -r requirements.txt")
os.system("pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118")
import gradio as gr
import torch
import subprocess
from main import create_original
device = "cuda" if torch.cuda.is_available() else "cpu"
secret_api = os.getenv("YOUR_GEMINI_API")
def infer():
title = None
create_original(api_key=secret_api, des=title)
file_path = f"result/output.mp4"
return file_path
def change_track():
subprocess.call("call change_track.bat")
file_path = f"result/output_changed.mp4"
return file_path
if torch.cuda.is_available():
power_device = "GPU"
else:
power_device = "CPU"
with gr.Blocks() as demo:
with gr.Column(elem_id="col-container"):
gr.Markdown(f"""
# Short Video Generator
-- Click run to generate video --
Currently running on {power_device}.
""")
with gr.Row():
run_button = gr.Button("Run", scale=0)
change_track_button = gr.Button("Change Track", scale=0)
# title = gr.Textbox()
result = gr.Video()
result_changed = gr.Video()
run_button.click(
fn = infer,
inputs = [],
outputs = [result]
)
change_track_button.click(
fn = change_track,
inputs = [],
outputs = [result_changed]
)
if __name__ == "__main__":
demo.launch()