File size: 610 Bytes
599a9f1
 
b52351a
599a9f1
 
ec62272
 
599a9f1
b267289
599a9f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b52351a
5801106
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
from PIL import Image
import requests 
from openai import OpenAI
import gradio as gr
client = OpenAI(api_key= "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")


def get_image(prompt):
    response = client.images.generate(
        model = "dall-e-3",
        prompt = prompt,
        size = "1024x1024",
        n = 1
    )
    image_url = response.data[0].url
    data = requests.get(image_url).content
    f = open('img.jpg','wb') 
    f.write(data)
    f.close()
    img = Image.open('img.jpg')
    return img



gr.Interface(fn=get_image,inputs = "textbox", outputs= gr.Image(type='pil')).launch()