File size: 831 Bytes
addf675
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import shutil
import glob
import os
import time

# Temporary Deforum frame output
temp_frames = "stable-diffusion-webui/deforum/output_temp/frames"
# Persistent folder in repo
persistent_frames = "stable-diffusion-webui/deforum/output_committed/frames"

# Ensure persistent folder exists
os.makedirs(persistent_frames, exist_ok=True)

print("🟒 Auto Frame Sync started...")

# Loop forever (or until the Space stops)
while True:
    # Copy any new frames
    for frame_file in glob.glob(os.path.join(temp_frames, "*.png")):
        dest_file = os.path.join(persistent_frames, os.path.basename(frame_file))
        if not os.path.exists(dest_file):
            shutil.copy(frame_file, dest_file)
            print(f"βœ… Copied {os.path.basename(frame_file)}")
    
    # Wait a few seconds before checking again
    time.sleep(5)