qurator-spk / eynollah

Document Layout Analysis
Apache License 2.0
332 stars 27 forks source link

error while running inference #75

Closed Ashbajawed closed 1 year ago

Ashbajawed commented 2 years ago

I'm recieving following error while running test either on my own document image or on the test tiff provided in resource folder

My versions pip 21.3.1 python3.6

tensorflow-estimator 1.15.1 tensorflow-gpu 1.15.5 keras-mxnet 2.2.4.3

ValueError Traceback (most recent call last)

in 16 headers_off=headers_off, 17 ) ---> 18 pcgts = eynollah.run() 19 eynollah.writer.write_pagexml(pcgts) 20 ~/ELD/lib/python3.6/site-packages/qurator/eynollah/eynollah.py in run(self) 2305 2306 t0 = time.time() -> 2307 img_res, is_image_enhanced, num_col_classifier, num_column_is_classified = self.run_enhancement() 2308 2309 self.logger.info("Enhancing took %.1fs ", time.time() - t0) ~/ELD/lib/python3.6/site-packages/qurator/eynollah/eynollah.py in run_enhancement(self) 1988 def run_enhancement(self): 1989 self.logger.info("Resizing and enhancing image...") -> 1990 is_image_enhanced, img_org, img_res, num_col_classifier, num_column_is_classified, img_bin = self.resize_and_enhance_image_with_column_classifier() 1991 self.logger.info("Image was %senhanced.", '' if is_image_enhanced else 'not ') 1992 K.clear_session() ~/ELD/lib/python3.6/site-packages/qurator/eynollah/eynollah.py in resize_and_enhance_image_with_column_classifier(self) 406 img_bin = None 407 --> 408 _, page_coord = self.early_page_for_num_of_column_classification(img_bin) 409 model_num_classifier, session_col_classifier = self.start_new_session_and_model(self.model_dir_of_col_classifier) 410 ~/ELD/lib/python3.6/site-packages/qurator/eynollah/eynollah.py in early_page_for_num_of_column_classification(self, img_bin) 646 else: 647 img = self.imread() --> 648 model_page, session_page = self.start_new_session_and_model(self.model_page_dir) 649 img = cv2.GaussianBlur(img, (5, 5), 0) 650 ~/ELD/lib/python3.6/site-packages/qurator/eynollah/eynollah.py in start_new_session_and_model(self, model_dir) 516 #gpu_options = tf.compat.v1.GPUOptions(per_process_gpu_memory_fraction=7.7, allow_growth=True) 517 session = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(gpu_options=gpu_options)) --> 518 model = load_model(model_dir, compile=False) 519 520 return model, session ~/ELD/lib/python3.6/site-packages/keras/engine/saving.py in load_model(filepath, custom_objects, compile) 494 f = h5dict(filepath, 'r') 495 try: --> 496 model = _deserialize_model(f, custom_objects, compile) 497 finally: 498 if opened_new_file: ~/ELD/lib/python3.6/site-packages/keras/engine/saving.py in _deserialize_model(f, custom_objects, compile) 300 raise ValueError('No model found in config.') 301 model_config = json.loads(model_config.decode('utf-8')) --> 302 model = model_from_config(model_config, custom_objects=custom_objects) 303 model_weights_group = f['model_weights'] 304 ~/ELD/lib/python3.6/site-packages/keras/engine/saving.py in model_from_config(config, custom_objects) 533 '`Sequential.from_config(config)`?') 534 from ..layers import deserialize --> 535 return deserialize(config, custom_objects=custom_objects) 536 537 ~/ELD/lib/python3.6/site-packages/keras/layers/__init__.py in deserialize(config, custom_objects) 53 module_objects=globs, 54 custom_objects=custom_objects, ---> 55 printable_module_name='layer') ~/ELD/lib/python3.6/site-packages/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name) 143 config['config'], 144 custom_objects=dict(list(_GLOBAL_CUSTOM_OBJECTS.items()) + --> 145 list(custom_objects.items()))) 146 with CustomObjectScope(custom_objects): 147 return cls.from_config(config['config']) ~/ELD/lib/python3.6/site-packages/keras/engine/network.py in from_config(cls, config, custom_objects) 1030 if layer in unprocessed_nodes: 1031 for node_data in unprocessed_nodes.pop(layer): -> 1032 process_node(layer, node_data) 1033 1034 name = config.get('name') ~/ELD/lib/python3.6/site-packages/keras/engine/network.py in process_node(layer, node_data) 989 # and building the layer if needed. 990 if input_tensors: --> 991 layer(unpack_singleton(input_tensors), **kwargs) 992 993 def process_layer(layer_data): ~/ELD/lib/python3.6/site-packages/keras/engine/base_layer.py in __call__(self, inputs, **kwargs) 442 'You can build it manually via: ' 443 '`layer.build(batch_input_shape)`') --> 444 self.build(unpack_singleton(input_shapes)) 445 self.built = True 446 ~/ELD/lib/python3.6/site-packages/keras/layers/merge.py in build(self, input_shape) 360 'inputs with matching shapes ' 361 'except for the concat axis. ' --> 362 'Got inputs shapes: %s' % (input_shape)) 363 364 def _merge_function(self, inputs): ValueError: A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 112, 112, 256), (0, 112, 112, 256)]
cneud commented 2 years ago

Thanks for reporting. I just tried current master with the test image from the resources folder and it processes fine for me.

Could you let us know which exact version/commit of Eynollah you are working with (e.g. git show)? Would it be possible for you to share your own document image that fails?

Ashbajawed commented 2 years ago

by upgrading the python to 3.7 and reinstallations its working fine.. But its taking 1-2 minute on a single image inspite of using gpu, -light ardument and , -di argument

any way to improve Textregion detection and run graphics times Image was enhanced.
image

cneud commented 2 years ago

its taking 1-2 minute on a single image

Dear @Ashbajawed, these inference times look OK and similar to what is our current throughput.

Note that Eynollah uses multiple deep learning models in combination - for the processing of a single page, several of these will need to be loaded to memory, which takes considerable time.

We are working on a "batch" mode that will allow loading the models only once for the processing of a larger amount of pages within a directory, which will then significantly reduce the time needed to process multiple document images at once.