Spaces:
Paused
Paused
File size: 834 Bytes
27cf343 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from openai import OpenAI
from dotenv import load_dotenv
import os
load_dotenv()
openai_key = os.getenv("OPENAI_KEY")
if openai_key == "<YOUR_OPENAI_KEY>":
openai_key = ""
if openai_key == "":
sys.exit("Please Provide Your OpenAI API Key")
def infer_stable_diffusion(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
return "dummy_image"
def infer_dall_e(text, model, quality, size):
try:
client = OpenAI(api_key=openai_key)
response = client.images.generate(
prompt=text,
model=model,
quality=quality,
size=size,
n=1,
)
except Exception as error:
print(str(error))
raise gr.Error("An error occurred while generating image.")
return response.data[0].url |