tori29umai commited on
Commit
6acc20e
·
verified ·
1 Parent(s): d12bd9a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -5
app.py CHANGED
@@ -45,7 +45,7 @@ pipe.load_lora_weights(
45
  "2vXpSwA7/iroiro-lora",
46
  weight_name="qwen_lora/Qwen-Image-Edit-2509-Lightning-4steps-V1.0-bf16_dim1.safetensors"
47
  )
48
- pipe.fuse_lora()
49
 
50
  # Apply the same optimizations from the first version
51
  pipe.transformer.__class__ = QwenImageTransformer2DModel
@@ -106,7 +106,7 @@ def generate_turnaround(
106
 
107
  # 入力画像の確認
108
  if image is None:
109
- return None, None, None, None, seed, "エラー: 入力画像をアップロードしてください"
110
 
111
  # PIL画像として処理
112
  if isinstance(image, Image.Image):
@@ -115,7 +115,7 @@ def generate_turnaround(
115
  try:
116
  input_image = Image.open(image).convert("RGB")
117
  except:
118
- return None, None, None, None, seed, "エラー: 画像の読み込みに失敗しました"
119
 
120
  pil_images = [input_image]
121
 
@@ -135,7 +135,25 @@ def generate_turnaround(
135
  progress(1.0, desc="右側面立ち絵を生成中...")
136
  right_image = generate_single_view([front_image], PROMPTS["right"], seed+3, num_inference_steps, true_guidance_scale)
137
 
138
- return front_image, back_image, left_image, right_image, seed, "✅ 4視点の立ち絵生成が完了しました"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
  # --- UI Layout ---
141
  css = """
@@ -185,6 +203,9 @@ with gr.Blocks(css=css) as demo:
185
  result_left = gr.Image(label="左側面", type="pil", height=500, show_download_button=True, container=True, image_mode="RGB")
186
  with gr.Column():
187
  result_right = gr.Image(label="右側面", type="pil", height=500, show_download_button=True, container=True, image_mode="RGB")
 
 
 
188
 
189
  with gr.Accordion("⚙️ 詳細設定", open=False):
190
  seed = gr.Slider(
@@ -223,7 +244,7 @@ with gr.Blocks(css=css) as demo:
223
  true_guidance_scale,
224
  num_inference_steps,
225
  ],
226
- outputs=[result_front, result_back, result_left, result_right, seed, status_text],
227
  )
228
 
229
  if __name__ == "__main__":
 
45
  "2vXpSwA7/iroiro-lora",
46
  weight_name="qwen_lora/Qwen-Image-Edit-2509-Lightning-4steps-V1.0-bf16_dim1.safetensors"
47
  )
48
+ pipe.fuse_lora(lora_scale=0.8)
49
 
50
  # Apply the same optimizations from the first version
51
  pipe.transformer.__class__ = QwenImageTransformer2DModel
 
106
 
107
  # 入力画像の確認
108
  if image is None:
109
+ return None, None, None, None, None, seed, "エラー: 入力画像をアップロードしてください"
110
 
111
  # PIL画像として処理
112
  if isinstance(image, Image.Image):
 
115
  try:
116
  input_image = Image.open(image).convert("RGB")
117
  except:
118
+ return None, None, None, None, None, seed, "エラー: 画像の読み込みに失敗しました"
119
 
120
  pil_images = [input_image]
121
 
 
135
  progress(1.0, desc="右側面立ち絵を生成中...")
136
  right_image = generate_single_view([front_image], PROMPTS["right"], seed+3, num_inference_steps, true_guidance_scale)
137
 
138
+ # 5. 4つの画像を連結(正面、右向き、背面、左向きの順)
139
+ images = [front_image, right_image, back_image, left_image]
140
+ widths = [img.width for img in images]
141
+ heights = [img.height for img in images]
142
+
143
+ # 連結画像のサイズを計算
144
+ total_width = sum(widths)
145
+ max_height = max(heights)
146
+
147
+ # 新しい画像を作成
148
+ combined_image = Image.new('RGB', (total_width, max_height))
149
+
150
+ # 画像を左から順に貼り付け
151
+ x_offset = 0
152
+ for img in images:
153
+ combined_image.paste(img, (x_offset, 0))
154
+ x_offset += img.width
155
+
156
+ return front_image, back_image, left_image, right_image, combined_image, seed, "✅ 4視点の立ち絵生成が完了しました"
157
 
158
  # --- UI Layout ---
159
  css = """
 
203
  result_left = gr.Image(label="左側面", type="pil", height=500, show_download_button=True, container=True, image_mode="RGB")
204
  with gr.Column():
205
  result_right = gr.Image(label="右側面", type="pil", height=500, show_download_button=True, container=True, image_mode="RGB")
206
+
207
+ gr.Markdown("### 連結画像(正面→右向き→背面→左向き)")
208
+ result_combined = gr.Image(label="4視点連結画像", type="pil", height=400, show_download_button=True, container=True, image_mode="RGB")
209
 
210
  with gr.Accordion("⚙️ 詳細設定", open=False):
211
  seed = gr.Slider(
 
244
  true_guidance_scale,
245
  num_inference_steps,
246
  ],
247
+ outputs=[result_front, result_back, result_left, result_right, result_combined, seed, status_text],
248
  )
249
 
250
  if __name__ == "__main__":