Last active
July 29, 2023 20:52
-
-
Save varunshenoy/4a9a6bbfedfa7def28178a8f0563320a to your computer and use it in GitHub Desktop.
An extension for Opendream that overrides the default `dream` function (that uses Stable Diffusion) with OpenAI's DALL-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
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"] | |
response = openai.Image.create( | |
prompt=prompt, | |
n=1, | |
size="512x512", | |
) | |
image_url = response['data'][0]['url'] | |
return Layer.from_url(image_url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment