Description
Object detection model trained to detect table cells one of the foremost architectures in the state-of-the-art, meticulously selected through benchmark evaluations and comparative analyses. Trained on an extensive and diverse dataset, this model has been finely tuned for precise table cell detection within documents. Its efficacy has been verified through rigorous testing, demonstrating exceptional performance in table cell detection across a spectrum of document formats.
Predicted Entities
Live Demo Open in Colab Copy S3 URI
How to use
binary_to_image = BinaryToImage()
img_to_hocr = ImageToHocr() \
.setInputCol("image") \
.setOutputCol("hocr") \
.setIgnoreResolution(False) \
.setOcrParams(["preserve_interword_spaces=0"])
cell_detector = ImageDocumentRegionDetector() \
.pretrained("region_cell_detection", "en", "clinical/ocr") \
.setInputCol("image") \
.setOutputCol("cells") \
.setScoreThreshold(0.8)
draw_regions = ImageDrawRegions() \
.setInputCol("image") \
.setInputRegionsCol("cells") \
.setOutputCol("image_with_regions") \
.setRectColor(Color.red)
hocr_to_table = HocrToTextTable() \
.setInputCol("hocr") \
.setRegionCol("table_regions") \
.setOutputCol("tables") \
.setUseCellsCol("cells")
pipeline = PipelineModel(stages=[
binary_to_image,
img_to_hocr,
cell_detector,
draw_regions,
hocr_to_table
])
imagePath = 'resources/ocr/table.jpg'
image_df = spark.read.format("binaryFile").load(imagePath).sort("path")
result = pipeline.transform(image_df)
val binary_to_image = BinaryToImage()
val img_to_hocr = ImageToHocr()
.setInputCol("image")
.setOutputCol("hocr")
.setIgnoreResolution(False)
.setOcrParams(Array("preserve_interword_spaces=0"))
val cell_detector = ImageDocumentRegionDetector()
.pretrained("region_cell_detection", "en", "clinical/ocr")
.setInputCol("image")
.setOutputCol("cells")
.setScoreThreshold(0.8)
val draw_regions = ImageDrawRegions()
.setInputCol("image")
.setInputRegionsCol("cells")
.setOutputCol("image_with_regions")
.setRectColor(Color.red)
val hocr_to_table = HocrToTextTable()
.setInputCol("hocr")
.setRegionCol("table_regions")
.setOutputCol("tables")
.setUseCellsCol("cells")
val pipeline = new PipelineModel().setStages(Array(
binary_to_image,
img_to_hocr,
cell_detector,
draw_regions,
hocr_to_table))
val imagePath = "resources/ocr/table.jpg"
val image_df = spark.read.format("binaryFile").load(imagePath).sort("path")
val result = pipeline.transform(image_df)
Example
Input:
Cell Detection:
Table Structure Recognition:
Model Information
Model Name: | region_cell_detection |
Type: | ocr |
Compatibility: | Visual NLP 5.1.2+ |
License: | Licensed |
Edition: | Official |
Language: | en |