Skip to content

Instantly share code, notes, and snippets.

View sleexyz's full-sized avatar

Sean Lee sleexyz

View GitHub Profile
@torch.no_grad()
def sample_euler(model, x, sigmas, extra_args=None, callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1.):
"""Implements Algorithm 2 (Euler steps) from Karras et al. (2022)."""
extra_args = {} if extra_args is None else extra_args
s_in = x.new_ones([x.shape[0]])
for i in trange(len(sigmas) - 1, disable=disable):
gamma = min(s_churn / (len(sigmas) - 1), 2 ** 0.5 - 1) if s_tmin <= sigmas[i] <= s_tmax else 0.
sigma_hat = sigmas[i] * (gamma + 1)
if gamma > 0:
eps = torch.randn_like(x) * s_noise
{
"last_node_id": 55,
"last_link_id": 74,
"nodes": [
{
"id": 7,
"type": "CLIPTextEncode",
"pos": [
469,
341
@sleexyz
sleexyz / animate.sh
Last active February 28, 2024 20:00
#!/bin/bash
# This file will be sourced in init.sh
# https://raw.githubusercontent.com/ai-dock/comfyui/main/config/provisioning/animated.sh
printf "\n##############################################\n# #\n# Provisioning container #\n# #\n# This will take some time #\n# #\n# Your container will be ready on completion #\n# #\n##############################################\n\n"
function download() {
wget -q --show-progress -e dotbytes="${3:-4M}" -O "$2" "$1"
}
{ pkgs }:
pkgs.stdenv.mkDerivation rec {
pname = "copy";
version = "1.3";
src = ./.;
buildInputs = [ pkgs.rustc ];
buildPhase = ''
rustc copy.rs
@sleexyz
sleexyz / copy.rs
Created June 6, 2023 05:10
keeps relative symlinks, derefs absolute symlinks
use std::env;
use std::os::unix::fs::symlink;
use std::fs;
use std::path::Path;
use std::io::{self, Error, ErrorKind};
fn copy_dir_recursive(src: &Path, dest: &Path) -> io::Result<()> {
if !src.is_dir() {
return Err(Error::new(ErrorKind::NotFound, "Source directory does not exist."));
}
@sleexyz
sleexyz / Justfile
Last active May 27, 2023 04:01
helpers to recurse into subdirectories
list:
#!/usr/bin/env just _recurse bash
echo "$DIR":
just -l | tail -n +2
test: (_recurse_subcommand "test")
_recurse_subcommand command:
#!/usr/bin/env just _recurse bash
if [[ "$DIR" == "." ]]; then
@sleexyz
sleexyz / scripts.nix
Created May 27, 2023 00:04
wrapper around just that always nix develops
self: super: {
just-wrapper = super.writeShellScriptBin "just" ''
# Check if path argument is provided
if [ -z "$1" ]; then
echo "Usage: just <path> [extra_arguments]"
exit 1
fi
# Split the path into $DIRECTORY and $COMMAND
DIRECTORY=$(dirname "$1")
zcc = pkgs.writeShellScriptBin "zcc" ''
export ZIG_LOCAL_CACHE_DIR=$TMPDIR/zig-cache
export ZIG_GLOBAL_CACHE_DIR=$ZIG_LOCAL_CACHE_DIR
${pkgs.zig}/bin/zig cc $@
'';
# TODO: remove once 1.22.3 lands in nixpkgs
(watchexec.overrideAttrs (old: rec {
name = "watchexec-${version}";
version = "1.22.3";
src = fetchFromGitHub {
owner = "watchexec";
repo = "watchexec";
rev = "v${version}";
sha256 = "sha256-DmbwC2+qPPeeWXfJUtYGlozVGfOjPse5ciO3Oj8R9DQ=";
};
#include "tree_sitter/parser.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
enum TokenType {
INDENT,
DEDENT,
NEWLINE,