Skip to content

Commit 1e0fbfd

Browse files
author
Amit Raj
committed
Code cleaning and removed redundant code-2
Signed-off-by: Amit Raj <[email protected]>
1 parent d676aab commit 1e0fbfd

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# -----------------------------------------------------------------------------
2+
#
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
# ----------------------------------------------------------------------------

QEfficient/utils/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def create_model_params(qeff_model, **kwargs) -> Dict:
532532
"""
533533
model_params = copy.deepcopy(kwargs)
534534
model_params = {k: v for k, v in model_params.items() if k in KWARGS_INCLUSION_LIST}
535-
model_params["config"] = qeff_model.model.config
535+
model_params["config"] = qeff_model.model.config.to_diff_dict()
536536
model_params["peft_config"] = getattr(qeff_model.model, "active_peft_config", None)
537537
model_params["applied_transform_names"] = qeff_model._transform_names()
538538
return model_params

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

scripts/Jenkinsfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pipeline {
2222
. preflight_qeff/bin/activate &&
2323
pip install --upgrade pip setuptools &&
2424
pip install .[test] &&
25+
pip install .[diffusers] &&
2526
pip install junitparser pytest-xdist &&
2627
pip install librosa==0.10.2 soundfile==0.13.1 && #packages needed to load example for whisper testing
2728
pip install --extra-index-url https://download.pytorch.org/whl/cpu timm==1.0.14 torchvision==0.22.0+cpu einops==0.8.1 && #packages to load VLMs

0 commit comments

Comments
 (0)