Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,8 +44,8 @@ BRA_FILE = "beautifulRealistic_v7.safetensors"
|
|
| 44 |
BRA_REV = "801a9b1999dd7018e58a1e2b432fdccd3d1d723d" # 固定 revision
|
| 45 |
|
| 46 |
# --- IP-Adapter 本体 & LoRA ---
|
| 47 |
-
###
|
| 48 |
-
IP_REPO, IP_BIN = "h94/IP-Adapter-FaceID", "
|
| 49 |
LORA_REPO,IP_LORA = "h94/IP-Adapter-FaceID", "ip-adapter-faceid-plusv2_sd15_lora.safetensors"
|
| 50 |
|
| 51 |
# --- ControlNet (MediaPipe Face) ---
|
|
@@ -94,12 +94,12 @@ def init():
|
|
| 94 |
pipe_.scheduler = DPMSolverMultistepScheduler.from_config(pipe_.scheduler.config)
|
| 95 |
|
| 96 |
# 6-4 IP-Adapter
|
| 97 |
-
#
|
| 98 |
pipe_.load_ip_adapter(IP_REPO, "", weight_name=IP_BIN, cache_dir=str(MODELS))
|
| 99 |
-
|
| 100 |
AttnProcsLayers(pipe_.unet.attn_processors).load_lora_weights(
|
| 101 |
-
|
| 102 |
)
|
|
|
|
| 103 |
pipe_.set_adapters(["ip_faceid"], adapter_weights=[0.6])
|
| 104 |
pipe_.to("cuda"); pipe_ = pipe_
|
| 105 |
|
|
@@ -169,7 +169,7 @@ async def api_gen(subj: str=Form(...), cfg: float=Form(7.5), stp: int=Form(30),
|
|
| 169 |
img = Image.open(io.BytesIO(await file.read())).convert("RGB")
|
| 170 |
res = generate(img, subj, "", "", cfg, ipw, stp, W, H, False, 4)
|
| 171 |
buf = io.BytesIO(); res.save(buf,"PNG")
|
| 172 |
-
return {"image":"data:image/png;base64,"+base64.
|
| 173 |
|
| 174 |
##############################################################################
|
| 175 |
# 11. Launch
|
|
|
|
| 44 |
BRA_REV = "801a9b1999dd7018e58a1e2b432fdccd3d1d723d" # 固定 revision
|
| 45 |
|
| 46 |
# --- IP-Adapter 本体 & LoRA ---
|
| 47 |
+
### 最終・根本修正 ### 存在する正しいファイル名を指定し、不要なパスを削除
|
| 48 |
+
IP_REPO, IP_BIN = "h94/IP-Adapter-FaceID", "ip-adapter-faceid-plusv2_sd15.bin"
|
| 49 |
LORA_REPO,IP_LORA = "h94/IP-Adapter-FaceID", "ip-adapter-faceid-plusv2_sd15_lora.safetensors"
|
| 50 |
|
| 51 |
# --- ControlNet (MediaPipe Face) ---
|
|
|
|
| 94 |
pipe_.scheduler = DPMSolverMultistepScheduler.from_config(pipe_.scheduler.config)
|
| 95 |
|
| 96 |
# 6-4 IP-Adapter
|
| 97 |
+
# 正しいリポジトリとファイル名を指定し、ライブラリにダウンロードと読み込みを任せる
|
| 98 |
pipe_.load_ip_adapter(IP_REPO, "", weight_name=IP_BIN, cache_dir=str(MODELS))
|
|
|
|
| 99 |
AttnProcsLayers(pipe_.unet.attn_processors).load_lora_weights(
|
| 100 |
+
LORA_REPO, weight_name=IP_LORA, adapter_name="ip_faceid", safe_load=True, cache_dir=str(MODELS)
|
| 101 |
)
|
| 102 |
+
|
| 103 |
pipe_.set_adapters(["ip_faceid"], adapter_weights=[0.6])
|
| 104 |
pipe_.to("cuda"); pipe_ = pipe_
|
| 105 |
|
|
|
|
| 169 |
img = Image.open(io.BytesIO(await file.read())).convert("RGB")
|
| 170 |
res = generate(img, subj, "", "", cfg, ipw, stp, W, H, False, 4)
|
| 171 |
buf = io.BytesIO(); res.save(buf,"PNG")
|
| 172 |
+
return {"image":"data:image/png;base64,"+base64.b6_encode(buf.getvalue()).decode()}
|
| 173 |
|
| 174 |
##############################################################################
|
| 175 |
# 11. Launch
|