fffiloni commited on
Commit
2c66889
·
verified ·
1 Parent(s): 8e24008

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -13
app.py CHANGED
@@ -50,24 +50,72 @@ def get_video_svd(image_in):
50
  print(result)
51
  return result[0]["video"]
52
 
53
- def infer(image_in, conditional_pose, prompt, chosen_model):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  iid_img = get_instantID(image_in, conditional_pose, prompt)
 
55
  if chosen_model == "i2vgen-xl" :
56
  video_res = get_video_i2vgen(iid_img, prompt)
57
  elif chosen_model == "stable-video" :
58
  video_res = get_video_svd(image_in)
 
59
  print(video_res)
 
60
  return video_res
61
 
62
- gr.Interface(
63
- fn = infer,
64
- inputs = [
65
- gr.Image(type="filepath", label="Face to copy"),
66
- gr.Image(type="filepath", label="Conditional pose (Optional)"),
67
- gr.Textbox(label="Prompt"),
68
- gr.Radio(label="Choose a model", choices=["i2vgen-xl", "stable-video"], value="i2vgen-xl", interactive=False, visible=False)
69
- ],
70
- outputs = [
71
- gr.Video()
72
- ]
73
- ).launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  print(result)
51
  return result[0]["video"]
52
 
53
+ def infer(image_in, camera_shot, conditional_pose, prompt, chosen_model):
54
+ if camera_shot == "custom":
55
+ if conditional_pose != None:
56
+ conditional_pose = conditional_pose
57
+ else :
58
+ raise gr.Error("No custom conditional shot found !")
59
+ else :
60
+ if camera_shot == "close-up" :
61
+ #
62
+ elif camera_shot == "medium close-up":
63
+ #
64
+ elif camera_shot == "medium shot":
65
+ #
66
+ elif camera_shot == "cowboy shot":
67
+ #
68
+ elif camera_shot == "medium full shot":
69
+ #
70
+ elif camera_shot == "full shot":
71
+ #
72
+
73
  iid_img = get_instantID(image_in, conditional_pose, prompt)
74
+
75
  if chosen_model == "i2vgen-xl" :
76
  video_res = get_video_i2vgen(iid_img, prompt)
77
  elif chosen_model == "stable-video" :
78
  video_res = get_video_svd(image_in)
79
+
80
  print(video_res)
81
+
82
  return video_res
83
 
84
+ with gr.Blocks as demo:
85
+ with gr.Column():
86
+ gr.HTML("""
87
+
88
+ """)
89
+ with gr.Row():
90
+ with gr.Column():
91
+ face_in = gr.Image(type="filepath", label="Face to copy")
92
+ camera_shot = gr.Dropdown(
93
+ label = "Camera Shot",
94
+ info = "Use standard camera shots vocabulary, or drop your custom shot as conditional pose (1280*720 ratio is recommended)"
95
+ choices = [
96
+ "custom", "close-up", "medium close-up", "medium shot", "cowboy shot", "medium full shot", "full shot"
97
+ ],
98
+ value = "custom"
99
+ )
100
+ condition_shot = gr.Image(type="filepath", label="Custom conditional shot (Optional)")
101
+ prompt = gr.Textbox(label="Prompt")
102
+ chosen_model = gr.Radio(label="Choose a model", choices=["i2vgen-xl", "stable-video"], value="i2vgen-xl", interactive=False, visible=False)
103
+ submit_btn = gr.Button("Submit")
104
+ with gr.Column():
105
+ video_out = gr.Video()
106
+
107
+ submit_btn.click(
108
+ fn = infer,
109
+ inputs = [
110
+ face_in,
111
+ camera_shot,
112
+ condition_shot,
113
+ prompt,
114
+ chosen_model
115
+ ],
116
+ outputs = [
117
+ video_out
118
+ ]
119
+ )
120
+
121
+ demo.queue(max_size=6).launch(debug=True)