Skip to content

Instantly share code, notes, and snippets.

@jamesWalker55
jamesWalker55 / audvis_visualizer_generator.py
Last active March 20, 2024 18:19
A Python script for Blender Audvis. This generates an audio visualizer that looks similar to Monstercat's early visualizers.
import bpy
import math
def delete_object_if_exists(name):
if name in bpy.data.objects:
bpy.data.objects.remove(bpy.data.objects[name], do_unlink=True)
def get_or_create_empty(name):
@jamesWalker55
jamesWalker55 / show_img.py
Last active October 23, 2023 11:32
Open and show an image in a Python notebook, using `IPython`, `PIL`, and `numpy`.
def open_image(path):
from PIL import Image
import numpy as np
img = Image.open(path)
return np.asarray(img)
# Using PIL and IPython
def show_img(img):
@jamesWalker55
jamesWalker55 / gen_buckets.py
Created September 5, 2023 19:38
A single function for NovelAI aspect ratio bucketing. No need for classes or objects.
def gen_buckets(
min_dim: int = 256,
base_res: tuple[int, int] = (512, 512),
max_size: tuple[int, int] = (768, 512),
dim_limit: int = 1024,
divisible=64,
):
"""
Adapted from:
https://github.com/NovelAI/novelai-aspect-ratio-bucketing/blob/main/bucketmanager.py
@jamesWalker55
jamesWalker55 / image_importer.py
Created September 3, 2023 19:06
Substance Painter script to drag-and-drop images to import to project.
import datetime
import substance_painter.resource as res
import substance_painter.ui
from PySide2 import QtWidgets
def now():
return datetime.datetime.now().timestamp()
@jamesWalker55
jamesWalker55 / curve_to_mesh_preserving_modifiers.py
Last active May 11, 2023 12:07
Blender addon to convert a curve to a mesh while preserving modifiers. Tested on Blender 3.5.
from typing import Any, NamedTuple
import bpy
class ModifierSpec(NamedTuple):
name: str
type: str
properties: dict[str, Any]
model:
base_learning_rate: 5.0e-03
target: ldm.models.diffusion.ddpm.LatentDiffusion
params:
linear_start: 0.00085
linear_end: 0.0120
num_timesteps_cond: 1
log_every_t: 200
timesteps: 1000
first_stage_key: image
@jamesWalker55
jamesWalker55 / config.json
Last active December 13, 2022 03:19
Default config files generated after installing Automatic1111's WebUI, obtained at 2022-12-13 02:02 UTC
{
"samples_save": true,
"samples_format": "png",
"samples_filename_pattern": "",
"save_images_add_number": true,
"grid_save": true,
"grid_format": "png",
"grid_extended_filename": false,
"grid_only_if_multiple": true,
"grid_prevent_empty_spots": false,
@jamesWalker55
jamesWalker55 / Remove_Keyboard_Layout_en-US.ps1
Created July 24, 2022 16:01
This is a powershell script that automatically adds then removes "en-US" from the keyboard input methods list.
# This script solves the issue in this stackoverflow question:
# https://superuser.com/questions/1092246/how-to-prevent-windows-10-from-automatically-adding-keyboard-layouts-i-e-us-ke
# This method adds the en-US layout then removes it, ensuring that the layout is always removed from the taskbar
# I don't have a high enough reputation so I can't post this there, so here is the script:
# define the language to be removed
$LanguageToRemove = "en-US"
# get the current language list
$LangList = Get-WinUserLanguageList
@jamesWalker55
jamesWalker55 / autoeditor.js
Last active April 6, 2022 22:25 — forked from ishitatsuyuki/autoeditor.js
This script loads a JSON file produced by auto-editor, and skips regions of the video based on the JSON output. Place this script in your mpv scripts folder.
var timeObserver;
/** seek playback to the given second */
function seek_to(time) {
mp.set_property_number("time-pos", time);
}
function get_json_path() {
var video_path = mp.get_property("path");
return video_path.replace(/\.[^.]+$/, ".json");