This file has been truncated, but you can view the full file.
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
{"0":{"op":"dream","image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAEAAElEQVR4nEz9abC1bXYWhl1ruJ9n733Oecdv6LlbLXVrAAkQUxmTwk6Riqtsl7EpA3H5Bz/iuFIxSSWVSlKQSqpiUMAMZsYgsJGQBaIEdhQwFGYICIGQhSRAAoOARlJP6u5vfN9z9n6ee6115cfab+NT37/v+87Z+xnWvdY1LfkjP/xjM2y62mK1TTETprkXpViulpHqyioRJWlmlUkRdcs5zQZzqmoVWaVDWRARgJkUM1SqSlXZMvbLrmPk3IYPQmLGWEbsU0RFAUgVx7DIJGnDaw9zZwWKap4RvgwCGakqEGp/GFL7c6qJCtg/0GFzu4xlAVFJd6sZIkqpAm2M/bIvy8LMqlR3VKpYkszy4bGHrSOTQhEhC6w0M5JCqmhWiQBCEEnCx9zzuBweH8cf+y+/+y//tt8ETPSPGAhF/sff+K988+1rr5vd6Hi63BxPt6svxnD1/XK5XC6woTRTlBCQ2M9VMmeJ68OLd5axZOK4rqpitkSFicl6/Nw77/70+y9+6LM/+QPbz/wLvNgBgPjqj8DoYmQxyX/zf/d//Pf+N7/BlpqzYuiZJKAiApUiC2ZSLBXNDBbdPWMXMbKMgCAjhxtAQOa2r4dBlkCqIAZV4UxVjSozE9PKEpWaqW4zppopBSpCEIBoZppqsWKmr0tlgVgWyz1UDWRmiQqK6ppFCFQgpplZVWZWSXPNmVAVAUmIZKYNqyQEqoYqkiBUkZHqXhHmXpn9LGWEqrEIUt2YKapqOmeaKVGAVFJFVYVZMBOWqFIQEQqFQE1y0swoxaIvY85gQoejQiCmIoSIRFJUwDJVCuY2fV0qp7nNPWyMmNN8gFlZ14/nVlVVdPdtu/jwjFJTc81IU2emuucMc2WmimWVqohIRonKsljsUaCYZpapQ1jVLy0FyAKqVERUIEJCRCisLB |
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 baseten | |
import base64 | |
from opendream import opendream | |
from opendream.layer import ImageLayer, Layer | |
@opendream.define_op | |
def dream(prompt: str): | |
# https://app.baseten.co/explore/stable_diffusion |
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 torch | |
from PIL import Image | |
from diffusers import ControlNetModel, StableDiffusionControlNetImg2ImgPipeline, UniPCMultistepScheduler | |
from opendream import opendream | |
from opendream.layer import ImageLayer, Layer | |
def resize_for_condition_image(input_image: Image, resolution: int): | |
input_image = input_image.convert("RGB") | |
W, H = input_image.size |
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
from opendream import opendream | |
from opendream.layer import Layer, ImageLayer, MaskLayer | |
import openai | |
import os | |
import json | |
from PIL import Image, ImageEnhance, ImageFilter | |
import pilgram | |
@opendream.define_op |
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
@opendream.define_op | |
def superresolution(image_layer: ImageLayer, model_ckpt: str = "runwayml/stable-diffusion-v1-5", batch_size = 1, seed = 42, selected = 0, num_steps = 20, **kwargs): | |
import modal | |
# Use ControlNet + Tile preprocessor | |
f = modal.Function.lookup("diffuseqr", "ControlNet.run_inference") | |
image = f.call(Layer.pil_to_b64(image_layer.get_image()))[0] | |
image = Layer.b64_to_pil(image) | |
return ImageLayer(image=image) |
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 numpy as np | |
from PIL import Image | |
from urllib.request import urlretrieve | |
from segment_anything import SamAutomaticMaskGenerator, sam_model_registry | |
from opendream import opendream | |
from opendream.layer import ImageLayer, MaskLayer | |
def convert_mask_to_layer(mask): |
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 torch | |
from diffusers import UniPCMultistepScheduler, ControlNetModel, StableDiffusionControlNetPipeline | |
from opendream import opendream | |
from opendream.layer import ImageLayer, Layer | |
from controlnet_aux import OpenposeDetector | |
@opendream.define_op | |
def controlnet_openpose(control_image_layer: ImageLayer, prompt, device: str = "cpu", model_ckpt: str = "runwayml/stable-diffusion-v1-5", batch_size = 1, seed = 42, selected = 0, num_steps = 20, **kwargs): | |
openpose = OpenposeDetector.from_pretrained("lllyasviel/Annotators") |
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 torch | |
from diffusers import UniPCMultistepScheduler, ControlNetModel, StableDiffusionControlNetPipeline | |
from opendream import opendream | |
from opendream.layer import ImageLayer, Layer | |
from controlnet_aux import CannyDetector | |
@opendream.define_op | |
def controlnet_canny(control_image_layer: ImageLayer, prompt, device: str = "cpu", model_ckpt: str = "runwayml/stable-diffusion-v1-5", batch_size = 1, seed = 42, selected = 0, num_steps = 20, **kwargs): | |
canny = CannyDetector() |
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 torch | |
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler | |
from opendream import opendream | |
from opendream.layer import Layer, ImageLayer | |
@opendream.define_op | |
def instruct_pix2pix(image_layer: ImageLayer, prompt, device = "mps"): | |
model_id = "timbrooks/instruct-pix2pix" | |
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float32, safety_checker=None) |
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
from opendream import opendream | |
from opendream.layer import Layer | |
import openai | |
import os | |
@opendream.define_op | |
def dream(prompt: str): | |
openai.api_key = os.environ["OPENAI_API_KEY"] |
NewerOlder