Update src/pipeline.py
Browse files- src/pipeline.py +8 -9
src/pipeline.py
CHANGED
|
@@ -17,17 +17,16 @@ os.environ["TOKENIZERS_PARALLELISM"] = "True"
|
|
| 17 |
torch._dynamo.config.suppress_errors = True
|
| 18 |
|
| 19 |
Pipeline = None
|
| 20 |
-
ids = "
|
| 21 |
-
Revision = "
|
| 22 |
|
| 23 |
def load_pipeline() -> Pipeline:
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
transformer = FluxTransformer2DModel.from_pretrained(path, torch_dtype=torch.bfloat16, use_safetensors=False).to(memory_format=torch.channels_last)
|
| 28 |
-
pipeline = DiffusionPipeline.from_pretrained(ids, revision=Revision, vae=vae, transformer=transformer, text_encoder_2=text_encoder_2, torch_dtype=torch.bfloat16,)
|
| 29 |
pipeline.to("cuda")
|
| 30 |
-
|
|
|
|
| 31 |
for _ in range(3):
|
| 32 |
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)
|
| 33 |
return pipeline
|
|
@@ -40,7 +39,7 @@ def infer(request: TextToImageRequest, pipeline: Pipeline) -> Image:
|
|
| 40 |
request.prompt,
|
| 41 |
generator=generator,
|
| 42 |
guidance_scale=0.0,
|
| 43 |
-
num_inference_steps=
|
| 44 |
max_sequence_length=256,
|
| 45 |
height=request.height,
|
| 46 |
width=request.width,
|
|
|
|
| 17 |
torch._dynamo.config.suppress_errors = True
|
| 18 |
|
| 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(ids, revision=Revision, transformer=transformer, local_files_only=True, torch_dtype=torch.bfloat16,)
|
|
|
|
|
|
|
| 27 |
pipeline.to("cuda")
|
| 28 |
+
quantize_(pipeline.vae, int8_weight_only())
|
| 29 |
+
pipeline.transformer = torch.compile(pipeline.transformer, mode="max-autotune", fullgraph=True)
|
| 30 |
for _ in range(3):
|
| 31 |
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)
|
| 32 |
return pipeline
|
|
|
|
| 39 |
request.prompt,
|
| 40 |
generator=generator,
|
| 41 |
guidance_scale=0.0,
|
| 42 |
+
num_inference_steps=1,
|
| 43 |
max_sequence_length=256,
|
| 44 |
height=request.height,
|
| 45 |
width=request.width,
|