Extracting entities from images¶
Marvin can use OpenAI's vision API to process images and convert them into structured data, transforming unstructured information into native types that are appropriate for a variety of programmatic use cases.
marvin.beta.extract function is an enhanced version of
marvin.extract that accepts images as well as text.
Please note that vision support in Marvin is still in beta, as OpenAI has not finalized the vision API yet. While it works as expected, it is subject to change.
What it does
extract function can extract entities from images and text.
How it works
This involves a two-step process: first, a caption is generated for the image that is aligned with the structuring goal. Next, the actual extract operation is performed with an LLM.
Example: identifying dogs
We will extract the breed of each dog in this image:
You can pass parameters to the underlying API via the
vision_model_kwargs arguments of
extract. These parameters are passed directly to the respective APIs, so you can use any supported parameter.
If you are using Marvin in an async environment, you can use