Datasets:
Update README.md
Browse files
README.md
CHANGED
|
@@ -38,7 +38,41 @@ The dataset simulates real-world book layouts to enhance OCR accuracy.
|
|
| 38 |
|
| 39 |
### Direct Use
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
[More Information Needed]
|
| 44 |
|
|
|
|
| 38 |
|
| 39 |
### Direct Use
|
| 40 |
|
| 41 |
+
```
|
| 42 |
+
from datasets import load_dataset
|
| 43 |
+
import base64
|
| 44 |
+
from io import BytesIO
|
| 45 |
+
from PIL import Image
|
| 46 |
+
# Load dataset with streaming enabled
|
| 47 |
+
ds = load_dataset("xya22er/text_to_image", streaming=True)
|
| 48 |
+
print(ds)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
# Load the dataset
|
| 54 |
+
|
| 55 |
+
# Iterate over a specific font dataset (e.g., Amiri)
|
| 56 |
+
for sample in ds["Amiri"]:
|
| 57 |
+
image_name = sample["image_name"]
|
| 58 |
+
chunk = sample["chunk"] # Arabic text transcription
|
| 59 |
+
font_name = sample["font_name"]
|
| 60 |
+
|
| 61 |
+
# Decode Base64 image
|
| 62 |
+
image_data = base64.b64decode(sample["image_base64"])
|
| 63 |
+
image = Image.open(BytesIO(image_data))
|
| 64 |
+
|
| 65 |
+
# Show the image (optional)
|
| 66 |
+
image.show()
|
| 67 |
+
|
| 68 |
+
# Print the details
|
| 69 |
+
print(f"Image Name: {image_name}")
|
| 70 |
+
print(f"Font Name: {font_name}")
|
| 71 |
+
print(f"Text Chunk: {chunk}")
|
| 72 |
+
|
| 73 |
+
# Break after one sample for testing
|
| 74 |
+
break
|
| 75 |
+
```
|
| 76 |
|
| 77 |
[More Information Needed]
|
| 78 |
|