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 numpy as np | |
class Agent: | |
def __init__(self, n_machines=10): | |
self.t = 0 # current time step | |
self.n_machines = n_machines | |
def pick_machine(self): | |
# returns index of machine |
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
#!/bin/sh | |
wget -O - https://pypi.org/simple/ 2>/dev/null | grep "$1" | grep -Po "(?<=>).*(?=<)" |
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 surprise | |
import pandas as pd | |
data = surprise.Dataset.load_builtin('ml-100k') | |
ddir = surprise.get_dataset_dir() | |
item_data = pd.read_csv(f'{ddir}/ml-100k/ml-100k/u.item', | |
sep='|', | |
header=None, | |
encoding='ISO-8859-1', |
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 requests | |
import json | |
from tqdm.auto import tqdm | |
import pandas as pd | |
def kwargs2url(**kwargs): | |
url = 'https://commons.wikimedia.org/w/api.php?' | |
for k, v in kwargs.items(): | |
url += f'{k}={v}&' | |
return url.rstrip('&') |
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
from diffusers import StableDiffusionXLPipeline | |
class CustomPipeline(StableDiffusionXLPipeline): | |
@classmethod | |
def from_pretrained(cls, *args, **kwargs): | |
self = super().from_pretrained(*args, **kwargs) | |
assert self.watermark is None # watermarking currently not supported | |
def postprocess_no_grad(image, *args, **kwargs): |
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 diffusers import StableDiffusionPipeline | |
from matplotlib import pyplot as plt | |
device = "cuda" if torch.cuda.is_available() else "cpu" | |
pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16) | |
pipe = pipe.to(device) | |
prompts = ["a hamburger"] * 8 + ["a birthday cake"] * 12 |
OlderNewer