Instructions to use csssss/com2ai-klein-4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use csssss/com2ai-klein-4b with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("csssss/com2ai-klein-4b", torch_dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
FLUX.2-klein-4B 整合GGUF权重包
---
license: apache-2.0
---
模型说明
本仓库为整合版权重仓库,仅做文件归集、整合打包,无任何权重训练、微调、参数修改操作:
GGUF量化Transformer主干:来源于
unsloth/FLUX.2-klein-4B-GGUF采用 Unsloth Dynamic 2.0 量化方案。VAE、模型配置、原生配套资源:来源于官方基座
black-forest-labs/FLUX.2-klein-4B
原始来源链接
GGUF量化主干模型:https://huggingface.co/unsloth/FLUX.2-klein-4B-GGUF
FLUX.2-klein-4B 官方原始基座:https://huggingface.co/black-forest-labs/FLUX.2-klein-4B
修改说明
本项目仅将两个上游仓库资源整合归集:将 Unsloth 量化的 GGUF Transformer 权重,与官方完整 VAE、模型配置文件合并为一体,方便本地diffusers GGUF 推理、。未修改权重参数、未微调、未重量化、未蒸馏。
快速使用 / 推理示例
安装依赖
pip install torch sdnq diffusers huggingface-hub
完整可运行代码
import torch
from sdnq import SDNQConfig
from diffusers import Flux2KleinPipeline, Flux2Transformer2DModel, GGUFQuantizationConfig
from huggingface_hub import hf_hub_download
device = "cuda"
dtype = torch.bfloat16
gguf_path = hf_hub_download(
repo_id="csssss/com2ai-klein-4b",
filename="transformer/flux-2-klein-4b-Q8_0.gguf",
)
config_path = hf_hub_download(
repo_id="csssss/com2ai-klein-4b",
filename="transformer/config.json",
)
transformer = Flux2Transformer2DModel.from_single_file(
gguf_path,
quantization_config=GGUFQuantizationConfig(compute_dtype=dtype),
torch_dtype=dtype,
config=config_path
)
pipe = Flux2KleinPipeline.from_pretrained(
"csssss/com2ai-klein-4b",
transformer=transformer,
torch_dtype=dtype
)
pipe.enable_model_cpu_offload()
prompt = "A cat holding a sign that says hello world"
image = pipe(
prompt=prompt,
height=1024,
width=1024,
guidance_scale=1.0,
num_inference_steps=4,
generator=torch.Generator(device=device).manual_seed(0)
).images[0]
image.save("flux-klein.png")
print("✅ 图像生成成功,已保存为 flux-klein.png")
- Downloads last month
- 180
Hardware compatibility
Log In to add your hardware
8-bit