gmft.table_visualization module
- gmft.table_visualization.display_html_and_image(html_content, pil_image)
This is strictly for Jupyter notebooks. It displays the HTML content and the PIL image side by side.
- gmft.table_visualization.plot_interval_histogram(histogram, figsize=(12, 6), invert_x=False, dotted_line_at=1)
Plot an interval histogram showing frequency changes and optionally the original intervals.
- Args:
histogram: IntervalHistogram instance to plot show_intervals: If True, show the original intervals below the histogram figsize: Tuple of (width, height) for the figure
- Returns:
matplotlib figure object
- gmft.table_visualization.plot_results_orig(pil_img, results, id2label, filter=None)
Takes tensor input. results = {
“scores”: tensor([0.993, 0.927]), “labels”: tensor([0, 0]), “boxes”: tensor([[0.000, 0.000, 70.333, 20.333], # bounding boxes: xmin, ymin, xmax, ymax
[10.001, 0.001, 0.998, 0.998]]),
}
- gmft.table_visualization.plot_results_unwr(pil_img, confidence: List[float], labels: List[int], boxes: List[Tuple[float, float, float, float]], id2label: dict[int, str], filter: List[int] = None, figsize: Tuple[int, int] = (32, 20), padding: Tuple[int, int] | None = None, margin: Tuple[int, int] | None = None, linewidth: int = 3, show_labels: bool = True, return_img: bool = False)
Helper method to visualize the results of the table detection/format model.
- Parameters:
pil_img – PIL image
confidence – list of floats, confidence scores
labels – list of integers, class labels
boxes – list of lists, bounding boxes in the format [xmin, ymin, xmax, ymax]
id2label – dictionary, mapping class labels (int) to class names
filter – list of integers, class labels to selectively display
figsize – tuple, figure size. None for a smaller size
show_labels – boolean, whether to display the class labels
Example:
confidence = [0.993, 0.927] labels = [0, 0] # 0 is the table class boxes = [ [0.000, 0.000, 70.333, 20.333], # bounding boxes: xmin, ymin, xmax, ymax [10.001, 0.001, 0.998, 0.998] ]
- gmft.table_visualization.plot_shaded_boxes(pil_img, labels: list[int], boxes: list[tuple[float, float, float, float]], id2color: dict = None, filter=None, alpha=0.2, id2border: dict = None)
Helper method to visualize the results of the table detection/format model using PIL.
- Parameters:
pil_img – PIL image
labels – list of integers, class labels
boxes – list of tuples, bounding boxes in the format [xmin, ymin, xmax, ymax]
id2color – dictionary, mapping class labels (int) to desired color
filter – list of integers, class labels to selectively display
alpha – float, transparency for the box fill (0 to 1)