Upload src/pipeline.py with huggingface_hub
Browse files- src/pipeline.py +7 -8
src/pipeline.py
CHANGED
@@ -30,10 +30,9 @@ REVISION = "5ef0012f11a863e5111ec56540302a023bc8587b"
|
|
30 |
TinyVAE = "madebyollin/taef1"
|
31 |
TinyVAE_REV = "2d552378e58c9c94201075708d7de4e1163b2689"
|
32 |
|
33 |
-
|
34 |
def load_pipeline() -> Pipeline:
|
35 |
-
|
36 |
-
path = os.path.join(HF_HUB_CACHE, "models--RobertML--FLUX.1-schnell-int8wo/snapshots/307e0777d92df966a3c0f99f31a6ee8957a9857a")
|
37 |
transformer = FluxTransformer2DModel.from_pretrained(
|
38 |
path,
|
39 |
use_safetensors=False,
|
@@ -49,19 +48,19 @@ def load_pipeline() -> Pipeline:
|
|
49 |
).to("cuda")
|
50 |
|
51 |
pipeline.transformer.to(memory_format=torch.channels_last)
|
52 |
-
pipeline.transformer = torch.compile(pipeline.transformer, mode="
|
53 |
# pipeline.vae.to(memory_format=torch.channels_last)
|
54 |
# quantize_(pipeline.vae, int8_weight_only())
|
55 |
# pipeline.vae = torch.compile(pipeline.vae, fullgraph=True, mode="max-autotune")
|
56 |
# pipeline.to("cuda")
|
57 |
PROMPT = 'semiconformity, peregrination, quip, twineless, emotionless, tawa, depickle'
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
torch.cuda.empty_cache()
|
62 |
return pipeline
|
63 |
|
64 |
-
|
65 |
def infer(request: TextToImageRequest, pipeline: Pipeline, generator: torch.Generator) -> Image:
|
66 |
|
67 |
return pipeline(
|
|
|
30 |
TinyVAE = "madebyollin/taef1"
|
31 |
TinyVAE_REV = "2d552378e58c9c94201075708d7de4e1163b2689"
|
32 |
|
33 |
+
|
34 |
def load_pipeline() -> Pipeline:
|
35 |
+
path = os.path.join(HF_HUB_CACHE, "models--jokerbit--flux.1-schnell-Robert-int8wo/snapshots/5ef0012f11a863e5111ec56540302a023bc8587b/transformer")
|
|
|
36 |
transformer = FluxTransformer2DModel.from_pretrained(
|
37 |
path,
|
38 |
use_safetensors=False,
|
|
|
48 |
).to("cuda")
|
49 |
|
50 |
pipeline.transformer.to(memory_format=torch.channels_last)
|
51 |
+
pipeline.transformer = torch.compile(pipeline.transformer, mode="max-autotune", fullgraph=True)
|
52 |
# pipeline.vae.to(memory_format=torch.channels_last)
|
53 |
# quantize_(pipeline.vae, int8_weight_only())
|
54 |
# pipeline.vae = torch.compile(pipeline.vae, fullgraph=True, mode="max-autotune")
|
55 |
# pipeline.to("cuda")
|
56 |
PROMPT = 'semiconformity, peregrination, quip, twineless, emotionless, tawa, depickle'
|
57 |
+
with torch.inference_mode():
|
58 |
+
for _ in range(4):
|
59 |
+
pipeline(prompt="onomancy, aftergo, spirantic, Platyhelmia, modificator, drupaceous, jobbernowl, hereness", width=1024, height=1024, guidance_scale=0.0, num_inference_steps=4, max_sequence_length=256)
|
60 |
torch.cuda.empty_cache()
|
61 |
return pipeline
|
62 |
|
63 |
+
@torch.inference_mode()
|
64 |
def infer(request: TextToImageRequest, pipeline: Pipeline, generator: torch.Generator) -> Image:
|
65 |
|
66 |
return pipeline(
|