Skip to content

Instantly share code, notes, and snippets.

@camenduru
Last active April 2, 2024 13:04
Show Gist options
  • Save camenduru/9ec5f8141db9902e375967e93250860f to your computer and use it in GitHub Desktop.
Save camenduru/9ec5f8141db9902e375967e93250860f to your computer and use it in GitHub Desktop.
import math
import os
import sys
import traceback
import modules.scripts as scripts
import gradio as gr
from modules.processing import Processed, process_images
class Script(scripts.Script):
def title(self):
return "Run n times"
def ui(self, is_img2img):
n = gr.Textbox(label="n")
return [n]
def run(self, p, n):
for x in range(int(n)):
p.seed = -1
proc = process_images(p)
image = proc.images
return Processed(p, image, p.seed, proc.info)
@Neytiri7
Copy link

What should I put in the "n" item? I entered "5" to make it 5 times, but the seed value continues to increase by +1.

@aarmstrongc
Copy link

It works fine! Thanks!
The scrip ignores the manual output directory, and uses the default output folder of the SD webui dou

@Trader5050
Copy link

A bug is created when using the saved styles dropdown with this script. Each iteration includes another copy of the style, meaning that it gets copied over and over into the prompt, generating very weird results.

@Woisek
Copy link

Woisek commented Mar 3, 2024

Since yesterday, I have found that using the script for batch generation and using ReActor, it no longer works for the batch. ReActor swaps the first image, but after that, it says "source not found".
23:22:34 - ReActor - ERROR - Cannot detect any Source
23:22:34 - ReActor - ERROR - Please provide a source face

Any idea what this could be?
A1111 1.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment