This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import itertools | |
| import time | |
| import numpy as np | |
| from numpy.random import default_rng | |
| import trimesh | |
| import igl | |
| from tqdm import tqdm |
NewerOlder