Image

gllm-docproc | Tutorial: Image Loader | Use Case: Advanced DPO Pipeline | API Reference

Image Loader is a component designed for extracting information from a standalone image file and converting it into a standardized JSON format.

Prerequisites

This example specifically requires completion of all setup steps listed on the Prerequisites page.

Installation

# you can use a Conda environment
pip install --extra-index-url https://oauth2accesstoken:$(gcloud auth print-access-token)@glsdk.gdplabs.id/gen-ai-internal/simple/ "gllm-docproc[image]"

You can use the following as a sample file: image-example.png.

Image Loader

ImageLoader is responsible to extract information from a standalone image. It uses magic to validate the file and base64 to encode it into a Base64 string.

1

Create a script called main.py:

from gllm_docproc.loader.image import ImageLoader

source = "./data/source/image-example.png"

# initialize the ImageLoader
loader = ImageLoader()

# load the image source
loaded_elements = loader.load(source)
2

Run the script:

python main.py
3

The loader will generate the following: output JSON.

Last updated