stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

Batch from Directory is not batching chronologically.

Open KewkLW opened this issue 3 years ago • 7 comments

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.

KewkLW avatar Oct 18 '22 12:10 KewkLW

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?

kryztoval avatar Oct 19 '22 00:10 kryztoval

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.

KewkLW avatar Oct 20 '22 03:10 KewkLW

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'

winterspringsummer avatar Oct 20 '22 08:10 winterspringsummer

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.

kryztoval avatar Oct 20 '22 13:10 kryztoval

Oh sweet, thanks! I'll test that out tonight.

KewkLW avatar Oct 20 '22 23:10 KewkLW

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 avatar Oct 21 '22 00:10 winterspringsummer

@winterspringsummer Thank you! :)

kryztoval avatar Oct 21 '22 01:10 kryztoval