AI 이미지/Stable Diffusion

ChatGPT로 스테이블 디퓨전 프롬프트 만들기

하늘이푸른오늘 2023. 6. 26. 14:23

스테이블 디퓨전으로 생성한 오드리 헵번, Leonid Afremov 스타일
스테이블 디퓨전으로 생성한 오드리 헵번, Leonid Afremov 스타일

요약

ChatGPT는 프롬프트를 사용하여 원하는 이미지를 생성하는 데 도움을 줄 수 있습니다. ChatGPT에 대한 간단한 소개 후, ChatGPT를 사용하여 프롬프트를 생성하는 방법을 예시로 소개합니다. 특히 영어에 약한 동양인으로서, ChatGPT로 프롬프트 작성법은 필수적이라고 생각합니다.

다만,  이 글을 읽어보기에 앞서, 프롬프트에 들어가면 좋은 키워드 등의 일반적인 프롬프트 작성법에 관한 글 읽어 보시면 이 글을 이해하는데 도움이 될 수 있습니다.

개요

스테이블 디퓨전을 사용해서 원하는 이미지를 생성하려면, 고 품질의 프롬프트가 필수입니다. 하지만, 영어가 딸리는 동양인으로서 고품질 프롬프트를 만드는 것은 쉽지 않습니다. 저도 대부분 civitai.com 등 인공지능 이미지 공유사이트에 올려진 프롬프트를 약간 고쳐서 사용하는 것이 대부분입니다.

그런데 ChatGPT를 사용하면 .괜찮은 프롬프트를 만들 수 있다는데 정말 가능할까요? 예. 가능합니다. 약간 특별한 방법이 필요하긴 하지만요. 일단 사용해보면 결과가 깜짝 놀랄만 할 겁니다. 

ChatGPT란? 

ChatGPT는 2022년 11월 Open AI에서 GPT-3.5를 기반으로 제작, 공개한 챗봇입니다. GPT-3는 인터넷상의 수많은 단어들로 구성된 문장을 사용하여 학습된 대형언어모델(LLM, Large Language Model)입니다. 학습한 데이터를 사람이 읽는다면 수천년이 걸린다고 하죠.

그 결과 ChatGPT는 방대한 양의 인간의 지식을 보유하고 있습니다. 그래서 에세이, 시, 소설 외에도 컴퓨터 프로그램 코드도 잘 생성합니다. 제가 요즘 Python 프로그래밍에 취미를 붙이고 있는데, 정말 ChatGPT가 없었으면 일찍 포기했을 거라는 생각이 들 정도입니다.

ChatGPT가 Stable Diffusion에 대해서 아는가?

모릅니다. ChatGPT 가 학습한 데이터는 2021년 9월 이전에 올려진 인터넷상의 문장으로 학습했다고 합니다. 따라서 2022년 10월에 공개된 스테이블 디퓨전에 대해 알리가 없는 거죠. ChatGPT에 "스테이블 디퓨전이 뭐야?"라고 물어 봤습니다.

스테이블 디퓨전은 인공지능 분야에서 사용되는 기술 중 하나입니다. 이 기술은 GPT와 같은 대형 언어 모델의 성능을 개선하기 위해 제안되었습니다.

GPT는 기본적으로 순차적인 텍스트를 입력으로 받아 순차적인 텍스트를 출력으로 생성합니다. 그러나 긴 문장이나 긴 문서의 경우, 이러한 순차적인 접근은 정보의 손실이나 일관성의 부재로 이어질 수 있습니다. 스테이블 디퓨전은 이 문제를 해결하기 위해 도입된 기술로, 텍스트 입력과 테이블 형식의 데이터를 함께 활용하여 더 정확하고 일관된 결과를 생성하는 것을 목표로 합니다. .... (이하 생략) ...

우리가 아는 이미지 생성형 인공지능인 스테이블 디퓨전과는 다르죠. 대형언어모델의 성능을 개선하기 위한 기술.... 이라니 맞는지 아닌지 아리송합니다마만, 저는 거짓말쪽에 걸고 싶습니다. ChatGPT의 거짓말 지어내기 실력은 수준급이죠. ㅎㅎㅎ

그런데, ChatGPT에게 "DALL E"가 뭐냐고 물어보면 OpenAI에서 개발한 이미지 생성 AI라고 비교적 정확하게 대답해줍니다. DALL E는 2021년 1월에 공개되었거든요. 그렇다보니 프롬프트가 뭔지에 대해서도 알고 있습니다.

프롬프트는 "인공지능 모델에게 작업을 지시하거나 원하는 결과를 얻기 위해 제공하는 텍스트 조각 또는 문장"이며, "프롬프트의 정확성과 명확성은 모델의 출력에 큰 영향을 미칠 수 있습니다. 잘 구성된 프롬프트는 모델의 생성 결과를 개선하고 원하는 결과를 얻는 데 도움을 줄 수 있습니다. 따라서 프롬프트 작성에 주의를 기울이는 것이 중요"하다며 비교적 정확한 답변을 해줍니다. 이때문에 우리는 ChatGPT를 사용해 프롬프트 작성에 도움을 받을 수 있는 겁니다.

ChatGPT 사용법

사용하는 방법은 간단합니다. 그냥 chat.openai.com에 접속해서 가입을 한 후, 화면 아래쪽에 보이는 입력창에 아무 말이나 입력하기만 하면 됩니다. 그러면 그에 대한 답변을 해줍니다.

ChatGPT 화면
ChatGPT 화면

구글과 같은 검색 엔진과 가장 큰 차이는 ChatGPT가 이전 대화를 인식한다는 것입니다. 이전 대화를 기반으로 대화를 이어갈 수 있기 때문에 질문 답변의 내용을 수정도 할 수 있습니다. 

무(無)에서 프롬프트 생성하기

먼저 제가 테스트해 본 방법을 보여드리겠습니다. 볼드체로 적은 건 제가 입력한 것이고, 인용문 안에 있는 것은 ChatGPT의 답변입니다. 흐름을 보여드리기 위해서 아무런 편집도 하지 않고 그대로 실었습니다.

- 인공지능을 이용해 20대 여성의 초상화 스타일의 이미지를 생성하는 프롬프트를 부탁해.

제공해 드릴 수 있습니다. 다음은 20대 여성의 초상화 스타일의 이미지를 생성하는 프롬프트입니다:

"20대 여성의 초상화 스타일의 이미지를 생성해주세요. 주인공은 귀여운 미소를 지으며 카메라 앞에서 자연스럽게 포즈를 취하고 있습니다. 그녀의 피부는 맑고 아름답게 빛나며, 긴 갈색 머리카락이 부드럽게 흐르고 있습니다. 그녀는 매력적인 눈동자와 선명한 눈썹을 가지고 있으며, 볼에는 약간의 청결한 홍조가 돌고 있습니다. 옷은 현대적이고 세련된 스타일로, 파스텔 톤의 블라우스와 슬림한 청바지를 착용하고 있습니다. 배경은 심플하면서도 부드러운 톤의 벽이며, 조명은 주인공의 아름다움을 더욱 강조하고 있습니다. 이 프롬프트를 활용하여 20대 여성의 초상화 스타일의 이미지를 생성해주세요."

- 영어로 그리고 짧막한 단어로 구성해줘.

Sure, here's a prompt in English using concise language:

"Generate a portrait-style image of a 20-something woman. She has a cute smile, poses naturally in front of the camera. Her skin is clear and radiant, with long flowing brown hair. She has captivating eyes with defined eyebrows, and a subtle rosy blush on her cheeks. She wears modern and stylish attire, a pastel-toned blouse with slim jeans. The background is a soft-toned, simple wall, with lighting that enhances her beauty. Create an image that embodies the portrait style of a 20-something woman."

- 짧은 문장이 아니라, 주어 동사 빼고 문구로 만들어줘.

미소 짓고 있는 20대 여성 초상화. 맑고 빛나는 피부, 긴 갈색 머리카락, 매력적인 눈동자와 선명한 눈썹. 청결한 홍조와 현대적인 스타일의 옷차림. 심플한 배경과 아름다운 조명.

- 좋아. 영어로 부탁해

A portrait of a smiling woman in her 20s. Clear and radiant skin, long brown hair, captivating eyes with defined eyebrows. A subtle rosy blush and modern attire. Simple background and beautiful lighting.

- 여기에 조명관련 키워드를 추가해줘.

A portrait of a smiling woman in her 20s. Clear and radiant skin, long brown hair, captivating eyes with defined eyebrows. Soft, flattering lighting accentuates her features. A subtle rosy blush and modern attire. Simple background with gentle illumination.

- 클럽에 있는 여성으로 내용을 수정해줘

A portrait of a woman in her 20s at a club. She's smiling, with clear and radiant skin, long brown hair, and captivating eyes with defined eyebrows. Vibrant club lighting highlights her features. She wears stylish attire that suits the club atmosphere. The background is dynamic, reflecting the club ambiance with colorful lights and energetic atmosphere.

- 주어 동사 없는 문구로 수정해줘

20대 여성의 클럽 초상화. 활기찬 미소, 맑고 빛나는 피부, 긴 갈색 머리카락, 매력적인 눈동자와 선명한 눈썹. 클럽의 환한 조명으로 특징을 부각시킵니다. 세련된 복장은 클럽 분위기와 어울립니다. 배경은 다이내믹하며, 화려한 조명과 에너지 넘치는 분위기를 반영합니다.

- 영어로

A club portrait of a woman in her 20s. Vibrant smile, clear and radiant skin, long brown hair, captivating eyes with defined eyebrows. Accentuated by lively club lighting. Stylish attire that complements the club ambiance. The background is dynamic, reflecting the energetic atmosphere with colorful lights.

이렇게 생성된 프롬프트를 사용해서 이미지를 생성해 보았습니다. 아래는 설정입니다.

모델: ChilloutMix
부정적 프롬프트: ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, extra limbs, disfigured, deformed, body out of frame, bad anatomy, watermark, signature, cut off, low contrast, underexposed, overexposed, bad art, beginner, amateur, distorted face 
샘플러: DPM++ 2M Karras
샘플링 스텝: 25
CFG스테일: 7
이미지 크기: 512 x 768

이대로 생성했더니 너무 헐벗은 모습이 많이 나와서 "skirt"를 하나 추가해주고 생성한 결과입니다.

위에서는 여러번에 걸쳐 수정했지만, 아래와 같이 입력하면 거의 한번에 원하는 프롬프트가 만들어집니다. 종종 이용할 것 같네요.

입력: 꽃으로 장식한 젊은 여자의 그래픽, 알폰스 무하 스타일의 그래픽을 주어와 동사가 없는 문구로 영어로 프롬프트를 만들어줘
결과: A young woman adorned with flower motifs in a graphic inspired by the style of Alphonse Mucha. Intricate linework and decorative elements bring the artwork to life, capturing the elegance and grace of the Art Nouveau era. 

이 방법에 대한 생각

이상에서 보시는 것처럼, 프롬프트를 생성하려고 시도하면, 자꾸 한국말로 생성하려는 경향이 있습니다. 이는 질문을 한글로 했기 때문으로, 물론 영어로 입력하면 좀 더 좋은 결과물을 얻을 가능성이 있지만, 일부러 한국말로 입력했습니다. 

또한 일반적인 프롬프트 형태가 아닌, 짧은 문장으로 구성된 프롬프트를 만들어주는 경향이 있습니다. 이대로 사용해도 무방하지만, 문장형태로 하면 쓸데없는 단어들이 많이 들어가기 때문에 "주어 동사 없는 문구"로 여러번 바꾼 모습을 보실 수 있을 겁니다.

최종적으로 나온 프롬프트를 보면, 아직도 문장이 남아있는 부분이 있는 등 완벽하지는 않지만, 적어도 제가 직접 영어로 적어가는 것 보다는 훨씬 나은 것 같습니다. 

또 다른 방법으로 한글로 생각나는 대로 적은 후, "DeepL"서비스를 이용해 번역하는 방법도 있지만, 아무래도 제 상상력의 한계에 갖힐 수 밖에 없기 때문에 ChatGPT를 사용하는 방법이 훨씬 나은 것 같네요.

또한, 저는 처음에 프롬프트의 내용을 대충 지정했지만, OpenArt 프롬프트 북에 나온 다음과 같은 질문 목록을 참고하면서 기본적인 한글 프롬프트를 준비한 후, ChatGPT에게 요청하는 게 좋지 않을까 싶네요.

  1. 사진인가 그림인가? (photo or painting)
  2. 주제는 사람? 동물? 풍경?(person or animal or landscape)
  3. 추가하고 싶은 요소
    • 특별한 조명 : 부드러운/은은한/링 조명/네온(soft, ambient, ring light, neon)
    • 환경: 실내, 야외, 물속, 우주 (indoor, outdoor, underwater, in space)
    • 색상 조합 : 생생한/어두운/파스텔(vibrant, dark, pastel)
    • 시점 : 전면, 상부, 측면(front, overhead, side)
    • 배경 : 단색, 성운, 숲(solid color, nebula, forest)
  4. 특별한 아트 스타일? 3D 렌더링, 지브리 스튜디오, 영화 포스터(3D render, studio ghibli, movie poster)
  5. 사진 종류? 마크로 렌즈, 망원렌즈(macro, telephoto)

기존 프롬프트로부터 더 나은 프롬프트 생성하기

위에서 보여드린 방법은 그냥 적당히 상상해서 프롬프트를 생성하는 방법입니다. 하지만, 이미 가지고 있는 프롬프트가 뭔가 부족해서 더 좋은 프롬프트로 고치고 싶은 경우가 있습니다. 예를 들면, AI 이미지 공유 사이트에서 괜찮은 프롬프트를 가져온 후, 더 괜찮은 무언가를 추가하고 싶은 경우입니다.

중요 사항

스테이블 디퓨전으로부터 고품질의 프롬프트를 이끌어내려면 다음과 같은 세가지 기법을 기억하시는 게 좋습니다.

  • 이미지 스타일을 명시할 것 : 물론 이것은 기본입니다. 맨 처음에 어떤 이미지를 생성할 것인지 구체적으로, 예를 들면 "사실적인 근접 사진 일러스트레이션"과 같이 지정하는 게 필요합니다.
  • 피사체 고정 : 이 글에서는 피사체를 "Audrey Hepburn"으로 고정시킵니다. 제가 물론  오드리 헵번님을 좋아하기 때문입니다. 이런 유명인의 이름은 강력한 키워드가 됩니다. 얼굴 뿐만아니라, 스타일에도 강력한 영향을 미칩니다. 만약 피사체를 고정하지 않으면, ChatGPT는 프롬프트마다 다른 스타일을 사용할 수 있습니다. 
  • 예제 프롬프트를 제공할 것: 고품질의 프롬프트를 생성할 때 가장 중요한 사항입니다. 주어진 예제 프롬프트를 기반으로 새로운 프롬프트를 제공하게 됩니다. 

이러한 점을 고려해 ChatGPT에 다음과 같이 입력합니다. 

아래는 인공지능 text-to-image 방식으로 Audrey Hepburn의 사실적인 근접 일러스트레이션을 만들어내는 프롬프트야. 
– portrait of beautiful happy young Audrey Hepburn, ethereal, realistic anime, trending on pixiv, detailed, clean lines, sharp lines, crisp lines, award winning illustration, masterpiece, 4k, eugene de blaas and ross tran, vibrant color scheme, intricately detailed
– alberto seveso and geo2099 style, A highly detailed and hyper realistic portrait of a gorgeous young Audrey Hepburn, trending on artstation, butterflies, floral, sharp focus, studio photo, intricate details, highly detailed, by Tvera and wlop and artgerm

다른 예제를 부탁해

아래는 두 가지 다른 예제를 제시합니다:

"Sunset at a serene beach, with palm trees swaying gently in the breeze, vibrant colors, realistic painting, impressionist style, trending on Instagram, soft brushstrokes, peaceful atmosphere, by Monet and Van Gogh."

"A futuristic cityscape at night, towering skyscrapers illuminated by neon lights, cyberpunk aesthetic, detailed and intricate architecture, trending on DeviantArt, dynamic composition, vibrant color palette, by Beeple and Simon Stalenhag."

Audrey Hepburn의 사실적인 근접 일러스트레이션을 만들어내는 다른 예제를 부탁해

"Graceful Audrey Hepburn in a classic black dress, captured in a realistic graphite drawing, trending on Behance, fine details, delicate shading, timeless elegance, by Diego Fazio and Kelvin Okafor, impeccable likeness, gallery-worthy masterpiece."

다른 예제 하나 더 부탁해

"Captivating Audrey Hepburn in a vibrant oil painting, capturing her iconic smile and expressive eyes, trending on ArtStation, rich brushwork, luminous colors, masterful blending, by Leonid Afremov and Jeremy Lipking, emotionally evocative, gallery showstopper."

중간에 다른 길로 새서, Audrey Hepburn 을 다시 넣어서 생성하라고 했습니다.

프롬프트들을 비교해 보겠습니다. 아래는 예제로 넣어준 프롬프트 중 하나입니다.

모델: Realistic Vision v2.0
프롬프트: alberto seveso and geo2099 style, A highly detailed and hyper realistic portrait of a gorgeous young Audrey Hepburn, trending on artstation, butterflies, floral, sharp focus, studio photo, intricate details, highly detailed, by Tvera and wlop and artgerm 
샘플러: DPM++ 2M Karras
샘플링 스텝: 25
CFG스테일: 7
이미지 크기: 512 x 768

아래는 결과입니다. 이걸로도 충분히 멋지네요.

다음은 ChatGPT가 생성해준 첫번째 프롬프트입니다. 다른 조건은 동일합니다. 그런데... 흑백사진이라고 지정하지 않았는데도 흑백사진만 나왔네요. 흑백사진을 주로 촬영한 작가 이름(Diego Fazio, Kelvin Okafor)이 영향을 준 듯 합니다.

프롬프트: Graceful Audrey Hepburn in a classic black dress, captured in a realistic graphite drawing, trending on Behance, fine details, delicate shading, timeless elegance, by Diego Fazio and Kelvin Okafor, impeccable likeness, gallery-worthy masterpiece. 

다음 ChatGPT가 제공한 두번째 프롬프트입니다. 다른 조건은 동일합니다. 원래 원하던 스타일은 아니지만, 제가 생각하지 못했던 새로운 스타일로 만들어줬네요. 아주 기쁩니다.ㅎㅎㅎ

프롬프트: Captivating Audrey Hepburn in a vibrant oil painting, capturing her iconic smile and expressive eyes, trending on ArtStation, rich brushwork, luminous colors, masterful blending, by Leonid Afremov and Jeremy Lipking, emotionally evocative, gallery showstopper

다른 예제: 전신 일러스트레이션

이번엔 원본 글에 있는 그대로 보여드리겠습니다.

Examples of high quality prompt for stunning photorealistic full body illustration of ana de armas for text-to-image models (Stable Diffusion, midjourney or Dalle2) are

  • full body portrait of beautiful happy young ana de armas, ethereal, realistic anime, trending on pixiv, detailed, clean lines, sharp lines, crisp lines, award winning illustration, masterpiece, 4k, eugene de blaas and ross tran, vibrant color scheme, intricately detailed
  • full body portrait of a gorgeous young ana de armas, A highly detailed and hyper realistic lisa frank, trending on artstation, butterflies, floral, sharp focus, studio photo, intricate details, highly detailed, by Tvera and wlop and artgerm, alberto seveso and geo2099 style,

Give me more examples

ChatGPT가 생성해준 답은 총 4가지입니다. 각각에 대해 이미지를 생성해 보겠습니다. 그런데... 역시 한글로 입력할 때보다 영어로 입력할 때가 더 좋은 품질이 나오네요. 여기에 있는 입력내용을 사용해서 프롬프트를 만드는 걸 적극 고려해 보는 게 좋겠다 싶습니다.

모델: Realistic Vision v2.0
프롬프트: A mesmerizing full body portrait of Ana de Armas, rendered in a hyper-realistic style with impeccable attention to detail. The illustration is trending on Behance, showcasing a perfect blend of elegance and contemporary flair. Created by renowned artists like Audrey Kawasaki and Greg 'Craola' Simkins, this masterpiece boasts lifelike textures, intricate patterns, and a captivating color palette

두 번째:

프롬프트: An ethereal and enchanting full body illustration of Ana de Armas, reminiscent of a Renaissance masterpiece. The artwork, created in the style of Leonardo da Vinci and Rembrandt, showcases Ana's grace and beauty with intricate lighting and subtle brushwork. This award-winning piece is currently making waves on art blogs and social media platforms, thanks to its stunning realism and emotional depth 

세번째:

프롬프트: A breathtaking full body portrait of Ana de Armas, executed in a photorealistic style with a touch of surrealism. The illustration, trending on DeviantArt, combines the talents of artists like Alex Grey and Audrey Kawasaki, resulting in a visually striking composition. The artwork features Ana surrounded by an otherworldly landscape, incorporating elements like flowing water, celestial bodies, and vibrant flora, creating a dreamlike atmosphere

네번째:

프롬프트: A stunning full body illustration of Ana de Armas, blending the realms of fantasy and reality. This piece, inspired by the works of Boris Vallejo and Julie Bell, presents Ana as a powerful and alluring warrior princess. The attention to anatomical accuracy, intricate armor design, and dynamic pose make this artwork a true standout, earning accolades as an exceptional example of the genre 

이상입니다. 저도 가끔 사용해봤습니다만, 앞으로는 프롬프트 작성할 때 보다 적극적으로 ChatGPT를 사용해야 겠다는 생각이 드네요. 

===

이 글은 Stable-diffusion-art.com의 글을 일부 참조해서, 제가 사용했던 경험을 기반으로 작성하였습니다. 

민, 푸른하늘