Datasets:
Tasks:
Image Segmentation
Modalities:
Image
Sub-tasks:
semantic-segmentation
Languages:
English
Size:
10K - 100K
License:
Update README.md
Browse files
README.md
CHANGED
@@ -72,17 +72,40 @@ train, test = data['train'], data['test']
|
|
72 |
# train[0]['mask'] -> PIL Image
|
73 |
```
|
74 |
|
75 |
-
### Get Segmentation Mask
|
76 |
|
77 |
```python
|
78 |
ids = 3
|
79 |
-
image, mask = train[ids]['image'],
|
|
|
|
|
|
|
|
|
80 |
|
|
|
81 |
mask = np.array(mask)
|
82 |
```
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
-
### Write Plotting Function
|
86 |
|
87 |
```python
|
88 |
from matplotlib.colors import ListedColormap, BoundaryNorm
|
@@ -105,37 +128,8 @@ def plot_mask(mask, alpha=1.0):
|
|
105 |
plt.axis('off')
|
106 |
plt.show()
|
107 |
|
108 |
-
def plot(image, mask, cmap='gray'):
|
109 |
-
plt.imshow(image * np.where(mask > 0,1,0), cmap=cmap)
|
110 |
-
plt.axis('off')
|
111 |
-
plt.show()
|
112 |
```
|
113 |
|
114 |
-
### Plot
|
115 |
-
|
116 |
-
```python
|
117 |
-
fig = plt.figure(figsize=(16,16))
|
118 |
-
ax1 = fig.add_subplot(131)
|
119 |
-
plt.axis('off')
|
120 |
-
ax1.imshow(image, cmap='gray')
|
121 |
-
ax2 = fig.add_subplot(132)
|
122 |
-
plt.axis('off')
|
123 |
-
ax2.imshow(mask, cmap='gray')
|
124 |
-
ax3 = fig.add_subplot(133)
|
125 |
-
ax3.imshow(image*np.where(mask>0,1,0), cmap='gray')
|
126 |
-
plt.axis('off')
|
127 |
-
plt.show()
|
128 |
-
```
|
129 |
-
|
130 |
-
![raw cmap](https://huggingface.co/datasets/ziq/RSNA-ATD2023/resolve/main/assets/raw.png)
|
131 |
-
|
132 |
-
```python
|
133 |
-
plot(image, mask)
|
134 |
-
```
|
135 |
-
|
136 |
-
![gray cmap](https://huggingface.co/datasets/ziq/RSNA-ATD2023/resolve/main/assets/grayscale.png)
|
137 |
-
|
138 |
-
|
139 |
### Custom Color
|
140 |
|
141 |
```python
|
|
|
72 |
# train[0]['mask'] -> PIL Image
|
73 |
```
|
74 |
|
75 |
+
### Get Image & Segmentation Mask
|
76 |
|
77 |
```python
|
78 |
ids = 3
|
79 |
+
image, mask = train[ids]['image'], \ # shape: (512, 512)
|
80 |
+
train[ids]['mask'] # shape: (512, 512)
|
81 |
+
```
|
82 |
+
|
83 |
+
### Convert mask into np.ndarray
|
84 |
|
85 |
+
```python
|
86 |
mask = np.array(mask)
|
87 |
```
|
88 |
|
89 |
+
### Visualize Image & Mask
|
90 |
+
|
91 |
+
```python
|
92 |
+
fig = plt.figure(figsize=(16,16))
|
93 |
+
ax1 = fig.add_subplot(131)
|
94 |
+
plt.axis('off')
|
95 |
+
ax1.imshow(image, cmap='gray')
|
96 |
+
ax2 = fig.add_subplot(132)
|
97 |
+
plt.axis('off')
|
98 |
+
ax2.imshow(mask, cmap='gray')
|
99 |
+
ax3 = fig.add_subplot(133)
|
100 |
+
ax3.imshow(image*np.where(mask>0,1,0), cmap='gray')
|
101 |
+
plt.axis('off')
|
102 |
+
plt.show()
|
103 |
+
```
|
104 |
+
|
105 |
+
![raw cmap](https://huggingface.co/datasets/ziq/RSNA-ATD2023/resolve/main/assets/raw.png)
|
106 |
+
|
107 |
|
108 |
+
### Write Custom Plotting Function
|
109 |
|
110 |
```python
|
111 |
from matplotlib.colors import ListedColormap, BoundaryNorm
|
|
|
128 |
plt.axis('off')
|
129 |
plt.show()
|
130 |
|
|
|
|
|
|
|
|
|
131 |
```
|
132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
### Custom Color
|
134 |
|
135 |
```python
|