tori29umai commited on
Commit
3c95d4f
1 Parent(s): 36e747a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -4,6 +4,14 @@ import os
4
  import zipfile
5
 
6
 
 
 
 
 
 
 
 
 
7
  def process_image(image):
8
  # 元の画像のサイズ
9
  original_width, original_height = image.size
@@ -57,8 +65,6 @@ def process_image(image):
57
  # 出力される4つの画像を返す
58
  return outputs[0], outputs[1], outputs[2], outputs[3]
59
 
60
-
61
-
62
  def zip_files(zip_files, zip_path):
63
  with zipfile.ZipFile(zip_path, 'w') as zipf:
64
  for file_path in zip_files:
@@ -82,11 +88,11 @@ class webui:
82
  output3_path = f"{image_name}_3.png"
83
  output4_path = f"{image_name}_4.png"
84
 
85
- # 画像を保存
86
- output1.save(output1_path)
87
- output2.save(output2_path)
88
- output3.save(output3_path)
89
- output4.save(output4_path)
90
 
91
  # 保存したファイルをリストに追加
92
  zip_files_list = [output1_path, output2_path, output3_path, output4_path]
@@ -119,4 +125,4 @@ class webui:
119
 
120
  if __name__ == "__main__":
121
  ui = webui()
122
- ui.launch(share=True)
 
4
  import zipfile
5
 
6
 
7
+ def save_image(image, path):
8
+ # RGBA画像をRGBに変換して保存
9
+ if image.mode == 'RGBA':
10
+ image = image.convert('RGB')
11
+
12
+ # 画像の保存
13
+ image.save(path)
14
+
15
  def process_image(image):
16
  # 元の画像のサイズ
17
  original_width, original_height = image.size
 
65
  # 出力される4つの画像を返す
66
  return outputs[0], outputs[1], outputs[2], outputs[3]
67
 
 
 
68
  def zip_files(zip_files, zip_path):
69
  with zipfile.ZipFile(zip_path, 'w') as zipf:
70
  for file_path in zip_files:
 
88
  output3_path = f"{image_name}_3.png"
89
  output4_path = f"{image_name}_4.png"
90
 
91
+ # 画像を保存(変換処理あり)
92
+ save_image(output1, output1_path)
93
+ save_image(output2, output2_path)
94
+ save_image(output3, output3_path)
95
+ save_image(output4, output4_path)
96
 
97
  # 保存したファイルをリストに追加
98
  zip_files_list = [output1_path, output2_path, output3_path, output4_path]
 
125
 
126
  if __name__ == "__main__":
127
  ui = webui()
128
+ ui.launch(share=True)