[AI]Ollama + Flux2

๐Ÿ‘‰๐Ÿป flux๋Š” ์ด๋ฏธ์ง€ ์ƒ์„ฑ AI ์ž…๋‹ˆ๋‹ค.
Flux is an image generation AI.

๐Ÿ‘‰๐Ÿป ๋กœ์ปฌํ™˜๊ฒฝ(๋งฅ๋ถ ํ™˜๊ฒฝ)์—์„œ ์ด๋ฏธ์ง€ ์ƒ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์„ค๋ช…์ž…๋‹ˆ๋‹ค.
This is an explanation of how to create an image in a local environment (MacBook environment).

๐Ÿ‘‰๐Ÿป์„ค์น˜ / Install

โœ”๏ธ flux๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ollama๊ฐ€ ์„ค์น˜๋˜์–ด์•ผํ•ฉ๋‹ˆ๋‹ค. ์ด์ „ํฌ์ŠคํŠธ๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”
To use Flux, Ollama must be installed. Please refer to the previous post.

โœ”๏ธ flux๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ„ฐ๋ฏธ๋„์—์„œ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.
Install flux in the terminal as follows.

ollama run x/flux2-klein

โœ”๏ธ ์œ„์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ ์„ค์น˜๊ฐ€ ์ง„ํ–‰๋ฉ๋‹ˆ๋‹ค.
If you run the command above, the installation will proceed as shown below.


MacBookAir .ollama % ollama run x/flux2-klein
pulling manifest 
pulling model: 100% โ–•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ– 5.7 GB                         
writing manifest 
success 
>>> Describe an image to generate (/help for commands)

๐Ÿ‘‰๐Ÿป ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ด๋ด…๋‹ˆ๋‹ค. ํ„ฐ๋ฏธ๋„์—์„œ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.
Let’s create an image. This is how to create an image in the terminal.

โœ”๏ธ ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ž…๋ ฅํ–ˆ์Šต๋‹ˆ๋‹ค.
I entered the prompt as follows.

— ์•„๋ฆ„๋‹ค์šด ์„œ์šธ ์•ผ๊ฒฝ, ํ•œ๊ฐ• ๋‹ค๋ฆฌ์™€ ๋ถˆ๊ฝƒ๋†€์ด, photorealistic
(Beautiful night view of Seoul, Han River bridges and fireworks,photorealistic)

MacBookAir .ollama % ollama run x/flux2-klein
>>> ์•„๋ฆ„๋‹ค์šด ์„œ์šธ ์•ผ๊ฒฝ, ํ•œ๊ฐ• ๋‹ค๋ฆฌ์™€ ๋ถˆ๊ฝƒ๋†€์ด, photorealistic
Image saved to: ------photorealistic-20260612-105824.png

>>> Describe an image to generate (/help for commands)

โœ”๏ธ ๊ทธ๋Ÿฌ๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ด๋ฏธ์ง€๊ฐ€ ์ƒ์„ฑ๋œ ๊ฒƒ์„ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
Then you can confirm that the image has been generated as follows.

–์•„๋ž˜์™€ ๊ฐ™์ด ์ด๋ฏธ์ง€ ์ƒ์„ฑ๋œ๊ฒฝ์šฐ ์ด๋ฆ„๋ฐ”๊พธ๋ ค๋ฉด mv ./imagename.png newimagename.png ์ด๋ ‡๊ฒŒ ๋ฐ”๊พธ๋ฉด๋ฉ๋‹ˆ๋‹ค.
If the image was created as shown below, to rename it, you can do so by changing it like this: mv ./imagename.png newimagename.png.

MacBookAir .ollama % ls -al
total 3848
-rw-r--r--   1 user  staff  1952015  6์›” 1 10:58 ------photorealistic-20260612-105824.png
drwxr-xr-x   9 user  staff      288  6์›” 1 12:58 .
drwxr-x---+ 61 user  staff     1952  6์›” 1 12:58 ..
-rw-------   1 user  staff      170  6์›” 1 12:58 history
-rw-------@  1 user  staff      387  6์›” 1 12:58 id_ed25519
-rw-r--r--@  1 user  staff       81  6์›” 1 12:58 id_ed25519.pub
drwxr-xr-x@ 14 user  staff      448  6์›” 1 12:58 logs
drwxr-xr-x   4 user  staff      128  6์›” 1 12:58 models
-rw-r--r--   1 user  staff       35  6์›” 1 12:58 server.json

๐Ÿ‘‰๐Ÿป ์ถ”๊ฐ€๋กœ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ด ๋ด…๋‹ˆ๋‹ค.
Let’s try creating an additional image.

โœ”๏ธ ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ž…๋ ฅํ–ˆ์Šต๋‹ˆ๋‹ค.
I entered the prompt as follows.

โœ”๏ธ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์•„๋ž˜์ฒ˜๋Ÿผ ์ž…๋ ฅํ•œ ๊ฒฝ์šฐ ์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ ์ž…๋‹ˆ๋‹ค.
This is the image generated when the prompt was entered as shown below.

–Full body shot of Johnny Silverhand, Keanu Reeves, standing confidently, cybernetic arm visible, holding pistol, leather jacket and boots, Night City alley with heavy rain and neon signs, cyberpunk atmosphere, dramatic rim lighting

โœ”๏ธ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์•„๋ž˜์ฒ˜๋Ÿผ ์ž…๋ ฅํ•œ ๊ฒฝ์šฐ ์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ ์ž…๋‹ˆ๋‹ค.
This is the image generated when the prompt was entered as shown below.

— Aloy from Horizon Zero Dawn, exact official game character, young woman with long bright red hair in intricate braids with beads, green eyes, freckles on face, athletic build, wearing Nora Brave outfit with tribal patterns and leather, holding a compound bow, confident and determined expression, Horizon Zero Dawn official game art style, in-game character render, detailed face, sharp textures, post-apocalyptic landscape with tall machines in background, cinematic lighting, high quality 3D render, unreal engine style

โœ”๏ธ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์•„๋ž˜์ฒ˜๋Ÿผ ์ž…๋ ฅํ•œ ๊ฒฝ์šฐ ์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ ์ž…๋‹ˆ๋‹ค.
This is the image generated when the prompt was entered as shown below.

— Kratos from God of War Ragnarok, exact likeness to the reference image, full body standing pose, bald head with prominent red Spartan tattoo across face and scalp,
thick dark beard, calm and slightly relaxed expression, confident but not angry, thoughtful look,
heavily muscled body with white ashen skin covered in scars,
wearing detailed bear fur armor with leather straps and metal pauldrons,
bare chest with red tattoo stripe, thick leather belt,
holding Leviathan Axe casually in his right hand with the axe head pointing down,
powerful yet relaxed imposing stance,
background: beautiful snowy Nordic forest with ancient trees and soft falling snow,
misty atmosphere, dramatic cinematic lighting with soft volumetric light,
pure black background removed,
highly detailed 3D render, official God of War Ragnarok character model style,
sharp textures, cinematic composition, photorealistic game render, masterpiece, best quality

— ์œ„์ฒ˜๋Ÿผ ํ„ฐ๋ฏธ๋„์— ์ž…๋ ฅ๋˜๋Š” ํ”„๋กฌํ”„ํŠธ๊ฐ€ ๋„ˆ๋ฌด ๊ธธ๋ฉด ์งค๋ ค์„œ ์ž…๋ ฅ๋ฉ๋‹ˆ๋‹ค.
As shown above, if the prompt entered into the terminal is too long, it will be cut off.

— ์ด๋Ÿฐ ๊ฒฝ์šฐ ํŒŒ์ผ์— ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ์ด ํŒŒ์ผ์„ ๋ถˆ๋Ÿฌ์˜ค๋ฉด๋ฉ๋‹ˆ๋‹ค.
In this case, you can enter the prompt into the file and load it.

MacBookAir ~ % touch kratos.txt
MacBookAir ~ % nano kratos.txt

# ctrl + 0 ๋กœ ํŒŒ์ผ ์ €์žฅ
# Save file with Ctrl + 0

MacBookAir ~ % ollama run x/flux2-klein "$(cat kratos.txt)"  

โญ๏ธ x/flux2-klein๋Š” ollama ์•ฑ ์—์„œ ์‹คํ–‰์‹œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
x/flux2-klein may cause errors when run in the ollama app.

Leave a Reply