AItool commited on
Commit
a275306
·
verified ·
1 Parent(s): 0a43e1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -4,7 +4,7 @@ import uuid
4
  import subprocess
5
  from pathlib import Path
6
  from typing import Tuple
7
-
8
  import gradio as gr
9
 
10
  # Demo images
@@ -14,7 +14,7 @@ DEMO = Path("demo/demo.gif")
14
 
15
  TMP_PREFIX = "/tmp/gradio/"
16
  TARGET_DIR = f"{TMP_PREFIX}output/"
17
- EXTENSION = "gif"
18
 
19
  def interpolate_image(img_a_path: str, img_b_path: str) -> Tuple[str, str]:
20
  """
@@ -32,12 +32,15 @@ def interpolate_image(img_a_path: str, img_b_path: str) -> Tuple[str, str]:
32
  palette_path = f"{TMP_PREFIX}palette.png"
33
 
34
  try:
 
 
 
35
  # 1) Run interpolation (frames -> TARGET_DIR/img1.png ... imgN.png)
36
- subprocess.run([
37
- "python3", "inference_img.py",
38
- "--img", str(img_a_path), str(img_b_path),
39
- "--exp", "4"
40
- ], check=True)
41
 
42
  # 2) Generate palette
43
  subprocess.run([
@@ -48,12 +51,12 @@ def interpolate_image(img_a_path: str, img_b_path: str) -> Tuple[str, str]:
48
  ], check=True)
49
 
50
  # 3) Use palette to produce final GIF
 
51
  subprocess.run([
52
- "ffmpeg", "-y", "-r", "14", "-f", "image2",
53
  "-i", f"{TARGET_DIR}img%d.png",
54
- "-i", palette_path,
55
- "-lavfi", "paletteuse",
56
- interpolated_path
57
  ], check=True)
58
 
59
  return interpolated_image, interpolated_path
 
4
  import subprocess
5
  from pathlib import Path
6
  from typing import Tuple
7
+ from inference_img import run_imginference
8
  import gradio as gr
9
 
10
  # Demo images
 
14
 
15
  TMP_PREFIX = "/tmp/gradio/"
16
  TARGET_DIR = f"{TMP_PREFIX}output/"
17
+ EXTENSION = "png"
18
 
19
  def interpolate_image(img_a_path: str, img_b_path: str) -> Tuple[str, str]:
20
  """
 
32
  palette_path = f"{TMP_PREFIX}palette.png"
33
 
34
  try:
35
+
36
+ run_imginference(img_a_path, img_b_path, exp=4)
37
+
38
  # 1) Run interpolation (frames -> TARGET_DIR/img1.png ... imgN.png)
39
+ # # subprocess.run([
40
+ # # "python3", "inference_img.py",
41
+ # # "--img", str(img_a_path), str(img_b_path),
42
+ # "--exp", "4"
43
+ # ], check=True)
44
 
45
  # 2) Generate palette
46
  subprocess.run([
 
51
  ], check=True)
52
 
53
  # 3) Use palette to produce final GIF
54
+ #!ffmpeg -r 14 -f image2 -i output/img%d.png -vf "palettegen=stats_mode=single" palette.png
55
  subprocess.run([
56
+ "ffmpeg", "-y", "-r", "14", "-f",
57
  "-i", f"{TARGET_DIR}img%d.png",
58
+ str(palettegen=stats_mode=single)",
59
+ str(palette.png)
 
60
  ], check=True)
61
 
62
  return interpolated_image, interpolated_path