kobkrit commited on
Commit
6fb0e0d
1 Parent(s): 641f696

Add images

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. convert.py +64 -0
  2. meta.txt +9 -0
  3. original/.DS_Store +0 -0
  4. original/test/.DS_Store +0 -0
  5. original/test/.gitattributes +0 -0
  6. original/test/r31/r31-0001.png +3 -0
  7. original/test/r31/r31-0002.png +3 -0
  8. original/test/r31/r31-0003.png +3 -0
  9. original/test/r31/r31-0004.png +3 -0
  10. original/test/r31/r31-0005.png +3 -0
  11. original/test/r31/r31-0006.png +3 -0
  12. original/test/r31/r31-0007.png +3 -0
  13. original/test/r31/r31-0008.png +3 -0
  14. original/test/r31/r31-0009.png +3 -0
  15. original/test/r31/r31-0010.png +3 -0
  16. original/test/r31/r31-0011.png +3 -0
  17. original/test/r31/r31-0012.png +3 -0
  18. original/test/r31/r31-0013.png +3 -0
  19. original/test/r31/r31-0014.png +3 -0
  20. original/test/r31/r31-0015.png +3 -0
  21. original/test/r31/r31-0016.png +3 -0
  22. original/test/r31/r31-0017.png +3 -0
  23. original/test/r31/r31-0018.png +3 -0
  24. original/test/r31/r31-0019.png +3 -0
  25. original/test/r31/r31-0020.png +3 -0
  26. original/test/r31/r31-0021.png +3 -0
  27. original/test/r31/r31-0022.png +3 -0
  28. original/test/r31/r31-0023.png +3 -0
  29. original/test/r31/r31-0024.png +3 -0
  30. original/test/r31/r31-0025.png +3 -0
  31. original/test/r31/r31-0026.png +3 -0
  32. original/test/r31/r31-0027.png +3 -0
  33. original/test/r31/r31-0028.png +3 -0
  34. original/test/r31/r31-0029.png +3 -0
  35. original/test/r31/r31-0030.png +3 -0
  36. original/test/r31/r31-0031.png +3 -0
  37. original/test/r31/r31-0032.png +3 -0
  38. original/test/r31/r31-0033.png +3 -0
  39. original/test/r31/r31-0034.png +3 -0
  40. original/test/r31/r31-0035.png +3 -0
  41. original/test/r31/r31-0036.png +3 -0
  42. original/test/r31/r31-0037.png +3 -0
  43. original/test/r31/r31-0038.png +3 -0
  44. original/test/r31/r31-0039.png +3 -0
  45. original/test/r31/r31-0040.png +3 -0
  46. original/test/r31/r31-0041.png +3 -0
  47. original/test/r31/r31-0042.png +3 -0
  48. original/test/r31/r31-0043.png +3 -0
  49. original/test/r31/r31-0044.png +3 -0
  50. original/test/r31/r31-0045.png +3 -0
convert.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pandas as pd
3
+ from PIL import Image
4
+ import codecs
5
+ import numpy as np
6
+ import glob
7
+
8
+ def create_dataset():
9
+ print("Starting dataset creation...")
10
+
11
+ # Create output directory for images
12
+ os.makedirs("processed_images", exist_ok=True)
13
+
14
+ # Find all label files matching pattern
15
+ print("Finding label files...")
16
+ label_files = glob.glob("./original/test/round3?_best2019.label")
17
+ print(f"Found {len(label_files)} label files")
18
+
19
+ # Parse image filenames and captions
20
+ data = []
21
+ for i, label_path in enumerate(label_files):
22
+ print(f"\nProcessing label file {i+1}/{len(label_files)}: {label_path}")
23
+
24
+ # Read label file with Windows-874 encoding
25
+ print("Reading label file...")
26
+ with codecs.open(label_path, 'r', encoding='cp874') as f:
27
+ lines = f.readlines()
28
+ print(f"Found {len(lines)} entries")
29
+
30
+ for j, line in enumerate(lines):
31
+ if j % 100 == 0:
32
+ print(f"Processing entry {j}/{len(lines)}")
33
+
34
+ filename, caption = line.strip().split(' ', 1)
35
+
36
+ # Get folder name from first 3 chars of filename
37
+ folder = filename[:3]
38
+ image_path = f"./original/test/{folder}/{filename}"
39
+
40
+ # Load and verify image exists
41
+ if os.path.exists(image_path):
42
+ try:
43
+ # Save image to processed directory and store path
44
+ output_path = f"processed_images/{filename}"
45
+ Image.open(image_path).save(output_path)
46
+ data.append({
47
+ 'image_path': output_path,
48
+ 'text': caption,
49
+ 'label_file': os.path.basename(label_path)
50
+ })
51
+ except Exception as e:
52
+ print(f"Error processing image {image_path}: {e}")
53
+
54
+ print(f"\nProcessed {len(data)} total images successfully")
55
+
56
+ # Convert to dataframe and save as parquet
57
+ print("Converting to dataframe...")
58
+ df = pd.DataFrame(data)
59
+ print("Saving to parquet file...")
60
+ df.to_parquet("handwriting_dataset.parquet", index=False)
61
+ print("Dataset creation complete!")
62
+
63
+ if __name__ == "__main__":
64
+ create_dataset()
meta.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ We want to create huggingface dataset for image handwritten recognition
2
+ (1) Read the dataset from ./original/test/round31_best2019.label (It is encoded as Windows-784)
3
+
4
+ round31_best2019.label
5
+ r31-0001.png เป็นมนุษย์สุดประเสริฐเลิศคุณค่า กว่าบรรดาฝูงสัตว์เดรัจฉาน
6
+ r31-0002.png เป็นมนุษย์สุดประเสริฐเลิศคุณค่า กว่าบรรดาฝูงสัตว์เดรัจฉาน
7
+
8
+ (2) Load the image from folder that is the first 3 letters of filename e.g. r31-0001.png located at ./original/test/r31/r31-0001.png
9
+ (3) Make image and caption pair save as the parquets
original/.DS_Store ADDED
Binary file (6.15 kB). View file
 
original/test/.DS_Store ADDED
Binary file (6.15 kB). View file
 
original/test/.gitattributes ADDED
The diff for this file is too large to render. See raw diff
 
original/test/r31/r31-0001.png ADDED

Git LFS Details

  • SHA256: 03bfcd4bab73322dd069347c461056c3a319d9a580b99b306366190988af3119
  • Pointer size: 130 Bytes
  • Size of remote file: 94.8 kB
original/test/r31/r31-0002.png ADDED

Git LFS Details

  • SHA256: 2163c774fbf07f46e974c2d7498d46083643aa85926323bba60d066898b1563f
  • Pointer size: 130 Bytes
  • Size of remote file: 86.3 kB
original/test/r31/r31-0003.png ADDED

Git LFS Details

  • SHA256: 7acf255ce3c5bed78334d169e6dd22f2834ecd869a192683e6ce770dfa8236e9
  • Pointer size: 131 Bytes
  • Size of remote file: 129 kB
original/test/r31/r31-0004.png ADDED

Git LFS Details

  • SHA256: f20fca89b134e8dde4012a5ed9a6dddd5de43cf65d2fa1f3028ce04cb3cd29f8
  • Pointer size: 130 Bytes
  • Size of remote file: 95.9 kB
original/test/r31/r31-0005.png ADDED

Git LFS Details

  • SHA256: 07289caf26ea8a0dcb582e650c7d26ad206f9c1ee9c3f91808d1edbbaba89bb4
  • Pointer size: 130 Bytes
  • Size of remote file: 98.9 kB
original/test/r31/r31-0006.png ADDED

Git LFS Details

  • SHA256: 2ae0d31de5284f1d6b0d930278fe564f01a3a9b9a348f8ed5d8118ff3d8cfc80
  • Pointer size: 131 Bytes
  • Size of remote file: 112 kB
original/test/r31/r31-0007.png ADDED

Git LFS Details

  • SHA256: 0c7c9236611dde1a5b4a5b5e730348cfc6cbae2cc976f4ccca15c752b47fb262
  • Pointer size: 130 Bytes
  • Size of remote file: 90.3 kB
original/test/r31/r31-0008.png ADDED

Git LFS Details

  • SHA256: ada6b97dc6cc07e1ff2a462edc4e14c05f6f5b8d7ad606aa3655af13f37ccf12
  • Pointer size: 130 Bytes
  • Size of remote file: 88.1 kB
original/test/r31/r31-0009.png ADDED

Git LFS Details

  • SHA256: 31b99acbbd06b2d8616938c9416f0163437f3c6c4fcf05c97c71b6030841e813
  • Pointer size: 130 Bytes
  • Size of remote file: 65.9 kB
original/test/r31/r31-0010.png ADDED

Git LFS Details

  • SHA256: 270edcb702b021b96461b925737dd9af4472e03765e2fab41266d32053d1de27
  • Pointer size: 130 Bytes
  • Size of remote file: 65.4 kB
original/test/r31/r31-0011.png ADDED

Git LFS Details

  • SHA256: fb77dabf3626b6db9144985f6cbcf5910ccc4b48c33ed5d3ebf809f382f20f46
  • Pointer size: 130 Bytes
  • Size of remote file: 86.1 kB
original/test/r31/r31-0012.png ADDED

Git LFS Details

  • SHA256: 4e30a061b6992a4ff576809c261dd6d2bd1c1755a5c36a109013bd27a41f6f6a
  • Pointer size: 130 Bytes
  • Size of remote file: 98.3 kB
original/test/r31/r31-0013.png ADDED

Git LFS Details

  • SHA256: bc976ce5c82577db0ff0a2ae259ca916ac3d246f3482055b33adb9201ed14d00
  • Pointer size: 130 Bytes
  • Size of remote file: 58.3 kB
original/test/r31/r31-0014.png ADDED

Git LFS Details

  • SHA256: 3f413de8db1562837805f9b45fd2c901fc2a15b0c6538e883b2a1335c2420e94
  • Pointer size: 130 Bytes
  • Size of remote file: 86.1 kB
original/test/r31/r31-0015.png ADDED

Git LFS Details

  • SHA256: e2a9ed9a8b3a4fbcd02d7c15d4b92b7f71a6f19bcc03b6da785a336f16daf0e6
  • Pointer size: 130 Bytes
  • Size of remote file: 79.5 kB
original/test/r31/r31-0016.png ADDED

Git LFS Details

  • SHA256: aac2f78adbdfe05a1528193ca8219b6a66afcca587dae93762a20fb5c805f7d0
  • Pointer size: 130 Bytes
  • Size of remote file: 90.7 kB
original/test/r31/r31-0017.png ADDED

Git LFS Details

  • SHA256: a9f569e942d76c77bf01c548f54e0b5a373a2e458a47972a63b914707a720353
  • Pointer size: 130 Bytes
  • Size of remote file: 71.8 kB
original/test/r31/r31-0018.png ADDED

Git LFS Details

  • SHA256: 3183aa5e768af2d512bb882745d43317f97afadeb866f90653b0ec5772694424
  • Pointer size: 130 Bytes
  • Size of remote file: 95.1 kB
original/test/r31/r31-0019.png ADDED

Git LFS Details

  • SHA256: 76fb959fdef92780cae85718c9e02dfc9de78f38cb233c5d4f00b6618d5f8b21
  • Pointer size: 130 Bytes
  • Size of remote file: 71.1 kB
original/test/r31/r31-0020.png ADDED

Git LFS Details

  • SHA256: 9de9c4c957808de691bfb7220e8bfb921e3bec1549ded3b4291f32fa9d674729
  • Pointer size: 131 Bytes
  • Size of remote file: 114 kB
original/test/r31/r31-0021.png ADDED

Git LFS Details

  • SHA256: ef6136872b84d9a83fd8ef7fc9f575138472a720f59511de9f9ed40d8a380d6b
  • Pointer size: 131 Bytes
  • Size of remote file: 109 kB
original/test/r31/r31-0022.png ADDED

Git LFS Details

  • SHA256: ba67142c4a9c9b4a20366837e628600166a3a43ac6a81a84495747909388c60d
  • Pointer size: 131 Bytes
  • Size of remote file: 105 kB
original/test/r31/r31-0023.png ADDED

Git LFS Details

  • SHA256: 97c9020da5f3e650cee4ab3606e8db80106296902bada3b71ea7d8f788f203ec
  • Pointer size: 131 Bytes
  • Size of remote file: 112 kB
original/test/r31/r31-0024.png ADDED

Git LFS Details

  • SHA256: d31b42eb8356d4e769a739ea11e7076ce5f61a93e820926e4b74cbad9b7d095f
  • Pointer size: 131 Bytes
  • Size of remote file: 116 kB
original/test/r31/r31-0025.png ADDED

Git LFS Details

  • SHA256: 762ae620ae095208535cf9cf51167b77c3c8a1e2700c81ef93e4801f8e798750
  • Pointer size: 131 Bytes
  • Size of remote file: 122 kB
original/test/r31/r31-0026.png ADDED

Git LFS Details

  • SHA256: 4c4574afdbeebd10fbaeff4e97b63836df4a5ed550276a38bdc57c56f82592cb
  • Pointer size: 131 Bytes
  • Size of remote file: 122 kB
original/test/r31/r31-0027.png ADDED

Git LFS Details

  • SHA256: 4b41837dea3802d852ac86ed47c66fb7b743e9daedc2d7cefa1f2fbf2d1f5372
  • Pointer size: 131 Bytes
  • Size of remote file: 119 kB
original/test/r31/r31-0028.png ADDED

Git LFS Details

  • SHA256: da47adc8b437f20839edb5cf5e7d0d739a256e393a5596781da19a140ffa0e28
  • Pointer size: 130 Bytes
  • Size of remote file: 83.1 kB
original/test/r31/r31-0029.png ADDED

Git LFS Details

  • SHA256: 758d7011f295476cff7c403c9525dece0b84aa8d84e3bc182036d202db62f54e
  • Pointer size: 130 Bytes
  • Size of remote file: 90 kB
original/test/r31/r31-0030.png ADDED

Git LFS Details

  • SHA256: f43b52b4e2d41476dd8b209bc76cc715cde8f1c18b7a4d6677f8fd18e5bb8472
  • Pointer size: 130 Bytes
  • Size of remote file: 78.1 kB
original/test/r31/r31-0031.png ADDED

Git LFS Details

  • SHA256: 6739dbe5a66be34e73becff3b8819be81d46833f5b626bc5cccf8ac628ad9463
  • Pointer size: 130 Bytes
  • Size of remote file: 42.3 kB
original/test/r31/r31-0032.png ADDED

Git LFS Details

  • SHA256: c91ff683df0cb9afac6de60c93353e51fef39321e28bf4556e10451428f9c4ff
  • Pointer size: 130 Bytes
  • Size of remote file: 77.4 kB
original/test/r31/r31-0033.png ADDED

Git LFS Details

  • SHA256: 5c12c9e5a4137caab6566cbf0ea086969e9afe6b1fbef750bee146fecf96670a
  • Pointer size: 130 Bytes
  • Size of remote file: 84.5 kB
original/test/r31/r31-0034.png ADDED

Git LFS Details

  • SHA256: 75b8ed33388a755d778a8db45cfa7ba278cb274ef93b9fbee0ea53518eb90733
  • Pointer size: 130 Bytes
  • Size of remote file: 47 kB
original/test/r31/r31-0035.png ADDED

Git LFS Details

  • SHA256: c19cdf4f6a87867c438db4631a1613fb1fc8b0a982da32ee3e866da171c43c21
  • Pointer size: 130 Bytes
  • Size of remote file: 46.2 kB
original/test/r31/r31-0036.png ADDED

Git LFS Details

  • SHA256: fcf2aa270a09698385b781df452fd53c7cc47b97d3b73c2900513b0792e52325
  • Pointer size: 130 Bytes
  • Size of remote file: 38.1 kB
original/test/r31/r31-0037.png ADDED

Git LFS Details

  • SHA256: f4d9d7494c4647cbaccb06abf58810e5a86cb3262ee2b031c91e64955f6bffac
  • Pointer size: 130 Bytes
  • Size of remote file: 51.8 kB
original/test/r31/r31-0038.png ADDED

Git LFS Details

  • SHA256: f229f6243de3c7e7ef213c0ce82a41ae1bc2ff8b3c64ff0dccf4cb3d74892f2d
  • Pointer size: 130 Bytes
  • Size of remote file: 49.1 kB
original/test/r31/r31-0039.png ADDED

Git LFS Details

  • SHA256: 34e6ad136a7c48c2437f2d295dbf5531472d430d28149e9cb12e3e21a75deaba
  • Pointer size: 130 Bytes
  • Size of remote file: 42 kB
original/test/r31/r31-0040.png ADDED

Git LFS Details

  • SHA256: f65acbbb4d71db78d2878772bc7c7290cf3c3e65a0d3810ab65e52d36e84ac27
  • Pointer size: 130 Bytes
  • Size of remote file: 53.2 kB
original/test/r31/r31-0041.png ADDED

Git LFS Details

  • SHA256: d5bfcc637a9f263bec0f0fd90bf88ebcd88d9bb161cd23740f1f5b376f3bcf0b
  • Pointer size: 131 Bytes
  • Size of remote file: 111 kB
original/test/r31/r31-0042.png ADDED

Git LFS Details

  • SHA256: f273fa993dd5d7743ee6c0a31176fd478258abc263797738629f9c363c7c6643
  • Pointer size: 131 Bytes
  • Size of remote file: 126 kB
original/test/r31/r31-0043.png ADDED

Git LFS Details

  • SHA256: 4fb3ccdd00e381f9026fce269e999f211b285179f747c41ec70ef0b65037b9ee
  • Pointer size: 130 Bytes
  • Size of remote file: 83.1 kB
original/test/r31/r31-0044.png ADDED

Git LFS Details

  • SHA256: 1cbe75082c7767bf25d29f73141b0c65577b1fddfc59ed983784b008baa65088
  • Pointer size: 131 Bytes
  • Size of remote file: 200 kB
original/test/r31/r31-0045.png ADDED

Git LFS Details

  • SHA256: c7c8ef1da17ace228f4da59814a3b71f3435c6306139b8ce31a8e22644cedebe
  • Pointer size: 131 Bytes
  • Size of remote file: 107 kB