Spaces:
Sleeping
Sleeping
Update models.py
Browse fileshttps://cookbook.openai.com/examples/generate_images_with_gpt_image
models.py
CHANGED
|
@@ -156,18 +156,12 @@ def generate_remixed_image(
|
|
| 156 |
model="gpt-image-1",
|
| 157 |
prompt=final_prompt,
|
| 158 |
size="1024x1024",
|
| 159 |
-
quality="medium",
|
| 160 |
-
|
| 161 |
-
n=1
|
| 162 |
)
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
image_data = requests.get(image_url).content
|
| 168 |
-
|
| 169 |
-
remixed_image = Image.open(BytesIO(image_data))
|
| 170 |
-
|
| 171 |
return final_prompt, remixed_image
|
| 172 |
|
| 173 |
except Exception as e:
|
|
|
|
| 156 |
model="gpt-image-1",
|
| 157 |
prompt=final_prompt,
|
| 158 |
size="1024x1024",
|
| 159 |
+
quality="medium", # valid: low | medium | high | auto
|
| 160 |
+
n=1,
|
|
|
|
| 161 |
)
|
| 162 |
+
b64 = dalle_response.data[0].b64_json
|
| 163 |
+
img_bytes = base64.b64decode(b64)
|
| 164 |
+
remixed_image = Image.open(BytesIO(img_bytes)).convert("RGB")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
return final_prompt, remixed_image
|
| 166 |
|
| 167 |
except Exception as e:
|