이미 알고계신 분도 계시겠지만, 정보 공유차 정리해봅니다.
webui를 사용하시다 보면 prompt의 우상단에 "XX / 75" 와 같이 숫자가 표시되는 것을 볼 수 있습니다.
text를 입력하면 token의 갯수로 표시해주는 부분입니다.
영어 문장을 입력하면 token이라고 불리는 단위 원소로 나뉘어지고, CLIP이라 불리는 모델의 입력으로 사용되어 이미지 생성에 사용되게 됩니다.
예를 들면 "shinyunbok anime" 와 같은 문장이 기계가 알아듣기 쉬운 "5664, 14976, 15289, 6469" 라는 4개의 token으로 바뀌게 됩니다. 여기서 이 CLIP 모델의 입력이 77개의 숫자까지만 받아들이도록 설계되어있고, webui에서는 이 부분이 75개의 제한으로 나타나 있는 것입니다.
출처 : https://huggingface.co/blog/stable_diffusion
그렇다면 그 한계를 넘어서 입력이 불가능한가에 대한 질문에 대한 답은 webui에서는 현재는 가능하다입니다. 한때 제한을 둔 적도 있었지만, 지금은 아래와 같이 자동으로 숫자가 늘어나는 것을 볼 수 있습니다. 이해를 돕기 위해 Metallica의 명곡 Until It Sleeps 의 가사를 넣었습니다.
당시 관련 논의는 아래 Pull Request에 상세하게 기록되어있습니다.
https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/2138
문제는 이 구현이 어떻게 동작하는지 이해하지 않고 그냥 사용할 경우에 발생합니다. 위의 극단적인 예를 사용했습니다.
Parameter: shinyunbok anime, (exceptional, best aesthetic, new, newest, best quality, masterpiece, extremely detailed, waifu:1.2), Where do I take this pain of mine, I run but it stays right by my side, So tear me open and pour me out, There's things inside that scream and shout, And the pain still hates me, So hold me until it sleeps, Just like the curse, just like the stray, You feed it once and now it stays, Now, it stays, So tear me open but beware, There's things inside without a care, And the dirt still stains me, So wash me until I'm clean, It grips you so hold me, It stains you so hold me yeah, It hates you so hold me yeah, It holds you so hold me, Until it sleeps Until it sleeps, Until it sleeps, So tell me why you've chosen me, Don't want your grip, don't want your greed, Don't want it, I'll tear me open, make you gone, No more can you hurt anyone, And the fear still shakes me, So hold me, until it sleeps, It grips you so hold me, It stains you so hold me, It hates you so hold me yeah, It holds you, Holds you, holds you, Until it sleeps Until it sleeps, Until it sleeps Until it sleeps, until it sleeps, I don't want it, I don't want it, Want it, want it, want it, want it, no, woah-woah, So tear me open but beware, There's things inside without a care, And the dirt still stains me, So wash me 'til I'm clean, I'll tear me open, make you gone, No longer will you hurt anyone, And the hate still shapes me
뭔가 신윤복 화백의 그림체도 아니고, "extreamly detailed"나 "best quality"도 아닌 것 같습니다.
아래는 동일한 Seed에 75 token에 맞춰서 그림을 다시 생성한 결과입니다.
Parameter: shinyunbok anime, (exceptional, best aesthetic, new, newest, best quality, masterpiece, extremely detailed, waifu:1.2), Where do I take this pain of mine, I run but it stays right by my side, So tear me open and pour me out, There's things inside that scream and shout, And the pain still hates me, So hold me until it sleeps
이유는 앞서 언급한 Pull Request에 적혀있는데, 75 token을 넘어설 경우에는 다시 새로운 token vector를 생성해서 CLIP에 따로따로 집어넣게 구현되어있습니다. 때문에 "shinyunbok anime, ~" 라는 문장과 그 이후에 따라오는 "Just like the curse, ~"라는 문장이 별도로 처리되게 되고, 다음 처리에서 앞부분에 언급되는 "Just like~"가 강하게 처리되어 기대했던 효과 "shinyunbok~"이 약해지는 효과로 나타난 것입니다.
이를 바탕으로, 굳이 앞서 쓰려했던 긴 prompt를 의도했던대로 다시 적는다면 아래와 같이 쓰는 것이 올바른 것이 되겠습니다.
Parameters: shinyunbok anime, (exceptional, best aesthetic, new, newest, best quality, masterpiece, extremely detailed, waifu:1.2), Where do I take this pain of mine, I run but it stays right by my side, So tear me open and pour me out, There's things inside that scream and shout, And the pain still hates me, So hold me until it sleeps BREAK
shinyunbok anime, (exceptional, best aesthetic, new, newest, best quality, masterpiece, extremely detailed, waifu:1.2), Just like the curse, just like the stray, You feed it once and now it stays, Now, it stays, So tear me open but beware, There's things inside without a care, And the dirt still stains me BREAK
shinyunbok anime, (exceptional, best aesthetic, new, newest, best quality, masterpiece, extremely detailed, waifu:1.2), So wash me until I'm clean, It grips you so hold me, It stains you so hold me yeah, It hates you so hold me yeah, It holds you so hold me, Until it sleeps Until it sleeps, Until it sleeps BREAK
shinyunbok anime, (exceptional, best aesthetic, new, newest, best quality, masterpiece, extremely detailed, waifu:1.2), So tell me why you've chosen me, Don't want your grip, don't want your greed, Don't want it, I'll tear me open, make you gone, No more can you hurt anyone, And the fear still shakes me BREAK
shinyunbok anime, (exceptional, best aesthetic, new, newest, best quality, masterpiece, extremely detailed, waifu:1.2), So hold me, until it sleeps, It grips you so hold me, It stains you so hold me, It hates you so hold me yeah, It holds you, Holds you, holds you, Until it sleeps Until it sleeps BREAK
shinyunbok anime, (exceptional, best aesthetic, new, newest, best quality, masterpiece, extremely detailed, waifu:1.2), Until it sleeps Until it sleeps, until it sleeps, I don't want it, I don't want it, Want it, want it, want it, want it, no, woah-woah, So tear me open but beware BREAK
shinyunbok anime, (exceptional, best aesthetic, new, newest, best quality, masterpiece, extremely detailed, waifu:1.2), There's things inside without a care, And the dirt still stains me, So wash me 'til I'm clean, I'll tear me open, make you gone, No longer will you hurt anyone, And the hate still shapes me
"BREAK"는 webui에서 사용하는 특수 예약어로, 75 token이 아직 다 채워지지 않은 상태에서 다음 입력으로 넘어가도록 만드는 기능을 가지고 있습니다. 75 token으로 생성한 결과와 비교하면 차이는 미미합니다만, 75 token 단위로 나누지 않았을 때와 비교하면 원래 의도했던 그림체로 돌아온 것을 확인할 수 있습니다.
감사합니다!!! BREAK
감사합니다!!!