aiqcamp commited on
Commit
798e1fa
β€’
1 Parent(s): 089e25c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -6
app.py CHANGED
@@ -48,6 +48,7 @@ def get_mask_location(mode, category, parsing, keypoints):
48
  mask = np.zeros_like(parsing)
49
 
50
  print(f"Selected category: {category}")
 
51
  print(f"Unique values in parsing: {np.unique(parsing)}")
52
 
53
  if category == "μƒμ˜":
@@ -71,7 +72,15 @@ def get_mask_location(mode, category, parsing, keypoints):
71
  print(f"Mask shape: {mask.shape}, Unique values in mask: {np.unique(mask)}")
72
  print(f"Number of masked pixels: {np.sum(mask == 255)}")
73
 
74
- mask_gray = Image.fromarray(mask)
 
 
 
 
 
 
 
 
75
  return mask_gray, mask_gray
76
 
77
 
@@ -194,14 +203,33 @@ def start_tryon(dict, garm_img, garment_des, is_checked, is_checked_crop, denois
194
  print(f"Unique values in parsing model output: {np.unique(model_parse)}")
195
 
196
  mask, mask_gray = get_mask_location('hd', category, model_parse, keypoints)
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  mask = mask.resize((768,1024))
198
  print(f"Mask created for category {category}")
199
 
200
- # 마슀크 확인
201
- print(f"Final mask shape: {mask.size}")
202
- mask_array = np.array(mask)
203
- print(f"Unique values in final mask: {np.unique(mask_array)}")
204
- print(f"Number of masked pixels in final mask: {np.sum(mask_array == 255)}")
 
 
 
 
 
 
205
 
206
  except Exception as e:
207
  status_message = f"μžλ™ 마슀크 생성 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}. κΈ°λ³Έ 마슀크λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€."
 
48
  mask = np.zeros_like(parsing)
49
 
50
  print(f"Selected category: {category}")
51
+ print(f"Parsing shape: {parsing.shape}")
52
  print(f"Unique values in parsing: {np.unique(parsing)}")
53
 
54
  if category == "μƒμ˜":
 
72
  print(f"Mask shape: {mask.shape}, Unique values in mask: {np.unique(mask)}")
73
  print(f"Number of masked pixels: {np.sum(mask == 255)}")
74
 
75
+ # 마슀크 μ‹œκ°ν™”λ₯Ό μœ„ν•œ μ½”λ“œ μΆ”κ°€
76
+ import matplotlib.pyplot as plt
77
+ plt.figure(figsize=(10, 10))
78
+ plt.imshow(mask, cmap='gray')
79
+ plt.title(f"Mask for {category}")
80
+ plt.savefig(f"mask_{category}.png")
81
+ plt.close()
82
+
83
+ mask_gray = Image.fromarray(mask.astype(np.uint8))
84
  return mask_gray, mask_gray
85
 
86
 
 
203
  print(f"Unique values in parsing model output: {np.unique(model_parse)}")
204
 
205
  mask, mask_gray = get_mask_location('hd', category, model_parse, keypoints)
206
+
207
+ # 마슀크 확인 및 μ‹œκ°ν™”
208
+ mask_array = np.array(mask)
209
+ print(f"Mask shape after get_mask_location: {mask_array.shape}")
210
+ print(f"Unique values in mask after get_mask_location: {np.unique(mask_array)}")
211
+ print(f"Number of masked pixels after get_mask_location: {np.sum(mask_array == 255)}")
212
+
213
+ plt.figure(figsize=(10, 10))
214
+ plt.imshow(mask_array, cmap='gray')
215
+ plt.title(f"Mask after get_mask_location for {category}")
216
+ plt.savefig(f"mask_after_get_mask_location_{category}.png")
217
+ plt.close()
218
+
219
  mask = mask.resize((768,1024))
220
  print(f"Mask created for category {category}")
221
 
222
+ # μ΅œμ’… 마슀크 확인
223
+ mask_array_final = np.array(mask)
224
+ print(f"Final mask shape: {mask_array_final.shape}")
225
+ print(f"Unique values in final mask: {np.unique(mask_array_final)}")
226
+ print(f"Number of masked pixels in final mask: {np.sum(mask_array_final == 255)}")
227
+
228
+ plt.figure(figsize=(10, 10))
229
+ plt.imshow(mask_array_final, cmap='gray')
230
+ plt.title(f"Final Mask for {category}")
231
+ plt.savefig(f"final_mask_{category}.png")
232
+ plt.close()
233
 
234
  except Exception as e:
235
  status_message = f"μžλ™ 마슀크 생성 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}. κΈ°λ³Έ 마슀크λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€."