thinkersloop commited on
Commit
3d4f9a9
1 Parent(s): 165876b

Upload 218 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
1.json2string.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # convert json to single line string from all the folders where json is present
2
+
3
+ import os
4
+ import json
5
+ import glob
6
+ import argparse
7
+
8
+ def json2string(dir_path):
9
+ for root, dirs, files in os.walk(dir_path):
10
+ for file in files:
11
+ if file.endswith('.json'):
12
+ with open(os.path.join(root, file), 'r') as f:
13
+ # print the name of the file
14
+ print(file)
15
+ data = json.load(f)
16
+ data = json.dumps(data)
17
+
18
+ # add double quotes to the string
19
+ data = '"' + data + '"'
20
+ print(data[:5])
21
+
22
+ # write to file
23
+ with open(os.path.join(root, file), 'w') as f:
24
+ f.write(data)
25
+
26
+
27
+ if __name__ == '__main__':
28
+ parser = argparse.ArgumentParser()
29
+ parser.add_argument('--dir_path', type=str, default='.', help='Directory path')
30
+ args = parser.parse_args()
31
+ json2string(args.dir_path)
2.remove_quotes.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """Remove the start and end quotes from all the files in a folder."""
4
+
5
+ import argparse
6
+ import glob
7
+ import os
8
+
9
+ def remove_quotes(dir_path):
10
+ """Remove the start and end quotes from all the files in a folder."""
11
+ for file in glob.glob(dir_path + "/*.json"):
12
+ with open(file, "r") as f:
13
+ data = f.read()
14
+ data = data[1:-1]
15
+ with open(file, "w") as f:
16
+ f.write(data)
17
+
18
+
19
+ def main():
20
+ """Main function."""
21
+ parser = argparse.ArgumentParser()
22
+ parser.add_argument("--dir_path", type=str, default=".", help="Directory path")
23
+ args = parser.parse_args()
24
+ remove_quotes(args.dir_path)
25
+
26
+ if __name__ == "__main__":
27
+ main()
3.listOfjsonl.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # read all txt files and save them in a metadata.jsonl file
2
+
3
+ import os
4
+ import glob
5
+ import argparse
6
+ import json
7
+
8
+ def readTxt(dir_path):
9
+ # read all txt files
10
+ for file in glob.glob(dir_path + '/*.json'):
11
+ # read jsonl file
12
+ with open(file, 'r') as f:
13
+ # print the name of the file
14
+ print(file)
15
+ # read the lines
16
+ lines = f.readlines()
17
+ # create a dictionary
18
+ metadata = {}
19
+ # add the name of the file
20
+ metadata["file_name"] = file.split("/")[-1].split('json')[1][1:-1] + '.jpg'
21
+ # add the text
22
+ metadata['ground_truth'] = lines[0].strip()
23
+
24
+ print(metadata)
25
+
26
+ # append the metadata to the metadata.jsonl file on the directory
27
+ with open(os.path.join(dir_path, 'metadata.jsonl'), 'a') as f:
28
+ f.write(json.dumps(metadata) + '\n')
29
+
30
+ if __name__ == '__main__':
31
+ parser = argparse.ArgumentParser()
32
+ parser.add_argument('--dir_path', type=str, default='data')
33
+ args = parser.parse_args()
34
+ readTxt(args.dir_path)
data/test/254686.jpg ADDED

Git LFS Details

  • SHA256: ff864cb46c50115c011a971847df5916a1ec563253bed4c8729188695b6d4683
  • Pointer size: 130 Bytes
  • Size of remote file: 63.4 kB
data/test/255070.jpg ADDED

Git LFS Details

  • SHA256: 0aef2f179ce7758c32aa8e98eb224fa6776243098eb9e008c61b00c4dd205714
  • Pointer size: 130 Bytes
  • Size of remote file: 51.6 kB
data/test/metadata.jsonl ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ {"file_name": ".jpg", "ground_truth": "{\"gt_parse\": {\"name\": {\"state\": \"Connecticut\", \"person\": \"BINGAMAN PETER RHOADS\"}, \"date\": {\"dob\": \"09/30/1964\"}}, \"meta\": {\"version\": \"v0.2\", \"split\": \"train\", \"image_id\": 0, \"image_size\": {\"width\": 501, \"height\": 317}}, \"valid_line\": [{\"words\": [{\"quad\": {\"x2\": 186, \"x1\": 22, \"y1\": 13, \"y2\": 13, \"x3\": 186, \"x4\": 22, \"y3\": 50, \"y4\": 50}, \"is_key\": 0, \"row_id\": 2028661, \"text\": \"Connecticut\"}], \"category\": \"name.state\", \"group_id\": 12}, {\"words\": [{\"quad\": {\"x2\": 265, \"x1\": 180, \"y1\": 234, \"y2\": 234, \"x3\": 265, \"x4\": 180, \"y3\": 250, \"y4\": 250}, \"is_key\": 0, \"row_id\": 2028663, \"text\": \"BINGAMAN\"}, {\"quad\": {\"x2\": 227, \"x1\": 180, \"y1\": 250, \"y2\": 250, \"x3\": 227, \"x4\": 180, \"y3\": 264, \"y4\": 264}, \"is_key\": 0, \"row_id\": 2028664, \"text\": \"PETER\"}, {\"quad\": {\"x2\": 290, \"x1\": 231, \"y1\": 251, \"y2\": 251, \"x3\": 290, \"x4\": 231, \"y3\": 265, \"y4\": 265}, \"is_key\": 0, \"row_id\": 2028664, \"text\": \"RHOADS\"}], \"category\": \"name.person\", \"group_id\": 14}, {\"words\": [{\"quad\": {\"x2\": 209, \"x1\": 184, \"y1\": 141, \"y2\": 141, \"x3\": 209, \"x4\": 184, \"y3\": 155, \"y4\": 155}, \"is_key\": 1, \"row_id\": 2028662, \"text\": \"DOB\"}, {\"quad\": {\"x2\": 315, \"x1\": 213, \"y1\": 133, \"y2\": 133, \"x3\": 315, \"x4\": 133, \"y3\": 152, \"y4\": 152}, \"is_key\": 0, \"row_id\": 2028662, \"text\": \"09/30/1964\"}], \"category\": \"date.dob\", \"group_id\": 19}], \"roi\": {}, \"repeating_symbol\": [], \"dontcare\": []}"}
2
+ {"file_name": ".jpg", "ground_truth": "{\"gt_parse\": {\"name\": {\"state\": \"Hawaii\", \"person\": \"ANDRADA ANDREA\"}, \"date\": {\"dob\": \"12/16/1988\"}}, \"meta\": {\"version\": \"v0.2\", \"split\": \"train\", \"image_id\": 0, \"image_size\": {\"width\": 503, \"height\": 317}}, \"valid_line\": [{\"words\": [{\"quad\": {\"x2\": 176, \"x1\": 9, \"y1\": 6, \"y2\": 6, \"x3\": 176, \"x4\": 9, \"y3\": 48, \"y4\": 48}, \"is_key\": 0, \"row_id\": 2028661, \"text\": \"Hawaii\"}], \"category\": \"name.state\", \"group_id\": 12}, {\"words\": [{\"quad\": {\"x2\": 127, \"x1\": 53, \"y1\": 248, \"y2\": 248, \"x3\": 127, \"x4\": 53, \"y3\": 260, \"y4\": 260}, \"is_key\": 0, \"row_id\": 2028663, \"text\": \"ANDRADA\"}, {\"quad\": {\"x2\": 0, \"x1\": 0, \"y1\": 0, \"y2\": 0, \"x3\": 0, \"x4\": 0, \"y3\": 0, \"y4\": 0}, \"is_key\": 0, \"row_id\": 2028663, \"text\": \"\"}, {\"quad\": {\"x2\": 127, \"x1\": 53, \"y1\": 248, \"y2\": 248, \"x3\": 127, \"x4\": 53, \"y3\": 260, \"y4\": 260}, \"is_key\": 0, \"row_id\": 2028664, \"text\": \"ANDREA\"}], \"category\": \"name.person\", \"group_id\": 14}, {\"words\": [{\"quad\": {\"x2\": 240, \"x1\": 180, \"y1\": 158, \"y2\": 158, \"x3\": 240, \"x4\": 180, \"y3\": 178, \"y4\": 178}, \"is_key\": 1, \"row_id\": 2028662, \"text\": \"DOB\"}, {\"quad\": {\"x2\": 363, \"x1\": 246, \"y1\": 158, \"y2\": 158, \"x3\": 363, \"x4\": 246, \"y3\": 178, \"y4\": 178}, \"is_key\": 0, \"row_id\": 2028662, \"text\": \"12/16/1988\"}], \"category\": \"date.dob\", \"group_id\": 19}], \"roi\": {}, \"repeating_symbol\": [], \"dontcare\": []}"}
data/train/0.jpg ADDED

Git LFS Details

  • SHA256: 6c5cf5e58442ad7c28954d34a3cadce1010920c734c5508e89e2070347d0164e
  • Pointer size: 130 Bytes
  • Size of remote file: 35.2 kB
data/train/155.jpg ADDED

Git LFS Details

  • SHA256: ffe568616b0f043dc42d2b264b53489abee4c4a28d9ff4de828dc6c51629e265
  • Pointer size: 130 Bytes
  • Size of remote file: 51.9 kB
data/train/2.jpg ADDED

Git LFS Details

  • SHA256: f8df00f89259a5ef7043ad1a0d84c0a91dda69bdf4054eb56dbd6632f79a171c
  • Pointer size: 130 Bytes
  • Size of remote file: 53 kB
data/train/21.jpg ADDED

Git LFS Details

  • SHA256: 82e89244f56a6d46a30580bd1e22c4283665da0ca26b5d6f068c48445f67cca0
  • Pointer size: 130 Bytes
  • Size of remote file: 55 kB
data/train/25.jpg ADDED

Git LFS Details

  • SHA256: 365b98c060894c7fdfd4b7b9fa7d0c7fd6c50e1957a6ea2316eb2f0a798f26b4
  • Pointer size: 130 Bytes
  • Size of remote file: 49.3 kB
data/train/254039.jpg ADDED

Git LFS Details

  • SHA256: 878d39a2db38b19cb9fdfff7951a8ac8baf3b651d1305643e6ee83ffbe791892
  • Pointer size: 130 Bytes
  • Size of remote file: 46.1 kB
data/train/254050.jpg ADDED

Git LFS Details

  • SHA256: c8a9f9f8de536a0e816936f3d326391c87c23d9f79880de8095850dbce31ada4
  • Pointer size: 130 Bytes
  • Size of remote file: 47.9 kB
data/train/254061.jpg ADDED

Git LFS Details

  • SHA256: 381c4d5903fb03bb2fab6954096182fbf5e715419bf164f609cc2b03d2fbc9a3
  • Pointer size: 130 Bytes
  • Size of remote file: 48.8 kB
data/train/254071.jpg ADDED

Git LFS Details

  • SHA256: b465bf138a0bd36521edf0cff8ecfbc04414dab18ab2ffa3ee9f3a9090e0a95a
  • Pointer size: 130 Bytes
  • Size of remote file: 69.2 kB
data/train/254095.jpg ADDED

Git LFS Details

  • SHA256: 52ad03b987baeec3fea11d1df7fce8a6416b86f01d8895969b9e1c1591023247
  • Pointer size: 130 Bytes
  • Size of remote file: 64.7 kB
data/train/254097.jpg ADDED

Git LFS Details

  • SHA256: fe83b8883822914f7a2fcf56900b5384f2032f2d3bfdf25d1a78a29d71d99837
  • Pointer size: 130 Bytes
  • Size of remote file: 63.9 kB
data/train/254099.jpg ADDED

Git LFS Details

  • SHA256: 2e56a8ff920a94e91215b3177f61661ddf8cd9dcbfb4c39e4e762b382726883e
  • Pointer size: 130 Bytes
  • Size of remote file: 60.8 kB
data/train/254100.jpg ADDED

Git LFS Details

  • SHA256: a50ba4358c0e6fadcb9709783161a11509823cd35c617d1acc4aabeabc1ec6ec
  • Pointer size: 130 Bytes
  • Size of remote file: 64 kB
data/train/254103.jpg ADDED

Git LFS Details

  • SHA256: 6efe790e7e98754e6f88af867180f2230ce0f2d80cccae58365a69ebff1da367
  • Pointer size: 130 Bytes
  • Size of remote file: 69.7 kB
data/train/254108.jpg ADDED

Git LFS Details

  • SHA256: eda5f4f240279800208c642f6b7db6f1fa887f723507a70b411b8325432b91d2
  • Pointer size: 130 Bytes
  • Size of remote file: 54.3 kB
data/train/254119.jpg ADDED

Git LFS Details

  • SHA256: 7ab5f7a299271767dba2b9fcd6bbeb525f6713f48a7921d307d09d1ee7ca30d7
  • Pointer size: 130 Bytes
  • Size of remote file: 67.6 kB
data/train/254121.jpg ADDED

Git LFS Details

  • SHA256: 2d82fcff0a3ef9940189491368c4d2419aa0c245391fc9d152b7369dabcde657
  • Pointer size: 130 Bytes
  • Size of remote file: 68.8 kB
data/train/254143.jpg ADDED

Git LFS Details

  • SHA256: c2d85a5c40aa3b4cf7817723f7f67f2ada80af7b8fb3c1cf1403ce5eba87a586
  • Pointer size: 130 Bytes
  • Size of remote file: 63.7 kB
data/train/254145.jpg ADDED

Git LFS Details

  • SHA256: 45b1a646e72ea4e0ca05718dd07964fc596bd0adb0134a17361010ebd9f4769b
  • Pointer size: 130 Bytes
  • Size of remote file: 44.8 kB
data/train/254147.jpg ADDED

Git LFS Details

  • SHA256: 386cc82751f55e7ea181dee8fcb7d80a478d62eb31cb9fdc5ac7ac615568b130
  • Pointer size: 130 Bytes
  • Size of remote file: 48.8 kB
data/train/254148.jpg ADDED

Git LFS Details

  • SHA256: 6a8b37be0b17974067a92f0deb9b66fb76ab5bd3b85a68cf2138c053d5a0dd28
  • Pointer size: 130 Bytes
  • Size of remote file: 49.2 kB
data/train/254149.jpg ADDED

Git LFS Details

  • SHA256: 1df72f7ab76e50b504275975ae1eebb1151463666bdb3f23fe7497fb83677f04
  • Pointer size: 130 Bytes
  • Size of remote file: 40 kB
data/train/254151.jpg ADDED

Git LFS Details

  • SHA256: 50cf4e84ead00ebe2cc5eb717ac26de4531ce57d17a94e5d8af37b4b14278af4
  • Pointer size: 130 Bytes
  • Size of remote file: 39.8 kB
data/train/254154.jpg ADDED

Git LFS Details

  • SHA256: 54ecbe097267396bf0ce8196672ca257f5b4f374e11c9adb7be225a514146a91
  • Pointer size: 130 Bytes
  • Size of remote file: 50.2 kB
data/train/254157.jpg ADDED

Git LFS Details

  • SHA256: 6a4652138405d56f01a101d78d3227da3b1d9f30af568c147d02d471fad2d920
  • Pointer size: 130 Bytes
  • Size of remote file: 62.8 kB
data/train/254158.jpg ADDED

Git LFS Details

  • SHA256: 268b71062742b370e8861a9b5982e87368b32ca48c8127d013b0679a2085c779
  • Pointer size: 130 Bytes
  • Size of remote file: 54.6 kB
data/train/254159.jpg ADDED

Git LFS Details

  • SHA256: 393bcdac85df9b9eba7a9653282973b8f0c129e57a373174832a7cf3888eef86
  • Pointer size: 130 Bytes
  • Size of remote file: 59.6 kB
data/train/254164.jpg ADDED

Git LFS Details

  • SHA256: 476792bb25ffad8f3f0c898d38a9b4308444ccdd73552f8c66f9f2db870f6bec
  • Pointer size: 130 Bytes
  • Size of remote file: 39.5 kB
data/train/254168.jpg ADDED

Git LFS Details

  • SHA256: 8dba7a54833268885c4f8f3bb295371311399755cf0a990156bd216700b73314
  • Pointer size: 130 Bytes
  • Size of remote file: 55.4 kB
data/train/254199.jpg ADDED

Git LFS Details

  • SHA256: 2012b1dbd1e300e60b4e3db456f9f577136002b71ece6b1b6827008a3f426c22
  • Pointer size: 130 Bytes
  • Size of remote file: 46.1 kB
data/train/254225.jpg ADDED

Git LFS Details

  • SHA256: 4ff92fa83cfaaa0ed5ed688a1d18cea4500b2e1d4a089d45509044b2db7e97b2
  • Pointer size: 130 Bytes
  • Size of remote file: 47.9 kB
data/train/254229.jpg ADDED

Git LFS Details

  • SHA256: ae1c79f426269601b122c191d0dd8c0b1564049a51b23459f8b7f16cb64b6e3f
  • Pointer size: 130 Bytes
  • Size of remote file: 40.5 kB
data/train/254234.jpg ADDED

Git LFS Details

  • SHA256: 867d119024bd2f46fa51b4657b4043a176034605e35d1b678637828fc5dd969e
  • Pointer size: 130 Bytes
  • Size of remote file: 56.8 kB
data/train/254241.jpg ADDED

Git LFS Details

  • SHA256: d42965da9f2e9b91b959535383af74d92831a99a6af886b18e13e9fad840e27a
  • Pointer size: 130 Bytes
  • Size of remote file: 56.1 kB
data/train/254253.jpg ADDED

Git LFS Details

  • SHA256: 4f186b16c4b5814ffbd97262924d4997151ba41420b23785a5ea8c770b8c90cb
  • Pointer size: 130 Bytes
  • Size of remote file: 58.8 kB
data/train/254259.jpg ADDED

Git LFS Details

  • SHA256: 3937e4887337aa4c1dc52d6a1a2c75dafad4d318d60c06bfeb84b9991bf93b55
  • Pointer size: 130 Bytes
  • Size of remote file: 59.2 kB
data/train/254260.jpg ADDED

Git LFS Details

  • SHA256: 07786acd3df6ffb7959b7abefa5f134b0f0b4d6707c6cf6096d1db7f8016f5e0
  • Pointer size: 130 Bytes
  • Size of remote file: 57.7 kB
data/train/254273.jpg ADDED

Git LFS Details

  • SHA256: ee9f0a056812b1e16dbf6bc153e3fd5accfbee9313b92e97d21ebfa9ac606b4c
  • Pointer size: 130 Bytes
  • Size of remote file: 52.2 kB
data/train/254288.jpg ADDED

Git LFS Details

  • SHA256: 0490f5ac107c8e6e939f2c3b2157c1bca6b2691aae853f9f130bb74998f89cfb
  • Pointer size: 130 Bytes
  • Size of remote file: 71.3 kB
data/train/254302.jpg ADDED

Git LFS Details

  • SHA256: b580cc51df28ce24ea93032818bbf852fc332b944be07d2b17b43cfc22ead6ba
  • Pointer size: 130 Bytes
  • Size of remote file: 70 kB
data/train/254303.jpg ADDED

Git LFS Details

  • SHA256: fe07a84ccf0aca61a4068397babb784585f0996f60f69e6ad178016eb6168991
  • Pointer size: 130 Bytes
  • Size of remote file: 71.6 kB
data/train/254304.jpg ADDED

Git LFS Details

  • SHA256: f56c89012834d6eb502be52cd31f44c51edc632dbdabd89468f16f88f42ce22f
  • Pointer size: 130 Bytes
  • Size of remote file: 64.1 kB
data/train/254311.jpg ADDED

Git LFS Details

  • SHA256: b6c00b1f7d77c2438fd84f79e5e8ca53efc0904a52bb3298223efe4b48894f39
  • Pointer size: 130 Bytes
  • Size of remote file: 53.1 kB
data/train/254318.jpg ADDED

Git LFS Details

  • SHA256: 9ba2b393192b226bed9c9ede54a76c8fcc5dd098af9ae48b0cc419740c8558e9
  • Pointer size: 130 Bytes
  • Size of remote file: 65.8 kB