Update README with installation guide
This commit is contained in:
parent
e3a85df133
commit
f0b02257e3
40
README.md
40
README.md
@ -22,23 +22,36 @@ like [Numpy](https://numpy.org) and [Pillow](https://pypi.org/project/pillow/) f
|
|||||||
- [x] FLUX.1-Scnhell
|
- [x] FLUX.1-Scnhell
|
||||||
- [ ] FLUX.1-Dev
|
- [ ] FLUX.1-Dev
|
||||||
|
|
||||||
### Prerequisites
|
### Installation
|
||||||
|
1. Clone the repo:
|
||||||
- The required libraries are listed in [requirements.txt](requirements.txt).
|
```
|
||||||
- Development and testing was done with Python 3.12
|
git clone git@github.com/filipstrand/mflux.git
|
||||||
- Download the weights and tokenizers at [Huggingface/black-forest-labs](https://huggingface.co/black-forest-labs/FLUX.1-schnell/tree/main).
|
```
|
||||||
Point to the location of the root folder as shown in the example below:
|
2. Navigate to the project and set up a virtual environment:
|
||||||
|
```
|
||||||
|
cd mflux && python3 -m venv .venv && source .venv/bin/activate
|
||||||
|
```
|
||||||
|
3. Install the required dependencies:
|
||||||
|
```
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
### Generating an image
|
### Generating an image
|
||||||
|
|
||||||
Run [main.py](/src/flux_1_schnell/main.py) or make a new script like the following
|
Run the provided [main.py](main.py)
|
||||||
(make sure to correctly define the root path to wherever the model is saved and where you want the images to be stored).
|
```
|
||||||
|
python main.py
|
||||||
|
```
|
||||||
|
|
||||||
|
or make a new separate script like the following
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
import sys
|
||||||
|
sys.path.append("/path/to/mflux/src")
|
||||||
|
|
||||||
from flux_1_schnell.config.config import Config
|
from flux_1_schnell.config.config import Config
|
||||||
from flux_1_schnell.models.flux import Flux1Schnell
|
from flux_1_schnell.models.flux import Flux1Schnell
|
||||||
|
|
||||||
flux = Flux1Schnell("/Users/filipstrand/.cache/FLUX.1-schnell/")
|
flux = Flux1Schnell("black-forest-labs/FLUX.1-schnell")
|
||||||
|
|
||||||
image = flux.generate_image(
|
image = flux.generate_image(
|
||||||
seed=3,
|
seed=3,
|
||||||
@ -48,13 +61,18 @@ image = flux.generate_image(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
image.save(f"/Users/filipstrand/Desktop/image.png")
|
image.save("image.png")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If the model is not already downloaded on your machine, it will start the download process and fetch the model weights (~34GB in size for the Schnell model).
|
||||||
|
|
||||||
Generating a single image (with 2 inference steps, Schnell model) takes between 2 and 3 minutes. This implementation has been tested on two Macbook Pro machines:
|
Generating a single image (with 2 inference steps, Schnell model) takes between 2 and 3 minutes. This implementation has been tested on two Macbook Pro machines:
|
||||||
- 2021 M1 Pro (32 GB)
|
- 2021 M1 Pro (32 GB)
|
||||||
- 2023 M2 Max (32 GB)
|
- 2023 M2 Max (32 GB)
|
||||||
|
|
||||||
|
Update:
|
||||||
|
On faster machines, [@karpathy](https://gist.github.com/awni/a67d16d50f0f492d94a10418e0592bde?permalink_comment_id=5153531#gistcomment-5153531) and [@awni](https://x.com/awnihannun/status/1823515121827897385) have reported times ~20s and below!
|
||||||
|
|
||||||
### Equivalent to Diffusers implementation
|
### Equivalent to Diffusers implementation
|
||||||
|
|
||||||
There is only a single source of randomness when generating an image: The initial latent array.
|
There is only a single source of randomness when generating an image: The initial latent array.
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'src')))
|
||||||
|
|
||||||
from flux_1_schnell.config.config import Config
|
from flux_1_schnell.config.config import Config
|
||||||
from flux_1_schnell.models.flux import Flux1Schnell
|
from flux_1_schnell.models.flux import Flux1Schnell
|
||||||
|
|
||||||
flux = Flux1Schnell("/Users/filipstrand/.cache/FLUX.1-schnell/")
|
flux = Flux1Schnell("black-forest-labs/FLUX.1-schnell")
|
||||||
|
|
||||||
image = flux.generate_image(
|
image = flux.generate_image(
|
||||||
seed=3,
|
seed=3,
|
||||||
@ -11,4 +16,4 @@ image = flux.generate_image(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
image.save("/Users/filipstrand/Desktop/image.png")
|
image.save("image.png")
|
||||||
Loading…
Reference in New Issue
Block a user