Skip to content

Instantly share code, notes, and snippets.

@SteveGilham
SteveGilham / prompt.ps1
Last active January 28, 2024 16:01
Using exiftool to add the prompt to a Bing Image Creator download
<#
.SYNOPSIS
Using exiftool to add the prompt to a Bing Image Creator download.
.DESCRIPTION
Use like
& '.\OneDrive\Pictures\aigen\prompt.ps1' "minimalist style corporate flower logo. simple, clean, uncluttered, modern, elegant"
or
@SteveGilham
SteveGilham / scan.ps1
Last active May 14, 2023 16:41
Script to extract SD Webui prompt data from .png files
[System.IO.Directory]::GetFiles((Get-Location), "?????-*.png") |
Group-Object -Property {[System.DateTime]::Parse([System.IO.File]::GetCreationTime($_).ToShortDateString())} |
Sort-Object -Property {[System.DateTime]::Parse($_.Name)} | % {
$names = $_.Group | Sort-Object -Property {[System.IO.File]::GetCreationTime($_)}
[PSCustomObject]@{
Key = $_.Name
Value = $names
}
} | % {
Write-Output ($_.Key.Split())[0]
@SteveGilham
SteveGilham / scan.fsx
Last active January 20, 2024 13:52
Extract the prompt metadata from a SD-WebUI .png file
open System
open System.IO
let dumpParams f =
let bytes = File.ReadAllBytes f
// printfn "%A bytes" bytes.Length
let rec readchunk index =
// printfn "readchunk %A" index
if index < bytes.Length then
let field = [| bytes[index+3]; bytes[index+2]; bytes[index+1]; bytes[index] |]
@SteveGilham
SteveGilham / model tests.txt
Last active April 3, 2024 10:25
Reproducing stable diffusion sample images
All the test images are run with the default Automatic1111 web ui parameters (with the exception of RNG which is kept as the original state of CPU) - Steps: 20, Sampler: Euler a, CFG scale: 7, ENSD: 31337, RNG: CPU; and assume the appropriate VAE for each model.
The voodoo prompt script (using the bad_prompt_version2 embedding):
--prompt "best quality, (masterpiece:1.3), illustration, absurdres, low sun, sunset glow, medium shot, (beautiful detailed girl), long brown hair and blue eyes, green dress, open jacket" --negative_prompt "cropped, simple background, missing hand, amputee, extra hands, cripple, mutated limbs, loli, lolicon, menu, ui, ux, user interface, mismatched eyes, malformed breasts, (bad_prompt_version2:0.8), (upskirt:1.5), (legwear:1.5), (hat:1.8)" --width 440 --height 592 --seed 1812824062
--prompt "best quality, (masterpiece:1.3), illustration, absurdres, low sun, sunset glow, medium shot, (beautiful detailed girl), long brown hair and blue eyes, green dress, open jacket, (white belt)" --ne
// do any required customizations here
var altcoverSettings = new AltCover.Cake.CoverageSettings {
PreparationPhase = new TestPrepareOptions(),
CollectionPhase = new TestCollectOptions(),
Options = new TestOptions()
};
var testSettings = new DotNetCoreTestSettings {
Configuration = configuration,
NoBuild = true,
DotNet.test
(fun to' ->
(to'
.WithCommon(withWorkingDirectoryVM "_DotnetTest")
.WithAltCoverGetVersion()
.WithAltCoverImportModule())
.WithAltCoverOptions
pp1
cc0
ForceTrue
let paramsToEnvironment (o: DotNet.Options) =
o.CustomParams
|> Option.map (fun x -> let bits = x.Split ("/p:", StringSplitOptions.RemoveEmptyEntries)
bits
|> Array.fold (fun (o2: DotNet.Options) flag -> let line = flag.TrimEnd([| ' '; '"' |])
let split = if line.Contains "=\""
then "=\""
else "="
let parts = line.Split (split, StringSplitOptions.RemoveEmptyEntries)
{ o2 with Environment = o2.Environment |> Map.add parts[0] parts[1] }) o)
@SteveGilham
SteveGilham / supernova.fsx
Created September 29, 2020 18:32
Faster version
open System
open System.Collections.Generic
open System.IO
let words = File.ReadAllLines(@".\brit-a-z.txt")
|> Array.filter (fun x -> x.IndexOf('\'') < 0)
let nines = words
|> Array.filter (fun x -> x.StartsWith("a"))
|> Array.filter (fun x -> x.Length = 9)
@SteveGilham
SteveGilham / supernova.fsx
Last active September 29, 2020 18:26
Puzzle solver
open System
open System.IO
let words = File.ReadAllLines(@".\brit-a-z.txt")
|> Array.filter (fun x -> x.IndexOf('\'') < 0)
let nines = words
|> Array.filter (fun x -> x.StartsWith("a"))
|> Array.filter (fun x -> x.Length = 9)
printfn "%d candidate words" nines.Length
@SteveGilham
SteveGilham / spotlight.ps1
Created June 24, 2020 09:20
Copying windows spotlight images
# where the images are
$assets = Join-path $env:userprofile "AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets"
# regularly refreshed screen images are recent
$weeks = new-object system.timespan (14,0,0,0)
# copy those files locally and apply '.jpg'
dir $assets | ? { $_.LastWriteTime -gt ([datetime]::now - $weeks) } | % { copy $_.FullName "$($_.Name).jpg" }