remade-effects / app.py
multimodalart's picture
Create app.py
2d37733 verified
raw
history blame
2.02 kB
import gradio as gr
import os
loras = [
{
"image": "https://huggingface.co/Remade-AI/Squish/resolve/main/example_videos/tank_squish.mp4",
"id": "squish",
"title": "Squish"
},
{
"image": "https://huggingface.co/Remade-AI/Rotate/resolve/main/example_videos/man_rotate.mp4",
"id": "rotate",
"title": "Rotate"
},
]
### Inside this function you can add a call to your backend passing the arguments, then you can return the path to a downloaded video
### To not have the code/API public, you can go on "Settings" and add a Secret. The secrets appear here as environemnt variables, e.g.
### os.getenv('BACKEND_URL')
### os.getenv('API_KEY')
def generate_video(input_image, prompt, duration, selected_index):
pass
def update_selection(evt: gr.SelectData):
selected_lora = loras[evt.index]
sentence = f"Selected LoRA: {selected_lora['title']}"
return selected_lora['id'], sentence
with gr.Blocks() as demo:
selected_index = gr.State(None)
gr.Markdown("# Remade AI - Wan 2.1 I2V effects LoRAs ")
selected_info = gr.HTML("")
with gr.Row():
with gr.Column():
gallery = gr.Gallery(
[(item["image"], item["title"]) for item in loras],
label="Select LoRA",
allow_preview=False,
columns=4,
elem_id="gallery",
show_share_button=False,
height=350
)
input_image = gr.Image()
prompt = gr.Textbox(label="Describe your object", placeholder="Cat toy")
duration = gr.Radio(["Short (3s)", "Long (5s)"], label="Duration")
button = gr.Button("Generate")
with gr.Column():
output = gr.Video(interactive=False, label="Output video")
gallery.select(
update_selection,
outputs=[selected_index, selected_info]
)
button.click(
generate_video,
inputs=[input_image, prompt, duration, selected_index],
outputs=[output]
)
if __name__ == "__main__":
demo.launch()