Skip to content

Instantly share code, notes, and snippets.

View dmarx's full-sized avatar

David Marx dmarx

View GitHub Profile
@dmarx
dmarx / symlink_reversi.py
Created February 24, 2023 17:03
adds symlinks to existing frames in reverse order to facilitate compiling bounce-looped videos.
@dmarx
dmarx / moar.yaml
Last active February 9, 2023 18:38
putting this in a gist so I don't have to keep looking for it. via: https://discord.com/channels/869630568818696202/899135695677968474/943391522353721384
scene1 {transition: t0} | scene2 {transition: t1} | scene3 {transition: t0} | scene4
scenes:
scene1:
prompts:
- foo
- bar
scene2:
prompts:
- baz
@dmarx
dmarx / ldm_config_utils.py
Created January 24, 2023 23:34
instantiate_from_config implementation used by CompVis
# via https://github.com/Stability-AI/stablediffusion/blob/main/ldm/util.py
def instantiate_from_config(config):
if not "target" in config:
if config == '__is_first_stage__':
return None
elif config == "__is_unconditional__":
return None
raise KeyError("Expected key `target` to instantiate.")
return get_obj_from_str(config["target"])(**config.get("params", dict()))
@dmarx
dmarx / exif.py
Created January 19, 2023 04:23
code snippets for getting useful exif metadata from generative art outputs
###############
# DreamStudio #
###############
import PIL
from PIL import Image, ExifTags
def get_exif(img):
outv = {}
for k, v in img.getexif().items():
#@title Prompts
prompts = {
0:"unfortunate failed crayon drawing sketched while drunk looks awful, should have thrown it away, badly drawn crayon sketch of bill murray scribbled by a child while having a stroke seizure, wouldnt even put this on my fridge, by five year old could've drawn this",
50:"unfortunate failed crayon drawing sketched while drunk looks awful, should have thrown it away, badly drawn crayon sketch CARICATURE of bill murray scribbled by a child while having a stroke seizure, wouldnt even put this on my fridge, by five year old could've drawn this",
150:"crayon drawing sketched while drunk looks awful, should have thrown it away, badly drawn crayon sketch of bill murray scribbled by a child while having a stroke seizure, wouldnt even put this on my fridge, by five year old could've drawn this",
200:"crayon drawing sketched while drunk, hastily drawn crayon sketch of bill murray scribbled by a child while having a stroke seizure, wouldnt even put this on my fridge, by five ye
"""
It looks like the Scene and Storyboard classes are intended to be used for creating animations by specifying keyframed curves for various parameters. The Scene class appears to allow users to specify the length of the scene and set keyframed curves for various attributes of the scene. The Storyboard class then allows users to create a sequence of Scene objects and specify default values for attributes that are not explicitly set in a given scene.
It looks like the KeyframedObject class is a subclass of the Keyframed class from the keyframed module, which provides some basic functionality for working with keyframed curves. The KeyframedObject class adds a weight attribute to the Keyframed class, which specifies the weight of the object when it is used in a storyboard.
The to_keyframed function provides a convenient way to convert various types of input into Keyframed objects, which can then be used as attributes in a Scene object. This function allows users to specify keyframed curves using strings, d
@dmarx
dmarx / perlin-noise.ipynb
Created February 14, 2022 08:06 — forked from adefossez/perlin-noise.ipynb
Perlin noise.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dmarx
dmarx / staged_classifiers_for_unknown_classes.r
Last active August 26, 2018 09:48
Demonstration of using a simple "two stage" strategy to handle classification that supports an "unknown" class that may contain arbitrarily many true subclasses.
library(MASS)
library(rpart)
random_pos_def_matrix = function(n){
# https://math.stackexchange.com/a/358092/109246
A = matrix(runif(n*n), n)
A = 0.5*(A+t(A))
A + n*diag(n)
}
library(tidyr) # just for gather()
simulate <- function(formulas
,obs_per_cell = 100
,n_cells_per_group = 3
,amp_mu = 50
,amp_sd = 1 # this is only thing that impacts sd
,true_effect = 3
,error_sd = 1
){
install.packages('doParallel')
library(igraph)
library(foreach)
library(doParallel)
stopCluster(cl)
cl <- makeCluster(8)
registerDoParallel(cl)
sj_alg <- function(G){