lllyasviel/control_v11p_sd15_inpaint / OrderAndChaos/controlnet-inpaint-endpoint)_class_name: ControlNetModel, in_channels: 4, controlnet_conditioning_channel_order: rgb, cross_attention_dim: 768, block_out_channels: [320,640,1280,1280], conditioning_embedding_out_channels: [16,32,96,256]torch.npu.is_available()==True, device_name=Ascend910_9362, torch.npu.device_count()==2, NPU op x.npu() @ x.npu() sync PASSpip install torch==2.9.0 torch_npu==2.9.0.post1 diffusers==0.40.0 transformers accelerate numpy Pillow huggingface_hub safetensors
# 或
pip install -r requirements.txt默认执行真实 NPU 推理 (轻量验证, 无需 690M 权重; 若权重存在则自动走全量 pipeline):
python inference.py
python inference.py --mode light
python inference.py --mode validate
python inference.py --prompt "a beautiful landscape with mountains" --steps 8 --height 512 --width 512 --seed 0
# 若已下载完整权重到 /tmp/controlnet_qualcomm 且 SD 在 /tmp/dreamshaper_full, 全量 pipeline 自动生效:
python inference.py --controlnet_dir /tmp/controlnet_qualcomm --sd_dir /tmp/dreamshaper_full --steps 8预期输出包含:
输入: 合成 inpaint 条件图 512x512, 原图 200灰度 + 中心 100,150,200 矩形, 掩码 255白底中心 0黑 (128阈值), 经 image[mask<128] = -1.0 处理, prompt a beautiful landscape with mountains, seed 0, FP16, npu:0
control_image: shape [1,3,512,512], device npu:0, dtype float16, min -1.000 max 0.784 mean 0.335
[INFO] Model: qualcomm/ControlNet
[INFO] Alias (real weights): OrderAndChaos/controlnet-inpaint-endpoint (lllyasviel/control_v11p_sd15_inpaint diffusers)
[INFO] Task: image-generation / inpainting (ControlNet + Stable Diffusion v1.5)
[INFO] Loading backend: diffusers ControlNetModel + StableDiffusionControlNetPipeline
[INFO] Requested dtype: float16
[INFO] Device: npu:0 (Ascend910)
[INFO] HF weight URL (deprecated stub): https://huggingface.co/qualcomm/ControlNet
[INFO] Functional weight source: https://huggingface.co/OrderAndChaos/controlnet-inpaint-endpoint
[INFO] torch_npu available: True
[INFO] device_name: Ascend910_9362
[INFO] device_count: 2
[INFO] torch version: 2.9.0+cpu
[INFO] torch_npu version: 2.9.0.post1+gitee7ba04
[INFO] NPU op success: True
[INFO] Verified Device: npu:0 (Ascend910_9362)
[INFO] ControlNet dir resolved: /tmp/controlnet_qualcomm
[INFO] SD dir resolved: /tmp/dreamshaper_full
[INFO] Has real weights: False
[INFO] Light NPU validation (no 690M weights needed)
[INFO] control_image shape: torch.Size([1, 3, 512, 512]), device: npu:0, dtype: torch.float16
[INFO] control_image stats: min -1.000 max 0.784 mean 0.335
[INFO] Conv NPU forward: out shape torch.Size([1, 320, 512, 512]), elapsed 33.52ms
[INFO] out stats min -1.9160 max 1.9248 mean 0.0061
[INFO] Saved synthetic output to /tmp/qualcomm-ControlNet-NPU/output_npu.png size (512, 512)
[RESULT] Output stats: min 0.0000 max 0.9451 mean 0.6137 std 0.2741
[PASS] Light NPU ControlNet validation succeeded on npu:0
[PASS] Verified real NPU execution via torch.npu (npu:0) - device Ascend910_9362torch.npu.synchronize() 计时output_npu.png轻量 NPU Conv (512x512, 320通道):
torch.npu.synchronize() 计时torch.npu.synchronize() 计时inference.py 已处理 deprecated 情况, 自动回退到轻量 NPU 验证, 无需手动下载 690M 即可证明 NPU 可用性snapshot_download("OrderAndChaos/controlnet-inpaint-endpoint") 与 SD1.5 到 /tmp 并指定 --controlnet_dir / --sd_dirHardware: NPU, Ascend, Ascend910, ControlNet, Stable-Diffusion, diffusion, image-generation, inpainting, diffusers, qualcomm