Fluminato
Browse files- .gitattributes +1 -0
- LICENSE +82 -201
- README.md +38 -397
- example.png +3 -0
- flumina.py +12 -4
- t2i_output.jpg +0 -0
.gitattributes
CHANGED
@@ -4,3 +4,4 @@ t5-v1_1-xxl-encoder-bf16//*.safetensor filter=lfs diff=lfs merge=lfs -text
|
|
4 |
t5-v1_1-xxl-encoder-bf16//spiece.model filter=lfs diff=lfs merge=lfs -text
|
5 |
t5-v1_1-xxl-encoder-bf16/model.safetensors filter=lfs diff=lfs merge=lfs -text
|
6 |
flux1-schnell.safetensors filter=lfs diff=lfs merge=lfs -text
|
|
|
|
4 |
t5-v1_1-xxl-encoder-bf16//spiece.model filter=lfs diff=lfs merge=lfs -text
|
5 |
t5-v1_1-xxl-encoder-bf16/model.safetensors filter=lfs diff=lfs merge=lfs -text
|
6 |
flux1-schnell.safetensors filter=lfs diff=lfs merge=lfs -text
|
7 |
+
example.png filter=lfs diff=lfs merge=lfs -text
|
LICENSE
CHANGED
@@ -1,201 +1,82 @@
|
|
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 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
-
or a Contribution incorporated within the Work constitutes direct
|
85 |
-
or contributory patent infringement, then any patent licenses
|
86 |
-
granted to You under this License for that Work shall terminate
|
87 |
-
as of the date such litigation is filed.
|
88 |
-
|
89 |
-
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
-
Work or Derivative Works thereof in any medium, with or without
|
91 |
-
modifications, and in Source or Object form, provided that You
|
92 |
-
meet the following conditions:
|
93 |
-
|
94 |
-
(a) You must give any other recipients of the Work or
|
95 |
-
Derivative Works a copy of this License; and
|
96 |
-
|
97 |
-
(b) You must cause any modified files to carry prominent notices
|
98 |
-
stating that You changed the files; and
|
99 |
-
|
100 |
-
(c) You must retain, in the Source form of any Derivative Works
|
101 |
-
that You distribute, all copyright, patent, trademark, and
|
102 |
-
attribution notices from the Source form of the Work,
|
103 |
-
excluding those notices that do not pertain to any part of
|
104 |
-
the Derivative Works; and
|
105 |
-
|
106 |
-
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
-
distribution, then any Derivative Works that You distribute must
|
108 |
-
include a readable copy of the attribution notices contained
|
109 |
-
within such NOTICE file, excluding those notices that do not
|
110 |
-
pertain to any part of the Derivative Works, in at least one
|
111 |
-
of the following places: within a NOTICE text file distributed
|
112 |
-
as part of the Derivative Works; within the Source form or
|
113 |
-
documentation, if provided along with the Derivative Works; or,
|
114 |
-
within a display generated by the Derivative Works, if and
|
115 |
-
wherever such third-party notices normally appear. The contents
|
116 |
-
of the NOTICE file are for informational purposes only and
|
117 |
-
do not modify the License. You may add Your own attribution
|
118 |
-
notices within Derivative Works that You distribute, alongside
|
119 |
-
or as an addendum to the NOTICE text from the Work, provided
|
120 |
-
that such additional attribution notices cannot be construed
|
121 |
-
as modifying the License.
|
122 |
-
|
123 |
-
You may add Your own copyright statement to Your modifications and
|
124 |
-
may provide additional or different license terms and conditions
|
125 |
-
for use, reproduction, or distribution of Your modifications, or
|
126 |
-
for any such Derivative Works as a whole, provided Your use,
|
127 |
-
reproduction, and distribution of the Work otherwise complies with
|
128 |
-
the conditions stated in this License.
|
129 |
-
|
130 |
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
-
any Contribution intentionally submitted for inclusion in the Work
|
132 |
-
by You to the Licensor shall be under the terms and conditions of
|
133 |
-
this License, without any additional terms or conditions.
|
134 |
-
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
-
the terms of any separate license agreement you may have executed
|
136 |
-
with Licensor regarding such Contributions.
|
137 |
-
|
138 |
-
6. Trademarks. This License does not grant permission to use the trade
|
139 |
-
names, trademarks, service marks, or product names of the Licensor,
|
140 |
-
except as required for reasonable and customary use in describing the
|
141 |
-
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
-
|
143 |
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
-
agreed to in writing, Licensor provides the Work (and each
|
145 |
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
-
implied, including, without limitation, any warranties or conditions
|
148 |
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
-
appropriateness of using or redistributing the Work and assume any
|
151 |
-
risks associated with Your exercise of permissions under this License.
|
152 |
-
|
153 |
-
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
-
whether in tort (including negligence), contract, or otherwise,
|
155 |
-
unless required by applicable law (such as deliberate and grossly
|
156 |
-
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
-
liable to You for damages, including any direct, indirect, special,
|
158 |
-
incidental, or consequential damages of any character arising as a
|
159 |
-
result of this License or out of the use or inability to use the
|
160 |
-
Work (including but not limited to damages for loss of goodwill,
|
161 |
-
work stoppage, computer failure or malfunction, or any and all
|
162 |
-
other commercial damages or losses), even if such Contributor
|
163 |
-
has been advised of the possibility of such damages.
|
164 |
-
|
165 |
-
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
-
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
-
or other liability obligations and/or rights consistent with this
|
169 |
-
License. However, in accepting such obligations, You may act only
|
170 |
-
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
-
of any other Contributor, and only if You agree to indemnify,
|
172 |
-
defend, and hold each Contributor harmless for any liability
|
173 |
-
incurred by, or claims asserted against, such Contributor by reason
|
174 |
-
of your accepting any such warranty or additional liability.
|
175 |
-
|
176 |
-
END OF TERMS AND CONDITIONS
|
177 |
-
|
178 |
-
APPENDIX: How to apply the Apache License to your work.
|
179 |
-
|
180 |
-
To apply the Apache License to your work, attach the following
|
181 |
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
-
replaced with your own identifying information. (Don't include
|
183 |
-
the brackets!) The text should be enclosed in the appropriate
|
184 |
-
comment syntax for the file format. We also recommend that a
|
185 |
-
file or class name and description of purpose be included on the
|
186 |
-
same "printed page" as the copyright notice for easier
|
187 |
-
identification within third-party archives.
|
188 |
-
|
189 |
-
Copyright 2024 Alex Redden
|
190 |
-
|
191 |
-
Licensed under the Apache License, Version 2.0 (the "License");
|
192 |
-
you may not use this file except in compliance with the License.
|
193 |
-
You may obtain a copy of the License at
|
194 |
-
|
195 |
-
http://www.apache.org/licenses/LICENSE-2.0
|
196 |
-
|
197 |
-
Unless required by applicable law or agreed to in writing, software
|
198 |
-
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
-
See the License for the specific language governing permissions and
|
201 |
-
limitations under the License.
|
|
|
1 |
+
**FLUX.1 \[dev\] Non-Commercial License**
|
2 |
+
|
3 |
+
Black Forest Labs, Inc. (“**we**” or “**our**” or “**Company**”) is pleased to make available the weights, parameters and inference code for the FLUX.1 \[dev\] Model (as defined below) freely available for your non-commercial and non-production use as set forth in this FLUX.1 \[dev\] Non-Commercial License (“**License**”). The “**FLUX.1 \[dev\] Model**” means the FLUX.1 \[dev\] text-to-image AI model and its elements which includes algorithms, software, checkpoints, parameters, source code (inference code, evaluation code, and if applicable, fine-tuning code) and any other materials associated with the FLUX.1 \[dev\] AI model made available by Company under this License, including if any, the technical documentation, manuals and instructions for the use and operation thereof (collectively, “**FLUX.1 \[dev\] Model**”).
|
4 |
+
|
5 |
+
By downloading, accessing, use, Distributing (as defined below), or creating a Derivative (as defined below) of the FLUX.1 \[dev\] Model, you agree to the terms of this License. If you do not agree to this License, then you do not have any rights to access, use, Distribute or create a Derivative of the FLUX.1 \[dev\] Model and you must immediately cease using the FLUX.1 \[dev\] Model. If you are agreeing to be bound by the terms of this License on behalf of your employer or other entity, you represent and warrant to us that you have full legal authority to bind your employer or such entity to this License. If you do not have the requisite authority, you may not accept the License or access the FLUX.1 \[dev\] Model on behalf of your employer or other entity.
|
6 |
+
|
7 |
+
1. **Definitions**. Capitalized terms used in this License but not defined herein have the following meanings:
|
8 |
+
|
9 |
+
1. “**Derivative**” means any (i) modified version of the FLUX.1 \[dev\] Model (including but not limited to any customized or fine-tuned version thereof), (ii) work based on the FLUX.1 \[dev\] Model, or (iii) any other derivative work thereof. For the avoidance of doubt, Outputs are not considered Derivatives under this License.
|
10 |
+
|
11 |
+
1. “**Distribution**” or “**Distribute**” or “**Distributing**” means providing or making available, by any means, a copy of the FLUX.1 \[dev\] Models and/or the Derivatives as the case may be.
|
12 |
+
|
13 |
+
1. “**Non-Commercial Purpose**” means any of the following uses, but only so far as you do not receive any direct or indirect payment arising from the use of the model or its output: (i) personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, or otherwise not directly or indirectly connected to any commercial activities, business operations, or employment responsibilities; (ii) use by commercial or for-profit entities for testing, evaluation, or non-commercial research and development in a non-production environment, (iii) use by any charitable organization for charitable purposes, or for testing or evaluation. For clarity, use for revenue-generating activity or direct interactions with or impacts on end users, or use to train, fine tune or distill other models for commercial use is not a Non-Commercial purpose.
|
14 |
+
|
15 |
+
1. “**Outputs**” means any content generated by the operation of the FLUX.1 \[dev\] Models or the Derivatives from a prompt (i.e., text instructions) provided by users. For the avoidance of doubt, Outputs do not include any components of a FLUX.1 \[dev\] Models, such as any fine-tuned versions of the FLUX.1 \[dev\] Models, the weights, or parameters.
|
16 |
+
|
17 |
+
1. “**you**” or “**your**” means the individual or entity entering into this License with Company.
|
18 |
+
|
19 |
+
1. **License Grant**.
|
20 |
+
|
21 |
+
1. License. Subject to your compliance with this License, Company grants you a non-exclusive, worldwide, non-transferable, non-sublicensable, revocable, royalty free and limited license to access, use, create Derivatives of, and Distribute the FLUX.1 \[dev\] Models solely for your Non-Commercial Purposes. The foregoing license is personal to you, and you may not assign or sublicense this License or any other rights or obligations under this License without Company’s prior written consent; any such assignment or sublicense will be void and will automatically and immediately terminate this License. Any restrictions set forth herein in regarding the FLUX.1 \[dev\] Model also applies to any Derivative you create or that are created on your behalf.
|
22 |
+
|
23 |
+
1. Non-Commercial Use Only. You may only access, use, Distribute, or creative Derivatives of or the FLUX.1 \[dev\] Model or Derivatives for Non-Commercial Purposes. If You want to use a FLUX.1 \[dev\] Model a Derivative for any purpose that is not expressly authorized under this License, such as for a commercial activity, you must request a license from Company, which Company may grant to you in Company’s sole discretion and which additional use may be subject to a fee, royalty or other revenue share. Please contact Company at the following e-mail address if you want to discuss such a license: [email protected].
|
24 |
+
|
25 |
+
1. Reserved Rights. The grant of rights expressly set forth in this License are the complete grant of rights to you in the FLUX.1 \[dev\] Model, and no other licenses are granted, whether by waiver, estoppel, implication, equity or otherwise. Company and its licensors reserve all rights not expressly granted by this License.
|
26 |
+
|
27 |
+
1. Outputs. We claim no ownership rights in and to the Outputs. You are solely responsible for the Outputs you generate and their subsequent uses in accordance with this License. You may use Output for any purpose (including for commercial purposes), except as expressly prohibited herein. You may not use the Output to train, fine-tune or distill a model that is competitive with the FLUX.1 \[dev\] Model.
|
28 |
+
|
29 |
+
1. **Distribution**. Subject to this License, you may Distribute copies of the FLUX.1 \[dev\] Model and/or Derivatives made by you, under the following conditions:
|
30 |
+
|
31 |
+
1. you must make available a copy of this License to third-party recipients of the FLUX.1 \[dev\] Models and/or Derivatives you Distribute, and specify that any rights to use the FLUX.1 \[dev\] Models and/or Derivatives shall be directly granted by Company to said third-party recipients pursuant to this License;
|
32 |
+
|
33 |
+
1. you must make prominently display the following notice alongside the Distribution of the FLUX.1 \[dev\] Model or Derivative (such as via a “Notice” text file distributed as part of such FLUX.1 \[dev\] Model or Derivative) (the “**Attribution Notice**”):
|
34 |
+
|
35 |
+
“The FLUX.1 \[dev\] Model is licensed by Black Forest Labs. Inc. under the FLUX.1 \[dev\] Non-Commercial License. Copyright Black Forest Labs. Inc.
|
36 |
+
|
37 |
+
IN NO EVENT SHALL BLACK FOREST LABS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH USE OF THIS MODEL.”
|
38 |
+
|
39 |
+
1. in the case of Distribution of Derivatives made by you, you must also include in the Attribution Notice a statement that you have modified the applicable FLUX.1 \[dev\] Model; and
|
40 |
+
|
41 |
+
1. in the case of Distribution of Derivatives made by you, any terms and conditions you impose on any third-party recipients relating to Derivatives made by or for you shall neither limit such third-party recipients’ use of the FLUX.1 \[dev\] Model or any Derivatives made by or for Company in accordance with this License nor conflict with any of its terms and conditions.
|
42 |
+
|
43 |
+
1. In the case of Distribution of Derivatives made by you, you must not misrepresent or imply, through any means, that the Derivatives made by or for you and/or any modified version of the FLUX.1 \[dev\] Model you Distribute under your name and responsibility is an official product of the Company or has been endorsed, approved or validated by the Company, unless you are authorized by Company to do so in writing.
|
44 |
+
|
45 |
+
1. **Restrictions**. You will not, and will not permit, assist or cause any third party to
|
46 |
+
|
47 |
+
1. use, modify, copy, reproduce, create Derivatives of, or Distribute the FLUX.1 \[dev\] Model (or any Derivative thereof, or any data produced by the FLUX.1 \[dev\] Model), in whole or in part, for (i) any commercial or production purposes, (ii) military purposes, (iii) purposes of surveillance, including any research or development relating to surveillance, (iv) biometric processing, (v) in any manner that infringes, misappropriates, or otherwise violates any third-party rights, or (vi) in any manner that violates any applicable law and violating any privacy or security laws, rules, regulations, directives, or governmental requirements (including the General Data Privacy Regulation (Regulation (EU) 2016/679), the California Consumer Privacy Act, and any and all laws governing the processing of biometric information), as well as all amendments and successor laws to any of the foregoing;
|
48 |
+
|
49 |
+
1. alter or remove copyright and other proprietary notices which appear on or in any portion of the FLUX.1 \[dev\] Model;
|
50 |
+
|
51 |
+
1. utilize any equipment, device, software, or other means to circumvent or remove any security or protection used by Company in connection with the FLUX.1 \[dev\] Model, or to circumvent or remove any usage restrictions, or to enable functionality disabled by FLUX.1 \[dev\] Model; or
|
52 |
+
|
53 |
+
1. offer or impose any terms on the FLUX.1 \[dev\] Model that alter, restrict, or are inconsistent with the terms of this License.
|
54 |
+
|
55 |
+
1. violate any applicable U.S. and non-U.S. export control and trade sanctions laws (“**Export Laws**”) in connection with your use or Distribution of any FLUX.1 \[dev\] Model;
|
56 |
+
|
57 |
+
1. directly or indirectly Distribute, export, or otherwise transfer FLUX.1 \[dev\] Model (a) to any individual, entity, or country prohibited by Export Laws; (b) to anyone on U.S. or non-U.S. government restricted parties lists; or (c) for any purpose prohibited by Export Laws, including nuclear, chemical or biological weapons, or missile technology applications; 3\) use or download FLUX.1 \[dev\] Model if you or they are (a) located in a comprehensively sanctioned jurisdiction, (b) currently listed on any U.S. or non-U.S. restricted parties list, or (c) for any purpose prohibited by Export Laws; and (4) will not disguise your location through IP proxying or other methods.
|
58 |
+
|
59 |
+
1. **DISCLAIMERS**. THE FLUX.1 \[dev\] MODEL IS PROVIDED “AS IS” AND “WITH ALL FAULTS” WITH NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. COMPANY EXPRESSLY DISCLAIMS ALL REPRESENTATIONS AND WARRANTIES, EXPRESS OR IMPLIED, WHETHER BY STATUTE, CUSTOM, USAGE OR OTHERWISE AS TO ANY MATTERS RELATED TO THE FLUX.1 \[dev\] MODEL, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, SATISFACTORY QUALITY, OR NON-INFRINGEMENT. COMPANY MAKES NO WARRANTIES OR REPRESENTATIONS THAT THE FLUX.1 \[dev\] MODEL WILL BE ERROR FREE OR FREE OF VIRUSES OR OTHER HARMFUL COMPONENTS, OR PRODUCE ANY PARTICULAR RESULTS.
|
60 |
+
|
61 |
+
1. **LIMITATION OF LIABILITY**. TO THE FULLEST EXTENT PERMITTED BY LAW, IN NO EVENT WILL COMPANY BE LIABLE TO YOU OR YOUR EMPLOYEES, AFFILIATES, USERS, OFFICERS OR DIRECTORS (A) UNDER ANY THEORY OF LIABILITY, WHETHER BASED IN CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY, WARRANTY, OR OTHERWISE UNDER THIS LICENSE, OR (B) FOR ANY INDIRECT, CONSEQUENTIAL, EXEMPLARY, INCIDENTAL, PUNITIVE OR SPECIAL DAMAGES OR LOST PROFITS, EVEN IF COMPANY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THE FLUX.1 \[dev\] MODEL, ITS CONSTITUENT COMPONENTS, AND ANY OUTPUT (COLLECTIVELY, “MODEL MATERIALS”) ARE NOT DESIGNED OR INTENDED FOR USE IN ANY APPLICATION OR SITUATION WHERE FAILURE OR FAULT OF THE MODEL MATERIALS COULD REASONABLY BE ANTICIPATED TO LEAD TO SERIOUS INJURY OF ANY PERSON, INCLUDING POTENTIAL DISCRIMINATION OR VIOLATION OF AN INDIVIDUAL’S PRIVACY RIGHTS, OR TO SEVERE PHYSICAL, PROPERTY, OR ENVIRONMENTAL DAMAGE (EACH, A “**HIGH-RISK USE**”). IF YOU ELECT TO USE ANY OF THE MODEL MATERIALS FOR A HIGH-RISK USE, YOU DO SO AT YOUR OWN RISK. YOU AGREE TO DESIGN AND IMPLEMENT APPROPRIATE DECISION-MAKING AND RISK-MITIGATION PROCEDURES AND POLICIES IN CONNECTION WITH A HIGH-RISK USE SUCH THAT EVEN IF THERE IS A FAILURE OR FAULT IN ANY OF THE MODEL MATERIALS, THE SAFETY OF PERSONS OR PROPERTY AFFECTED BY THE ACTIVITY STAYS AT A LEVEL THAT IS REASONABLE, APPROPRIATE, AND LAWFUL FOR THE FIELD OF THE HIGH-RISK USE.
|
62 |
+
|
63 |
+
1. **INDEMNIFICATION**
|
64 |
+
|
65 |
+
You will indemnify, defend and hold harmless Company and our subsidiaries and affiliates, and each of our respective shareholders, directors, officers, employees, agents, successors, and assigns (collectively, the “**Company Parties**”) from and against any losses, liabilities, damages, fines, penalties, and expenses (including reasonable attorneys’ fees) incurred by any Company Party in connection with any claim, demand, allegation, lawsuit, proceeding, or investigation (collectively, “**Claims**”) arising out of or related to (a) your access to or use of the FLUX.1 \[dev\] Model (as well as any Output, results or data generated from such access or use), including any High-Risk Use (defined below); (b) your violation of this License; or (c) your violation, misappropriation or infringement of any rights of another (including intellectual property or other proprietary rights and privacy rights). You will promptly notify the Company Parties of any such Claims, and cooperate with Company Parties in defending such Claims. You will also grant the Company Parties sole control of the defense or settlement, at Company’s sole option, of any Claims. This indemnity is in addition to, and not in lieu of, any other indemnities or remedies set forth in a written agreement between you and Company or the other Company Parties.
|
66 |
+
|
67 |
+
1. **Termination; Survival**.
|
68 |
+
|
69 |
+
1. This License will automatically terminate upon any breach by you of the terms of this License.
|
70 |
+
|
71 |
+
1. We may terminate this License, in whole or in part, at any time upon notice (including electronic) to you.
|
72 |
+
|
73 |
+
1. If You initiate any legal action or proceedings against Company or any other entity (including a cross-claim or counterclaim in a lawsuit), alleging that the FLUX.1 \[dev\] Model or any Derivative, or any part thereof, infringe upon intellectual property or other rights owned or licensable by you, then any licenses granted to you under this License will immediately terminate as of the date such legal action or claim is filed or initiated.
|
74 |
+
|
75 |
+
1. Upon termination of this License, you must cease all use, access or Distribution of the FLUX.1 \[dev\] Model and any Derivatives. The following sections survive termination of this License 2(c), 2(d), 4-11.
|
76 |
+
|
77 |
+
1. **Third Party Materials**. The FLUX.1 \[dev\] Model may contain third-party software or other components (including free and open source software) (all of the foregoing, “**Third Party Materials**”), which are subject to the license terms of the respective third-party licensors. Your dealings or correspondence with third parties and your use of or interaction with any Third Party Materials are solely between you and the third party. Company does not control or endorse, and makes no representations or warranties regarding, any Third Party Materials, and your access to and use of such Third Party Materials are at your own risk.
|
78 |
+
|
79 |
+
1. **Trademarks**. You have not been granted any trademark license as part of this License and may not use any name or mark associated with Company without the prior written permission of Company, except to the extent necessary to make the reference required in the Attribution Notice as specified above or as is reasonably necessary in describing the FLUX.1 \[dev\] Model and its creators.
|
80 |
+
|
81 |
+
1. **General**. This License will be governed and construed under the laws of the State of Delaware without regard to conflicts of law provisions. If any provision or part of a provision of this License is unlawful, void or unenforceable, that provision or part of the provision is deemed severed from this License, and will not affect the validity and enforceability of any remaining provisions. The failure of Company to exercise or enforce any right or provision of this License will not operate as a waiver of such right or provision. This License does not confer any third-party beneficiary rights upon any other person or entity. This License, together with the Documentation, contains the entire understanding between you and Company regarding the subject matter of this License, and supersedes all other written or oral agreements and understandings between you and Company regarding such subject matter. No change or addition to any provision of this License will be binding unless it is in writing and signed by an authorized representative of both you and Company.
|
82 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
@@ -1,420 +1,61 @@
|
|
1 |
-
|
|
|
|
|
2 |
|
3 |
-
|
4 |
|
5 |
-
|
6 |
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
- The "fp8 wo quant" refers to the original BFL codebase using fp8 weight only quantization, not using fp8 matmul which is default in this repo.
|
11 |
-
- The "compile blocks & extras" refers to the option within this repo setting the config values `"compile_blocks" true` & `"compile_extras": true`. ❌ means both were set to false, ✅ means both were set to true.
|
12 |
-
- All generations which including a ❌ or ✅ are using this repo.
|
13 |
|
14 |
-
|
15 |
-
| ---------- | ---------- | -------------------------- | ------------ |
|
16 |
-
| 1024x1024 | RTX4090 | bfl codebase fp8 wo quant | 1.7 |
|
17 |
-
| 1024x1024 | RTX4090 | ❌ compile blocks & extras | 2.55 |
|
18 |
-
| 1024x1024 | RTX4090 | ✅ compile blocks & extras | 3.51 |
|
19 |
-
| 1024x1024 | RTX4000ADA | ❌ compile blocks & extras | 0.79 |
|
20 |
-
| 1024x1024 | RTX4000ADA | ✅ compile blocks & extras | 1.26 |
|
21 |
-
| 1024x1024 | RTX6000ADA | bfl codebase | 1.74 |
|
22 |
-
| 1024x1024 | RTX6000ADA | ❌ compile blocks & extras | 2.08 |
|
23 |
-
| 1024x1024 | RTX6000ADA | ✅ compile blocks & extras | 2.8 |
|
24 |
-
| 1024x1024 | H100 | ❌ compile blocks & extras | 6.1 |
|
25 |
-
| 1024x1024 | H100 | ✅ compile blocks & extras | 11.5 |
|
26 |
-
| 768x768 | RTX4090 | bfl codebase fp8 wo quant | 2.32 |
|
27 |
-
| 768x768 | RTX4090 | ❌ compile blocks & extras | 4.47 |
|
28 |
-
| 768x768 | RTX4090 | ✅ compile blocks & extras | 6.2 |
|
29 |
-
| 768x768 | RTX4000 | ❌ compile blocks & extras | 1.41 |
|
30 |
-
| 768x768 | RTX4000 | ✅ compile blocks & extras | 2.19 |
|
31 |
-
| 768x768 | RTX6000ADA | bfl codebase | 3.01 |
|
32 |
-
| 768x768 | RTX6000ADA | ❌ compile blocks & extras | 3.43 |
|
33 |
-
| 768x768 | RTX6000ADA | ✅ compile blocks & extras | 4.46 |
|
34 |
-
| 768x768 | H100 | ❌ compile blocks & extras | 10.3 |
|
35 |
-
| 768x768 | H100 | ✅ compile blocks & extras | 20.8 |
|
36 |
-
| 1024x720 | RTX4090 | bfl codebase fp8 wo quant | 3.01 |
|
37 |
-
| 1024x720 | RTX4090 | ❌ compile blocks & extras | 3.6 |
|
38 |
-
| 1024x720 | RTX4090 | ✅ compile blocks & extras | 4.96 |
|
39 |
-
| 1024x720 | RTX4000 | ❌ compile blocks & extras | 1.14 |
|
40 |
-
| 1024x720 | RTX4000 | ✅ compile blocks & extras | 1.78 |
|
41 |
-
| 1024x720 | RTX6000ADA | bfl codebase | 2.37 |
|
42 |
-
| 1024x720 | RTX6000ADA | ❌ compile blocks & extras | 2.87 |
|
43 |
-
| 1024x720 | RTX6000ADA | ✅ compile blocks & extras | 3.78 |
|
44 |
-
| 1024x720 | H100 | ❌ compile blocks & extras | 8.2 |
|
45 |
-
| 1024x720 | H100 | ✅ compile blocks & extras | 15.7 |
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
- [Installation](#installation)
|
50 |
-
- [Usage](#usage)
|
51 |
-
- [Configuration](#configuration)
|
52 |
-
- [API Endpoints](#api-endpoints)
|
53 |
-
- [Examples](#examples)
|
54 |
-
- [License](https://github.com/aredden/flux-fp8-api/blob/main/LICENSE)
|
55 |
-
|
56 |
-
### Updates 08/24/24
|
57 |
-
|
58 |
-
- Add config options for levels of quantization for the flow transformer:
|
59 |
-
- `quantize_modulation`: Quantize the modulation layers in the flow model. If false, adds ~2GB vram usage for moderate precision improvements `(default: true)`
|
60 |
-
- `quantize_flow_embedder_layers`: Quantize the flow embedder layers in the flow model. If false, adds ~512MB vram usage, but precision improves considerably. `(default: false)`
|
61 |
-
- Override default config values when loading FluxPipeline, e.g. `FluxPipeline.load_pipeline_from_config_path(config_path, **config_overrides)`
|
62 |
-
|
63 |
-
#### Fixes
|
64 |
-
|
65 |
-
- Fix bug where loading text encoder from HF with bnb will error if device is not set to cuda:0
|
66 |
-
|
67 |
-
**note:** prequantized flow models will only work with the specified quantization levels as when they were created. e.g. if you create a prequantized flow model with `quantize_modulation` set to false, it will only work with `quantize_modulation` set to false, same with `quantize_flow_embedder_layers`.
|
68 |
-
|
69 |
-
### Updates 08/25/24
|
70 |
-
|
71 |
-
- Added LoRA loading functionality to FluxPipeline. Simple example:
|
72 |
-
|
73 |
-
```python
|
74 |
-
from flux_pipeline import FluxPipeline
|
75 |
-
|
76 |
-
config_path = "path/to/config/file.json"
|
77 |
-
config_overrides = {
|
78 |
-
#...
|
79 |
-
}
|
80 |
-
|
81 |
-
lora_path = "path/to/lora/file.safetensors"
|
82 |
-
|
83 |
-
pipeline = FluxPipeline.load_pipeline_from_config_path(config_path, **config_overrides)
|
84 |
-
|
85 |
-
pipeline.load_lora(lora_path, scale=1.0)
|
86 |
-
```
|
87 |
-
|
88 |
-
### Updates 09/07/24
|
89 |
-
|
90 |
-
- Improve quality by ensuring that the RMSNorm layers use fp32
|
91 |
-
- Raise the clamp range for single blocks & double blocks to +/-32000 to reduce deviation from expected outputs.
|
92 |
-
- Make BF16 _not_ clamp, which improves quality and isn't needed because bf16 is the expected dtype for flux. **I would now recommend always using `"flow_dtype": "bfloat16"` in the config**, though it will slow things down on consumer gpus- but not by much at all since most of the compute still happens via fp8.
|
93 |
-
- Allow for the T5 Model to be run without any quantization, by specifying `"text_enc_quantization_dtype": "bfloat16"` in the config - or also `"float16"`, though not recommended since t5 deviates a bit when running with float16. I noticed that even with qint8/qfloat8 there is a bit of deviation from bf16 text encoder outputs- so for those who want more accurate / expected text encoder outputs, you can use this option.
|
94 |
-
|
95 |
-
### Updates 10/3/24
|
96 |
-
|
97 |
-
- #### Adding configurable clip model path
|
98 |
-
Now you can specify the clip model's path in the config, using the `clip_path` parameter in a config file.
|
99 |
-
- #### Improved lora loading
|
100 |
-
I believe I have fixed the lora loading bug that was causing the lora to not apply properly, or when not all of the linear weights in the q/k/v/o had loras attached (it wouldn't be able to apply if only some of them did).
|
101 |
-
- #### Lora loading via api endpoint
|
102 |
-
|
103 |
-
You can now post to the `/lora` endpoint with a json file containing a `scale`, `path`, `name`, and `action` parameters.
|
104 |
-
|
105 |
-
The `path` should be the path to the lora safetensors file either absolute or relative to the root of this repo.
|
106 |
-
|
107 |
-
The `name` is an optional parameter, mainly just for checking purposes to see if the correct lora was being loaded, it's used as an identifier to check whether it's already been loaded or which lora to unload if `action` is `unload` (you can also use the exact same path which was loaded previously to unload the same lora).
|
108 |
-
|
109 |
-
The `action` should be either `load` or `unload`, to load or unload the lora.
|
110 |
-
|
111 |
-
The `scale` should be a float, which is the scale of the lora.
|
112 |
-
|
113 |
-
e.g.
|
114 |
-
|
115 |
-
```json
|
116 |
-
{
|
117 |
-
<!-- If you have a lora directory like 'fluxloras' in the root of this repo -->
|
118 |
-
"path": "./fluxloras/loras/aidmaImageUpgrader-FLUX-V0.2.safetensors",
|
119 |
-
<!-- name is optional -->
|
120 |
-
"name": "imgupgrade",
|
121 |
-
<!-- action (load or unload) is required -->
|
122 |
-
"action": "load",
|
123 |
-
<!-- lora scale to use -->
|
124 |
-
"scale": 0.6
|
125 |
-
}
|
126 |
-
```
|
127 |
-
|
128 |
-
## Installation
|
129 |
-
|
130 |
-
This repo _requires_ at least pytorch with cuda=12.4 and an ADA gpu with fp8 support, otherwise `torch._scaled_mm` will throw a CUDA error saying it's not supported. To install with conda/mamba:
|
131 |
-
|
132 |
-
```bash
|
133 |
-
mamba create -n flux-fp8-matmul-api python=3.11 pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia
|
134 |
-
mamba activate flux-fp8-matmul-api
|
135 |
-
|
136 |
-
# or with conda
|
137 |
-
conda create -n flux-fp8-matmul-api python=3.11 pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia
|
138 |
-
conda activate flux-fp8-matmul-api
|
139 |
-
|
140 |
-
# or with nightly... (which is what I am using) - also, just switch 'mamba' to 'conda' if you are using conda
|
141 |
-
mamba create -n flux-fp8-matmul-api python=3.11 pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch-nightly -c nvidia
|
142 |
-
mamba activate flux-fp8-matmul-api
|
143 |
-
|
144 |
-
# or with pip
|
145 |
-
python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
|
146 |
-
# or pip nightly
|
147 |
-
python -m pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu124
|
148 |
-
```
|
149 |
-
|
150 |
-
To install the required dependencies, run:
|
151 |
-
|
152 |
-
```bash
|
153 |
-
python -m pip install -r requirements.txt
|
154 |
-
```
|
155 |
-
|
156 |
-
If you get errors installing `torch-cublas-hgemm`, feel free to comment it out in requirements.txt, since it's not necessary, but will speed up inference for non-fp8 linear layers.
|
157 |
-
|
158 |
-
## Usage
|
159 |
-
|
160 |
-
For a single ADA GPU with less than 24GB vram, and more than 16GB vram, you should use the `configs/config-dev-offload-1-4080.json` config file as a base, and then tweak the parameters to fit your needs. It offloads all models to CPU when not in use, compiles the flow model with extra optimizations, and quantizes the text encoder to nf4 and the autoencoder to qfloat8.
|
161 |
-
|
162 |
-
For a single ADA GPU with more than ~32GB vram, you should use the `configs/config-dev-1-RTX6000ADA.json` config file as a base, and then tweak the parameters to fit your needs. It does not offload any models to CPU, compiles the flow model with extra optimizations, and quantizes the text encoder to qfloat8 and the autoencoder to stays as bfloat16.
|
163 |
-
|
164 |
-
For a single 4090 GPU, you should use the `configs/config-dev-offload-1-4090.json` config file as a base, and then tweak the parameters to fit your needs. It offloads the text encoder and the autoencoder to CPU, compiles the flow model with extra optimizations, and quantizes the text encoder to nf4 and the autoencoder to float8.
|
165 |
-
|
166 |
-
**NOTE:** For all of these configs, you must change the `ckpt_path`, `ae_path`, and `text_enc_path` parameters to the path to your own checkpoint, autoencoder, and text encoder.
|
167 |
-
|
168 |
-
You can run the API server using the following command:
|
169 |
|
170 |
```bash
|
171 |
-
|
172 |
```
|
173 |
|
174 |
-
###
|
175 |
-
|
176 |
-
- `--config-path`: Path to the configuration file. If not provided, the model will be loaded from the command line arguments.
|
177 |
-
- `--port`: Port to run the server on (default: 8088).
|
178 |
-
- `--host`: Host to run the server on (default: 0.0.0.0).
|
179 |
-
- `--flow-model-path`: Path to the flow model.
|
180 |
-
- `--text-enc-path`: Path to the text encoder.
|
181 |
-
- `--autoencoder-path`: Path to the autoencoder.
|
182 |
-
- `--model-version`: Choose model version (`flux-dev` or `flux-schnell`).
|
183 |
-
- `--flux-device`: Device to run the flow model on (default: cuda:0).
|
184 |
-
- `--text-enc-device`: Device to run the text encoder on (default: cuda:0).
|
185 |
-
- `--autoencoder-device`: Device to run the autoencoder on (default: cuda:0).
|
186 |
-
- `--compile`: Compile the flow model with extra optimizations (default: False).
|
187 |
-
- `--quant-text-enc`: Quantize the T5 text encoder to the given dtype (`qint4`, `qfloat8`, `qint2`, `qint8`, `bf16`), if `bf16`, will not quantize (default: `qfloat8`).
|
188 |
-
- `--quant-ae`: Quantize the autoencoder with float8 linear layers, otherwise will use bfloat16 (default: False).
|
189 |
-
- `--offload-flow`: Offload the flow model to the CPU when not being used to save memory (default: False).
|
190 |
-
- `--no-offload-ae`: Disable offloading the autoencoder to the CPU when not being used to increase e2e inference speed (default: True [implies it will offload, setting this flag sets it to False]).
|
191 |
-
- `--no-offload-text-enc`: Disable offloading the text encoder to the CPU when not being used to increase e2e inference speed (default: True [implies it will offload, setting this flag sets it to False]).
|
192 |
-
- `--prequantized-flow`: Load the flow model from a prequantized checkpoint, which reduces the size of the checkpoint by about 50% & reduces startup time (default: False).
|
193 |
-
- `--no-quantize-flow-modulation`: Disable quantization of the modulation layers in the flow transformer, which improves precision _moderately_ but adds ~2GB vram usage.
|
194 |
-
- `--quantize-flow-embedder-layers`: Quantize the flow embedder layers in the flow transformer, reduces precision _considerably_ but saves ~512MB vram usage.
|
195 |
-
|
196 |
-
## Configuration
|
197 |
-
|
198 |
-
The configuration files are located in the `configs` directory. You can specify different configurations for different model versions and devices.
|
199 |
-
|
200 |
-
Example configuration file for a single 4090 (`configs/config-dev-offload-1-4090.json`):
|
201 |
-
|
202 |
-
```js
|
203 |
-
{
|
204 |
-
"version": "flux-dev", // or flux-schnell
|
205 |
-
"params": {
|
206 |
-
"in_channels": 64,
|
207 |
-
"vec_in_dim": 768,
|
208 |
-
"context_in_dim": 4096,
|
209 |
-
"hidden_size": 3072,
|
210 |
-
"mlp_ratio": 4.0,
|
211 |
-
"num_heads": 24,
|
212 |
-
"depth": 19,
|
213 |
-
"depth_single_blocks": 38,
|
214 |
-
"axes_dim": [16, 56, 56],
|
215 |
-
"theta": 10000,
|
216 |
-
"qkv_bias": true,
|
217 |
-
"guidance_embed": true // if you are using flux-schnell, set this to false
|
218 |
-
},
|
219 |
-
"ae_params": {
|
220 |
-
"resolution": 256,
|
221 |
-
"in_channels": 3,
|
222 |
-
"ch": 128,
|
223 |
-
"out_ch": 3,
|
224 |
-
"ch_mult": [1, 2, 4, 4],
|
225 |
-
"num_res_blocks": 2,
|
226 |
-
"z_channels": 16,
|
227 |
-
"scale_factor": 0.3611,
|
228 |
-
"shift_factor": 0.1159
|
229 |
-
},
|
230 |
-
"ckpt_path": "/your/path/to/flux1-dev.sft", // local path to original bf16 BFL flux checkpoint
|
231 |
-
"ae_path": "/your/path/to/ae.sft", // local path to original bf16 BFL autoencoder checkpoint
|
232 |
-
"repo_id": "black-forest-labs/FLUX.1-dev", // can ignore
|
233 |
-
"repo_flow": "flux1-dev.sft", // can ignore
|
234 |
-
"repo_ae": "ae.sft", // can ignore
|
235 |
-
"text_enc_max_length": 512, // use 256 if you are using flux-schnell
|
236 |
-
"text_enc_path": "city96/t5-v1_1-xxl-encoder-bf16", // or custom HF full bf16 T5EncoderModel repo id
|
237 |
-
"text_enc_device": "cuda:0",
|
238 |
-
"ae_device": "cuda:0",
|
239 |
-
"flux_device": "cuda:0",
|
240 |
-
"flow_dtype": "float16",
|
241 |
-
"ae_dtype": "bfloat16",
|
242 |
-
"text_enc_dtype": "bfloat16",
|
243 |
-
"flow_quantization_dtype": "qfloat8", // will always be qfloat8, so can ignore
|
244 |
-
"text_enc_quantization_dtype": "qint4", // choose between qint4, qint8, qfloat8, qint2 or delete entry for no quantization
|
245 |
-
"ae_quantization_dtype": "qfloat8", // can either be qfloat8 or delete entry for no quantization
|
246 |
-
"compile_extras": true, // compile the layers not included in the single-blocks or double-blocks
|
247 |
-
"compile_blocks": true, // compile the single-blocks and double-blocks
|
248 |
-
"offload_text_encoder": true, // offload the text encoder to cpu when not in use
|
249 |
-
"offload_vae": true, // offload the autoencoder to cpu when not in use
|
250 |
-
"offload_flow": false, // offload the flow transformer to cpu when not in use
|
251 |
-
"prequantized_flow": false, // load the flow transformer from a prequantized checkpoint, which reduces the size of the checkpoint by about 50% & reduces startup time (default: false)
|
252 |
-
"quantize_modulation": true, // quantize the modulation layers in the flow transformer, which reduces precision moderately but saves ~2GB vram usage (default: true)
|
253 |
-
"quantize_flow_embedder_layers": false, // quantize the flow embedder layers in the flow transformer, if false, improves precision considerably at the cost of adding ~512MB vram usage (default: false)
|
254 |
-
}
|
255 |
-
```
|
256 |
-
|
257 |
-
The only things you should need to change in general are the:
|
258 |
-
|
259 |
-
```json5
|
260 |
-
"ckpt_path": "/path/to/your/flux1-dev.sft", // path to your original BFL flow transformer (not diffusers)
|
261 |
-
"ae_path": "/path/to/your/ae.sft", // path to your original BFL autoencoder (not diffusers)
|
262 |
-
"text_enc_path": "path/to/your/t5-v1_1-xxl-encoder-bf16", // HF T5EncoderModel - can use "city96/t5-v1_1-xxl-encoder-bf16" for a simple to download version
|
263 |
-
```
|
264 |
-
|
265 |
-
Other things to change can be the
|
266 |
-
|
267 |
-
- `"text_enc_max_length": 512`
|
268 |
-
max length for the text encoder, 256 if you are using flux-schnell
|
269 |
-
|
270 |
-
- `"ae_quantization_dtype": "qfloat8"`
|
271 |
-
quantization dtype for the autoencoder, can be `qfloat8` or delete entry for no quantization, will use the float8 linear layer implementation included in this repo.
|
272 |
-
|
273 |
-
- `"text_enc_quantization_dtype": "qfloat8"`
|
274 |
-
quantization dtype for the text encoder, if `qfloat8` or `qint2` will use quanto, `qint4`, `qint8` will use bitsandbytes
|
275 |
-
|
276 |
-
- `"compile_extras": true,`
|
277 |
-
compiles all modules that are not the single-blocks or double-blocks (default: false)
|
278 |
-
|
279 |
-
- `"compile_blocks": true,`
|
280 |
-
compiles all single-blocks and double-blocks (default: false)
|
281 |
-
|
282 |
-
- `"text_enc_offload": false,`
|
283 |
-
offload text encoder to cpu (default: false) - set to true if you only have a single 4090 and no other GPUs, otherwise you can set this to false and reduce latency [NOTE: this will be slow, if you have multiple GPUs, change the text_enc_device to a different device so you can set offloading for text_enc to false]
|
284 |
-
|
285 |
-
- `"ae_offload": false,`
|
286 |
-
offload autoencoder to cpu (default: false) - set to true if you only have a single 4090 and no other GPUs, otherwise you can set this to false and reduce latency [NOTE: this will be slow, if you have multiple GPUs, change the ae_device to a different device so you can set offloading for ae to false]
|
287 |
-
|
288 |
-
- `"flux_offload": false,`
|
289 |
-
offload flow transformer to cpu (default: false) - set to true if you only have a single 4090 and no other GPUs, otherwise you can set this to false and reduce latency [NOTE: this will be slow, if you have multiple GPUs, change the flux_device to a different device so you can set offloading for flux to false]
|
290 |
-
|
291 |
-
- `"flux_device": "cuda:0",`
|
292 |
-
device for flow transformer (default: cuda:0) - this gpu must have fp8 support and at least 16GB of memory, does not need to be the same as text_enc_device or ae_device
|
293 |
-
|
294 |
-
- `"text_enc_device": "cuda:0",`
|
295 |
-
device for text encoder (default: cuda:0) - set this to a different device - e.g. `"cuda:1"` if you have multiple gpus so you can set offloading for text_enc to false, does not need to be the same as flux_device or ae_device
|
296 |
-
|
297 |
-
- `"ae_device": "cuda:0",`
|
298 |
-
device for autoencoder (default: cuda:0) - set this to a different device - e.g. `"cuda:1"` if you have multiple gpus so you can set offloading for ae to false, does not need to be the same as flux_device or text_enc_device
|
299 |
-
|
300 |
-
- `"prequantized_flow": false,`
|
301 |
-
load the flow transformer from a prequantized checkpoint, which reduces the size of the checkpoint by about 50% & reduces startup time (default: false)
|
302 |
-
|
303 |
-
- Note: MUST be a prequantized checkpoint created with the same quantization settings as the current config, and must have been quantized using this repo.
|
304 |
-
|
305 |
-
- `"quantize_modulation": true,`
|
306 |
-
quantize the modulation layers in the flow transformer, which improves precision at the cost of adding ~2GB vram usage (default: true)
|
307 |
-
|
308 |
-
- `"quantize_flow_embedder_layers": false,`
|
309 |
-
quantize the flow embedder layers in the flow transformer, which improves precision considerably at the cost of adding ~512MB vram usage (default: false)
|
310 |
-
|
311 |
-
## API Endpoints
|
312 |
-
|
313 |
-
### Generate Image
|
314 |
-
|
315 |
-
- **URL**: `/generate`
|
316 |
-
- **Method**: `POST`
|
317 |
-
- **Request Body**:
|
318 |
-
|
319 |
-
- `prompt` (str): The text prompt for image generation.
|
320 |
-
- `width` (int, optional): The width of the generated image (default: 720).
|
321 |
-
- `height` (int, optional): The height of the generated image (default: 1024).
|
322 |
-
- `num_steps` (int, optional): The number of steps for the generation process (default: 24).
|
323 |
-
- `guidance` (float, optional): The guidance scale for the generation process (default: 3.5).
|
324 |
-
- `seed` (int, optional): The seed for random number generation.
|
325 |
-
- `init_image` (str, optional): The base64 encoded image to be used as a reference for the generation process.
|
326 |
-
- `strength` (float, optional): The strength of the diffusion process when image is provided (default: 1.0).
|
327 |
-
|
328 |
-
- **Response**: A JPEG image stream.
|
329 |
-
|
330 |
-
## Examples
|
331 |
-
|
332 |
-
### Running the Server
|
333 |
-
|
334 |
-
```bash
|
335 |
-
python main.py --config-path configs/config-dev-1-4090.json --port 8088 --host 0.0.0.0
|
336 |
-
```
|
337 |
-
|
338 |
-
Or if you need more granular control over the all of the settings, you can run the server with something like this:
|
339 |
|
340 |
```bash
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
|
|
352 |
```
|
353 |
|
354 |
-
|
355 |
|
356 |
-
|
357 |
|
358 |
-
|
359 |
-
{
|
360 |
-
"prompt": "a beautiful asian woman in traditional clothing with golden hairpin and blue eyes, wearing a red kimono with dragon patterns",
|
361 |
-
"width": 1024,
|
362 |
-
"height": 1024,
|
363 |
-
"num_steps": 24,
|
364 |
-
"guidance": 3.0,
|
365 |
-
"seed": 13456
|
366 |
-
}
|
367 |
-
```
|
368 |
-
|
369 |
-
For an example of how to generate from a python client using the FastAPI server:
|
370 |
|
371 |
-
|
372 |
-
import requests
|
373 |
-
import io
|
374 |
|
375 |
-
|
376 |
-
res = requests.post(
|
377 |
-
"http://localhost:8088/generate",
|
378 |
-
json={
|
379 |
-
"width": 1024,
|
380 |
-
"height": 720,
|
381 |
-
"num_steps": 20,
|
382 |
-
"guidance": 4,
|
383 |
-
"prompt": prompt,
|
384 |
-
},
|
385 |
-
stream=True,
|
386 |
-
)
|
387 |
|
388 |
-
|
389 |
-
|
|
|
|
|
|
|
|
|
|
|
390 |
|
391 |
-
|
392 |
|
393 |
-
You can also generate an image by directly importing the FluxPipeline class and using it to generate an image. This is useful if you have a custom model configuration and want to generate an image without having to run the server.
|
394 |
|
395 |
-
|
396 |
-
import io
|
397 |
-
from flux_pipeline import FluxPipeline
|
398 |
|
399 |
-
|
400 |
-
pipe = FluxPipeline.load_pipeline_from_config_path(
|
401 |
-
"configs/config-dev-offload-1-4090.json" # or whatever your config is
|
402 |
-
)
|
403 |
-
|
404 |
-
output_jpeg_bytes: io.BytesIO = pipe.generate(
|
405 |
-
# Required args:
|
406 |
-
prompt="A beautiful asian woman in traditional clothing with golden hairpin and blue eyes, wearing a red kimono with dragon patterns",
|
407 |
-
# Optional args:
|
408 |
-
width=1024,
|
409 |
-
height=1024,
|
410 |
-
num_steps=20,
|
411 |
-
guidance=3.5,
|
412 |
-
seed=13456,
|
413 |
-
init_image="path/to/your/init_image.jpg",
|
414 |
-
strength=0.8,
|
415 |
-
)
|
416 |
-
|
417 |
-
with open("output.jpg", "wb") as f:
|
418 |
-
f.write(output_jpeg_bytes.getvalue())
|
419 |
-
|
420 |
-
```
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
|
5 |
+
# FLUX.1 [schnell] -- Flumina Server App (FP8 Version)
|
6 |
|
7 |
+
This repository contains an implementation of the FLUX.1 [schnell] [FP8 version](https://github.com/aredden/flux-fp8-api), which utilizes float8 numerics instead of bfloat16. This update allows for a 2x performance improvement, significantly speeding up inference tasks when deployed via Fireworks AI’s Flumina Server App toolkit.
|
8 |
|
9 |
+

|
10 |
|
11 |
+
## Getting Started -- Serverless deployment on Fireworks
|
|
|
|
|
|
|
12 |
|
13 |
+
This FP8 Server App is deployed to Fireworks as-is in a "serverless" deployment, offering high-speed, hassle-free performance.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
Grab an [API Key](https://fireworks.ai/account/api-keys) from Fireworks and set it in your environment variables:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
```bash
|
18 |
+
export API_KEY=YOUR_API_KEY_HERE
|
19 |
```
|
20 |
|
21 |
+
### Text-to-Image Example Call
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
```bash
|
24 |
+
curl -X POST 'https://api.fireworks.ai/inference/v1/workflows/accounts/fireworks/models/flux-1-schnell-fp8/text_to_image' \
|
25 |
+
-H "Authorization: Bearer $API_KEY" \
|
26 |
+
-H "Content-Type: application/json" \
|
27 |
+
-H "Accept: image/jpeg" \
|
28 |
+
-d '{
|
29 |
+
"prompt": "Woman laying in the grass",
|
30 |
+
"aspect_ratio": "16:9",
|
31 |
+
"guidance_scale": 3.5,
|
32 |
+
"num_inference_steps": 4,
|
33 |
+
"seed": 0
|
34 |
+
}' \
|
35 |
+
--output output.jpg
|
36 |
```
|
37 |
|
38 |
+

|
39 |
|
40 |
+
## What is Flumina?
|
41 |
|
42 |
+
Flumina is Fireworks.ai’s innovative platform for hosting Server Apps that lets users deploy deep learning inference to production environments in just minutes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
+
## What does Flumina offer for FLUX models?
|
|
|
|
|
45 |
|
46 |
+
Flumina provides the following advantages for FLUX models:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
+
* Clear, precise definitions of server-side workloads by reviewing the server app implementation (right here).
|
49 |
+
* Extensibility interface for dynamic loading and dispatching of add-ons server-side. For FLUX, this includes:
|
50 |
+
* ControlNet (Union) adapters
|
51 |
+
* LoRA adapters
|
52 |
+
* Off-the-shelf support for on-demand capacity scaling with Server Apps on Fireworks.
|
53 |
+
* Customization of the deployment logic through modifications to the Server App, with easy redeployment.
|
54 |
+
* Support for FP8 numerics, unlocking faster, more efficient inference capabilities.
|
55 |
|
56 |
+
## Deploying FLUX.1 [schnell] FP8 Version to Fireworks On-Demand
|
57 |
|
|
|
58 |
|
59 |
+
## Deploying Custom FLUX.1 [schnell] FP8 Apps to Fireworks On-demand
|
|
|
|
|
60 |
|
61 |
+
Coming soon!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
example.png
ADDED
![]() |
Git LFS Details
|
flumina.py
CHANGED
@@ -95,7 +95,7 @@ def parse_accept_header(accept: str) -> str:
|
|
95 |
r"(?P<media_type>[^;]+)(;q=(?P<q_factor>\d+(\.\d+)?))?", part.strip()
|
96 |
)
|
97 |
if match:
|
98 |
-
media_type = match.group("media_type")
|
99 |
q_factor = (
|
100 |
float(match.group("q_factor")) if match.group("q_factor") else 1.0
|
101 |
)
|
@@ -106,11 +106,19 @@ def parse_accept_header(accept: str) -> str:
|
|
106 |
# Sort the media types by q-factor, descending
|
107 |
sorted_types = sorted(weighted_types, key=lambda x: x[1], reverse=True)
|
108 |
|
|
|
|
|
|
|
109 |
for media_type, _ in sorted_types:
|
110 |
-
if media_type in
|
111 |
return media_type
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
-
raise ValueError(f"Accept header did not include
|
114 |
|
115 |
|
116 |
# Define request and response schemata
|
@@ -319,7 +327,7 @@ if __name__ == "__main__":
|
|
319 |
body=Text2ImageRequest(
|
320 |
prompt="test"
|
321 |
),
|
322 |
-
accept="
|
323 |
))
|
324 |
with open("out_image.png", "wb") as f:
|
325 |
f.write(out)
|
|
|
95 |
r"(?P<media_type>[^;]+)(;q=(?P<q_factor>\d+(\.\d+)?))?", part.strip()
|
96 |
)
|
97 |
if match:
|
98 |
+
media_type = match.group("media_type").strip()
|
99 |
q_factor = (
|
100 |
float(match.group("q_factor")) if match.group("q_factor") else 1.0
|
101 |
)
|
|
|
106 |
# Sort the media types by q-factor, descending
|
107 |
sorted_types = sorted(weighted_types, key=lambda x: x[1], reverse=True)
|
108 |
|
109 |
+
# Define a list of supported MIME types
|
110 |
+
supported_types = ["image/jpeg", "image/png"]
|
111 |
+
|
112 |
for media_type, _ in sorted_types:
|
113 |
+
if media_type in supported_types:
|
114 |
return media_type
|
115 |
+
elif media_type == "*/*":
|
116 |
+
return supported_types[0] # Default to the first supported type
|
117 |
+
elif media_type == "image/*":
|
118 |
+
# If "image/*" is specified, return the first matching supported image type
|
119 |
+
return supported_types[0]
|
120 |
|
121 |
+
raise ValueError(f"Accept header did not include any supported MIME types: {supported_types}")
|
122 |
|
123 |
|
124 |
# Define request and response schemata
|
|
|
327 |
body=Text2ImageRequest(
|
328 |
prompt="test"
|
329 |
),
|
330 |
+
accept="*/*"
|
331 |
))
|
332 |
with open("out_image.png", "wb") as f:
|
333 |
f.write(out)
|
t2i_output.jpg
ADDED
![]() |