|
1 | 1 | --- |
2 | 2 | meta: |
3 | | - title: Processing Images and Getting Structured Outputs with Pixtral Vision Model |
| 3 | + title: Processing images and getting structured outputs with Pixtral vision model |
4 | 4 | description: Learn how to use Mistral's Pixtral vision model to automatically generate a product catalog from images. |
5 | 5 | content: |
6 | | - h1: Processing Images and Getting Structured Outputs with Pixtral Vision Model |
| 6 | + h1: Processing images and getting structured outputs with Pixtral vision model |
7 | 7 | paragraph: Discover how to leverage Mistral's Pixtral vision model to analyze images and generate comprehensive structured outputs. |
8 | 8 | tags: AI vision-model image-processing Pixtral Mistral structured-data |
9 | 9 | categories: |
@@ -52,7 +52,7 @@ Before we dive into using Pixtral, let's set up our Python environment and insta |
52 | 52 |
|
53 | 53 | ## Defining the data model |
54 | 54 |
|
55 | | -We'll start by defining our data model using Pydantic. This will ensure that our structured output has a consistent format and that all required fields are present. |
| 55 | +We'll start by defining our data model using `pydantic`. This will ensure that our structured output has a consistent format and that all required fields are present. |
56 | 56 |
|
57 | 57 | Create a new file called `models.py` and add the following code: |
58 | 58 |
|
@@ -126,7 +126,7 @@ def get_pixtral_client(): |
126 | 126 | return client |
127 | 127 | ``` |
128 | 128 |
|
129 | | -Make sure to set the `SCALEWAY_API_KEY` and `SCALEWAY_INFERENCE_ENDPOINT_URL` environment variables with your actual API key from Scaleway's IAM and the appropriate endpoint URL for Scaleway Managed Inference or Generative APIs service. |
| 129 | +Make sure to set the `SCALEWAY_API_KEY` and `SCALEWAY_INFERENCE_ENDPOINT_URL` environment variables with your actual API key from Scaleway IAM, and the appropriate endpoint URL for Scaleway Managed Inference or Generative APIs service. |
130 | 130 |
|
131 | 131 | ## Creating the image processor |
132 | 132 |
|
@@ -220,7 +220,7 @@ This script does the following: |
220 | 220 | 2. Defines a function to process images using the Pixtral model. |
221 | 221 | 3. Creates a prompt that instructs the model on how to analyze the images and what information to extract. |
222 | 222 | 4. Sends the images and prompt to the Pixtral model and receives the generated structured data. |
223 | | -5. Validates the received data against our Pydantic models. |
| 223 | +5. Validates the received data against our `pydantic` models. |
224 | 224 | 6. Saves the generated structured output to a JSON file. |
225 | 225 |
|
226 | 226 | ## Running the image processor |
|
0 commit comments