slobers commited on
Commit
e396643
·
verified ·
1 Parent(s): 3c92519

Update src/pipeline.py

Browse files
Files changed (1) hide show
  1. src/pipeline.py +6 -10
src/pipeline.py CHANGED
@@ -17,18 +17,14 @@ 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 = AutoencoderKL.from_pretrained(ids,revision=Revision, subfolder="vae", local_files_only=True, torch_dtype=torch.bfloat16,)
25
- quantize_(vae, int8_weight_only())
26
- 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)
27
- path = os.path.join(HF_HUB_CACHE, "models--RobertML--FLUX.1-schnell-int8wo/snapshots/307e0777d92df966a3c0f99f31a6ee8957a9857a")
28
- transformer = FluxTransformer2DModel.from_pretrained(path, torch_dtype=torch.bfloat16, use_safetensors=False).to(memory_format=torch.channels_last)
29
- pipeline = DiffusionPipeline.from_pretrained(ids, revision=Revision, transformer=transformer, text_encoder_2=text_encoder_2, torch_dtype=torch.bfloat16,)
30
  pipeline.to("cuda")
31
-
 
32
  for _ in range(3):
33
  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)
34
  return pipeline
@@ -45,4 +41,4 @@ def infer(request: TextToImageRequest, pipeline: Pipeline) -> Image:
45
  max_sequence_length=256,
46
  height=request.height,
47
  width=request.width,
48
- ).images[0]
 
17
  torch._dynamo.config.suppress_errors = True
18
 
19
  Pipeline = None
20
+ ids = "slobers/Flux.1.Schnella"
 
21
 
22
  def load_pipeline() -> Pipeline:
23
+ transformer = FluxTransformer2DModel.from_pretrained(ids, subfolder="transformer", torch_dtype=torch.bfloat16, use_safetensors=False)
24
+ pipeline = FluxPipeline.from_pretrained(ids, transformer=transformer, torch_dtype=torch.bfloat16,)
 
 
 
 
25
  pipeline.to("cuda")
26
+ pipeline.transformer = torch.compile(pipeline.transformer, mode="max-autotune", fullgraph=True)
27
+ quantize_(pipeline.vae, int8_weight_only())
28
  for _ in range(3):
29
  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)
30
  return pipeline
 
41
  max_sequence_length=256,
42
  height=request.height,
43
  width=request.width,
44
+ ).images[0]