AItool commited on
Commit
db549bc
·
verified ·
1 Parent(s): b0f6301

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -9,9 +9,10 @@ import io
9
 
10
  FRAME1_PATH = "demo/frame1.png"
11
  FRAME2_PATH = "demo/frame2.png"
12
- TARGET_DIR = "/home/user/app/output/"
13
- OUTPUT_GIF = "output.gif"
14
- PALETTE_PNG = "palette.png"
 
15
 
16
 
17
  def generate_demo_gif(exp=2, progress=gr.Progress(track_tqdm=True)):
@@ -38,7 +39,7 @@ def generate_demo_gif(exp=2, progress=gr.Progress(track_tqdm=True)):
38
  print("Exists?", os.path.exists("output/img0.png")) # ⬅️ Add it here
39
 
40
 
41
- # Step 2: Generate palette
42
  subprocess.run([
43
  "ffmpeg", "-y", "-r", "14", "-f", "image2",
44
  "-i", f"{TARGET_DIR}img%d.png",
@@ -55,14 +56,13 @@ subprocess.run([
55
  OUTPUT_GIF
56
  ], check=True)
57
 
58
- # Step 3: Check and display result
59
- if os.path.exists(TARGET_DIR/OUTPUT_GIF):
60
- with open(TARGET_DIR/OUTPUT_GIF, "rb") as f:
61
- gif = Image.open(io.BytesIO(f.read()))
62
- print(" GIF created!")
63
- # You can return or display the gif here
64
- else:
65
- print("❌ Inference failed or output missing")
66
 
67
  # UI setup
68
  with gr.Blocks() as demo_ui:
 
9
 
10
  FRAME1_PATH = "demo/frame1.png"
11
  FRAME2_PATH = "demo/frame2.png"
12
+ TARGET_DIR = "output/"
13
+ #TARGET_DIR = "/home/user/app/output/"
14
+ OUTPUT_GIF = "output/output.gif"
15
+ PALETTE_FULL_PATH = "/demo/palette.png"
16
 
17
 
18
  def generate_demo_gif(exp=2, progress=gr.Progress(track_tqdm=True)):
 
39
  print("Exists?", os.path.exists("output/img0.png")) # ⬅️ Add it here
40
 
41
 
42
+ # Generate palette
43
  subprocess.run([
44
  "ffmpeg", "-y", "-r", "14", "-f", "image2",
45
  "-i", f"{TARGET_DIR}img%d.png",
 
56
  OUTPUT_GIF
57
  ], check=True)
58
 
59
+ subprocess.run([
60
+ "ffmpeg", "-y", "-r", "14", "-f", "image2",
61
+ "-i", f"{TARGET_DIR}img%d.png",
62
+ "-i", PALETTE_PNG,
63
+ "-lavfi", "paletteuse",
64
+ OUTPUT_GIF
65
+ ], check=True)
 
66
 
67
  # UI setup
68
  with gr.Blocks() as demo_ui: