Model Pipeline - Table extraction from images
This pipeline extracts tables from images by detecting table regions, recognizing lines and cells, and then converting them into structured data like CSV or JSON.
Jump into concepts and practice - no test required
This pipeline extracts tables from images by detecting table regions, recognizing lines and cells, and then converting them into structured data like CSV or JSON.
Loss
1.2 |*
0.8 | **
0.5 | ***
0.3 | ****
0.2 | *****
----------------
1 3 5 7 10 Epochs
| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 1.2 | 0.45 | Initial training with high loss and low accuracy on table detection |
| 3 | 0.8 | 0.65 | Model starts to detect tables more accurately |
| 5 | 0.5 | 0.80 | Improved detection and segmentation of table cells |
| 7 | 0.3 | 0.90 | High accuracy in detecting tables and segmenting cells |
| 10 | 0.2 | 0.94 | Model converged with low loss and high accuracy |
table extraction from images in computer vision?cells_text?
import cv2
import pytesseract
image = cv2.imread('table.png', 0)
_, thresh = cv2.threshold(image, 128, 255, cv2.THRESH_BINARY_INV)
contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cells_text = []
for cnt in contours:
x, y, w, h = cv2.boundingRect(cnt)
cell_img = image[y:y+h, x:x+w]
text = pytesseract.image_to_string(cell_img, config='--psm 6')
cells_text.append(text.strip())
print(type(cells_text))cells_text is initialized as an empty list and text from each detected cell is appended to it.cells_textcells_text collects multiple strings in a list, its type remains list.