Scribble at 2026-03-31 20:48:25 Last modified: unmodified

添付画像

テーマを与えて、それに応じた FLUX.2 用のプロンプトを吐き出すシステムを作ってみた。これまで LM Studio で手動で作らせるか、あるいはテーマを1行ずつ書いたテキスト・ファイルを LM Studio のサーバへ Python で投げて変換してもらったテキスト・ファイルを得るという方法を使ってきたり、Z-Image Engineer というプロンプト・エンジニアリング専用のモデルを使ったりしてきたのだが、今回は PHP で簡単にしてみた。

まず、Ollama をインストールして、これをサーバとして使う。起動して Qwen3 をロードしておくと、サーバに PHP の curl() 関数でリクエストを投げてレスポンスを得るというだけのことだ。得たレスポンスは JSON なので、これをデコードしてプレーンな英文だけのプロンプトとして吐き出せば、上のようになる。元の「テーマ」として設定したのは "Osaka" という言葉一つだけだが、そこから Qwen3 が適当に想像力を働かせてプロンプトを吐き出すわけである。上の例では、

"A neon-drenched Osaka skyline at twilight pulses with electric-blue skyscrapers and glowing cherry-blossom motifs, their reflections shimmering in the rain-slicked streets below as a crowd of西装-clad businessmen and scantily clad geisha navigate the labyrinthine alleys, their silhouettes blurred by the shallow depth of field captured through a 35mm f/1.4 lens, the sharp focus landing on a woman in a blood-red kimono, her lips parted in a silent scream as she grips a sword hilt, her eyes locked with a man in a black trench coat who grips her wrist, their bodies angled diagonally across the frame, the background a riot of flickering signage and steam rising from street vendors’ stalls, the air thick with the scent of grilled skewers and the hum of a thousand conversations, the light a chiaroscuro of warm amber and icy cyan, the shadows pooling around the couple’s feet while the city’s glow bleeds into the clouds, the atmosphere charged with tension as the camera lingers on the woman’s trembling fingers and the man’s smirking lips, the lens flaring slightly as a sudden flash from a nearby shrine’s lantern bathes the scene in a sudden burst of golden light, the entire composition saturated with hyper-detailed textures of wet concrete, metallic signs, and the glossy sheen of raindrops, the chromatic nuances shifting between the cool blues of the skyline and the warm oranges of the streetlights, the shot framed in a 2.35:1 aspect ratio, the movement implied by the shallow focus and the dynamic interplay of light and shadow, the moment suspended between chaos and control."(夕暮れ時のネオンに照らされた大阪のスカイラインは、エレクトリックブルーの摩天楼と輝く桜のモチーフで脈動し、雨に濡れた路面にその反射が揺らめいている。西装のビジネスマンと薄着の芸妓たちが迷路のような路地を歩き回り、35mm f/1.4レンズで捉えられた浅い被写界深度によってシルエットがぼやけている。血のように赤い着物を着た女性にピントが合い、彼女は無言の叫びを上げるように唇を開き、刀の柄を握りしめている。彼女の目は、彼女の手首を掴む黒いトレンチコートを着た男と絡み合っている。二人の体はフレームを斜めに横切り、背景にはちらつく看板と露店の屋台から立ち上る湯気が溢れ、空気は焼き串の匂いと無数の会話のざわめきで満ちている。光は温かみのある琥珀色と氷のようなシアンの明暗対比で、影はカップルの足元に溜まっている。街の輝きが雲に溶け込み、緊張感が漂う中、カメラは女性の震える指と男性のニヤリとした唇を捉え、近くの神社の提灯から突然閃光が放たれ、シーン全体が金色の光に包まれ、レンズがわずかにフレアする。構図全体は、濡れたコンクリート、金属製の看板、雨粒の光沢といった非常に詳細な質感で満たされ、色彩のニュアンスはスカイラインのクールな青と街灯の温かいオレンジの間で変化し、ショットは2.35:1のアスペクト比でフレームされ、浅い被写界深度と光と影のダイナミックな相互作用によって動きが示唆され、その瞬間は混沌と制御の間で宙吊りになっている。)

という、よく分からない情景を描いているが、試しに FLUX.2 Klein 9B で使ってみよう。

  1. もっと新しいノート <<
  2. >> もっと古いノート

冒頭に戻る