Git Product home page Git Product logo

flux's Introduction

FLUX

by Black Forest Labs: https://blackforestlabs.ai

grid

This repo contains minimal inference code to run text-to-image and image-to-image with our Flux latent rectified flow transformers.

Inference partners

We are happy to partner with Replicate, FAL and Mystic. You can sample our models using their services. Below we list relevant links.

Replicate:

FAL:

Mystic:

Local installation

cd $HOME && git clone https://github.com/black-forest-labs/flux
cd $HOME/flux
python3.10 -m venv .venv
source .venv/bin/activate
pip install -e ".[all]"

Models

We are offering three models:

  • FLUX.1 [pro] the base model, available via API
  • FLUX.1 [dev] guidance-distilled variant
  • FLUX.1 [schnell] guidance and step-distilled variant
Name HuggingFace repo License md5sum
FLUX.1 [schnell] https://huggingface.co/black-forest-labs/FLUX.1-schnell apache-2.0 a9e1e277b9b16add186f38e3f5a34044
FLUX.1 [dev] https://huggingface.co/black-forest-labs/FLUX.1-dev FLUX.1-dev Non-Commercial License a6bd8c16dfc23db6aee2f63a2eba78c0
FLUX.1 [pro] Only available in our API.

The weights of the autoencoder are also released under apache-2.0 and can be found in either of the two HuggingFace repos above. They are the same for both models.

Usage

The weights will be downloaded automatically from HuggingFace once you start one of the demos. To download FLUX.1 [dev], you will need to be logged in, see here. If you have downloaded the model weights manually, you can specify the downloaded paths via environment-variables:

export FLUX_SCHNELL=<path_to_flux_schnell_sft_file>
export FLUX_DEV=<path_to_flux_dev_sft_file>
export AE=<path_to_ae_sft_file>

For interactive sampling run

python -m flux --name <name> --loop

Or to generate a single sample run

python -m flux --name <name> \
  --height <height> --width <width> \
  --prompt "<prompt>"

We also provide a streamlit demo that does both text-to-image and image-to-image. The demo can be run via

streamlit run demo_st.py

We also offer a Gradio-based demo for an interactive experience. To run the Gradio demo:

python demo_gr.py --name flux-schnell --device cuda

Options:

  • --name: Choose the model to use (options: "flux-schnell", "flux-dev")
  • --device: Specify the device to use (default: "cuda" if available, otherwise "cpu")
  • --offload: Offload model to CPU when not in use
  • --share: Create a public link to your demo

To run the demo with the dev model and create a public link:

python demo_gr.py --name flux-dev --share

Diffusers integration

FLUX.1 [schnell] and FLUX.1 [dev] are integrated with the 🧨 diffusers library. To use it with diffusers, install it:

pip install git+https://github.com/huggingface/diffusers.git

Then you can use FluxPipeline to run the model

import torch
from diffusers import FluxPipeline

model_id = "black-forest-labs/FLUX.1-schnell" #you can also use `black-forest-labs/FLUX.1-dev`

pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16)
pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power

prompt = "A cat holding a sign that says hello world"
seed = 42
image = pipe(
    prompt,
    output_type="pil",
    num_inference_steps=4, #use a larger number if you are using [dev]
    generator=torch.Generator("cpu").manual_seed(seed)
).images[0]
image.save("flux-schnell.png")

To learn more check out the diffusers documentation

API usage

Our API offers access to the pro model. It is documented here: docs.bfl.ml.

In this repository we also offer an easy python interface. To use this, you first need to register with the API on api.bfl.ml, and create a new API key.

To use the API key either run export BFL_API_KEY=<your_key_here> or provide it via the api_key=<your_key_here> parameter. It is also expected that you have installed the package as above.

Usage from python:

from flux.api import ImageRequest

# this will create an api request directly but not block until the generation is finished
request = ImageRequest("A beautiful beach")
# or: request = ImageRequest("A beautiful beach", api_key="your_key_here")

# any of the following will block until the generation is finished
request.url
# -> https:<...>/sample.jpg
request.bytes
# -> b"..." bytes for the generated image
request.save("outputs/api.jpg")
# saves the sample to local storage
request.image
# -> a PIL image

Usage from the command line:

$ python -m flux.api --prompt="A beautiful beach" url
https:<...>/sample.jpg

# generate and save the result
$ python -m flux.api --prompt="A beautiful beach" save outputs/api

# open the image directly
$ python -m flux.api --prompt="A beautiful beach" image show

flux's People

Contributors

anvilarth avatar apolinario avatar artificialzeng avatar cbrownstein-lambda avatar chamini2 avatar deforum avatar eltociear avatar emadbagheri96 avatar jakedahn avatar jenuk avatar klace avatar omahs avatar paulcjh avatar timudk avatar tjkdev1 avatar zeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flux's Issues

It is a bit shame that no Gradio demo :(

I wish you had included a Gradio demo

So we could easily locally install and test locally

Moreover where is requirements.txt file? I would like to install into python venv and run like any other AI model

AssertionError: Torch not compiled with CUDA enabled

Pretty required to have this capability as at least a warning. I know HOW to do this, but it should at least warn. The demo isn't very verbose nor is it very helpful in terms of messaging, so I had to probe a bit before I figured out why it wasn't rendering up to speed.

When rendering only with the cpu it should automatically warn the user and there should definitely be a progress bar.

image-to-image

Anyone solwed it in Comfy UI?

Control-NET?
Inpainting?

请问提示这个错误呢,在load模型得时候,应该如何做呢,谢谢

You are using the default legacy behaviour of the <class 'transformers.models.t5.tokenization_t5.T5Tokenizer'>. This is expected, and simply means that the legacy (previous) behavior will be used so nothing changes for you. If you want to use the new behaviour, set legacy=False. This should only be set if you understand what it means, and thoroughly read the reason why this was added as explained in huggingface/transformers#24565

can't load pipline components with none error

Hi guys:

 I tried to run with following codes, but couldn't load pipline components and there was none error.

`import torch
from diffusers import FluxPipeline

device = (
"mps"
if torch.backends.mps.is_available()
else "cuda"
if torch.cuda.is_available()
else "cpu"
)
print("show pipe lines")
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16)
print("load pipeline")
pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power
prompt = "A cat holding a sign that says hello world"
image = pipe(
prompt,
guidance_scale=0.0,
output_type="pil",
num_inference_steps=4,
max_sequence_length=256,
generator=torch.Generator(device=device).manual_seed(0)
).images[0]
print('draw')
image.save("gc-img/shanshui_pil_4_246-2.webp")`

show in console:

32fe517514d88fee182c1cac8d74718

No Error -> images come out Black

I use the provided example workflow tried various combinations of smaller T5 and Flux models with recommended settings but all generated images come out black. anyone else experience this?
image

image

Details of the model distillation technique

Hi, thank you for the great work!

I was wondering if there is any reference or technical report that I could look into regarding the technique for distilling the Schnell and the Dev models from the Pro model?

Please recognize environment variables and prevent re-download of models

Many developers download all the model/vae files in advance, a task that can take hours, so there's no need to download them all over again.

You have provided a way to set environmental variables specifying the location of local copies of the model files, and this ought to prevent re-downloading ... in principle. But this doesn't happen.

After setting the environment variables in a shell script:

export FLUX_DEV="<local path>"
export AE="<local path>"

Then entering the venv, then establishing and verifying that the environment variables are present:

(.venv) ...$ . shell_script_with_environment_variables.sh (.venv) ...$ env | grep -E "AE|FLUX" # this confirms the presence of the variables
, the various provided demonstrations then proceed to download a new, unexplained model file.

Am I missing something? Thanks!

-- UPDATE --

Okay, apparently I missed something. I downloaded the requisite files from huggingface, totaling 34.2 GB, then I followed the instructions to complete the installation as explained above, then:

$ source .venv/bin/activate
(.venv) $ pip install -e '.[all]'

-- all successful and uneventful. Then the moment of truth:

(.venv) $ python -m flux --name flux-dev --loop

Instead of prompting for user input, this command tries to download a file named "pytorch_model.bin" that is 44.5 GB in size (not a typo). Unfortunately, because I live on Planet Earth and have a mortal's Internet connection, this download fails over and over again, and a download link isn't provided, which if it existed would allow various strategies to acquire this unexpected additional download.

Please edit your install instructions to accommodate this outcome -- explain what and why. Thanks!

Textures are bad

Textures like wrinkels and skin pores are so much worse as with your SDXL model. I hope this will be addressed first. Now its more like a good model to produce paintbrush but realisme is
view
This is a SDXL model to be precise Boltning - Realistic, Lightning, HYPER

ComfyUI_0052
This is a FLUX image its is either smooth like this or

ComfyUI_0034
totally exaggerated like this.

I tried for full 2 day's tried with samplers and steps, there is just no realistic texture or I am doing something wrong. I sure hope its the latter. Can someone correct my findings?

useless due censorship

you reach chinese kling censorship level. this is good model but useless due censorship. if it hasn't breasts, I don't wanna see it.

Looks like image2image wrong code

        if init_image is not None:
            t_idx = int((1 - image2image_strength) * num_steps)

if num_steps = 50 we get only 5 values due to rounding

and image2image_strength is not used anywhere else

an AUR package

It would be nice to easily be able to run this with minimal setup an archlinux.

Installing dependencies based on Conda

Thank you for sharing this very interesting and useful project!
I noticed that the README file of the project does not mention the steps to install a Conda environment. For the convenience of Anaconda/Miniconda users like myself, could you please consider adding a tutorial for installing dependencies based on Conda?

How to install this !?

Please can we have more explanation about the install, or is it only for the elite researchers lol some syntax are different from usual (I'm on Windows)

cd $HOME && git clone https://github.com/black-forest-labs/flux
I'm guessing here $HOME is some environment variable, doesn't work for me I can only git clone this repo that's all

python3.10 -m venv .venv
okay this part is easy but I just type "python" or "py" I never had to type a full version before. I do have Python 3.10 installed though

source .venv/bin/activate
"source" doesn't work. Instead I can go inside .venv/Scripts and use activate.bat

pip install -e '.[all]'
Excuse me, what ?

Inpainting support

Excellent model for text to image generation.

Is there any plan to add inpainting feature to this model? That will significantly increase model's reach and use cases.

VRAM Usage

Hello there, great work!

Can you put the VRAM usage for your open models on the readme? Saves us GPU poors from downloading the model in vain 🙃

Are the current models as small as they will get or can we expect pruned / lower precision models in the near future?

Image striping?

Anyone know how to get rid of this sort of banding/striping happening in the image?

image

Plan of a paper

Hi,
Really nice work!
Do you plan to release a paper?
Thanks!

VAE fix maybe?

Are you going to fix AE.SFT for clean picture output?
Now it gives light grid artifacts constantly
Screenshot 2024-08-06 013715

Local Install Tutorial?

Hello,

How can I use FLUX.1 Pro locally on Windows 11? Is there a tutorial to install it, perhaps I can use it on ComfyUI.

Thanks in advance

Exception: data did not match any variant of untagged enum PyPreTokenizerTypeWrapper at line 960 column 3

Hi, Thanks for the awesome work.

I wanna run the flux by diffusers code, but I got some tokenizer error like

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
Input [In [3]](vscode-notebook-cell:?execution_count=3%3E), in <cell line: 7>()
      [3](vscode-notebook-cell:?execution_count=3&line=3) from diffusers import FluxPipeline
      [5](vscode-notebook-cell:?execution_count=3&line=5) model_id = "black-forest-labs/FLUX.1-schnell" #you can also use `black-forest-labs/FLUX.1-dev`
----> [7](vscode-notebook-cell:?execution_count=3&line=7) pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16)
      [8](vscode-notebook-cell:?execution_count=3&line=8) pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power
     [10](vscode-notebook-cell:?execution_count=3&line=10) prompt = "A cat holding a sign that says hello world"

File [~/anaconda3/envs/vdds/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py:114](https://vscode-remote+ssh-002dremote-002b143-002e248-002e159-002e93.vscode-resource.vscode-cdn.net/home/jhpark/flux/~/anaconda3/envs/vdds/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py:114), in validate_hf_hub_args.<locals>._inner_fn(*args, **kwargs)
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py:1'>1</a>;32m    [111](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py?line=110) if check_use_auth_token:
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py:1'>1</a>;32m    [112](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py?line=111)     kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py:0'>0</a>;32m--> [114](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py?line=113) return fn(*args, **kwargs)

File [~/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:876](https://vscode-remote+ssh-002dremote-002b143-002e248-002e159-002e93.vscode-resource.vscode-cdn.net/home/jhpark/flux/~/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:876), in DiffusionPipeline.from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:1'>1</a>;32m    [873](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py?line=872)     loaded_sub_model = passed_class_obj[name]
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:1'>1</a>;32m    [874](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py?line=873) else:
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:1'>1</a>;32m    [875](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py?line=874)     # load sub model
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:0'>0</a>;32m--> [876](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py?line=875)     loaded_sub_model = load_sub_model(
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:1'>1</a>;32m    [877](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py?line=876)         library_name=library_name,
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:1'>1</a>;32m    [878](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py?line=877)         class_name=class_name,
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:1'>1</a>;32m    [879](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py?line=878)         importable_classes=importable_classes,
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:1'>1</a>;32m    [880](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py?line=879)         pipelines=pipelines,
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:1'>1</a>;32m    [881](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py?line=880)         is_pipeline_module=is_pipeline_module,
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py:1'>1</a>;32m    [882](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/diffusers/pipelines/pipeline_utils.py?line=881)         pipeline_class=pipeline_class,
...
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/transformers/tokenization_utils_fast.py:1'>1</a>;32m    [112](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/transformers/tokenization_utils_fast.py?line=111) elif slow_tokenizer is not None:
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/transformers/tokenization_utils_fast.py:1'>1</a>;32m    [113](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/transformers/tokenization_utils_fast.py?line=112)     # We need to convert a slow tokenizer to build the backend
ref='~/anaconda3/envs/vdds/lib/python3.9/site-packages/transformers/tokenization_utils_fast.py:1'>1</a>;32m    [114](file:///home/jhpark/anaconda3/envs/vdds/lib/python3.9/site-packages/transformers/tokenization_utils_fast.py?line=113)     fast_tokenizer = convert_slow_tokenizer(slow_tokenizer)

Exception: data did not match any variant of untagged enum PyPreTokenizerTypeWrapper at line 960 column 3

My tokenizers version is 0.11.1 and I failed to run diffuser flux code.
And I tried to run the diffusers flux code with tokenizers with 0.13.3 but also failed.

How can I fix this error?

Out of Memory error when loading model - Only using 1 GPU

Hello,
I'm trying to load models using the streamlit app. I have 4 NVIDIA L4, but it only uses 1 and reaches an out of memory error on flux-schnell. Is there a way to make it load on several GPUs ?
Error :
OutOfMemoryError: CUDA out of memory. Tried to allocate 126.00 MiB. GPU 0 has a total capacity of 21.95 GiB of which 54.12 MiB is free. Process 31512 has 0 bytes memory in use. Of the allocated memory 21.70 GiB is allocated by PyTorch, and 13.95 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)

int4?

With the variety of quantization methods available, could we select an optimal one for INT4 quantization? This would enable users with low-memory devices to utilize the model, and the potential quality loss seems acceptable

Fine-tuning code

Congrats on the release! Will code be released to fine-tune the [schnell] model? (is it even fine-tuneable?)

[Feature Reqeust] Ip-Adapter

Thank you for sharing excellent model and research.

Is there any plan to support Ip-Adapter for Flux? Or any similar feature support reference image input with text?

Thank you!

MacBook Pro M1: model will be on CPU

It seems as if the --device were not passed down:

❯ python -m flux --name flux-dev --loop --device mps
Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.
❯ git rev-parse HEAD
eae154e8a2a4aad791d52b34bcacb67ab6a9b8db
❯ pip freeze
altair==5.3.0
attrs==23.2.0
blinker==1.8.2
cachetools==5.4.0
certifi==2024.7.4
charset-normalizer==3.3.2
click==8.1.7
einops==0.8.0
filelock==3.15.4
fire==0.6.0
-e git+https://github.com/black-forest-labs/flux@eae154e8a2a4aad791d52b34bcacb67ab6a9b8db#egg=flux
fsspec==2024.6.1
gitdb==4.0.11
GitPython==3.1.43
huggingface-hub==0.24.5
idna==3.7
invisible-watermark==0.2.0
Jinja2==3.1.4
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
markdown-it-py==3.0.0
MarkupSafe==2.1.5
mdurl==0.1.2
mpmath==1.3.0
networkx==3.3
numpy==2.0.1
opencv-python==4.10.0.84
packaging==24.1
pandas==2.2.2
pillow==10.4.0
protobuf==5.27.3
pyarrow==17.0.0
pydeck==0.9.1
Pygments==2.18.0
python-dateutil==2.9.0.post0
pytz==2024.1
PyWavelets==1.6.0
PyYAML==6.0.1
referencing==0.35.1
regex==2024.7.24
requests==2.32.3
rich==13.7.1
rpds-py==0.19.1
safetensors==0.4.3
sentencepiece==0.2.0
six==1.16.0
smmap==5.0.1
streamlit==1.37.0
streamlit-keyup==0.2.4
sympy==1.13.1
tenacity==8.5.0
termcolor==2.4.0
tokenizers==0.19.1
toml==0.10.2
toolz==0.12.1
torch==2.4.0
torchvision==0.19.0
tornado==6.4.1
tqdm==4.66.4
transformers==4.43.3
typing_extensions==4.12.2
tzdata==2024.1
urllib3==2.2.2

Incompetence?

Who decided to put 'cd $HOME' in the local installation commands?

And no requirements.txt? I have to use a -e '[.all]'??? wtf is that?

Why not just be normal, and provide instructions that work like literally every other Python program on the planet?

What is the input schema for flux-schnell and how to set image size?

What is the correct schema?

I'm seeing 2 different schemas

I'm running flux-schnell via replicate and its corresponding npm package. As far as I can tell, this is the combined schema from both sets of docs

input: {
  prompt: string;
  aspect_ratio: "1:1" | "16:9" | "21:9" | "2:3" | "3:2" | "4:5" | "5:4" | "9:16" | "9:21";
  output_format: "webp" | "png" | "jpg";
  num_outputs: number;
  image_size: "square_hd" | "square" | "portrait_4_3" | "portrait_16_9" | "landscape_4_3" | "landscape_16_9" | { width: number; height: number; };
  num_inference_steps: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
  enable_safety_checker: boolean;
  safety_tolerance: 1 | 2 | 3 | 4 | 5;
  guidance: 2 | 3 | 4 | 5;
  seed: number;
  sync_mode: boolean;
  output_quality: 0 - 100;
  interval: 1 | 2 | 3| 4;
  steps: 1 - 50;
}

I also found this colab notebook, though I'm not sure if it's affiliated, that has width and height in the schema.

How do I set the size?

I would assume that I should use the schema for the service i'm using, replicate. However, num_outputs is not on the replicate schema but it works. I've tried various combinations of the above image_size, aspect_ratio and width + height but I'm unable to determine the correct pattern.

It's possible I've bungled it on my end. Please help, thank you.

How can I use multiple gpu's?

I'm using flux.1-dev,now that I'm running with only one gpu, I've tried using the device_map,but it not worked,how do I get my full gpu to reason at the same time?

Errors when running Steamlit demo

I tried using the Steamlit demo with Schnell and I keep getting errors. Not sure what I am doing wrong.

OSError: Unable to load weights from pytorch checkpoint file for '/home/test/.cache/huggingface/hub/models--google--t5-v1_1-xxl/snapshots/3db67ab1af984cf10548a73467f0e5bca2aaaeb2/pytorch_model.bin' at '/home/test/.cache/huggingface/hub/models--google--t5-v1_1-xxl/snapshots/3db67ab1af984cf10548a73467f0e5bca2aaaeb2/pytorch_model.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.

Traceback:
File "/home/test/flux/.venv/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 75, in exec_func_with_error_handling
result = func()
File "/home/test/flux/.venv/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 574, in code_to_exec
exec(code, module.dict)
File "/home/test/flux/demo_st.py", line 287, in
app()
File "/home/test/flux/demo_st.py", line 283, in app
Fire(main)
File "/home/test/flux/.venv/lib/python3.10/site-packages/fire/core.py", line 143, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/home/test/flux/.venv/lib/python3.10/site-packages/fire/core.py", line 477, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/home/test/flux/.venv/lib/python3.10/site-packages/fire/core.py", line 693, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "/home/test/flux/.venv/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
File "/home/test/flux/demo_st.py", line 62, in main
model, ae, t5, clip, nsfw_classifier = get_models(
File "/home/test/flux/.venv/lib/python3.10/site-packages/streamlit/runtime/caching/cache_utils.py", line 168, in wrapper
return cached_func(*args, **kwargs)
File "/home/test/flux/.venv/lib/python3.10/site-packages/streamlit/runtime/caching/cache_utils.py", line 197, in call
return self._get_or_create_cached_value(args, kwargs)
File "/home/test/flux/.venv/lib/python3.10/site-packages/streamlit/runtime/caching/cache_utils.py", line 224, in _get_or_create_cached_value
return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
File "/home/test/flux/.venv/lib/python3.10/site-packages/streamlit/runtime/caching/cache_utils.py", line 280, in _handle_cache_miss
computed_value = self._info.func(*func_args, **func_kwargs)
File "/home/test/flux/demo_st.py", line 25, in get_models
t5 = load_t5(device, max_length=256 if is_schnell else 512)
File "/home/test/flux/src/flux/util.py", line 131, in load_t5
return HFEmbedder("google/t5-v1_1-xxl", max_length=max_length, torch_dtype=torch.bfloat16).to(device)
File "/home/test/flux/src/flux/modules/conditioner.py", line 18, in init
self.hf_module: T5EncoderModel = T5EncoderModel.from_pretrained(version, **hf_kwargs)
File "/home/test/flux/.venv/lib/python3.10/site-packages/transformers/modeling_utils.py", line 3716, in from_pretrained
state_dict = load_state_dict(resolved_archive_file)
File "/home/test/flux/.venv/lib/python3.10/site-packages/transformers/modeling_utils.py", line 596, in load_state_dict
raise OSError(

Possible to train LoRA?

Hey, really loving the model. The team did great work. I saw a post on Reddit earlier that claimed fine tuning was impossible. I was wondering if the same applies to LoRA creation? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.