yfszzx / stable-diffusion-webui-inspiration

115 stars 23 forks source link

Code change suggestions to handle interrupted generations #10

Open kryztoval opened 2 years ago

kryztoval commented 2 years ago

Can we change this line https://github.com/yfszzx/stable-diffusion-webui-inspiration/blob/main/scripts/inspiration.py#L47 to

            while len(line) > 0 and shared.state.interrupted == False:

so if the generation is interrupted we do not continue reading from the file?

And this line https://github.com/yfszzx/stable-diffusion-webui-inspiration/blob/main/scripts/inspiration.py#L53 to

                if len(os.listdir(artist_path)) > (batch_count-1)*batch_size:

in such a way that if we generate a batch_size lot it will not go over the batch_size * batch_count. So if you want to make 2 batches of 5 you can. or 5 batches of 2. and finally 10 batches of 1 and you will be sure that the ending folders will have 10 files each at least.

I would love this line https://github.com/yfszzx/stable-diffusion-webui-inspiration/blob/main/scripts/inspiration.py#L58 to be nested inside a if shared.state.interrupted == False: so if I cancel a batch the partially generated images are not written and I do not have to go clean up the folder the execution was stopped at.

I am loving the generation script, have not tried the browser yet.