i0switch commited on
Commit
fc0ad0a
·
verified ·
1 Parent(s): 65f45f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -112,8 +112,19 @@ pipe.vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse", torch_dtyp
112
  pipe.controlnet = controlnet
113
  pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True, algorithm_type="sde-dpmsolver++")
114
 
115
- pipe.load_ip_adapter(str(LORA_DIR), subfolder="", weight_name=IP_BIN_FILE.name)
116
- # load FaceID LoRA (Δ only LoRA weights, not full IP-Adapter)
 
 
 
 
 
 
 
 
 
 
 
117
  pipe.load_lora_weights(str(LORA_DIR), weight_name=LORA_FILE.name)
118
  pipe.set_ip_adapter_scale(0.65)
119
 
@@ -154,7 +165,6 @@ BASE_PROMPT = (
154
  "<lora:ip-adapter-faceid-plusv2_sd15_lora:0.65>, (face),\n"
155
  "(aesthetic:1.1), (cinematic:0.8)"
156
  )
157
- # [!!] 下記のNEG_PROMPTを修正しました。不要なカンマと重複した文字列を削除し、単一の文字列になるようにしました。
158
  NEG_PROMPT = (
159
  "ng_deepnegative_v1_75t, CyberRealistic_Negative-neg, UnrealisticDream, "
160
  "(worst quality:2), (low quality:1.8), lowres, (jpeg artifacts:1.2), "
@@ -204,7 +214,6 @@ def generate(
204
  ##############################################################################
205
  # 5. Gradio UI
206
  ##############################################################################
207
-
208
  with gr.Blocks() as demo:
209
  gr.Markdown("# InstantID – Beautiful Realistic Asians v7")
210
  with gr.Row():
@@ -232,4 +241,4 @@ with gr.Blocks() as demo:
232
  )
233
 
234
  print("launching …")
235
- demo.queue().launch(show_error=True)
 
112
  pipe.controlnet = controlnet
113
  pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True, algorithm_type="sde-dpmsolver++")
114
 
115
+ # --- 修正ポイントここから --------------------------------------------------
116
+ # 画像エンコーダは Lora/models/image_encoder/ に格納されている
117
+ IMAGE_ENCODER_DIR = LORA_DIR / "models" / "image_encoder"
118
+
119
+ pipe.load_ip_adapter(
120
+ str(LORA_DIR), # ip_adapter.bin の親ディレクトリ
121
+ subfolder="", # ip_adapter.bin は Lora/ 直下
122
+ weight_name=IP_BIN_FILE.name, # LoRA 本体
123
+ image_encoder_path=str(IMAGE_ENCODER_DIR) # 画像エンコーダの場所を明示
124
+ )
125
+ # --- 修正ポイントここまで --------------------------------------------------
126
+
127
+ # FaceID LoRA (差分 LoRA)
128
  pipe.load_lora_weights(str(LORA_DIR), weight_name=LORA_FILE.name)
129
  pipe.set_ip_adapter_scale(0.65)
130
 
 
165
  "<lora:ip-adapter-faceid-plusv2_sd15_lora:0.65>, (face),\n"
166
  "(aesthetic:1.1), (cinematic:0.8)"
167
  )
 
168
  NEG_PROMPT = (
169
  "ng_deepnegative_v1_75t, CyberRealistic_Negative-neg, UnrealisticDream, "
170
  "(worst quality:2), (low quality:1.8), lowres, (jpeg artifacts:1.2), "
 
214
  ##############################################################################
215
  # 5. Gradio UI
216
  ##############################################################################
 
217
  with gr.Blocks() as demo:
218
  gr.Markdown("# InstantID – Beautiful Realistic Asians v7")
219
  with gr.Row():
 
241
  )
242
 
243
  print("launching …")
244
+ demo.queue().launch(show_error=True)