slobers commited on
Commit
58d4a01
·
verified ·
1 Parent(s): 5e98920

Update src/pipeline.py

Browse files
Files changed (1) hide show
  1. 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 = "black-forest-labs/FLUX.1-schnell"
21
- Revision = "741f7c3ce8b383c54771c7003378a50191e9efe9"
22
 
23
  def load_pipeline() -> Pipeline:
24
- vae = AutoencoderTiny.from_pretrained("slobers/tt1",revision="ec746bf42d91e3335760895281f070df54f2196a", torch_dtype=torch.bfloat16,)
25
- text_encoder_2 = T5EncoderModel.from_pretrained("city96/t5-v1_1-xxl-encoder-bf16", revision = "1b9c856aadb864af93c1dcdc226c2774fa67bc86", torch_dtype=torch.bfloat16).to(memory_format=torch.channels_last)
26
- path = os.path.join(HF_HUB_CACHE, "models--RobertML--FLUX.1-schnell-int8wo/snapshots/307e0777d92df966a3c0f99f31a6ee8957a9857a")
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=4,
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,