File size: 2,020 Bytes
2d37733
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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()