Handle avi & ogg output formats
Browse files
app.py
CHANGED
|
@@ -35,7 +35,7 @@ def animate(
|
|
| 35 |
seed: Optional[int] = 42,
|
| 36 |
randomize_seed: bool = True,
|
| 37 |
motion_bucket_id: int = 127,
|
| 38 |
-
fps_id: int =
|
| 39 |
noise_aug_strength: float = 0.1,
|
| 40 |
decoding_t: int = 3,
|
| 41 |
video_format: str = "mp4",
|
|
@@ -92,7 +92,22 @@ def animate(
|
|
| 92 |
((str(minutes) + " min, ") if hours != 0 or minutes != 0 else "") + \
|
| 93 |
str(secondes) + " sec."
|
| 94 |
|
| 95 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
@spaces.GPU(duration=120)
|
| 98 |
def animate_on_gpu(
|
|
@@ -165,7 +180,7 @@ def reset():
|
|
| 165 |
with gr.Blocks() as demo:
|
| 166 |
gr.HTML("""
|
| 167 |
<h1><center>Image-to-Video</center></h1>
|
| 168 |
-
<big><center>Animate your
|
| 169 |
<br/>
|
| 170 |
|
| 171 |
<p>
|
|
@@ -183,7 +198,7 @@ with gr.Blocks() as demo:
|
|
| 183 |
motion_bucket_id = gr.Slider(label="Motion bucket id", info="Controls how much motion to add/remove from the image", value=127, minimum=1, maximum=255)
|
| 184 |
noise_aug_strength = gr.Slider(label="Noise strength", info="The noise to add", value=0.1, minimum=0, maximum=1, step=0.1)
|
| 185 |
decoding_t = gr.Slider(label="Decoding", info="Number of frames decoded at a time; this eats more VRAM; reduce if necessary", value=3, minimum=1, maximum=5, step=1)
|
| 186 |
-
video_format = gr.Radio([["*.mp4", "mp4"], ["*.gif", "gif"]], label="Video format for result", info="File extention", value="mp4", interactive=True)
|
| 187 |
frame_format = gr.Radio([["*.webp", "webp"], ["*.png", "png"], ["*.jpeg", "jpeg"], ["*.gif (unanimated)", "gif"], ["*.bmp", "bmp"]], label="Image format for frames", info="File extention", value="webp", interactive=True)
|
| 188 |
version = gr.Radio([["Auto", "auto"], ["ππ»ββοΈ SVD (trained on 14 f/s)", "svd"], ["ππ»ββοΈπ¨ SVD-XT (trained on 25 f/s)", "svdxt"], ["DragNUWA", "dragnuwa"]], label="Model", info="Trained model", value="auto", interactive=True)
|
| 189 |
seed = gr.Slider(label="Seed", value=42, randomize=True, minimum=0, maximum=max_64_bit_int, step=1)
|
|
@@ -193,7 +208,7 @@ with gr.Blocks() as demo:
|
|
| 193 |
reset_btn = gr.Button(value="π§Ή Reinit page", variant="stop", elem_id="reset_button", visible = False)
|
| 194 |
|
| 195 |
with gr.Column():
|
| 196 |
-
video_output = gr.Video(label="Generated video", autoplay=True)
|
| 197 |
gif_output = gr.Image(label="Generated video", format="gif", visible=False)
|
| 198 |
download_button = gr.DownloadButton(label="πΎ Download video", visible=False)
|
| 199 |
information_msg = gr.HTML(visible=False)
|
|
|
|
| 35 |
seed: Optional[int] = 42,
|
| 36 |
randomize_seed: bool = True,
|
| 37 |
motion_bucket_id: int = 127,
|
| 38 |
+
fps_id: int = 25,
|
| 39 |
noise_aug_strength: float = 0.1,
|
| 40 |
decoding_t: int = 3,
|
| 41 |
video_format: str = "mp4",
|
|
|
|
| 92 |
((str(minutes) + " min, ") if hours != 0 or minutes != 0 else "") + \
|
| 93 |
str(secondes) + " sec."
|
| 94 |
|
| 95 |
+
return [
|
| 96 |
+
# Display for video
|
| 97 |
+
gr.update(value = video_path, format = video_format if video_format != "gif" else None, visible=video_format != "gif"),
|
| 98 |
+
# Display for gif
|
| 99 |
+
gr.update(value = gif_path, visible = video_format == "gif"),
|
| 100 |
+
# Download button
|
| 101 |
+
gr.update(label = "πΎ Download animation in *." + video_format + " format", value=result_path, visible=True),
|
| 102 |
+
# Frames
|
| 103 |
+
gr.update(label = "Generated frames in *." + frame_format + " format", format = frame_format, value = frames, visible = True),
|
| 104 |
+
# Used seed
|
| 105 |
+
seed,
|
| 106 |
+
# Information
|
| 107 |
+
gr.update(value = information, visible = True),
|
| 108 |
+
# Reset button
|
| 109 |
+
gr.update(visible = True)
|
| 110 |
+
]
|
| 111 |
|
| 112 |
@spaces.GPU(duration=120)
|
| 113 |
def animate_on_gpu(
|
|
|
|
| 180 |
with gr.Blocks() as demo:
|
| 181 |
gr.HTML("""
|
| 182 |
<h1><center>Image-to-Video</center></h1>
|
| 183 |
+
<big><center>Animate your image into 25 frames of 1024x576 pixels freely, without account, without watermark and download the video</center></big>
|
| 184 |
<br/>
|
| 185 |
|
| 186 |
<p>
|
|
|
|
| 198 |
motion_bucket_id = gr.Slider(label="Motion bucket id", info="Controls how much motion to add/remove from the image", value=127, minimum=1, maximum=255)
|
| 199 |
noise_aug_strength = gr.Slider(label="Noise strength", info="The noise to add", value=0.1, minimum=0, maximum=1, step=0.1)
|
| 200 |
decoding_t = gr.Slider(label="Decoding", info="Number of frames decoded at a time; this eats more VRAM; reduce if necessary", value=3, minimum=1, maximum=5, step=1)
|
| 201 |
+
video_format = gr.Radio([["*.mp4", "mp4"], ["*.avi", "avi"], ["*.ogg", "ogg"], ["*.gif", "gif"]], label="Video format for result", info="File extention", value="mp4", interactive=True)
|
| 202 |
frame_format = gr.Radio([["*.webp", "webp"], ["*.png", "png"], ["*.jpeg", "jpeg"], ["*.gif (unanimated)", "gif"], ["*.bmp", "bmp"]], label="Image format for frames", info="File extention", value="webp", interactive=True)
|
| 203 |
version = gr.Radio([["Auto", "auto"], ["ππ»ββοΈ SVD (trained on 14 f/s)", "svd"], ["ππ»ββοΈπ¨ SVD-XT (trained on 25 f/s)", "svdxt"], ["DragNUWA", "dragnuwa"]], label="Model", info="Trained model", value="auto", interactive=True)
|
| 204 |
seed = gr.Slider(label="Seed", value=42, randomize=True, minimum=0, maximum=max_64_bit_int, step=1)
|
|
|
|
| 208 |
reset_btn = gr.Button(value="π§Ή Reinit page", variant="stop", elem_id="reset_button", visible = False)
|
| 209 |
|
| 210 |
with gr.Column():
|
| 211 |
+
video_output = gr.Video(label="Generated video", format="mp4", autoplay=True)
|
| 212 |
gif_output = gr.Image(label="Generated video", format="gif", visible=False)
|
| 213 |
download_button = gr.DownloadButton(label="πΎ Download video", visible=False)
|
| 214 |
information_msg = gr.HTML(visible=False)
|