howto

Running flux locally on a mac

lets get those gpus running

tags
local
llm
flux
osx

I got this new computer and I wanted to get the GPUs running hot!

Lets go!

Install uv and mflux

Go to the uv installation page and follow then instructions.

Then install mflux with python version 3.12

1
  uv tool install -p 3.12 --upgrade mflux

Basic running

I'm passing in -q 4 for the smallest quantizied version. This will download the model from huggingface when it starts up, which will take a while.

30G a while.

1
2
3
4
5
  mflux-generate --model schnell \
                 --prompt "Luxury food photograph" \
                 --steps 2 --seed 2 \
                 -q 4 --output luxury.png \
                 --metadata

Dev model

Install huggingface

1
  brew install huggingface-cli
1
  huggingface-cli login

Then go to

https://huggingface.co/black-forest-labs/FLUX.1-dev

But this model didn't make any good outputs for me, so I stuck with schnell.

Different styles

1
2
3
4
5
  mflux-generate --model schnell \
                   --prompt "women looking pensive, line drawing chinese style" \
                   --steps 10 -q 4 \
                   --seed 2 \
                   --output chinese.png

1
2
3
4
5
    mflux-generate --model schnell \
                   --prompt "connecticut town in spring in the anime style of studio ghibli" \
                   --steps 2 -q 4 \
                   --seed 2 \
                   --output ct.png

1
2
3
4
5
    mflux-generate --model schnell \
                   --prompt "charcoal drawing of an elegant ballerina" \
                   --steps 2 -q 4 \
                   --seed 2 \
                   --output ballerina.png

1
2
3
4
5
    mflux-generate --model schnell \
                   --prompt "detailed architectural diagram of a factory campus that has shipping, processing, assembing and different areas. make it look like a fancy architect drafted up the plans" \
                   --steps 2 -q 4 \
                   --seed 2 \
                   --output plans.png

1
2
3
4
5
    mflux-generate --model schnell \
                   --prompt "cyberpunk kowloon city noodle store in the rain" \
                   --steps 2 -q 4 \
                   --seed 2 \
                   --output noodles.png

lora

Lets combine some post training.

Download the tensors from impressionism-sdxl-pony-flux

1
2
3
4
5
6
7
  mflux-generate --model schnell \
                 --prompt "forest with a lot of undergrowth" \
                 --steps 5 -q 4 \
                 --lora-paths ImpressionismFlux.safetensors \
                 --lora-scales 1.0 --metadata \
                 --height 1024 --width 1024 --seed 2 \
                 --output forest.png

How about monica-bellucci-flux

1
2
3
4
5
6
7
  mflux-generate --model schnell \
               --prompt "1 woman sitting at a cafe laughing" \
               --steps 5 -q 4 \
               --lora-paths Monica_Bellucci_Flux.safetensors \
               --lora-scales 1.0 --metadata \
               --height 1024 --width 1024 --seed 2 \
               --output cafe.png

Or: Amateur Photography

1
2
3
4
5
6
7
  mflux-generate --model schnell \
               --prompt "a man with wild hair holding up handwritten sign that says boo" \
               --steps 5 -q 4 \
               --lora-paths amateurphoto-v6-forcu.safetensors \
               --lora-scales 0.8 --metadata \
               --height 1152 --width 896 --seed 2 \
               --output sign.png

image to image

Lets see if we can swap out the face. Lets first grab a nice image from the internet

Before:

And then pass it from image to image with the monica belluci lora:

1
2
3
4
5
6
7
8
9
  mflux-generate --model schnell \
                 --init-image-path pexels-lance-reis-255748881-19797385.jpg \
                 --init-image-strength 0.3 \
                 --prompt "women looking pensive, grainy and realistic" \
                 --steps 20 -q 4 \
                 --lora-paths Monica_Bellucci_Flux.safetensors \
                 --lora-scales 1.0 --metadata \
                 --height 1500 --width 1200 --seed 2 \
                 --output monica.png

pinokio

YouTube suggested pinokio.computer to do the download, but it didn't really work out of the box. Which is the point of it, that it works out of the box.

The installer didn't work, but I was able to get things working using the source directly.

1
2
3
4
  git clone git@github.com:pinokiocomputer/pinokio.git
  cd pinokio
  npm i
  npm run start

From here you can search for MFlux-webui and play around there. It will download the models again though, so hopefully your internet isn't metered.

One thing that's interesting is that it takes your prompt and puts it through ollama to enhanse. Let do that.

Ollama prompt enhancement

Lets make a nice new Modelfile

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  FROM dolphin-mistral
  SYSTEM "
  # Image Prompt Enhancement System

  ## Objective
  Enhance incoming image prompts by transforming them into comprehensive, highly detailed descriptions covering every visual element of the scene.

  ## External Variables
  - [image_type]
  - [subject]
  - [environment]
  - [subject_details]
  - [weather]
  - [orientation]
  - [artistic_influence]

  ## Internal Variables

  ### Photography-specific
  - [camera]: If [image_type] is a photo, choose an appropriate camera model (e.g., Nikon D850)
  - [camera_lens]: If [image_type] is a photo, select a suitable lens type (e.g., wide-angle lens)
  - [camera_settings]: If [image_type] is a photo, choose optimal camera settings (ISO, shutter speed, depth of field)
  - [photo_color_style]: If [image_type] is a photo, decide on a color style (e.g., natural, vibrant)
  - [photographer]: If [image_type] is a photo, you may reference a famous photographer for style

  ### Art-specific
  - [art_style]: If [image_type] is art, select an art style (e.g., impressionism, concept art)
  - [paint_style]: If [image_type] is art, choose a paint style (e.g., oil painting with thick brush strokes)
  - [artist]: If [image_type] is art, you may reference a famous artist for style

  ### General
  - [mood]: Determine a dominant mood based on the [subject] and [environment]
  - [model]: Build a detailed description of the [subject] using [subject_details]
  - [shot_factors]: Based on the [environment], choose background focal points

  ### Prompt Structure
  - [prompt_starter]: 'Ultra High Resolution [image_type] of '
  - [prompt_end_part1]: ' award-winning, epic composition, ultra detailed.'

  ## Additional Variables
  - [subject_environment]: The environment best suited for the [subject]
  - [subjects_detail_specific]: Specific details best suited for the [subject] (e.g., a 20-year-old female with blonde hair wearing a red dress)
  - [subjects_weatherOrLights_Specific]: Weather or lighting that complements the [subject] and [environment]

  ## Enhancement Process

  1. **Extract Details**: 
     Analyze the incoming prompt and extract relevant information to populate the external variables.

  2. **Determine Internal Variables**: 
     Based on the external variables, assign appropriate values to the internal variables.

  3. **Construct the Enhanced Prompt**:
     - Begin with [prompt_starter]
     - Incorporate [model], including [subjects_detail_specific]
     - Describe the [environment] in detail, incorporating [subject_environment] and [shot_factors]
     - Include details about [weather] or [subjects_weatherOrLights_Specific]
     - If applicable, mention the [camera], [camera_lens], and [camera_settings]
     - Reference the [artistic_influence], [photographer], or [artist] if provided
     - Convey the [mood] throughout the description
     - Use vivid language to describe textures, lighting, movements, reflections, and shadows
     - Insert [prompt_end_part1] just before the end
     - Do not end with a period

  4. **Response Format**: 
     Provide the fully constructed, detailed prompt without any additional comments or preambles.
  "

Then create it:

1
  ollama create imageplus -f Modelfile

Test it:

1
  ollama run imageplus 'Luxury food photograph'
 Ultra High Resolution luxury food photograph of an exquisite meal,
 award-winning, epic composition, ultra detailed. Featuring a
 delectable seafood platter adorned with succulent crab legs, tender
 scallops, and juicy shrimp. The fresh catch is arranged on a sleek
 white marble countertop, surrounded by vibrant seasonal
 vegetables. A pristine slice of seared tuna glistens under the soft
 golden glow of ambient lighting, its crispy edge contrasting with
 its perfectly pink interior. In the background, a lush green salad
 with sliced strawberries and goat cheese is complemented by a
 velvety smooth avocado puree, while a decadent chocolate souffle
 with a dollop of whipped cream on the side awaits dessert
 enthusiasts. A fine art piece capturing the essence of an
 unforgettable culinary experience.

Now we can pass our prompts through it:

1
2
3
4
5
  mflux-generate --model schnell \
               --prompt "$(ollama run imageplus 'Luxury food photograph')" \
               --steps 2 --seed 2 \
               --metadata \
               -q 4 --output enhance.png

Before:

After

asitop

1
  brew install asitop

References

Previously

articles

Living in mktemp and git and codespaces

Everything is throw away until it isn’t

tags
mktemp
git
docker
transient

Next

fragments

Emerson

tags