Update README.md
Browse files
README.md
CHANGED
|
@@ -42,4 +42,37 @@ The dataset is split using a **class-wise stratified approach** to ensure balanc
|
|
| 42 |
| Val | 23,952 | 15,738 |21,042 | `val/` |
|
| 43 |
| Test | 18,492 | 10,278 |12,819 | `test/` |
|
| 44 |
|
| 45 |
-
Each split contains separate folders for annotations and images: `train/`, `val/`, `test/`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
| Val | 23,952 | 15,738 |21,042 | `val/` |
|
| 43 |
| Test | 18,492 | 10,278 |12,819 | `test/` |
|
| 44 |
|
| 45 |
+
Each split contains separate folders for annotations and images: `train/`, `val/`, `test/`
|
| 46 |
+
|
| 47 |
+
## Extracting Images from Parquet Files
|
| 48 |
+
|
| 49 |
+
The dataset stores all images in Parquet format as raw bytes. To convert these bytes back into .png images, you can use the following Python code:
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
import pandas as pd
|
| 53 |
+
from PIL import Image
|
| 54 |
+
import io
|
| 55 |
+
import os
|
| 56 |
+
|
| 57 |
+
# Load Parquet
|
| 58 |
+
train_df = pd.read_parquet("train/train.parquet")
|
| 59 |
+
|
| 60 |
+
# Directory to save images
|
| 61 |
+
output_dir = "train/images"
|
| 62 |
+
os.makedirs(output_dir, exist_ok=True)
|
| 63 |
+
|
| 64 |
+
# Loop over all rows
|
| 65 |
+
for idx, row in train_df.iterrows():
|
| 66 |
+
imagename = row['image_name']
|
| 67 |
+
image_bytes = row['image']
|
| 68 |
+
|
| 69 |
+
# Convert bytes to PIL Image
|
| 70 |
+
img = Image.open(io.BytesIO(image_bytes))
|
| 71 |
+
|
| 72 |
+
# Save image as PNG
|
| 73 |
+
save_path = os.path.join(output_dir, f"{imagename}")
|
| 74 |
+
img.save(save_path)
|
| 75 |
+
```
|
| 76 |
+
### Note:
|
| 77 |
+
* This will create a folder ```train/images/``` and save all images as ```.png```.
|
| 78 |
+
* You can modify the path if your Parquet file is in a different location or if you want to save images elsewhere.
|