Aniquel commited on
Commit
8421132
1 Parent(s): f632572

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -16
app.py CHANGED
@@ -9,22 +9,13 @@ openai.api_key = os.getenv("OPENAI_API_KEY")
9
 
10
 
11
  # Define the function that generates the image
12
- def generate_image(prompt):
13
- response = requests.post("https://api.openai.com/v1/images/generations", json={
14
- "model": "image-alpha-001",
15
- "prompt": prompt,
16
- "num_images": 4,
17
- "size": "1024x1024",
18
- "response_format": "url"
19
- }, headers={
20
- "Content-Type": "application/json",
21
- "Authorization": "Bearer "
22
- })
23
- response.raise_for_status()
24
- image_url = response.json()["data"][0]["url"]
25
- image = Image.open(BytesIO(requests.get(image_url).content))
26
- return image
27
-
28
 
29
  iface = gr.Interface(
30
  fn=generate_image,
 
9
 
10
 
11
  # Define the function that generates the image
12
+ response = openai.Image.create(
13
+ prompt=prompt,
14
+ n=1,
15
+ size="1024x1024"
16
+ )
17
+ image_url = response['data'][0]['url']
18
+
 
 
 
 
 
 
 
 
 
19
 
20
  iface = gr.Interface(
21
  fn=generate_image,