-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.py
63 lines (47 loc) · 1.61 KB
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# import xml.dom.minidom
# import os
# charrss = set()
# directory = '/home/saksham/Desktop/urdu_ocr/urdu_benchmark'
# max_len = 0
# num = 0
# for filename in os.listdir(directory) :
# if (filename.endswith('.xml')) :
# f = os.path.join(directory, filename)
# docs = xml.dom.minidom.parse(f)
# items = docs.getElementsByTagName('name')
# num += 1
# for element in items:
# if (element.firstChild) :
# txt = element.firstChild.data
# chars = txt.split(' ')
# max_len = max(max_len, len(chars))
# for c in chars:
# charrss.add(c)
# docs = xml.dom.minidom.parse('/home/saksham/Desktop/urdu_ocr/urdu_benchmark/UR5-100-500-page-015_1.xml')
# print(len(charrss))
# items = docs.getElementsByTagName('name')
# for element in items:
# txt = element.firstChild.data
# print(txt.split(' '))
# directory = r'C:\Users\admin'
# for filename in os.listdir(directory):
# if filename.endswith(".jpg") or filename.endswith(".png"):
# print(os.path.join(directory, filename))
# else:
# continue
# import cv2 as cv
# import tensorflow as tf
# import numpy as np
# #Dense to corresponding text removing Unidentified Character
# def dense_to_text(dense):
# text=''
# for num in dense:
# if (num < len(chars)+1 and num > 0):
# text+=chars[num-1]
# return text
# Load Character set
# chars=''
# with open('/home/saksham/Desktop/urdu_ocr/chars.txt',encoding='utf-8') as f:
# chars=f.read()
# for i in range(len(chars)) :
# print(i, chars[i])