slobers commited on
Commit
78f2eeb
·
verified ·
1 Parent(s): 386ee19

Update pyproject.toml

Browse files
Files changed (1) hide show
  1. pyproject.toml +41 -36
pyproject.toml CHANGED
@@ -1,42 +1,47 @@
1
- [build-system]
2
- requires = ["setuptools >= 75.0"]
3
- build-backend = "setuptools.build_meta"
 
 
 
 
 
 
 
 
 
 
4
 
5
- [project]
6
- name = "flux-schnell-edge-inference"
7
- description = "An edge-maxxing model submission for the 4090 Flux contest"
8
- requires-python = ">=3.10,<3.13"
9
- version = "8"
10
- dependencies = [
11
- "diffusers==0.31.0",
12
- "transformers==4.46.2",
13
- "accelerate==1.1.0",
14
- "omegaconf==2.3.0",
15
- "torch==2.5.1",
16
- "protobuf==5.28.3",
17
- "sentencepiece==0.2.0",
18
- "torchao==0.6.1",
19
- "hf_transfer==0.1.8",
20
- "setuptools==75.2.0",
21
- "edge-maxxing-pipelines @ git+https://github.com/womboai/edge-maxxing@7c760ac54f6052803dadb3ade8ebfc9679a94589#subdirectory=pipelines",
22
- ]
23
 
24
- [[tool.edge-maxxing.models]]
25
- repository = "black-forest-labs/FLUX.1-schnell"
26
- revision = "741f7c3ce8b383c54771c7003378a50191e9efe9"
27
- exclude = ["transformer", "vae", "text_encoder_2"]
28
 
29
- [[tool.edge-maxxing.models]]
30
- repository = "RobertML/FLUX.1-schnell-int8wo"
31
- revision = "307e0777d92df966a3c0f99f31a6ee8957a9857a"
 
 
 
 
32
 
33
- [[tool.edge-maxxing.models]]
34
- repository = "city96/t5-v1_1-xxl-encoder-bf16"
35
- revision = "1b9c856aadb864af93c1dcdc226c2774fa67bc86"
36
 
37
- [[tool.edge-maxxing.models]]
38
- repository = "slobers/tt1"
39
- revision = "ec746bf42d91e3335760895281f070df54f2196a"
40
 
41
- [project.scripts]
42
- start_inference = "main:main"
 
 
 
 
 
 
 
 
1
+ #6
2
+ from huggingface_hub.constants import HF_HUB_CACHE
3
+ from transformers import T5EncoderModel, T5TokenizerFast, CLIPTokenizer, CLIPTextModel
4
+ import torch
5
+ import torch._dynamo
6
+ import gc
7
+ import os
8
+ from diffusers import FluxPipeline, AutoencoderKL, AutoencoderTiny
9
+ from PIL.Image import Image
10
+ from pipelines.models import TextToImageRequest
11
+ from torch import Generator
12
+ from diffusers import FluxTransformer2DModel, DiffusionPipeline
13
+ from torchao.quantization import quantize_, int8_weight_only, fpx_weight_only
14
 
15
+ os.environ['PYTORCH_CUDA_ALLOC_CONF']="expandable_segments:True"
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
34
 
35
+ @torch.no_grad()
36
+ def infer(request: TextToImageRequest, pipeline: Pipeline) -> Image:
37
+ generator = Generator(pipeline.device).manual_seed(request.seed)
38
 
39
+ return pipeline(
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,
47
+ ).images[0]