CARVIEW |
Select Language
HTTP/2 200
date: Fri, 18 Jul 2025 14:01:54 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"cf35aa89812ab50fcc10796427766efc"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=Uvawm31RLyYj2752QRX31YWsJCJfrTQt6Oc2ovilXWwMHkr5qI%2Bq4Mit99w8pbhdVgxSXUG1TiCBSAGRKwBDWfA7LmGWopOkaSxgo8FFKCIfDKweBiVMkhardezpjh5vlqqe1VuAKfokfieKNe8lj52l%2FnWPNdsYOf7b1FWTYdRfJGrJsVhrScb%2BgXj%2BY%2FmxmIe6TKrnQVDjiqrOanu59woUZVNsSiUS%2FMLEp%2FFNRizr4X9S%2Bb%2Fmj4hGoRayMNyyy8WowNcV5sZv9F81msAc1A%3D%3D--29aPLWY%2Fi9EiIpNi--YwhcemKEOuN%2BanLBHJ8D8Q%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.225077878.1752847314; Path=/; Domain=github.com; Expires=Sat, 18 Jul 2026 14:01:54 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sat, 18 Jul 2026 14:01:54 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: D24A:27D643:FE2279:12E8780:687A53D2
Developing custom scripts · AUTOMATIC1111/stable-diffusion-webui Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Developing custom scripts
AUTOMATIC1111 edited this page Sep 30, 2022
·
1 revision
The Script class definition can be found in modules/scripts.py
. To create your own custom script, create a python script that implements the class and drop it into the scripts
folder, using the below example or other scripts already in the folder as a guide.
The Script class has four primary methods, described in further detail below with a simple example script that rotates and/or flips generated images.
import modules.scripts as scripts
import gradio as gr
import os
from modules import images
from modules.processing import process_images, Processed
from modules.processing import Processed
from modules.shared import opts, cmd_opts, state
class Script(scripts.Script):
# The title of the script. This is what will be displayed in the dropdown menu.
def title(self):
return "Flip/Rotate Output"
# 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):
angle = gr.Slider(minimum=0.0, maximum=360.0, step=1, value=0,
label="Angle")
hflip = gr.Checkbox(False, label="Horizontal flip")
vflip = gr.Checkbox(False, label="Vertical flip")
overwrite = gr.Checkbox(False, label="Overwrite existing files")
return [angle, hflip, vflip, overwrite]
# 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, angle, hflip, vflip, overwrite):
# function which takes an image from the Processed object,
# and the angle and two booleans indicating horizontal and
# vertical flips from the UI, then returns the
# image rotated and flipped accordingly
def rotate_and_flip(im, angle, hflip, vflip):
from PIL import Image
raf = im
if angle != 0:
raf = raf.rotate(angle, expand=True)
if hflip:
raf = raf.transpose(Image.FLIP_LEFT_RIGHT)
if vflip:
raf = raf.transpose(Image.FLIP_TOP_BOTTOM)
return raf
# If overwrite is false, append the rotation information to the filename
# using the "basename" parameter and save it in the same directory.
# If overwrite is true, stop the model from saving its outputs and
# save the rotated and flipped images instead.
basename = ""
if(not overwrite):
if angle != 0:
basename += "rotated_" + str(angle)
if hflip:
basename += "_hflip"
if vflip:
basename += "_vflip"
else:
p.do_not_save_samples = True
proc = process_images(p)
# rotate and flip each image in the processed images
# use the save_images method from images.py to save
# them.
for i in range(len(proc.images)):
proc.images[i] = rotate_and_flip(proc.images[i], angle, hflip, vflip)
images.save_image(proc.images[i], p.outpath_samples, basename,
proc.seed + i, proc.prompt, opts.samples_format, info= proc.info, p=p)
return proc
This is the Stable Diffusion web UI wiki. Wiki Home
Setup
- Install and run on NVidia GPUs
- Install and run on AMD GPUs
- Install and run on Apple Silicon
- Install and run on Intel Silicon (external wiki page)
- Install and run via container (i.e. Docker)
- Run via online services
Reproducing images / troubleshooting
Usage
- Features
- Command Line Arguments and Settings
- Optimizations
- Custom Filename Name and Subdirectory
- Change model folder location e.g. external disk
- User Interface Customizations
- Guides and Tutorials
Developers
Clone this wiki locally
You can’t perform that action at this time.