Spaces:
Running
Running
added stable video option
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ def get_instantID(portrait_in, condition_pose, prompt):
|
|
25 |
print(result)
|
26 |
return result[0]
|
27 |
|
28 |
-
def
|
29 |
client = Client("https://modelscope-i2vgen-xl.hf.space/")
|
30 |
result = client.predict(
|
31 |
image_in,
|
@@ -35,9 +35,27 @@ def get_video(image_in, prompt):
|
|
35 |
print(result)
|
36 |
return result
|
37 |
|
38 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
iid_img = get_instantID(image_in, conditional_pose, prompt)
|
40 |
-
|
|
|
|
|
|
|
41 |
print(video_res)
|
42 |
return video_res
|
43 |
|
@@ -47,6 +65,7 @@ gr.Interface(
|
|
47 |
gr.Image(type="filepath", label="Face to copy"),
|
48 |
gr.Image(type="filepath", label="Conditional pose (Optional)"),
|
49 |
gr.Textbox()
|
|
|
50 |
],
|
51 |
outputs = [
|
52 |
gr.Video()
|
|
|
25 |
print(result)
|
26 |
return result[0]
|
27 |
|
28 |
+
def get_video_i2vgen(image_in, prompt):
|
29 |
client = Client("https://modelscope-i2vgen-xl.hf.space/")
|
30 |
result = client.predict(
|
31 |
image_in,
|
|
|
35 |
print(result)
|
36 |
return result
|
37 |
|
38 |
+
def get_video_svd(image_in):
|
39 |
+
from gradio_client import Client
|
40 |
+
|
41 |
+
client = Client("https://multimodalart-stable-video-diffusion.hf.space/--replicas/ej45m/")
|
42 |
+
result = client.predict(
|
43 |
+
https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png, # filepath in 'Upload your image' Image component
|
44 |
+
0, # float (numeric value between 0 and 9223372036854775807) in 'Seed' Slider component
|
45 |
+
True, # bool in 'Randomize seed' Checkbox component
|
46 |
+
127, # float (numeric value between 1 and 255) in 'Motion bucket id' Slider component
|
47 |
+
6, # float (numeric value between 5 and 30) in 'Frames per second' Slider component
|
48 |
+
api_name="/video"
|
49 |
+
)
|
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 |
|
|
|
65 |
gr.Image(type="filepath", label="Face to copy"),
|
66 |
gr.Image(type="filepath", label="Conditional pose (Optional)"),
|
67 |
gr.Textbox()
|
68 |
+
gr.Radio(label="Choose a model", choices=["i2vgen-xl", "stable-video"], value="i2vgen-xl")
|
69 |
],
|
70 |
outputs = [
|
71 |
gr.Video()
|