Replies: 8 comments 6 replies
-
So I have a similar use case, so I created a script that 'overrides' various settings in IMG2IMG with ones read from the PNG info for the file. Basically it batch-does the "send to img2img" in the "Png info" tab but you can choose which settings you want from the UI and which ones from the file. Just put this in a file in your scripts folder and choose "Override from file PNGInfo" script and check the checkboxes you want. I only spent about 30 seconds trying it, but its pretty simple. However, it won't work with SD upscaling because they're both a dropdown script and I don't know what I'm doing enough to change that. import modules.scripts as scripts
import gradio as gr
import os
from modules import images
from modules import processing
from modules.processing import process_images, Processed
from modules.processing import Processed
from modules.shared import opts, cmd_opts, state
from modules.generation_parameters_copypaste import parse_generation_parameters
from modules.extras import run_pnginfo
class Script(scripts.Script):
# The title of the script. This is what will be displayed in the dropdown menu.
def title(self):
return "Override from file PNGInfo"
# Determines when the script should be shown in the dropdown menu via the
# returned value. As an example:
# is_img2img is True if the current tab is img2img, and False if it is txt2img.
# Thus, return is_img2img to only show the script on the img2img tab.
def show(self, is_img2img):
return is_img2img
# How the script's is displayed in the UI. See https://gradio.app/docs/#components
# for the different UI components you can use and how to create them.
# Most UI components can return a value, such as a boolean for a checkbox.
# The returned values are passed to the run method as parameters.
def ui(self, is_img2img):
wantPrompt = gr.Checkbox(False, label="Override Prompt")
wantNegative= gr.Checkbox(False, label="Override Negative Prompt")
wantSeed = gr.Checkbox(False, label="Override Seed")
wantSteps = gr.Checkbox(False, label="Override Steps")
wantCFGScale = gr.Checkbox(False, label="Override CFG scale")
wantSize = gr.Checkbox(False, label="Override Width and Height")
wantdenoise = gr.Checkbox(False, label="Override Denoising strength")
return [wantPrompt, wantNegative, wantSeed,wantSteps,wantCFGScale,wantSize,wantdenoise]
# This is where the additional processing is implemented. The parameters include
# self, the model object "p" (a StableDiffusionProcessing class, see
# processing.py), and the parameters returned by the ui method.
# Custom functions can be defined here, and additional libraries can be imported
# to be used in processing. The return value should be a Processed object, which is
# what is returned by the process_images method.
def run(self, p, wantPrompt, wantNegative, wantSeed,wantSteps,wantCFGScale,wantSize,wantdenoise):
#proc = process_images(p)
mytext = run_pnginfo(p.init_images[0])[1]
deets = parse_generation_parameters(mytext)
if wantPrompt and 'Prompt' in deets:
p.prompt = deets['Prompt']
if wantNegative and 'Negative prompt' in deets:
p.negative_prompt = deets['Negative prompt']
if wantSeed and 'Seed' in deets:
p.seed = float(deets['Seed'])
if wantSteps and 'Steps' in deets:
p.steps = int(deets['Steps'])
if wantCFGScale and 'Seed' in deets:
p.cfg_scale = int(deets['CFG scale'])
if wantSize and 'Size-1' in deets:
p.width = int(deets['Size-1'])
if wantSize and 'Size-2' in deets:
p.height = int(deets['Size-2'])
if wantdenoise and 'Denoising strength' in deets:
p.denoising_strength = float(deets['Denoising strength'])
processing.fix_seed(p)
return process_images(p) |
Beta Was this translation helpful? Give feedback.
-
In the meantime, is there already a customized code that works with SD upscaling? I think many would be interested in achieving good upscaling results even with bulk processing. Actually one should only merge the script with the SD upscaler script, right? Then the features of both scripts would run under one dropdown script area. The merge should be easy for a programmer. The code seems to be simple. However, I have no idea about programming. Anyone else? |
Beta Was this translation helpful? Give feedback.
-
I cant get the API's upscaling to work at all |
Beta Was this translation helpful? Give feedback.
-
I have modified @kevmatic's code to implement the options to add or remove tags for each image. I hope this will be useful.
|
Beta Was this translation helpful? Give feedback.
-
Is there a possibility to add the prompt to the console output? I'd like to know which image is being processed, so I can track any bad source images or prompts. Asking because I can't tell what order the images are being processed. |
Beta Was this translation helpful? Give feedback.
-
Made this Google Colab Notebook that can generate bulk images by just providing a list of prompts in a go! Colab Link - http://bit.ly/40BM7v4 You can Upscale an entire batch of images and download them as a ZIP |
Beta Was this translation helpful? Give feedback.
-
error |
Beta Was this translation helpful? Give feedback.
-
this thing doesnt work, even if I copy this py script to the script directory it is not available in the drop down even restarting UI |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've generated 2 samples for 300 different artists.
Now i wish to upscale in batch (600 images)
How can I make each sample refer to its specific prompt?
I cannot change it every 2 images for 300 times!
Thank you
Beta Was this translation helpful? Give feedback.
All reactions