R사용자회 chatGPT 예제 따라하기

Code source : https://r2bit.com/chatGPT/image2image.html

API Key : https://platform.openai.com/account/api-keys

#library(openai)


response1 <- create_image(
  prompt = "Create R programming language logo for Korean R user group in a kandinsky and Gustav Klimt style embracing Python programming language supported by many contributors around the world, which must include R logo from R consortium and wikipedia",
  n = 1,
  size = "1024x1024",
  response_format = "url",
  openai_api_key = api_key
)

image_url1 <- response1$data$url

image_url1
## [1] "https://oaidalleapiprodscus.blob.core.windows.net/private/org-qhk0rBISNA27fY69f8UOqrWM/user-JHMxrXovUl9Ru7l5LViUEa8G/img-AKbQW1fRjjptPTZtxcmLcpyg.png?st=2023-03-06T05%3A50%3A29Z&se=2023-03-06T07%3A50%3A29Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-03-06T01%3A24%3A57Z&ske=2023-03-07T01%3A24%3A57Z&sks=b&skv=2021-08-06&sig=l2QZHKLBeyyTQjufEjl%2BWkFcsHHAv8SxXf6go78HIgE%3D"
#library(magick)

result1 <- image_read(response1$data$url)

print(result1)
##   format width height colorspace matte filesize density
## 1    PNG  1024   1024       sRGB FALSE  3147977   72x72

#Surrealism style

response2 <- create_image(
  prompt = "Create R programming language logo for Korean R user group in a surrealism style embracing Python programming language supported by many contributors around the world, which must include R logo from R consortium and wikipedia",
  n = 1,
  size = "1024x1024",
  response_format = "url",
  openai_api_key = api_key
)

image_url2 <- response2$data$url

image_url2
## [1] "https://oaidalleapiprodscus.blob.core.windows.net/private/org-qhk0rBISNA27fY69f8UOqrWM/user-JHMxrXovUl9Ru7l5LViUEa8G/img-uxTaKkSKboTCVW08iuYQILOO.png?st=2023-03-06T05%3A50%3A38Z&se=2023-03-06T07%3A50%3A38Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-03-05T15%3A29%3A57Z&ske=2023-03-06T15%3A29%3A57Z&sks=b&skv=2021-08-06&sig=8hZn3xQ0TaI8gxaVXcg8BeKqSIH5KOPEO4JKTviIcdM%3D"
result2 <- image_read(response2$data$url)

print(result2)
##   format width height colorspace matte filesize density
## 1    PNG  1024   1024       sRGB FALSE  3147977   72x72

#Impressionism style

response3 <- create_image(
  prompt = "Create R programming language logo for Korean R user group in impressionism style embracing Python programming language supported by many contributors around the world, which must include R logo from R consortium and wikipedia",
  n = 1,
  size = "1024x1024",
  response_format = "url",
  openai_api_key = api_key
)

image_url3 <- response3$data$url

image_url3
## [1] "https://oaidalleapiprodscus.blob.core.windows.net/private/org-qhk0rBISNA27fY69f8UOqrWM/user-JHMxrXovUl9Ru7l5LViUEa8G/img-XAmjaB8wzVu28e26bzbHKwjx.png?st=2023-03-06T05%3A50%3A46Z&se=2023-03-06T07%3A50%3A46Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-03-05T08%3A03%3A54Z&ske=2023-03-06T08%3A03%3A54Z&sks=b&skv=2021-08-06&sig=wZ%2BoWmb1aRdhNtVVMAHTvNEtszrs9Mc0GvdlcRtpSJc%3D"
result3 <- image_read(response3$data$url)

print(result3)
##   format width height colorspace matte filesize density
## 1    PNG  1024   1024       sRGB FALSE  3147977   72x72