@@ -1512,52 +1512,10 @@ def extract_text_regions(self, img, patches, cols):
15121512 img_width_h = img .shape [1 ]
15131513 model_region = self .model_zoo .get ("region_fl" ) if patches else self .model_zoo .get ("region_fl_np" )
15141514
1515- if not patches :
1516- img = otsu_copy_binary (img )
1517- img = img .astype (np .uint8 )
1518- prediction_regions2 = None
1519- elif cols :
1520- if cols == 1 :
1521- img_height_new = int (img_height_h * 0.7 )
1522- img_width_new = int (img_width_h * 0.7 )
1523- elif cols == 2 :
1524- img_height_new = int (img_height_h * 0.4 )
1525- img_width_new = int (img_width_h * 0.4 )
1526- else :
1527- img_height_new = int (img_height_h * 0.3 )
1528- img_width_new = int (img_width_h * 0.3 )
1529- img2 = otsu_copy_binary (img )
1530- img2 = img2 .astype (np .uint8 )
1531- img2 = resize_image (img2 , img_height_new , img_width_new )
1532- prediction_regions2 = self .do_prediction (patches , img2 , model_region , marginal_of_patch_percent = 0.1 )
1533- prediction_regions2 = resize_image (prediction_regions2 , img_height_h , img_width_h )
1534-
1535- img = otsu_copy_binary (img ).astype (np .uint8 )
1536- if cols == 1 :
1537- img = resize_image (img , int (img_height_h * 0.5 ), int (img_width_h * 0.5 )).astype (np .uint8 )
1538- elif cols == 2 and img_width_h >= 2000 :
1539- img = resize_image (img , int (img_height_h * 0.9 ), int (img_width_h * 0.9 )).astype (np .uint8 )
1540- elif cols == 3 and ((self .scale_x == 1 and img_width_h > 3000 ) or
1541- (self .scale_x != 1 and img_width_h > 2800 )):
1542- img = resize_image (img , 2800 * img_height_h // img_width_h , 2800 ).astype (np .uint8 )
1543- elif cols == 4 and ((self .scale_x == 1 and img_width_h > 4000 ) or
1544- (self .scale_x != 1 and img_width_h > 3700 )):
1545- img = resize_image (img , 3700 * img_height_h // img_width_h , 3700 ).astype (np .uint8 )
1546- elif cols == 4 :
1547- img = resize_image (img , int (img_height_h * 0.9 ), int (img_width_h * 0.9 )).astype (np .uint8 )
1548- elif cols == 5 and self .scale_x == 1 and img_width_h > 5000 :
1549- img = resize_image (img , int (img_height_h * 0.7 ), int (img_width_h * 0.7 )).astype (np .uint8 )
1550- elif cols == 5 :
1551- img = resize_image (img , int (img_height_h * 0.9 ), int (img_width_h * 0.9 )).astype (np .uint8 )
1552- elif img_width_h > 5600 :
1553- img = resize_image (img , 5600 * img_height_h // img_width_h , 5600 ).astype (np .uint8 )
1554- else :
1555- img = resize_image (img , int (img_height_h * 0.9 ), int (img_width_h * 0.9 )).astype (np .uint8 )
1556-
15571515 prediction_regions = self .do_prediction (patches , img , model_region , marginal_of_patch_percent = 0.1 )
15581516 prediction_regions = resize_image (prediction_regions , img_height_h , img_width_h )
15591517 self .logger .debug ("exit extract_text_regions" )
1560- return prediction_regions , prediction_regions2
1518+ return prediction_regions , None
15611519
15621520 def get_textlines_of_a_textregion_sorted (self , textlines_textregion , cx_textline , cy_textline , w_h_textline ):
15631521 N = len (cy_textline )
0 commit comments