--- pipeline_tag: image-to-image --- # FLUX\.2\-klein\-4B 整合GGUF权重包 ```Plain Text --- 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](https://huggingface.co/unsloth/FLUX.2-klein-4B-GGUF) - FLUX\.2\-klein\-4B 官方原始基座:[https://huggingface\.co/black\-forest\-labs/FLUX\.2\-klein\-4B](https://huggingface.co/black-forest-labs/FLUX.2-klein-4B) ## 修改说明 本项目仅将两个上游仓库资源整合归集:将 Unsloth 量化的 GGUF Transformer 权重,与官方完整 VAE、模型配置文件合并为一体,方便本地diffusers GGUF 推理、。**未修改权重参数、未微调、未重量化、未蒸馏**。 ## 快速使用 / 推理示例 ### 安装依赖 ```Plain Text pip install torch sdnq diffusers huggingface-hub ``` ### 完整可运行代码 ```Plain Text 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") ```