-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for creating variations #8
Comments
Thanks you for your first issue in dalle2-in-python |
So, endpoint is like in #10 and #11 we need to have generation ID and put it to [prompt][parent_generation_id] from time import sleep
import requests
def save_response_images_to_file_api(response: dict):
# save images to disk
pass
auth_header = "Bearer sess-..."
payload = {
"task_type": "variations",
"prompt": {
"batch_size": 3,
"parent_generation_id": "generation-LVAn5NE3twBGOFh6SJOwFxC8",
},
}
content_type = "application/json"
create_task_link = "https://labs.openai.com/api/labs/tasks"
headers = {
"Content-type": content_type,
"Authorization": auth_header,
}
if __name__ == "__main__":
ret = requests.post(create_task_link, json=payload, headers=headers)
ret = ret.json()
sleep(3)
while ret["status"] == "pending":
ret = requests.get(create_task_link + "/" + ret["id"], headers=headers)
ret = ret.json()
sleep(3)
if ret["status"] == "succeeded":
save_response_images_to_file_api(ret)
print("DONE") |
That's for the already generated image. About uploads I will have to look later, they do base64 encoding, but i'm not sure they do it the way I do it. Further testing is required 😄 |
Would be great if you could create this feature as well ! |
DALL·E supports an edit API that lets you generate variations on a given image. The image can either be one that was generated by DALL·E and lives on the server, or one that you upload.
The text was updated successfully, but these errors were encountered: