Skip to content

Instantly share code, notes, and snippets.

View dmarx's full-sized avatar

David Marx dmarx

View GitHub Profile
@sekstini
sekstini / KVCacheFun.ipynb
Last active November 28, 2023 10:12
Answering what happens when you give the KV-Cache of an instruct model to its base model. (update: better version in the comments)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
'''
https://gist.github.com/kohya-ss/3f774da220df102548093a7abc8538ed
1. put this file in ComfyUI/custom_nodes
2. load node from <loaders>
'''
import torch
from comfy.ldm.modules.diffusionmodules.openaimodel import forward_timestep_embed, timestep_embedding, th
def apply_control(h, control, name):
@karpathy
karpathy / stablediffusionwalk.py
Last active April 25, 2024 11:25
hacky stablediffusion code for generating videos
"""
stable diffusion dreaming
creates hypnotic moving videos by smoothly walking randomly through the sample space
example way to run this script:
$ python stablediffusionwalk.py --prompt "blueberry spaghetti" --name blueberry
to stitch together the images, e.g.:
$ ffmpeg -r 10 -f image2 -s 512x512 -i blueberry/frame%06d.jpg -vcodec libx264 -crf 10 -pix_fmt yuv420p blueberry.mp4
@rom1504
rom1504 / open_clip_slurm.md
Last active August 7, 2023 02:01
open clip at slurm

Install

git clone https://github.com/mlfoundations/open_clip.git
cd open_clip
python3.8 -m venv .env
source .env/bin/activate
pip install -U pip
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
pip install -e .
@rahulrajpl
rahulrajpl / diffusionmap.ipynb
Last active December 9, 2022 09:31
DiffusionMap.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
; acceleration_enabled = {acceleration_enabled}
; acceleration_infill = {acceleration_infill}
; acceleration_ironing = {acceleration_ironing}
; acceleration_layer_0 = {acceleration_layer_0}
; acceleration_prime_tower = {acceleration_prime_tower}
; acceleration_print = {acceleration_print}
; acceleration_print_layer_0 = {acceleration_print_layer_0}
; acceleration_roofing = {acceleration_roofing}
; acceleration_skirt_brim = {acceleration_skirt_brim}
; acceleration_support = {acceleration_support}
@gilrosenthal
gilrosenthal / Fast.ai install script
Created July 4, 2018 20:14
Fast.ai Install on Google Colab
!pip install fastai
!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python
import cv2
from os import path
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())
accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'
!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.3.0.post4-{platform}-linux_x86_64.whl torchvision
@tomfa
tomfa / handler.py
Last active February 14, 2023 15:08
AWS Lambda: Python store to S3
# This file is your Lambda function
import json
import boto3
def save_to_bucket(event, context):
AWS_BUCKET_NAME = 'my-bucket-name'
s3 = boto3.resource('s3')
bucket = s3.Bucket(AWS_BUCKET_NAME)
path = 'my-path-name.txt'
@shagunsodhani
shagunsodhani / LIME.md
Created January 28, 2017 12:32
Summary of "Why Should I Trust You? Explaining the Predictions of Any Classifier" paper

"Why Should I Trust You?": Explaining the Predictions of Any Classifier

Introduction

  • The paper introduces a novel technique to explain the predictions of any classifier in an interpretable and faithful manner.
  • It also proposes a method to explain models by obtaining representative individual predictions and their explanations.
  • Link to the paper
  • Demo

Desired Characteristics for Explanations

@thomasp85
thomasp85 / animate.R
Created February 3, 2016 19:43
Animating graph over time
library(ggraph)
library(gganimate)
library(igraph)
# Data from http://konect.uni-koblenz.de/networks/sociopatterns-infectious
infect <- read.table('out.sociopatterns-infectious', skip = 2, sep = ' ', stringsAsFactors = FALSE)
infect$V3 <- NULL
names(infect) <- c('from', 'to', 'time')
infect$timebins <- as.numeric(cut(infect$time, breaks = 100))
# We want that nice fading effect so we need to add extra data for the trailing