Skip to content

Commit eb55c51

Browse files
author
Amit Raj
committed
Code cleaning and removed redundant code-2
Signed-off-by: Amit Raj <amitraj@qti.qualcommm.com>
1 parent d676aab commit eb55c51

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

examples/diffusers/flux/flux_1_schnell.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,48 @@
44
# SPDX-License-Identifier: BSD-3-Clause
55
#
66
# -----------------------------------------------------------------------------
7+
8+
"""
9+
FLUX.1-schnell Image Generation Example
10+
11+
This example demonstrates how to use the QEFFFluxPipeline to generate images
12+
using the FLUX.1-schnell model from Black Forest Labs. FLUX.1-schnell is a
13+
fast, distilled version of the FLUX.1 text-to-image model optimized for
14+
speed with minimal quality loss.
15+
16+
Key Features:
17+
- Fast inference with only 4 steps
18+
- High-quality image generation from text prompts
19+
- Optimized for Qualcomm Cloud AI 100 using ONNX runtime
20+
- Deterministic output using fixed random seed
21+
22+
Output:
23+
- Generates an image based on the text prompt
24+
- Saves the image as 'cat_with_sign.png' in the current directory
25+
"""
26+
727
import torch
828

929
from QEfficient import QEFFFluxPipeline
1030

11-
pipeline = QEFFFluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", use_onnx_function=True)
31+
# Initialize the FLUX.1-schnell pipeline from pretrained weights
32+
# use_onnx_function=True enables ONNX-based optimizations for faster compilation
33+
pipeline = QEFFFluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", use_onnx_function=False)
1234

35+
# Generate an image from a text prompt
1336
output = pipeline(
1437
prompt="A cat holding a sign that says hello world",
1538
guidance_scale=0.0,
1639
num_inference_steps=4,
1740
max_sequence_length=256,
1841
generator=torch.manual_seed(42),
1942
)
43+
44+
# Extract the generated image from the output
2045
image = output.images[0]
46+
47+
# Save the generated image to disk
2148
image.save("cat_with_sign.png")
2249

50+
# Print the output object (contains perf info)
2351
print(output)

examples/diffusers/flux/flux_1_shnell_custom.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@
3737
# Option 1: Basic initialization with custom image dimensions
3838
pipeline = QEFFFluxPipeline.from_pretrained(
3939
"black-forest-labs/FLUX.1-schnell",
40-
height=256,
41-
width=256,
40+
height=512,
41+
width=512,
4242
)
4343

4444
# Option 2: Advanced initialization with custom modules
4545
# Uncomment and modify to use your own custom components:
4646
#
4747
# pipeline = QEFFFluxPipeline.from_pretrained(
4848
# "black-forest-labs/FLUX.1-schnell",
49-
# height=256,
50-
# width=256,
49+
# height=512,
50+
# width=512,
5151
# text_encoder=custom_text_encoder, # Your custom CLIP text encoder
5252
# transformer=custom_transformer, # Your custom transformer model
5353
# tokenizer=custom_tokenizer, # Your custom tokenizer

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies = [
2222
"transformers==4.55.0",
2323
"huggingface-hub==0.34.0",
2424
"hf_transfer==0.1.9",
25-
"peft==0.17.0",
25+
"peft==0.13.2",
2626
"datasets==2.20.0",
2727
"fsspec==2023.6.0",
2828
"multidict==6.0.4",
@@ -71,4 +71,4 @@ target-version = "py310"
7171
[tool.pytest.ini_options]
7272
addopts = "-W ignore -s -v"
7373
junit_logging = "all"
74-
doctest_optionflags = "NUMBER NORMALIZE_WHITESPACE ELLIPSIS"
74+
doctest_optionflags = "NUMBER NORMALIZE_WHITESPACE ELLIPSIS"

0 commit comments

Comments
 (0)