Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
fengzch-das
nunchaku
Commits
a1a15d64
Commit
a1a15d64
authored
Mar 07, 2025
by
muyangli
Browse files
update two example scripts
parent
82274c1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
examples/int4-flux.1-dev-offload.py
examples/int4-flux.1-dev-offload.py
+15
-0
examples/int4-flux.1-schnell-offload.py
examples/int4-flux.1-schnell-offload.py
+16
-0
No files found.
examples/int4-flux.1-dev-offload.py
0 → 100644
View file @
a1a15d64
import
torch
from
diffusers
import
FluxPipeline
from
nunchaku
import
NunchakuFluxTransformer2dModel
,
NunchakuT5EncoderModel
transformer
=
NunchakuFluxTransformer2dModel
.
from_pretrained
(
"mit-han-lab/svdq-int4-flux.1-dev"
,
offload
=
True
)
# set offload to False if you want to disable offloading
text_encoder_2
=
NunchakuT5EncoderModel
.
from_pretrained
(
"mit-han-lab/svdq-flux.1-t5"
)
pipeline
=
FluxPipeline
.
from_pretrained
(
"black-forest-labs/FLUX.1-dev"
,
transformer
=
transformer
,
torch_dtype
=
torch
.
bfloat16
)
pipeline
.
enable_sequential_cpu_offload
()
# remove this line if you want to disable the CPU offloading
image
=
pipeline
(
"A cat holding a sign that says hello world"
,
num_inference_steps
=
50
,
guidance_scale
=
3.5
).
images
[
0
]
image
.
save
(
"flux.1-dev.png"
)
examples/int4-flux.1-schnell-offload.py
0 → 100644
View file @
a1a15d64
import
torch
from
diffusers
import
FluxPipeline
from
nunchaku
import
NunchakuFluxTransformer2dModel
,
NunchakuT5EncoderModel
transformer
=
NunchakuFluxTransformer2dModel
.
from_pretrained
(
"mit-han-lab/svdq-int4-flux.1-schnell"
,
offload
=
True
)
# set offload to False if you want to disable offloading
pipeline
=
FluxPipeline
.
from_pretrained
(
"black-forest-labs/FLUX.1-schnell"
,
transformer
=
transformer
,
torch_dtype
=
torch
.
bfloat16
)
pipeline
.
enable_sequential_cpu_offload
()
# remove this line if you want to disable the CPU offloading
image
=
pipeline
(
"A cat holding a sign that says hello world"
,
width
=
1024
,
height
=
1024
,
num_inference_steps
=
4
,
guidance_scale
=
0
).
images
[
0
]
image
.
save
(
"flux.1-schnell.png"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment