Batch from Directory is not batching chronologically.
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior: Extras tab > Batch from Directory > Input directory. Set to a directory with an image animation in chronological order. Use any upscalers. Generate When all images have been upscaled, compare images and names from both directories.
Expected behavior When using batch from directory, images should be batched in order and renamed in order.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Tested on Windows and Linux
- Browser: Brave and Firefox
- Commit revision: 43cb1ddad2af31170352394b81b9a299b151ea05
Additional context Add any other context about the problem here.
I think the order is alphabetical, and I think it is strictly alphabetical in that (as in 1, 10, 11, 12, 13, 14, 2, 3, 4, 5, 6, 7 etc.)
Have you checked that?
I'm not sure why you're asking me to check? I have no control over the naming convention of the animation output, so even if it was alphabetical, there's no way for me to adjust. Every notebook out there exports chronologically numerically.
There is an option to keep original filenames during batch process in setting page. 'Use original name for output filename during batch process in extras tab'
I ask you to check because you are the one experiencing the issue, not me. I generate files that are normally a full name and end in a "000001" style with zero padding, and the process batch from directory takes the files in alphabetical order. This is why I save the files in strict alphabetical order with zero padding.
And I was not talking about the name generated at the output, I was talking about the input filenames in the folder.
However, I did review the source code and the returned list of files is not sorted, this means the input files in the directory will be processed however the filesystem will return such list and I am going to assume you do not use ExFAT which would keep a somewhat sorted list based on creation order.
if this line was changed https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/7f8ab1ee8f304031b3404e25761dd0f4c7be7df8/modules/extras.py#L42
to image_list = [file for file in [os.path.join(input_dir, x) for x in sorted(os.listdir(input_dir))] if os.path.isfile(file)] that should force alphabetical ordering from the listdir call.
I can confirm this is a bug.
Oh sweet, thanks! I'll test that out tonight.
to
image_list = [file for file in [os.path.join(input_dir, x) for x in sorted(os.listdir(input_dir))] if os.path.isfile(file)]that should force alphabetical ordering from the listdir call.
thanks @kryztoval , i added it to pull request
@winterspringsummer Thank you! :)