multimodalart HF staff commited on
Commit
9093067
·
verified ·
1 Parent(s): 2d37733

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -14
app.py CHANGED
@@ -1,5 +1,7 @@
1
- import gradio as gr
2
  import os
 
 
 
3
 
4
  loras = [
5
  {
@@ -19,8 +21,16 @@ loras = [
19
  ### 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.
20
  ### os.getenv('BACKEND_URL')
21
  ### os.getenv('API_KEY')
22
- def generate_video(input_image, prompt, duration, selected_index):
23
- pass
 
 
 
 
 
 
 
 
24
 
25
  def update_selection(evt: gr.SelectData):
26
  selected_lora = loras[evt.index]
@@ -34,19 +44,19 @@ with gr.Blocks() as demo:
34
  with gr.Row():
35
  with gr.Column():
36
  gallery = gr.Gallery(
37
- [(item["image"], item["title"]) for item in loras],
38
- label="Select LoRA",
39
- allow_preview=False,
40
- columns=4,
41
- elem_id="gallery",
42
- show_share_button=False,
43
- height=350
44
  )
45
- input_image = gr.Image()
46
- prompt = gr.Textbox(label="Describe your object", placeholder="Cat toy")
47
  duration = gr.Radio(["Short (3s)", "Long (5s)"], label="Duration")
48
-
49
  button = gr.Button("Generate")
 
50
  with gr.Column():
51
  output = gr.Video(interactive=False, label="Output video")
52
 
@@ -56,7 +66,7 @@ with gr.Blocks() as demo:
56
  )
57
  button.click(
58
  generate_video,
59
- inputs=[input_image, prompt, duration, selected_index],
60
  outputs=[output]
61
  )
62
 
 
 
1
  import os
2
+ import requests
3
+ import gradio as gr
4
+
5
 
6
  loras = [
7
  {
 
21
  ### 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.
22
  ### os.getenv('BACKEND_URL')
23
  ### os.getenv('API_KEY')
24
+ def generate_video(input_image, subject, duration, selected_index):
25
+ if selected_index == "squish":
26
+ #I suggest not exposing this to the user for simplicity
27
+ prompt = f"In the video, a miniature {subject} is presented. The {subject} is held in a person's hands. The person then presses on the {subject}, causing a sq41sh squish effect. The person keeps pressing down on the {subject}, further showing the sq41sh squish effect."
28
+
29
+ #do all the things to submit the request
30
+ #url and heads can come from the env variable
31
+ response = requests.post(url, data=data, files=files, headers=headers)
32
+
33
+ pass
34
 
35
  def update_selection(evt: gr.SelectData):
36
  selected_lora = loras[evt.index]
 
44
  with gr.Row():
45
  with gr.Column():
46
  gallery = gr.Gallery(
47
+ [(item["image"], item["title"]) for item in loras],
48
+ label="Select LoRA",
49
+ allow_preview=False,
50
+ columns=4,
51
+ elem_id="gallery",
52
+ show_share_button=False,
53
+ height=350
54
  )
55
+ input_image = gr.Image(type="filepath")
56
+ subject = gr.Textbox(label="Describe your subject", placeholder="Cat toy")
57
  duration = gr.Radio(["Short (3s)", "Long (5s)"], label="Duration")
 
58
  button = gr.Button("Generate")
59
+
60
  with gr.Column():
61
  output = gr.Video(interactive=False, label="Output video")
62
 
 
66
  )
67
  button.click(
68
  generate_video,
69
+ inputs=[input_image, subject, duration, selected_index],
70
  outputs=[output]
71
  )
72