Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -96,15 +96,19 @@ def resize_image_to_bucket(image: Union[Image.Image, np.ndarray], bucket_reso: T
|
|
96 |
return image
|
97 |
|
98 |
|
99 |
-
|
|
|
100 |
# Debugging print statements
|
101 |
print(f"Frame 1 Type: {type(frame1)}")
|
102 |
print(f"Frame 2 Type: {type(frame2)}")
|
|
|
|
|
|
|
|
|
103 |
|
104 |
# Load and preprocess frames
|
105 |
cond_frame1 = np.array(frame1)
|
106 |
cond_frame2 = np.array(frame2)
|
107 |
-
height, width = 720, 1280
|
108 |
cond_frame1 = resize_image_to_bucket(cond_frame1, bucket_reso=(width, height))
|
109 |
cond_frame2 = resize_image_to_bucket(cond_frame2, bucket_reso=(width, height))
|
110 |
cond_video = np.zeros(shape=(num_frames, height, width, 3))
|
@@ -136,7 +140,6 @@ def generate_video(prompt: str, frame1: Image.Image, frame2: Image.Image, guidan
|
|
136 |
with open(video_path, "rb") as video_file:
|
137 |
video_bytes = video_file.read()
|
138 |
return video_bytes
|
139 |
-
|
140 |
@torch.inference_mode()
|
141 |
def call_pipe(
|
142 |
pipe,
|
@@ -301,11 +304,16 @@ def main():
|
|
301 |
gr.Textbox(label="Prompt", value="a woman"),
|
302 |
gr.Image(label="Frame 1", type="pil"),
|
303 |
gr.Image(label="Frame 2", type="pil"),
|
|
|
|
|
|
|
|
|
|
|
304 |
# gr.Textbox(label="Frame 1 URL", value="https://i-bacon.bunkr.ru/11b45aa7-630b-4189-996f-a6b37a697786.png"),
|
305 |
# gr.Textbox(label="Frame 2 URL", value="https://i-bacon.bunkr.ru/2382224f-120e-482d-a75d-f1a1bf13038c.png"),
|
306 |
gr.Slider(minimum=0.1, maximum=20, step=0.1, label="Guidance Scale", value=6.0),
|
307 |
-
gr.Slider(minimum=1, maximum=129, step=1, label="Number of Frames", value=
|
308 |
-
gr.Slider(minimum=1, maximum=100, step=1, label="Number of Inference Steps", value=
|
309 |
]
|
310 |
|
311 |
# Define the interface outputs
|
|
|
96 |
return image
|
97 |
|
98 |
|
99 |
+
|
100 |
+
def generate_video(prompt: str, frame1: Image.Image, frame2: Image.Image, resolution: str, guidance_scale: float, num_frames: int, num_inference_steps: int) -> bytes:
|
101 |
# Debugging print statements
|
102 |
print(f"Frame 1 Type: {type(frame1)}")
|
103 |
print(f"Frame 2 Type: {type(frame2)}")
|
104 |
+
print(f"Resolution: {resolution}")
|
105 |
+
|
106 |
+
# Parse resolution
|
107 |
+
width, height = map(int, resolution.split('x'))
|
108 |
|
109 |
# Load and preprocess frames
|
110 |
cond_frame1 = np.array(frame1)
|
111 |
cond_frame2 = np.array(frame2)
|
|
|
112 |
cond_frame1 = resize_image_to_bucket(cond_frame1, bucket_reso=(width, height))
|
113 |
cond_frame2 = resize_image_to_bucket(cond_frame2, bucket_reso=(width, height))
|
114 |
cond_video = np.zeros(shape=(num_frames, height, width, 3))
|
|
|
140 |
with open(video_path, "rb") as video_file:
|
141 |
video_bytes = video_file.read()
|
142 |
return video_bytes
|
|
|
143 |
@torch.inference_mode()
|
144 |
def call_pipe(
|
145 |
pipe,
|
|
|
304 |
gr.Textbox(label="Prompt", value="a woman"),
|
305 |
gr.Image(label="Frame 1", type="pil"),
|
306 |
gr.Image(label="Frame 2", type="pil"),
|
307 |
+
gr.Dropdown(
|
308 |
+
label="Resolution",
|
309 |
+
choices=["720x1280", "544x960", "1280x720", "960x544", "720x720"],
|
310 |
+
value="544x960"
|
311 |
+
),
|
312 |
# gr.Textbox(label="Frame 1 URL", value="https://i-bacon.bunkr.ru/11b45aa7-630b-4189-996f-a6b37a697786.png"),
|
313 |
# gr.Textbox(label="Frame 2 URL", value="https://i-bacon.bunkr.ru/2382224f-120e-482d-a75d-f1a1bf13038c.png"),
|
314 |
gr.Slider(minimum=0.1, maximum=20, step=0.1, label="Guidance Scale", value=6.0),
|
315 |
+
gr.Slider(minimum=1, maximum=129, step=1, label="Number of Frames", value=49),
|
316 |
+
gr.Slider(minimum=1, maximum=100, step=1, label="Number of Inference Steps", value=30)
|
317 |
]
|
318 |
|
319 |
# Define the interface outputs
|