Downloads · 30 days
36
27% of all-time downloads
MrbandiTw/always-pikachu-lora-sd15
always-pikachu-lora-sd15 is a text-to-image model from MrbandiTw. Use it when you need an image from a text prompt. It is set up for diffusers. The card lists the license as creativeml-openrail-m.
把任何一隻寶可夢都變成皮卡丘:保留宿主寶可夢的輪廓與五官位置,套上皮卡丘的外觀(黃色毛皮、紅臉頰、黑耳尖)。
Downloads · 30 days
36
27% of all-time downloads
All-time downloads
131
Public
Repo size
60.2 MB
Likes
1
Public
Click a slice to open those files.
.safetensors54.4 MB · 96%
From the Hugging Face model README
把任何一隻寶可夢都變成皮卡丘:保留宿主寶可夢的輪廓與五官位置,套上皮卡丘的外觀(黃色毛皮、紅臉頰、黑耳尖)。
這是一個 SD 1.5 的概念型 LoRA,搭配 ControlNet (Canny) 使用。LoRA 把「皮卡丘的長相」寫進 UNet 權重,ControlNet 則用宿主的邊緣輪廓鎖住結構——兩者合力,就能把噴火龍、水箭龜、妙蛙花……統統變皮卡丘。

| 步驟 | 內容 |
|---|---|
| ① 輸入原圖 | 任一隻寶可夢(RGBA / RGB 皆可) |
| ② 前景剪影 | 取前景遮罩,做出「猜猜我是誰」黑影 |
| ③ Canny 邊緣 | 邊緣偵測,作為 ControlNet 的結構條件 |
| ④ 皮卡丘化 | SD 1.5 + ControlNet + 本 LoRA 生成,再用遮罩還原透明背景 |
結構由宿主輪廓(ControlNet)決定,外觀由本 LoRA承載——這正符合目標:把每一隻寶可夢都變皮卡丘。

import torch
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
from diffusers.utils import load_image
import cv2, numpy as np
from PIL import Image
# 1. 載入 SD 1.5 + ControlNet (Canny)
controlnet = ControlNetModel.from_pretrained(
"lllyasviel/control_v11p_sd15_canny", torch_dtype=torch.float16
)
pipe = StableDiffusionControlNetPipeline.from_pretrained(
"stable-diffusion-v1-5/stable-diffusion-v1-5",
controlnet=controlnet, torch_dtype=torch.float16,
).to("cuda")
# 2. 載入本 LoRA(皮卡丘外觀就在這裡)
pipe.load_lora_weights("MrbandiTw/always-pikachu-lora-sd15", weight_name="pikachu_lora_v1.safetensors")
# 3. 用宿主圖做 Canny 條件
src = load_image("charmander.png").convert("RGB").resize((512, 512))
edges = cv2.Canny(np.array(src), 80, 160)
canny = Image.fromarray(np.stack([edges] * 3, axis=-1))
# 4. 生成
image = pipe(
prompt="pikachu, yellow body, red cheeks, cute face",
negative_prompt="dark head, black head, glass sphere, bubble, reflective orb, "
"glossy, transparent dome, helmet, lowres, deformed",
image=canny,
num_inference_steps=25,
guidance_scale=7.5,
controlnet_conditioning_scale=0.72,
cross_attention_kwargs={"scale": 0.64}, # LoRA 強度
).images[0]
image.save("pikachu.png")
| 參數 | 值 | 說明 |
|---|---|---|
| LoRA scale | 0.64 | 皮卡丘外觀強度;過高會吃掉宿主結構 |
| ControlNet scale | 0.72 | 平衡:宿主身分 + 乾淨的皮卡丘臉 |
| Steps | 25 | |
| Guidance (CFG) | 7.5 | |
| Canny thresholds | 80 / 160 | 抓出眼睛、肚子、四肢等內部線條 |
| Prompt | pikachu, yellow body, red cheeks, cute face | 技術性 CFG 觸發詞;空 prompt 會讓 guidance 失效、洗白結果 |
Prompt 只是讓 CFG 有作用的占位詞,語意不是重點——外觀完全由 LoRA 承載。
| 項目 | 設定 |
|---|---|
| 基底模型 | stable-diffusion-v1-5/stable-diffusion-v1-5 |
| 工具 | kohya_ss / sd-scripts(CLI) |
| 資料 | ~42 張皮卡丘圖(6 張來源 × 旋轉擴增),空 caption |
| 訓練範圍 | 僅 UNet(--network_train_unet_only,不訓 text encoder) |
| Network Dim / Alpha | 32 / 16 |
| LoRA 目標 | Attention only (Q, K, V, Out) |
| Learning Rate | 1e-4,cosine + 10% warmup |
| Optimizer | AdamW8bit |
| Batch / Steps | 4 / 2500 |
| Precision | bf16 |
| Resolution | 512 |
| 硬體 | RTX 5060 Ti 16GB (Blackwell, CUDA 12.8) |
設計理念——純視覺概念 LoRA:完全不放 caption、只訓 UNet,使 LoRA 成為「永遠啟動的外觀位移」。皮卡丘的長相存在於權重中、無條件套用,因此不需要任何觸發詞。
在 1160 隻寶可夢全集上以無參數指標自動評估:
| 指標 | 數值 |
|---|---|
| 轉換成功率 | 98.6% |
| Identity(像皮卡丘) | 86.8% |
| Structure(遵循原輪廓) | 90.3% |
| 綜合準確率 | 77.7% |
| 平均邊緣 IoU | 0.653 |
LoRA 權重以 CreativeML OpenRAIL-M 釋出。 寶可夢與皮卡丘為 Nintendo / Game Freak / The Pokémon Company 之商標,本模型僅供研究與教育用途。