Image

class py_doc.Image(name, bytes=None)[source]

A class for representing an image. Takes in a name and a image. If the image is not provided, the name is used to load the image.

Parameters:

name (str) – The name of the image.

draw_classifications(output_file=None)[source]

Draw the bounding boxes on the image. Contains the option to save the image to a file, otherwise it will just return the image.

Parameters:

file (str) – The output file to save the image to.

Returns:

If the file is provided, it will return a boolean based on the success, otherwise it will return the image.

Return type:

bool or numpy.ndarray

get_bboxes()[source]

Use an object detection model to get bounding boxes for titles, text, figures, lists, and tables in the image.

Returns:

A list of bounding boxes of the image.

Return type:

list

get_name()[source]

Get the name of the image.

Returns:

The name of the image.

Return type:

str

get_text()[source]

Get the text from the image.

Returns:

The text from the image.

Return type:

str

get_text_from_bbox(bbox)[source]

Get the text from the bounding box.

Parameters:

bbox (list with 4 elements [x1, y1, x2, y2]) – The bounding box to get the text from.

Returns:

The text from the bounding box.

Return type:

str