Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ FRAME1 = Path("demo/frame1.png")
|
|
| 9 |
FRAME2 = Path("demo/frame2.png")
|
| 10 |
|
| 11 |
TARGET_DIR = "/home/user/app/output/" # absolute path that inference writes to
|
| 12 |
-
PALETTE_PNG = Path("/home/user/app/palette.png")
|
| 13 |
OUTPUT_GIF= Path("/home/user/app/output/output.gif")
|
| 14 |
OUTPUT_GIF_DIR= Path("/home/user/app/output")
|
| 15 |
|
|
@@ -29,14 +29,15 @@ def interpolate_image(img_a_path: str, img_b_path: str) -> tuple[str, str]:
|
|
| 29 |
"ffmpeg", "-y", "-r", "14", "-f", "image2",
|
| 30 |
"-i", f"{TARGET_DIR}img%d.png",
|
| 31 |
"-vf", "palettegen=stats_mode=single",
|
| 32 |
-
|
|
|
|
| 33 |
], check=True)
|
| 34 |
|
| 35 |
# 3) Generate final GIF using palette
|
| 36 |
subprocess.run([
|
| 37 |
"ffmpeg", "-y", "-r", "14", "-f", "image2",
|
| 38 |
"-i", f"{TARGET_DIR}img%d.png",
|
| 39 |
-
"-i",
|
| 40 |
"-lavfi", "paletteuse",
|
| 41 |
OUTPUT_GIF
|
| 42 |
], check=True)
|
|
|
|
| 9 |
FRAME2 = Path("demo/frame2.png")
|
| 10 |
|
| 11 |
TARGET_DIR = "/home/user/app/output/" # absolute path that inference writes to
|
| 12 |
+
PALETTE_PNG = Path("/home/user/app/output/palette.png")
|
| 13 |
OUTPUT_GIF= Path("/home/user/app/output/output.gif")
|
| 14 |
OUTPUT_GIF_DIR= Path("/home/user/app/output")
|
| 15 |
|
|
|
|
| 29 |
"ffmpeg", "-y", "-r", "14", "-f", "image2",
|
| 30 |
"-i", f"{TARGET_DIR}img%d.png",
|
| 31 |
"-vf", "palettegen=stats_mode=single",
|
| 32 |
+
"-frames:v", "1", # <- critical: write exactly one image
|
| 33 |
+
"/home/user/app/output/palette.png"
|
| 34 |
], check=True)
|
| 35 |
|
| 36 |
# 3) Generate final GIF using palette
|
| 37 |
subprocess.run([
|
| 38 |
"ffmpeg", "-y", "-r", "14", "-f", "image2",
|
| 39 |
"-i", f"{TARGET_DIR}img%d.png",
|
| 40 |
+
"-i", "/home/user/app/output/palette.png",
|
| 41 |
"-lavfi", "paletteuse",
|
| 42 |
OUTPUT_GIF
|
| 43 |
], check=True)
|