見出し画像

GoogleColaboratoryで画像生成

色々試してわかったこと

・弱々IntelMacでもGoogleColaboratoryを使えばそこそこ生成できる。
・GoogleColaboratoryでPythonを使っているが、codeは探せば落ちてる。
・StableDiffusion diffusersってのを使う。
・diffusersで使えるStableDiffusionのモデルは限られている。
・LoRAっていう拡張機能も使えるらしいがまだわからない。
・GPUをたくさん使えるWindowsが最強らしい。
・プロンプト(入力する文章)と、ネガティブプロンプト(これは生成しないでね。という文章)が大事だが使うモデル次第で生成される画像は制限される。

多分としか書けない知識量

前段の知識が精一杯なのです。多分全然足りてない。
「学習させて特定の顔を生成」と聞くがこれに関しては全然わからないし
GoogleColaboratoryで出来るのかさえはっきりしない。
多分できないと思っている。

生成環境

今のところ
GoogleColaboratory で StableDiffusion diffusersを動かしている。
model_id は "SG161222/Realistic_Vision_V4.0" 色々使ってみたが
今のところ、これが一番良さそう。
Photoshop(beta)で背景の拡張生成と衣服の生成を行っている。

プロンプトとネガティブプロンプト

英語で入力する。
わからないのでchatGPTに書いてもらう。

例えば、
『「画像生成のプロンプトを以下の文章から英語で5例生成してください。「公園で撮影された日本人女性の全身画像を作成する。白いTシャツを着ている。」』とか。

この場合、出力結果は


  1. "Create a full-body image of a Japanese woman taken at the park. She is wearing a white T-shirt."

  2. "Generate a complete picture of a Japanese woman at the park, dressed in a white T-shirt."

  3. "I would like an AI-generated full-length photo of a Japanese woman at the park, sporting a white T-shirt."

  4. "Design an image of a Japanese woman in a white T-shirt, captured at the park."

  5. "Produce a high-quality full-body shot of a Japanese woman wearing a white T-shirt, taken at the park."

これらのプロンプトを使用することで、公園で撮影された日本人女性の全身画像が生成されることを期待します。

ネガティブプロンプトは書いてくれなさそう。
https://civitai.com/ でお気に入りの画像を表示して
そこに書いてあるものを適当にコピーしてくる。

chatGPTにお願いしてると答えてくれないこともあります。
センシティブな内容はダメみたい。
ここの基準は不明。ヌードとか入ってなくてもダメなこともあります。
なぜ?

単純に英訳ならこちら。

chatGPTに書いてもらっていると大体コツはわかってきます。
人物を生成するなら
人物の特徴、場所、立ってるとか座ってるとか。
ポーズについては指定が難しいですが、これも拡張機能にあるらしい。

実際にやってみる

日本人の若い女性。公園に立っている。
英語で
Young Japanese woman standing in a park.
ネガティブプロンプトは
rib cage, monochrome, bad art, bad mirror, ugly face, messed up face, poorly drawn hands, bad hands, bad eyes, Three arms, three legs, bad legs, makeup, photoshop, doll, plastic_doll, silicone, anime, cartoon, fake, filter, airbrush, 3d max, infant, featureless, colorless, impassive, shaders, reflection of a mirror, black-and-white photograph
色々削ったり付け足したりしてもう元の文章はわからない。

3つ生成

この服は無いな
顔が崩壊
こちらも顔は崩壊

で、今さらに
人物の特徴を追加して入力

prompt = "Young Japanese woman.Straight short hair. Her face is small and egg-shaped with a pointed chin. She has a small nose and mouth, and large almond-shaped eyes. standing in a park."
和訳
日本人女性。ストレートのショートヘア。顔は小さく卵型で、あごが尖っている。鼻と口は小さく、アーモンド形の大きな目をしている。

顔の特徴をかくと突然アップ画像。

さらに服装を追加
prompt = "Young Japanese woman. Straight short hair. Her face is small and egg-shaped with a pointed chin. She has a small nose and mouth, and large almond-shaped eyes. She's wearing a plain white t-shirt and shorts. standing in a park."
追加分はShe's wearing a plain white t-shirt and shorts.

さらにlong shotを追加
場所を芝生の公園に変更
in Lawn park

prompt = "Young Japanese woman. Straight short hair. Her face is small and egg-shaped with a pointed chin. She has a small nose and mouth, and large almond-shaped eyes. She's wearing a plain white t-shirt and shorts. long shot. standing in Lawn park."


long shotは効いてなさそうなので
Full body photoに変更

prompt = "Young Japanese woman. Straight short hair. Her face is small and egg-shaped with a pointed chin. She has a small nose and mouth, and large almond-shaped eyes. She's wearing a plain white t-shirt and shorts. Full body photo. standing in Lawn park."


なぜか2人出てくるのでAをつけてみる。
年齢を16歳に指定

prompt = "A Cute 16 year old Japanese girl. Straight short hair. Her face is small and egg-shaped with a pointed chin. She has a small nose and mouth, and large almond-shaped eyes. She's wearing a plain white t-shirt and shorts. Full body photo. standing in Lawn park."


やっぱり2人出てくるので
One 16 year old beautiful and cute Japanese girl.では?

prompt = "One 16 year old beautiful and cute Japanese girl. Straight short hair. Her face is small and egg-shaped with a pointed chin. She has a small nose and mouth, and large almond-shaped eyes. She's wearing a plain white t-shirt and shorts. Full body photo. standing in Lawn park."


ちょっといい感じになってきた。
ある程度プロンプトを決めたら
少しずつ変えながら
あとはガチャ!


今回はこんな感じか?

prompt = "Professionally Photographed. One 15 year old beautiful and cute Japanese girl. Straight short hair. face is small and egg-shaped with a pointed chin. She has a small nose and mouth, pouty lips, and large almond-shaped eyes. wearing a White shirt with collar. standing in Lawn park."

色々変えました。変えても通じない言葉があったりポーズ指定が難しかったりまだまだですが、勉強していきます。

画像生成してフォトショップで加工していきます。
また次の記事で詳しく!

この記事が気に入ったらサポートをしてみませんか?