Update src/pipeline.py
Browse files- src/pipeline.py +12 -9
src/pipeline.py
CHANGED
@@ -19,21 +19,24 @@ torch._dynamo.config.suppress_errors = True
|
|
19 |
Pipeline = None
|
20 |
ids = "slobers/Flux.1.Schnella"
|
21 |
Revision = "e34d670e44cecbbc90e4962e7aada2ac5ce8b55b"
|
|
|
|
|
|
|
22 |
|
23 |
def load_pipeline() -> Pipeline:
|
24 |
path = os.path.join(HF_HUB_CACHE, "models--slobers--Flux.1.Schnella/snapshots/e34d670e44cecbbc90e4962e7aada2ac5ce8b55b/transformer")
|
25 |
transformer = FluxTransformer2DModel.from_pretrained(path, torch_dtype=torch.bfloat16, use_safetensors=False)
|
26 |
-
pipeline = FluxPipeline.from_pretrained(
|
27 |
-
|
28 |
pipeline.transformer = torch.compile(pipeline.transformer, mode="max-autotune", fullgraph=True)
|
29 |
-
basepath = os.path.join(HF_HUB_CACHE, "models--manbeast3b--Flux.1.schnell_eagle5_1_0.1_unst_7_2k/snapshots/b7a5ce1313327009093d3178220267d0cf669b76")
|
30 |
-
basepath = os.path.join(HF_HUB_CACHE, "models--manbeast3b--Flux.1.schnell_eagle5_1_0.1_unst_8/snapshots/3666a458a53e7dc83adfecb0bf955a0b4d575843")
|
31 |
-
basepath = os.path.join(HF_HUB_CACHE, "models--manbeast3b--Flux.1.schnell_eagle5_1_0.1_unst_13/snapshots/b3bdda899cd1961ec9b97bffde3ded31afa73ce3")
|
32 |
-
basepath = os.path.join(HF_HUB_CACHE, "models--manbeast3b--Flux.1.schnell_eagle5_1_0.1_unst_10/snapshots/20e4cf6ce3cc658237dfd6aae1d5f14bc6b3d1a4")
|
33 |
-
pipeline.vae.encoder.load_state_dict(torch.load(os.path.join(basepath, "encoder.pth")), strict=False)
|
34 |
-
pipeline.vae.decoder.load_state_dict(torch.load(os.path.join(basepath, "decoder.pth")), strict=False)
|
35 |
quantize_(pipeline.vae, int8_weight_only())
|
36 |
-
|
37 |
for _ in range(3):
|
38 |
pipeline(prompt="insensible, timbale, pothery, electrovital, actinogram, taxis, intracerebellar, centrodesmus", width=1024, height=1024, guidance_scale=0.0, num_inference_steps=4, max_sequence_length=256)
|
39 |
return pipeline
|
|
|
19 |
Pipeline = None
|
20 |
ids = "slobers/Flux.1.Schnella"
|
21 |
Revision = "e34d670e44cecbbc90e4962e7aada2ac5ce8b55b"
|
22 |
+
ckpt_id = "manbeast3b/flux.1-schnell-full1"
|
23 |
+
ckpt_revision = "cb1b599b0d712b9aab2c4df3ad27b050a27ec146"
|
24 |
+
|
25 |
|
26 |
def load_pipeline() -> Pipeline:
|
27 |
path = os.path.join(HF_HUB_CACHE, "models--slobers--Flux.1.Schnella/snapshots/e34d670e44cecbbc90e4962e7aada2ac5ce8b55b/transformer")
|
28 |
transformer = FluxTransformer2DModel.from_pretrained(path, torch_dtype=torch.bfloat16, use_safetensors=False)
|
29 |
+
pipeline = FluxPipeline.from_pretrained(ckpt_id, revision=ckpt_revision, transformer=transformer, local_files_only=True, torch_dtype=torch.bfloat16,)
|
30 |
+
pipeline.to("cuda")
|
31 |
pipeline.transformer = torch.compile(pipeline.transformer, mode="max-autotune", fullgraph=True)
|
32 |
+
# basepath = os.path.join(HF_HUB_CACHE, "models--manbeast3b--Flux.1.schnell_eagle5_1_0.1_unst_7_2k/snapshots/b7a5ce1313327009093d3178220267d0cf669b76")
|
33 |
+
# basepath = os.path.join(HF_HUB_CACHE, "models--manbeast3b--Flux.1.schnell_eagle5_1_0.1_unst_8/snapshots/3666a458a53e7dc83adfecb0bf955a0b4d575843")
|
34 |
+
# basepath = os.path.join(HF_HUB_CACHE, "models--manbeast3b--Flux.1.schnell_eagle5_1_0.1_unst_13/snapshots/b3bdda899cd1961ec9b97bffde3ded31afa73ce3")
|
35 |
+
# basepath = os.path.join(HF_HUB_CACHE, "models--manbeast3b--Flux.1.schnell_eagle5_1_0.1_unst_10/snapshots/20e4cf6ce3cc658237dfd6aae1d5f14bc6b3d1a4")
|
36 |
+
# pipeline.vae.encoder.load_state_dict(torch.load(os.path.join(basepath, "encoder.pth")), strict=False)
|
37 |
+
# pipeline.vae.decoder.load_state_dict(torch.load(os.path.join(basepath, "decoder.pth")), strict=False)
|
38 |
quantize_(pipeline.vae, int8_weight_only())
|
39 |
+
|
40 |
for _ in range(3):
|
41 |
pipeline(prompt="insensible, timbale, pothery, electrovital, actinogram, taxis, intracerebellar, centrodesmus", width=1024, height=1024, guidance_scale=0.0, num_inference_steps=4, max_sequence_length=256)
|
42 |
return pipeline
|