Skip to content

Instantly share code, notes, and snippets.

@UuuNyaa
UuuNyaa / setup_stable-diffusion-webui.sh
Last active May 26, 2023 16:38
Setup EC2 instance for stable-diffusion-webui
# install NVIDIA Drivers
sudo yum update -y
sudo yum install -y kernel-devel
# for amazon linux 2
# sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc10-cc 30
# for amazon linux 2023
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
@UuuNyaa
UuuNyaa / gimp_color_correction.scm
Created March 10, 2023 18:26
Color correction for GIMP Script-Fu
(define (string-replace strIn strReplace strReplaceWith)
(let* (
(curIndex 0)
(replaceLen (string-length strReplace))
(replaceWithLen (string-length strReplaceWith))
(inLen (string-length strIn))
(result strIn)
)
;loop through the main string searching for the substring
(while (<= (+ curIndex replaceLen) inLen)
@UuuNyaa
UuuNyaa / batch_request.py
Last active November 4, 2025 04:29
Batch processing for stable-diffusion-webui API with sd-webui-controlnet
import base64
import collections.abc
import glob
import io
import json
import math
import os
from concurrent.futures import ThreadPoolExecutor
from functools import lru_cache
from typing import Any, Dict, Iterable, List, Optional, Tuple, TypeVar
@UuuNyaa
UuuNyaa / apply_smpl_motion.py
Created December 14, 2022 18:58
Apply SMPL motion to a SMPL model.
import json
import bpy
from mathutils import Matrix, Quaternion, Vector
SMPL_JOINT_NAMES = [
'pelvis', # 0
'left_hip', # 1
'right_hip', # 2
'spine1', # 3
@UuuNyaa
UuuNyaa / plot_verts_and_edgs.py
Created November 30, 2022 03:51
Plot vertices and edges as mesh objects
import bpy
frames = [
{'leg.l': [(0.0, 1.1860303, 0.0), (-0.0695946, 1.0660217, -0.034061156), (-0.11811634, 0.57155114, -0.13624609), (-0.008873149, 0.04841693, -0.2796949), (-0.053069953, 0.0, -0.09684668)], 'leg.r': [(0.0, 1.1860303, 0.0), (0.0724319, 1.073727, -0.009826176), (0.12871023, 0.61304337, 0.20569803), (0.089175716, 0.058375914, 0.2882095), (0.11506506, 0.064310126, 0.47270375)], 'spine': [(0.0, 1.1860303, 0.0), (0.017183019, 1.3511815, -0.041037392), (0.022112308, 1.5361633, -0.020832425), (0.013682552, 1.6097751, -0.029291518), (-0.009506061, 1.884695, -0.101417266), (-0.029154574, 2.0003433, -0.036746368)], 'arm.l': [(0.013682552, 1.6097751, -0.029291518), (-0.10034585, 1.7455293, -0.08684481), (-0.2577192, 1.7277443, -0.10872765), (-0.11073624, 1.4572028, 0.040203743), (-0.045355406, 1.7803317, 0.16021127)], 'arm.r': [(0.013682552, 1.6097751, -0.029291518), (0.107355446, 1.7587388, -0.06060553), (0.26224223, 1.7657496, -0.13296261), (0.1572879, 1.4490935, -0.14701252), (0.22211389, 1.501365
import mathutils
from mathutils import Matrix
import bpy
from typing import List, Dict, Tuple, Optional
target_mesh_objects: List[bpy.types.Object] = [o for o in C.selected_objects if o.type == 'MESH' and not o.hide]
i2vm: Dict[int, Tuple[bpy.types.MeshVertex, bpy.types.Object]] = dict(enumerate((v, m) for m in target_mesh_objects for v in m.data.vertices if v.select))
mesh_object: Optional[bpy.types.Object] = None
@UuuNyaa
UuuNyaa / babylon_rgb_hsv_converters.ts
Last active June 3, 2022 12:59
RGB/HSV converter shader block for Babylon.js
class RGBtoHSVBlock extends NodeMaterialBlock {
/**
* Creates a new RGBtoHSVBlock
* @param name defines the block name
*/
public constructor(name: string) {
super(name, NodeMaterialBlockTargets.Fragment)
this.registerInput("rgb", NodeMaterialBlockConnectionPointTypes.Color3)
this.registerOutput("hsv", NodeMaterialBlockConnectionPointTypes.Color3)
}
@UuuNyaa
UuuNyaa / face_normals_correction.py
Last active October 20, 2023 16:46
Face normals correction for toon shader
# Face normals correction
# Usage:
# 1. Select a mesh
# 2. Enter edit mode
# 3. Select face vertices
# 4. Return to object mode
# 5. Run this script
# 6. Return to object mode
# 7. Enter edit mode
# 8. Normals are displayed correctly.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# Output results to the system console
from datetime import datetime
import functools
import bpy
prop_name2values = {
'bpy.context.scene.eevee.taa_render_samples' : [32, 1, 16, 64, 128, 512],
'bpy.context.scene.eevee.use_gtao' : [True, False],