Closed tokenwizard closed 6 months ago
Actually I think I found the fix!
In the custom_nodes/ComfyUI-N-Nodes/py
folder, edit the utility node.py
file.
In lines 48 and 93, replace each instance of os.listdir(folder)
with sorted(os.listdir(folder))
Now when you run this script, the Load Images from Folder node should load the images in that folder sequentially.
Describe the bug I am trying to use this node to facilitate video faceswaps for longer videos (I have scripts with ffmpeg to extract frames and break them into 500 frame chunks to alleviate crashing ComfyUI)
I pass the folder containing 500 frames to the Input Image from Folder node and then output the images to Reactor, which then outputs to a Save Image (without preview) node. But the swapped frames it outputs are not in the same sequence as they exist in the source folder.
Is there a way to ensure the Load Image from Folder Node loads each image in sequence? It seems to be pulling images in random order.
To Reproduce Steps to reproduce the behavior: You can recreate this issue manually by setting your ComfyUI Workspace like this:
I will attach the source image I am testing for the face swap as well as the source frames.
Expected behavior Each image form the Source Folder will be loading in sequence, have the face swapped, and then output the swapped frame. (ie. source_frame_000001.png -> face_swapped -> swapped_frames/frame_000001.png. The swapped frame should be identical to the source frame with the exception of the face)
Full log FULL LOG is attached as a plain text file because it is quite long. For this example, there are 75+ frames and there are multiple lines of console output per frame.
output.log
Screenshots The Output folder (swapped_frames in this case) contains the same number of frames as the source folder. But if you look at each frame side-by-side, you will see they do not match up. Frame 00005 in the source folder is not the same image as Frame 00005 in the swapped-frames folder. This makes it impossible to build a cohesive video from the swapped_frames folder.
Source Folder, frame_000005.png:
Swapped Folder, frame_000005.png:
Desktop (please complete the following information):
Additional context Source Face Image:
Source Frames for testing: source-frames.zip
FYI, I have removed the Reactor node and simply just gone from the Load Images from Folder directly into the Save Image node, and the output frames are still mismatched/out of sequence.