Skip to content

Instantly share code, notes, and snippets.

View zetyquickly's full-sized avatar
🎰
<-- generated prior COVID

Emil Bogomolov zetyquickly

🎰
<-- generated prior COVID
View GitHub Profile
@zetyquickly
zetyquickly / stablediffusionwalk.py
Created April 12, 2025 23:27 — forked from karpathy/stablediffusionwalk.py
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
@zetyquickly
zetyquickly / stablediffusionwalk.py
Created April 12, 2025 23:27 — forked from karpathy/stablediffusionwalk.py
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
@zetyquickly
zetyquickly / view_contig.py
Last active March 15, 2022 03:36
View Contiguous
import torch
# Tensor of interest
tens_A = torch.rand((2,3,4)) # 3-dimensional tensor of shape (2,3,4)
def test_view(tensor, sizes):
try:
tensor.view(*sizes)
except Exception as e:
print(e)
@zetyquickly
zetyquickly / contig_and_again.py
Last active March 14, 2022 04:15
Non-contiguous and restoration
import torch
# Tensor of interest
tens_A = torch.rand((2,3,4)) # 3-dimensional tensor of shape (2,3,4)
# Transposed tensor
transp_A = tens_A.t()
# Check contiguity
print(transp_A.is_contiguous()) # output: False
# Make contiguous
tens_B = transp_A.contiguous() # triggers copying because wasn't contiguous
@zetyquickly
zetyquickly / stride_product_tail.py
Created March 14, 2022 03:52
Strides are tail products
import torch
# Tensor of interest
tens_A = torch.rand((2,3,4)) # 3-dimensional tensor of shape (2,3,4)
sizes = tens_A.shape
print(tens_A.is_contiguous()) # outputs: True
print(tens_A.stride()) # outputs: (12,4,1)
print(tens_A.stride() == (sizes[1]*sizes[2], sizes[2], 1)) # outputs: True
@zetyquickly
zetyquickly / stride_offset_jump.py
Last active March 14, 2022 00:19
Tensor stride is a jump within underlying data
import torch
# Tensor of interest
tens_A = torch.rand((2,3,4)) # 3-dimensional tensor of shape (2,3,4)
# Start index
x = 0
y = 1
z = 3
@zetyquickly
zetyquickly / und_data_resh.py
Last active March 13, 2022 22:48
Tensor reshape 2x4 to 2x2x2
import torch
data = [1,2,3,4,5,6,7,8]
# Original tensor of shape 2x4
tens_A = torch.tensor(data).reshape(shape=(2,4))
# Reshaped from 2x4 to 2x2x2 (preserving number of elements)
tens_B = tens_A.reshape(shape=(2,2,2))
@zetyquickly
zetyquickly / und_data_init.py
Last active March 13, 2022 22:47
Underlying data reshape
import torch
# underlying data
data = [1,2,3,4,5,6,7,8] # has 8 elements
# two ways to store identical data
tens_A = torch.tensor(data).reshape(shape=(2,4)) # 2-dimensional tensor of shape (2,4)
tens_B = torch.tensor(data).reshape(shape=(2,2,2)) # 3-dimensional tensor of shape (2,2,2)
@zetyquickly
zetyquickly / baseline.py
Last active January 26, 2022 08:34
Codenrock New Year Battle Baseline Model
import torch
from torch import nn
import torchvision
from torchvision import transforms
from torch.utils.data import Dataset
from PIL import Image
import os
from sklearn.model_selection import train_test_split
import itertools
import time
import numpy as np
from numpy.random import default_rng
import trimesh
import igl
from tqdm import tqdm