Skip to content

Instantly share code, notes, and snippets.

@w-e-w
w-e-w / demo_txt2img_upscal_generation_parameters .py
Created October 19, 2024 12:33
webui demo txt2img_upscale read generation_parameters from image and pass to script
from modules import patches, txt2img, script_callbacks, infotext_utils, errors, scripts
from functools import wraps
import inspect
import json
global_carry_info = None
def wrap_txt2img_upscale(func):
@wraps(func)
@w-e-w
w-e-w / civitai-click-show-more.user.js
Last active August 25, 2024 04:07
Civitai click "Show more" Tampermonkey
// ==UserScript==
// @name Civitai click "Show more"
// @namespace w-e-w
// @version 1.4
// @description Automatically click the "Show more" button and other specific buttons when they appear on the page
// @author https://github.com/w-e-w
// @match https://civitai.com/models/*
// @match https://civitai.com/images/*
// @icon https://civitai.com/favicon.ico
// @grant none
@w-e-w
w-e-w / sd_webui_prompt_ext_demo.py
Last active June 8, 2024 21:45
a example on how an webui extention can get the prompt from the ui
from modules import scripts
import gradio as gr
class DemoExt(scripts.Script):
def __init__(self):
super().__init__()
self.promp_elm = None
self.promp_n_elm = None
self.on_after_component_elem_id = [
@w-e-w
w-e-w / Interval tester.py
Created May 18, 2024 09:01
Generate a function that checks if a list of value is in the interval
import re
def parse_interval_rule(symbols, num):
match symbols:
case '[':
return lambda n: n >= num
case '(':
return lambda n: n > num
case ']':
@w-e-w
w-e-w / sd-webui-txt2img-img2img-api-example.py
Last active November 14, 2024 15:22
Stable Diffusion web UI txt2img img2img api example script
from datetime import datetime
import urllib.request
import base64
import json
import time
import os
webui_server_url = 'http://127.0.0.1:7860'
out_dir = 'api_out'
@w-e-w
w-e-w / sd-webui-version-info.py
Last active November 24, 2023 18:31
stable-diffusion-webui version info
from pkg_resources import parse_version
from importlib.util import find_spec
from subprocess import check_output
from pathlib import Path
from os import environ
import re
def get_version_from_changelog():
"""
@w-e-w
w-e-w / replace_illegal_filename_characters.py
Last active November 3, 2023 19:03
Python replace illegal filename characters
import re
character_translation_table = str.maketrans('"*/:<>?\\|\t\n\v\f\r', '"*/:<>?\│ ')
leading_space_pattern = re.compile(r'^\s+')
def replace_illegal_filename_characters(input_filename: str):
r"""
Replace illegal characters with full-width variant
Table
@w-e-w
w-e-w / WindowSpy Regex.ahk
Created June 3, 2023 13:54
AutoHotkey V2 WindowSpy.ahk mod
; modify version of https://github.com/AutoHotkey/AutoHotkeyUX/blob/988fc7e6f84635dc0eb8ebee679d6766f4e25e65/WindowSpy.ahk
; ahk_exe as Regex escape full path
; id of Control Under Mouse
;
; Window Spy for AHKv2
;
#Requires AutoHotkey v2.0
#NoTrayIcon
@w-e-w
w-e-w / run webui.bat
Last active July 2, 2023 07:17
One-Click Install AUTOMATIC1111 Stable-Diffusion-Webui for Windows 10/11 Nvidia GPU
@echo off
cd /d "%~dp0"
set PATH=%~dp0internal\git\cmd;%~dp0internal\python;%~dp0internal\python\Scripts;%PATH%
set TRANSFORMERS_CACHE=%~dp0internal\transformers-cache
if not exist "internal" mkdir "internal"
if not exist "internal\git" (
if not exist "internal\cache_downloads" mkdir "internal\cache_downloads"
@w-e-w
w-e-w / replace datetime.py
Last active October 23, 2022 09:23
customizable filename pattern [datetime] for AUTOMATIC1111/stable-diffusion-webui
import datetime
import pytz
import re
def replace_datetime(input_str: str, time_datetime: datetime.datetime = None):
"""
Args:
input_str (`str`):
the String to be Formatted