Update main.py

Issues 30 and 40 are resolved
pull/41/head
vahidrezanezhad 4 years ago committed by GitHub
parent a7c92c92ff
commit 0f09f4a1f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,6 +3,7 @@
__version__ = '1.0' __version__ = '1.0'
import os import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import sys import sys
import cv2 import cv2
import numpy as np import numpy as np
@ -17,8 +18,9 @@ import math
from shapely import geometry from shapely import geometry
from sklearn.cluster import KMeans from sklearn.cluster import KMeans
import gc import gc
from keras import backend as K
import tensorflow as tf import tensorflow as tf
tf.get_logger().setLevel('ERROR')
from keras import backend as K
from scipy.signal import find_peaks from scipy.signal import find_peaks
from scipy.ndimage import gaussian_filter1d from scipy.ndimage import gaussian_filter1d
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
@ -29,8 +31,10 @@ from multiprocessing import Process, Queue, cpu_count
import datetime import datetime
with warnings.catch_warnings(): warnings.filterwarnings('ignore')
warnings.simplefilter("ignore")
##with warnings.catch_warnings():
##warnings.simplefilter("ignore",category=RuntimeWarning)
__doc__ = \ __doc__ = \
""" """
@ -2063,23 +2067,30 @@ class textline_detector:
t2=time.time() t2=time.time()
# extract text regions and corresponding contours and surrounding box try:
text_regions=self.extract_text_regions(image_page) # extract text regions and corresponding contours and surrounding box
text_regions=self.extract_text_regions(image_page)
text_regions = cv2.erode(text_regions, self.kernel, iterations=3)
text_regions = cv2.dilate(text_regions, self.kernel, iterations=4)
#plt.imshow(text_regions[:,:,0])
#plt.show()
contours=self.get_text_region_contours_and_boxes(text_regions)
text_regions = cv2.erode(text_regions, self.kernel, iterations=3)
text_regions = cv2.dilate(text_regions, self.kernel, iterations=4)
#plt.imshow(text_regions[:,:,0])
#plt.show()
contours=self.get_text_region_contours_and_boxes(text_regions)
##########
K.clear_session()
gc.collect()
##########
K.clear_session()
gc.collect()
except:
text_regions=None
contours=[]
t3=time.time() t3=time.time()

Loading…
Cancel
Save