Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
dirs = ['^','>','v','<'] | |
dir_map = {'^':0,'>':1,'v':2,'<':3} | |
delta = [(-1,0),(0,1),(1,0),(0,-1)] | |
def parse_grid(grid_str): | |
grid = [list(line) for line in grid_str.split('\n')] | |
rows, cols = len(grid), len(grid[0]) | |
gpos, gdir = None, None | |
for r in range(rows): | |
for c in range(cols): |
This file contains 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
class Snail: | |
def __init__(self): | |
self.speed = 0.001 | |
self.pos = 0 | |
def move(self): | |
self.pos += self.speed | |
print(f'moved to {self.pos}') | |
garry = Snail() |
This file contains 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 os | |
import yaml | |
from pprint import pprint | |
def dir_structure(dir_path, nested=False): | |
result = [] | |
if nested: | |
# return directory structure as nested dict | |
for item in os.listdir(dir_path): |
This file contains 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
# based on github.com/weifeng-Chen/prompt2prompt/ - shoutout to Weifeng Cheng! | |
# Create pipeline and run it once | |
import torch | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from diffusers.pipelines import Prompt2PromptPipeline | |
pipe = Prompt2PromptPipeline.from_pretrained("CompVis/stable-diffusion-v1-4").to("cuda") |