Skip to content

Instantly share code, notes, and snippets.

@catboxanon
catboxanon / README.md
Last active March 2, 2025 19:56
NAI: Add artists and "de-aligned" tags to tag suggestions

NAI Tags+

This userscript injects artists and tags that do not conform to "AI alignment" standards into NovelAI's suggested imagegen tags.

Prerequisites

You will need a userscript extension. Below is a suggestion.

Installation

@catboxanon
catboxanon / 4chan-pixeldrain.user.js
Last active March 13, 2024 20:33
Parse pixeldrain URLs on 4chan
// ==UserScript==
// @name 4chan pixeldrain URL parser
// @namespace 4chanpixeldrainparse
// @match https://boards.4chan.org/*/thread/*
// @grant none
// @version 1.0.3
// @author Anonymous
// @description Parse pixeldrain URLs on 4chan
// @updateURL https://gist.github.com/raw/6fedeaacb169bc89bc5186bd00741b4a/4chan-pixeldrain.user.js
// @downloadURL https://gist.github.com/raw/6fedeaacb169bc89bc5186bd00741b4a/4chan-pixeldrain.user.js
@catboxanon
catboxanon / README.md
Last active March 2, 2025 19:48
Make NAI Prompting Great Again

NOTICE

I no longer plan to maintain this userscript, since as of 2025-03-01, NovelAI has added a native shortcut for attention emphasis. It only took them 1 year and 3 months!

The shortcut is triggered by highlighting anything in the prompt, and pressing [ to de-emphasize, or Shift + [ to emphasize.

Auto-saving images has also been a native feature for quite a while now, accessible by clicking on the goose icon in the top left.

Of the other two features exclusive to this script, generating forever and wildcards, the former still works, while the latter is broken.

@catboxanon
catboxanon / dall-3-save.user.js
Last active January 28, 2024 03:48
Save DALL-3 images on current page with Ctrl+S
// ==UserScript==
// @name DALL-3 Save
// @namespace bingdall3save
// @match https://www.bing.com/images/create*
// @version 1.0.2
// @author Anonymous
// @updateURL https://gist.github.com/raw/fa297d9a104b7dc63f92b444cbe51b39/dall-3-save.user.js
// @downloadURL https://gist.github.com/raw/fa297d9a104b7dc63f92b444cbe51b39/dall-3-save.user.js
// @require https://cdn.jsdelivr.net/npm/file-saver
// ==/UserScript==
import torch
from modules import script_callbacks, shared
def on_model_loaded(sd_model):
if hasattr(shared.opts, 'clip_tensor_fix_enabled') and shared.opts.data.get('clip_tensor_fix_enabled', False): # type: ignore
try:
t1 = None
t2 = torch.arange(0, 77, dtype=torch.int64).unsqueeze(0)
import gradio as gr
import numpy as np
import torch
from PIL import Image
from scipy.ndimage import gaussian_filter
from skimage.transform import resize
import modules.scripts as scripts
from modules import devices, script_callbacks, shared
from modules.processing import StableDiffusionProcessingTxt2Img
@catboxanon
catboxanon / lora_scanner.py
Last active May 30, 2023 23:50
LoRA scanner
import argparse
from glob import glob
from pathlib import Path
import numpy as np
from tqdm import tqdm
def read_metadata_from_safetensors(filename):
import json
from pathlib import Path
from tqdm import tqdm
import argparse
def read_metadata_from_safetensors(filename):
import json
with open(filename, mode="rb") as file:
metadata_len = file.read(8)
metadata_len = int.from_bytes(metadata_len, "little")
import os
from typing import Callable, List, Union
import gradio as gr
from modules import scripts
from modules.processing import StableDiffusionProcessing, StableDiffusionProcessingTxt2Img
from modules.script_callbacks import (CFGDenoisedParams, CFGDenoiserParams,
on_cfg_denoised, on_cfg_denoiser)
import os
import torch
import gradio as gr
from modules import script_callbacks, scripts, shared
class CLIPBlend:
def __init__(self):