Upload layer_diff_dataset/test.py with huggingface_hub
Browse files- layer_diff_dataset/test.py +14 -0
layer_diff_dataset/test.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import cv2
|
| 2 |
+
import numpy as np
|
| 3 |
+
rgba = cv2.imread('/mnt/workspace/workgroup/sihui.jsh/layer_diff_dataset/try/rgba/1#Accessories#1#Bag#2339506821_83cf9f1d22_o.png',cv2.IMREAD_UNCHANGED)
|
| 4 |
+
mask = rgba[:,:,3]
|
| 5 |
+
|
| 6 |
+
# 检查除了0和255以外的值是否存在
|
| 7 |
+
# unique_values = np.unique(mask)
|
| 8 |
+
other_values_exist = not np.all(np.isin(unique_values, [0, 255]))
|
| 9 |
+
cv2.imwrite('mask.png',mask)
|
| 10 |
+
# 输出结果
|
| 11 |
+
if other_values_exist:
|
| 12 |
+
print("Mask contains values other than 0 and 255.")
|
| 13 |
+
else:
|
| 14 |
+
print("Mask contains only 0 and 255.")
|