Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 202 |
-
|
| 203 |
-
print(f"Unique values in final mask: {np.unique(
|
| 204 |
-
print(f"Number of masked pixels in final mask: {np.sum(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)}. κΈ°λ³Έ λ§μ€ν¬λ₯Ό μ¬μ©ν©λλ€."
|