■ OpenAI 클래스의 images 변수를 사용해 이미지에 대해 이미지 변형을 만드는 방법을 보여준다.
[원본 이미지]
[결과 이미지]
▶ 예제 코드 (PY)
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 29 30 31 32 |
import os from openai import OpenAI os.environ["OPENAI_API_KEY"] = "<OPENAI_API_KEY>" openAI = OpenAI() image = open("image.png", "rb") imageResponse = openAI.images.create_variation( image = image, size = "512x512", n = 1 ) print(imageResponse) """ ImagesResponse( created = 1717575422, data = [ Image( b64_json = None, revised_prompt = None, url = 'https://oaidalleapiprodscus.blob.core.windows.net/private/org-EkYGQNtJSwLObhqCI65I747J/user-89spyW5FYIOQ1WqSb6pwacpU/img-CiaFlRejfDdU3kmYPoTav8m0.png?st=2024-06-05T07%3A17%3A02Z&se=2024-06-05T09%3A17%3A02Z&sp=r&sv=2023-11-03&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-06-05T05%3A36%3A52Z&ske=2024-06-06T05%3A36%3A52Z&sks=b&skv=2023-11-03&sig=y6NnVvRqnUBVnA44OhDnH9hLTuX%2Bplme/iTEqccK6V0%3D' ) ] ) """ |
▶ requirements.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
annotated-types==0.7.0 anyio==4.4.0 certifi==2024.6.2 distro==1.9.0 exceptiongroup==1.2.1 h11==0.14.0 httpcore==1.0.5 httpx==0.27.0 idna==3.7 openai==1.31.0 pydantic==2.7.3 pydantic_core==2.18.4 sniffio==1.3.1 tqdm==4.66.4 typing_extensions==4.12.1 |