Skip to content
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

Open
charlesjlee opened this issue Jul 22, 2022 · 4 comments
Open

Add support for creating variations #8

charlesjlee opened this issue Jul 22, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@charlesjlee
Copy link
Contributor

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.

@github-actions
Copy link

Thanks you for your first issue in dalle2-in-python

@ezzcodeezzlife ezzcodeezzlife added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jul 22, 2022
@kv-crosstech
Copy link

So, endpoint is https://labs.openai.com/api/labs/tasks, but payload is different. Pay attention to batch_size - it's limited to 3. I'm not sure what is the reasoning behind that (aside their current UI limitations), but I hope that we will have ability to change that number after full release.

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")

@kv-crosstech
Copy link

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 😄
Probably current functionality for inpainting can do such upload correctly

@ezzcodeezzlife ezzcodeezzlife changed the title Add support for edit API Add support for creating variations Aug 12, 2022
@zhoujs93
Copy link

zhoujs93 commented Sep 7, 2022

d

Would be great if you could create this feature as well !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants