{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Copyright 2025 Google LLC\n",
        "#\n",
        "# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
        "# you may not use this file except in compliance with the License.\n",
        "# You may obtain a copy of the License at\n",
        "#\n",
        "#     https://www.apache.org/licenses/LICENSE-2.0\n",
        "#\n",
        "# Unless required by applicable law or agreed to in writing, software\n",
        "# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
        "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
        "# See the License for the specific language governing permissions and\n",
        "# limitations under the License."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "YOrUAvz6DMw-"
      },
      "source": [
        "# BigFrames Multimodal DataFrame\n",
        "\n",
        "<table align=\"left\">\n",
        "\n",
        "  <td>\n",
        "    <a href=\"https://colab.research.google.com/github/googleapis/python-bigquery-dataframes/blob/main/notebooks/multimodal/multimodal_dataframe.ipynb\">\n",
        "      <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/colab-logo.png\" alt=\"Colab logo\"> Run in Colab\n",
        "    </a>\n",
        "  </td>\n",
        "  <td>\n",
        "    <a href=\"https://github.com/googleapis/python-bigquery-dataframes/blob/main/notebooks/multimodal/multimodal_dataframe.ipynb\">\n",
        "      <img src=\"https://raw.githubusercontent.com/googleapis/python-bigquery-dataframes/refs/heads/main/third_party/logo/github-logo.png\" width=\"32\" alt=\"GitHub logo\">\n",
        "      View on GitHub\n",
        "    </a>\n",
        "  </td>\n",
        "  <td>\n",
        "    <a href=\"https://console.cloud.google.com/bigquery/import?url=https://github.com/googleapis/python-bigquery-dataframes/blob/main/notebooks/multimodal/multimodal_dataframe.ipynb\">\n",
        "      <img src=\"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTW1gvOovVlbZAIZylUtf5Iu8-693qS1w5NJw&s\" alt=\"BQ logo\" width=\"35\">\n",
        "      Open in BQ Studio\n",
        "    </a>\n",
        "  </td>\n",
        "</table>\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "This notebook is introducing BigFrames Multimodal features:\n",
        "1. Create Multimodal DataFrame\n",
        "2. Combine unstructured data with structured data\n",
        "3. Conduct image transformations\n",
        "4. Use LLM models to ask questions and generate embeddings on images\n",
        "5. PDF chunking function\n",
        "6. Transcribe audio"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "PEAJQQ6AFg-n"
      },
      "source": [
        "### Setup"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Install the latest bigframes package if bigframes version < 2.4.0"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {},
      "outputs": [],
      "source": [
        "# !pip install bigframes --upgrade"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 3,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "bGyhLnfEeB0X",
        "outputId": "83ac8b64-3f44-4d43-d089-28a5026cbb42"
      },
      "outputs": [],
      "source": [
        "PROJECT = \"bigframes-dev\" # replace with your project. \n",
        "# Refer to https://cloud.google.com/bigquery/docs/multimodal-data-dataframes-tutorial#required_roles for your required permissions\n",
        "\n",
        "OUTPUT_BUCKET = \"bigframes_blob_test\" # replace with your GCS bucket. \n",
        "# The connection (or bigframes-default-connection of the project) must have read/write permission to the bucket. \n",
        "# Refer to https://cloud.google.com/bigquery/docs/multimodal-data-dataframes-tutorial#grant-permissions for setting up connection service account permissions.\n",
        "# In this Notebook it uses bigframes-default-connection by default. You can also bring in your own connections in each method.\n",
        "\n",
        "import bigframes\n",
        "# Setup project\n",
        "bigframes.options.bigquery.project = PROJECT\n",
        "\n",
        "# Display options\n",
        "bigframes.options.display.blob_display_width = 300\n",
        "bigframes.options.display.progress_bar = None\n",
        "\n",
        "import bigframes.pandas as bpd"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ifKOq7VZGtZy"
      },
      "source": [
        "### 1. Create Multimodal DataFrame\n",
        "There are several ways to create Multimodal DataFrame. The easiest way is from the wildcard paths."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "fx6YcZJbeYru",
        "outputId": "d707954a-0dd0-4c50-b7bf-36b140cf76cf"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/global_session.py:113: DefaultLocationWarning: No explicit location is set, so using location US for the session.\n",
            "  _global_session = bigframes.session.connect(\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        }
      ],
      "source": [
        "# Create blob columns from wildcard path.\n",
        "df_image = bpd.from_glob_path(\n",
        "    \"gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/images/*\", name=\"image\"\n",
        ")\n",
        "# Other ways are: from string uri column\n",
        "# df = bpd.DataFrame({\"uri\": [\"gs://<my_bucket>/<my_file_0>\", \"gs://<my_bucket>/<my_file_1>\"]})\n",
        "# df[\"blob_col\"] = df[\"uri\"].str.to_blob()\n",
        "\n",
        "# From an existing object table\n",
        "# df = bpd.read_gbq_object_table(\"<my_object_table>\", name=\"blob_col\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 487
        },
        "id": "HhCb8jRsLe9B",
        "outputId": "03081cf9-3a22-42c9-b38f-649f592fdada"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>image</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fk9-guard-dog-paw-balm.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T175044Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492703986347&X-Goog-Signature=7044b84dabc93450c25c1ac9819a9adb9c29a6a4d1755e61179efcf86a7c994f3a046f129671a0e1a208a58ae1e2b19814f976babdb771fa617c0e3e3f3c8484353782500dcdeee346db5288e47c8b3130711c2980aae2eed2ef43f905209b124b4b52bf51ba10f4ee59cbd666b1b18ad740b2fab23ef9a4d3dc8ebb188eb60875d81c9826e2f2b45f85999eccbd9fc174ffc32c769ecb8dd2b2e93d7a4fc37db76bf6370c07cb1a7765622c4feab230c6fead56117e87cd20b01f778e764500e5ebf6eef0fe0b9742cf31d96d583244cbcac07f3dac9fc441987d4f24a979c2a9bd6086ea225050d1dd29abe70aa8e05358ffd6f98fdd0b725db4bb42290660\" width=\"300\"></td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fk9-guard-dog-hot-spot-spray.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T175044Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492702954473&X-Goog-Signature=66562fd0a307d1ca5558a37ee81ab137f538c30a19fbd0400567134b628732ad934f77dab2a706cbc67b8e53dfe08340aa5c71313d8f41d8272a13b41603efb76650d1a5a53da51660e1736f3b314539d1cfc0e6656b69f37fff2077fc30b7eb90abb4247a9d0503c8c24a4c0f5a854cc4076a07258e1abbf3fe2b296b7cec3687e3958e8c120a9b9332a0359d10370663de3f5c7c019b6e5941cc2bd5df13e7fb78ae37518be8e0f55943f0a5a35b10046e158efa518d1be6afad3145036be19d4a319b3a9978a898673cfe67a840185eda00705b90ab1ad20650576b73a342fb60efc2616115845c7d51a3f8ee949a95befe5aea59659a4fc42fcf5ed0611d\" width=\"300\"></td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Ffluffy-buns-chinchilla-food-variety-pack.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T175044Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492694988945&X-Goog-Signature=d97daeffa46f0152ac94ae0a472c0f490e147c94d66c0cd547f8eaf8a71e5d55725780888570cb146222ff7c59672f47970429da2ab4343fdb1381e6dd6a0f3bff6aa9fc7c1dc49724c8cf6b91aeb3ee0bba3adf34079344c039278bcd8d23639724101efd60927f62e36a073436d62dd7fb8faf5977bd462694d761a4bb36ef730bbceb1f8ce6f910fd0d2ed1b54784ff0bff9d91440f969cf12002b2d0bdbbdddde28d5bd32add32ffabf4e7fce7c660824fb69ce256007a5f4cf6511152baa13ac7d612b87a2c4204074fd1d44942de61ba0b923677623e0025796a28a4b05bae0a3c44cce6483d8c5710a6078b19ef8ba0c653316877be5d237f00bf5c67\" width=\"300\"></td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fpurrfect-perch-cat-scratcher.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T175044Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492719670724&X-Goog-Signature=1aaff4ad1cf107a4059a99447865495fa56420c0d2acf6c51d168a3667ccdc519c0ece1beea23643e6a762e9e3a47534c23cf71e5b03d7a8e815f73b8950eadc737a27762c37a315a529ea428df35d540764efec5e4494a16e0dcd0511fdb6886e535e09176f09de2d5e479a14c9530b03e57fb23ebb70444976aeaca1586896a4b87a7ff071ba7dc68fb33c33d4330bf93d619493a0edafa13409257eef5f9976509c56d904f03b0bb96ea4835c03e926f469f1b6a13ed359e27775d3784867e46d1498f38d9c1fa9f4b4d90c50a3feb2bf92fd1b2df1eeb1f781a36d1114ca805dcb2b55b07ea1241bf0b758f6e962a4739aceb6788b116c4a906a39aa8a20\" width=\"300\"></td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fchirpy-seed-deluxe-bird-food.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T175044Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492687196980&X-Goog-Signature=35c9bd5e6b4aace37f1f7794d970f78df785256bc251634cff78ca1d1712a907039b469a95cef7c211e753319e2add2bf5bc0340b3a9b92087bd95888b0a915e2358bcd49f3993692bec18cbfaa288aef8cfa0e07b967199c8cef9f5ea3dffd4aee43545e9d7508ae6998b5f707d3410cd2a676f4be0fdb9644b0229569ff02a7f457e045363511465cf63b5afb096052b54ce6e8efa819042cbd8879aac35c81bbb9f638996f2d5f7b3dbdb254ae9f9c08887d830c2d887d5842144f3531672daf741712aebf6c5e9bc024f6688abee3e651accf4996b9eef9d83504f93225079cf02735d1abb254cdcd758e6dbbdea86ff540eb3544d57ed0bc5d6fd7d2f8c\" width=\"300\"></td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>5 rows × 1 columns</p>\n",
              "</div>[5 rows x 1 columns in total]"
            ],
            "text/plain": [
              "                                               image\n",
              "0  {'uri': 'gs://cloud-samples-data/bigquery/tuto...\n",
              "1  {'uri': 'gs://cloud-samples-data/bigquery/tuto...\n",
              "2  {'uri': 'gs://cloud-samples-data/bigquery/tuto...\n",
              "3  {'uri': 'gs://cloud-samples-data/bigquery/tuto...\n",
              "4  {'uri': 'gs://cloud-samples-data/bigquery/tuto...\n",
              "\n",
              "[5 rows x 1 columns]"
            ]
          },
          "execution_count": 5,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "# Take only the 5 images to deal with. Preview the content of the Mutimodal DataFrame\n",
        "df_image = df_image.head(5)\n",
        "df_image"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "b6RRZb3qPi_T"
      },
      "source": [
        "### 2. Combine unstructured data with structured data"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4YJCdmLtR-qu"
      },
      "source": [
        "Now you can put more information into the table to describe the files. Such as author info from inputs, or other metadata from the gcs object itself."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "metadata": {
        "id": "YYYVn7NDH0Me"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:121: UserWarning: The `json_extract` is deprecated and will be removed in a future\n",
            "version. Use `json_query` instead.\n",
            "  warnings.warn(bfe.format_message(msg), category=UserWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:121: UserWarning: The `json_extract` is deprecated and will be removed in a future\n",
            "version. Use `json_query` instead.\n",
            "  warnings.warn(bfe.format_message(msg), category=UserWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:121: UserWarning: The `json_extract` is deprecated and will be removed in a future\n",
            "version. Use `json_query` instead.\n",
            "  warnings.warn(bfe.format_message(msg), category=UserWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>image</th>\n",
              "      <th>author</th>\n",
              "      <th>content_type</th>\n",
              "      <th>size</th>\n",
              "      <th>updated</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fk9-guard-dog-paw-balm.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T175114Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492703986347&X-Goog-Signature=1e94cd84478ac149a6f7e4cedde439f6c11c12c8d9562669350ccadc0f12ade625f9477eac197c868dcc794b60fffb72eac9293dabdb447e03ef91c421b96141d8954121aed914edf01de7f3dca78602f423782ee6d00245d240518a26010ae2150bcf8598da9fa0fa9260ad18f4323153cee46e29dab1af67fb34e5ebb44c4f581022505ea0d147e78e00a03f9816421012aa4385388c792317ad5dcdee11134e7dbe28f08cd0b0900e7dbfe75d255e7387cebe5f67e4c9efd3077d518e157b4ac506786cb2f02bdc51db75a0f4b3503929abc3a8c92da797f2c769e86a5306671037d9fdc5ec373720838ff3728b42dacc9902ae9903bb9dba313913e82610\" width=\"300\"></td>\n",
              "      <td>alice</td>\n",
              "      <td>image/png</td>\n",
              "      <td>1591240</td>\n",
              "      <td>2025-03-20 17:45:04+00:00</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fk9-guard-dog-hot-spot-spray.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T175114Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492702954473&X-Goog-Signature=359d4be8b70a3b32496f6143fa0a72711df0d054a59a19cd0f78c78a1f9561445738a9bbd696fb6f82826278f96541199c2375284712f87f12c686e34f854a72346fd79868a71aaba4c08956fa98169a9d2f6d2d98676c4397865761ae6f3828c38cbb8ebfdae0c51acbef1cb82a8c7c29e142bcb6b047952deea349904b5cee583e0b5b800274ca61f78b0cf719a4f3e1ac5d8d429b27a393c70921e2d8e16f454d58e1e86bf57ac3a3e7bed7d572571c82e9fc10320bae7930f209c03cdb683a42342e042adb230da457ac32b1b8450a948ae5427a699088e095c0f3357a4e22ff962e6610e29583bf9d55781f4e1a62a264888d80a922352a5eed959bfe22\" width=\"300\"></td>\n",
              "      <td>bob</td>\n",
              "      <td>image/png</td>\n",
              "      <td>1182951</td>\n",
              "      <td>2025-03-20 17:45:02+00:00</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Ffluffy-buns-chinchilla-food-variety-pack.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T175114Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492694988945&X-Goog-Signature=e133a64a0502c08f151ba44738dbb46ac86ad0fd3b5c11007ac9b6a0996bed9931320b6fe4576ec2c9663eacceddcef8067a6d39e55d6ff0f97f7727e83663161c48038c2a3d51c257d543780563d961f43fefc15d971fc83a77ccf90546eb77d10de00b8d564212da5bb1ee46e93b1ecb9f307e20bb713781f6340afd7ed278b4ea40cc24add1266f907fd244d840f957e6b87f9b14a19d08a1c41c7226f234c5faa4c34ca38e45de9dc423f57a039cbf54e057583aba0bab6b7bd88e8e8e04b73c45f15669fc25b3cdeb2efd122d2b573cef1b482ab9e421a510e1283f2f6b97cda6d3c155c25d2c2c279de41f70872cd45955bc1ba2e84f07491c6fd3cfff\" width=\"300\"></td>\n",
              "      <td>bob</td>\n",
              "      <td>image/png</td>\n",
              "      <td>1520884</td>\n",
              "      <td>2025-03-20 17:44:55+00:00</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fpurrfect-perch-cat-scratcher.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T175114Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492719670724&X-Goog-Signature=54ccb2dfa1a7583be26d1df7b72366f10fc81ee66f216da1bd250967ec56f8c5c346ff8427fa49c29de13641b228d3681cac4a1cd1d7103854d9c0139d8403147b65e1e848cdf1fb805d1b2d70dd5da0f1deab04ebbc7f656cb0cadcfa3d44bc5238230b1e69d4f34de105b4fbd57cad16ae0dd50f3f441bbc321697b0a8126ffe63489f4654c6d968e7af4e324afd441d7d12de2589c5eee636bee88f3efb9974cf7d1d1c7363127ffbefd7f036b67dc86cf645f1237be3a36e391cb92d6ce60fa3ef32b3d5ca9f277a815829006a4896c9c8e07c3dd81125ae6fd90afb8a1a9cb6239d6c1903340ff9dc54d6c8f467b04cc2ca899fa203959c1349c7b157aa\" width=\"300\"></td>\n",
              "      <td>alice</td>\n",
              "      <td>image/png</td>\n",
              "      <td>1235401</td>\n",
              "      <td>2025-03-20 17:45:19+00:00</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fchirpy-seed-deluxe-bird-food.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T175114Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492687196980&X-Goog-Signature=078c407a7483af4bfcdb06a8513a9dd86ff38b0ba3eccbb7a9399d24bc8b46994ac3b3c65114154d1aebbc4505a369cc7024dc1bc9623f99d02024ceee3c3a2a8d06acd604167988cfdde153bacd72f673215b04067ba3a020e0d26424e07d6b9214a4b0ab28405b6bf9421f746cebee36a9cf5a6d48f44941d4958c6f98aab7441099821850f4a0c5720414160315b7a89f0b8cb89a30b746df69a287cc3134e6463cdc7a2143af8d098794e1acfa2b82b0e4723be1198e228badcdb511bcfd5ef87a450fc964f671670f943da274bb5b68e9851d0ca5f13081bfed6a1a506fd12f4a2ebb292a370932cfa9ba900aa125ef8caec03ed21b58d0cc21be7fa7e4\" width=\"300\"></td>\n",
              "      <td>bob</td>\n",
              "      <td>image/png</td>\n",
              "      <td>1591923</td>\n",
              "      <td>2025-03-20 17:44:47+00:00</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>5 rows × 5 columns</p>\n",
              "</div>[5 rows x 5 columns in total]"
            ],
            "text/plain": [
              "                                               image author content_type  \\\n",
              "0  {'uri': 'gs://cloud-samples-data/bigquery/tuto...  alice    image/png   \n",
              "1  {'uri': 'gs://cloud-samples-data/bigquery/tuto...    bob    image/png   \n",
              "2  {'uri': 'gs://cloud-samples-data/bigquery/tuto...    bob    image/png   \n",
              "3  {'uri': 'gs://cloud-samples-data/bigquery/tuto...  alice    image/png   \n",
              "4  {'uri': 'gs://cloud-samples-data/bigquery/tuto...    bob    image/png   \n",
              "\n",
              "      size                    updated  \n",
              "0  1591240  2025-03-20 17:45:04+00:00  \n",
              "1  1182951  2025-03-20 17:45:02+00:00  \n",
              "2  1520884  2025-03-20 17:44:55+00:00  \n",
              "3  1235401  2025-03-20 17:45:19+00:00  \n",
              "4  1591923  2025-03-20 17:44:47+00:00  \n",
              "\n",
              "[5 rows x 5 columns]"
            ]
          },
          "execution_count": 6,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "# Combine unstructured data with structured data\n",
        "df_image[\"author\"] = [\"alice\", \"bob\", \"bob\", \"alice\", \"bob\"]  # type: ignore\n",
        "df_image[\"content_type\"] = df_image[\"image\"].blob.content_type()\n",
        "df_image[\"size\"] = df_image[\"image\"].blob.size()\n",
        "df_image[\"updated\"] = df_image[\"image\"].blob.updated()\n",
        "df_image"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "NUd4Kog_QLRS"
      },
      "source": [
        "Then you can filter the rows based on the structured data. And for different content types, you can display them respectively or together."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 7,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 75
        },
        "id": "UGuAk9PNDRF3",
        "outputId": "73feb33d-4a05-48fb-96e5-3c48c2a456f3"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:121: UserWarning: The `json_extract` is deprecated and will be removed in a future\n",
            "version. Use `json_query` instead.\n",
            "  warnings.warn(bfe.format_message(msg), category=UserWarning)\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "<img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fk9-guard-dog-paw-balm.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T175128Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&X-Goog-Signature=a8770138ffd6cb4877fc5b3e49d1e304a7d9a58b4b54ccdfb928705d46741f3fa11da97f35438f5a3c35f2b30f73ed68b86eabe08e752e20c588b3e405b623f714054e2c84722e1e23707c9b4c4e5b91558975a97658c2455aef326c8b521ebaacbd43a18bb5ff5942219ccf2563bb6df3b5a409a8128daf2312b2a6bda587841415f7463bca65c41ebf958a19f13037dde375e6b9629ac014d0e7c18feb4f60e409b66aea22b0770bd6f1eef093110ba2a75e5c0077f430024c6f6f2555116d2372173606dab337baac62ad367085db6ea29e4226be99b1c6934267188f5f00474e133953c2eb3b271bc793c5277c4a8bdc2106566f42f382c172641197ff7c\" width=\"300\"/>"
            ],
            "text/plain": [
              "<IPython.core.display.Image object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        },
        {
          "data": {
            "text/html": [
              "<img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fpurrfect-perch-cat-scratcher.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T175128Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&X-Goog-Signature=1cbe97848ca86cfda2e7e697e6f509194b04e79b3c842648ce7d84b4feb31228c5f09f49a409b23f208de388cd5603d30ca934054b3e62c03264ae8945596c23d672cd36e6148b2e0b782ee7614a9b81312708f16244ada0a2393c2d7fde773837d1058a20adb0c562ff0219ae18669b3b05e30333d46c90c4bc9ad03e97fae52447c09bf557fad26391858c0e5eb9379c9efb403905daa46553adab7f82ca69e8dd6c33da8dcfd94e78b345f928298d1734fff7d7bc57f5da0dc05f301feec01d1e706cfefe1d2424e8b5e30ee79394c6d7e6144b7d47234d57888168bff0a1abb99687fb04a5c6e3df079767cdd4a0a5e8ac237bdfadf80ca94cfc1ca60671\" width=\"300\"/>"
            ],
            "text/plain": [
              "<IPython.core.display.Image object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "# filter images and display, you can also display audio and video types\n",
        "df_image[df_image[\"author\"] == \"alice\"][\"image\"].blob.display()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "1IJuakwJTZey"
      },
      "source": [
        "### 3. Conduct image transformations\n",
        "BigFrames Multimodal DataFrame provides image(and other) transformation functions. Such as image_blur, image_resize and image_normalize. The output can be saved to GCS folders or to BQ as bytes."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 8,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "VWsl5BBPJ6N7",
        "outputId": "45d2356e-322b-4982-cfa7-42d034dc4344"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/log_adapter.py:182: FunctionAxisOnePreviewWarning: Blob Functions use bigframes DataFrame Managed function with axis=1 senario, which is a preview feature.\n",
            "  return method(*args, **kwargs)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/log_adapter.py:182: FunctionAxisOnePreviewWarning: Blob Functions use bigframes DataFrame Managed function with axis=1 senario, which is a preview feature.\n",
            "  return method(*args, **kwargs)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/log_adapter.py:182: FunctionAxisOnePreviewWarning: Blob Functions use bigframes DataFrame Managed function with axis=1 senario, which is a preview feature.\n",
            "  return method(*args, **kwargs)\n"
          ]
        }
      ],
      "source": [
        "df_image[\"blurred\"] = df_image[\"image\"].blob.image_blur(\n",
        "    (20, 20), dst=f\"gs://{OUTPUT_BUCKET}/image_blur_transformed/\", engine=\"opencv\"\n",
        ")\n",
        "df_image[\"resized\"] = df_image[\"image\"].blob.image_resize(\n",
        "    (300, 200), dst=f\"gs://{OUTPUT_BUCKET}/image_resize_transformed/\", engine=\"opencv\"\n",
        ")\n",
        "df_image[\"normalized\"] = df_image[\"image\"].blob.image_normalize(\n",
        "    alpha=50.0,\n",
        "    beta=150.0,\n",
        "    norm_type=\"minmax\",\n",
        "    dst=f\"gs://{OUTPUT_BUCKET}/image_normalize_transformed/\",\n",
        "    engine=\"opencv\",\n",
        ")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 9,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "rWCAGC8w64vU",
        "outputId": "d7d456f0-8b56-492c-fe1b-967e9664d813"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/log_adapter.py:182: FunctionAxisOnePreviewWarning: Blob Functions use bigframes DataFrame Managed function with axis=1 senario, which is a preview feature.\n",
            "  return method(*args, **kwargs)\n"
          ]
        }
      ],
      "source": [
        "# You can also chain functions together\n",
        "df_image[\"blur_resized\"] = df_image[\"blurred\"].blob.image_resize((300, 200), dst=f\"gs://{OUTPUT_BUCKET}/image_blur_resize_transformed/\", engine=\"opencv\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Using `verbose` mode for detailed output\\n\n",
        "\\n\n",
        "All multimodal functions support a `verbose` parameter, which defaults to `False`.\\n\n",
        "\\n\n",
        "*   When `verbose=False` (the default), the function will only return the main content of the result (e.g., the transformed image, the extracted text).\\n\n",
        "*   When `verbose=True`, the function returns a `STRUCT` containing two fields:\\n\n",
        "    *   `content`: The main result of the operation.\\n\n",
        "    *   `status`: An informational field. If the operation is successful, this will be empty. If an error occurs during the processing of a specific row, this field will contain the error message, allowing the overall job to complete without failing.\\n\n",
        "\\n\n",
        "Using `verbose=True` is highly recommended for debugging and for workflows where you need to handle potential failures on a row-by-row basis. Let's see it in action with the `image_blur` function."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 10,
      "metadata": {},
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/log_adapter.py:182: FunctionAxisOnePreviewWarning: Blob Functions use bigframes DataFrame Managed function with axis=1 senario, which is a preview feature.\n",
            "  return method(*args, **kwargs)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>blurred_verbose</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>{'status': '', 'content': {'uri': 'gs://bigfra...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>{'status': '', 'content': {'uri': 'gs://bigfra...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>{'status': '', 'content': {'uri': 'gs://bigfra...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>{'status': '', 'content': {'uri': 'gs://bigfra...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>{'status': '', 'content': {'uri': 'gs://bigfra...</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>5 rows × 1 columns</p>\n",
              "</div>[5 rows x 1 columns in total]"
            ],
            "text/plain": [
              "                                     blurred_verbose\n",
              "0  {'status': '', 'content': {'uri': 'gs://bigfra...\n",
              "1  {'status': '', 'content': {'uri': 'gs://bigfra...\n",
              "2  {'status': '', 'content': {'uri': 'gs://bigfra...\n",
              "3  {'status': '', 'content': {'uri': 'gs://bigfra...\n",
              "4  {'status': '', 'content': {'uri': 'gs://bigfra...\n",
              "\n",
              "[5 rows x 1 columns]"
            ]
          },
          "execution_count": 10,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "df_image[\"blurred_verbose\"] = df_image[\"image\"].blob.image_blur(\n",
        "    (20, 20), dst=f\"gs://{OUTPUT_BUCKET}/image_blur_transformed_verbose/\", engine=\"opencv\", verbose=True\n",
        ")\n",
        "df_image[[\"blurred_verbose\"]]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 11,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 605
        },
        "id": "6NGK6GYSU44B",
        "outputId": "859101c1-2ee4-4f9a-e250-e8947127420a"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>image</th>\n",
              "      <th>author</th>\n",
              "      <th>content_type</th>\n",
              "      <th>size</th>\n",
              "      <th>updated</th>\n",
              "      <th>blurred</th>\n",
              "      <th>resized</th>\n",
              "      <th>normalized</th>\n",
              "      <th>blur_resized</th>\n",
              "      <th>blurred_verbose</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fk9-guard-dog-paw-balm.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492703986347&X-Goog-Signature=621df5d63be748ee0e58eea62522e0ed89858a31556c380ab74192cf51c1ab00d1fd0f93b74006c25b23e346b4712c7ceb2b8c220c0b5dc0d47b703116967d2077c6c7bbc27af0077bc4e5192da2e362f0075fa2f37bad70eb697e63044544be51e2c7f621ebf482644d84f55f22b68d9c09bfb633bd0044168dcd90337ca72013392b0093a71fb5f0322ee2248161e925b6a7c48b59fb07f386a9aeb734b0d9c1d79f4829511fc28165ab7d00ec1f804a54e23df233251cb47e98e67e2e0a95e23e833ad8d221ea7c63933c86a6ad7931a0440926a3a5870a447b357fa1e41c6fdf7f84bd00180a38fefcc324f4083e6a6ed3fdfc0b03e726303bdc04a78841\" width=\"300\"></td>\n",
              "      <td>alice</td>\n",
              "      <td>image/png</td>\n",
              "      <td>1591240</td>\n",
              "      <td>2025-03-20 17:45:04+00:00</td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_blur_transformed%2Fk9-guard-dog-paw-balm.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761328612470468&X-Goog-Signature=ac5308c2523c6711c6104ad41f3c1a87dfb20c7e2d5a7a9bd6c82eb594437c887e23ee56aebdeadfde462145170f3455288057d77347122d53b877c4eff190da810c75ee344c69b3417a2f0873d880bf7720966955caba1e898d4318284f434640501003f6714a110094d1f90d8d17ca7abeda5d0124f9d000cb7c78b755674d5b495103ce107c785b3fc16f273bb23cf1692ca5e9d9d30ddd74981afcfeb66ef1b7dafe8d0e59099fff254d5b85f18d1969dbdb6c2722b21e2641cbfcdf6f5ed7223e160e3bb25245356e5c3acdee41da18665515c9f67424c4572ec28ac08d03eef179e218a71e5fd68f07423c7167b1059eb64747591b9c0b948bf975f562\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_resize_transformed%2Fk9-guard-dog-paw-balm.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761328973833395&X-Goog-Signature=83d191a3bb9f9f062caa2d3b0752460c995886763b0130b4d999b4c5a6ce26ee9246c091ae84e9d1ca17f95db7c229dc4276fa0565f91e4f648b954a35490d874a357e6cc81f79b511ceb4f522a8c7400312f98c2fbc79bb7be22f4f3ddc2aff2a245821f6e3801f7c5e0c84813e18223ae6953fd44cbd8b0ed1a9e86b55b42f12deb508353b81a4f1a2e116174d78694e62c3f67938b9575a3c06f2a51c53d1e094a24155396c97747c3de57d6aaa64ffe9b82d43124453a4e8481f092a480812067452c13a4470b1c7c2a4c5a52e5ae1377001de0815a6835e90758939f84ae8794033a74c011fcf71b575646af0e980fa1e6794eab6fa9b08170b8fdea947\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_normalize_transformed%2Fk9-guard-dog-paw-balm.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761329287395434&X-Goog-Signature=c7ede0f35e2ee836e43bb32567f20bec9a8137a38403ec0fb96ff23ab7e34cc12e2ab5d06b8e1fba3c2448a35e74f7626ed8e74f11da182f1a39b2930f551f43f1566e0e204c8862c205abfe750df8609ba28d1761f2e89d177b197d58a2b2fbc72fa5f21bf837623adf40e66df1e646cfcd9836418124ca87cb0e193ae1afb6115574123163b6a7dbd468352fe53e68a93a0e962e0df58347a1a6551e7c434db637c2bb28f086d9ed6431d4c4edf31c56960074aaa1bf7aa93a4f0a76f293bc71fdda502636100bd09047d507bf3b7ea6271b80ab34a1d076f404368e5fe108b14e07f3cb2cf5f202b22cc7bbc335795a91b6693b920d87fc2a40fd54b80457\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_blur_resize_transformed%2Fk9-guard-dog-paw-balm.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761329599245353&X-Goog-Signature=1ef8f11607f42950058b8acb2f3b9af05f7cbd3e16c311f5649d05a7e3a2226189aed3274950e42eec2e832b574225ef8d0ee0a05ebd1b265c45dcccd2c88ee2dfc4086b4c2967e257d407751bd9e87f9447c75facf703510b3a4218f4a086d2551550fa85271268e49c90b6d8af946b74de8034d25e690cfaa50518ac955fd7cb1c196014947f361b496e5e5cac2bd2eeb617e93987238e05aefe0bcf81a9015c5a9fa6821dc8432ae14a24045eb58d55ea43a7ed5275d74838ca8c008eee3c62ec333357a7871ea4d305cb572645f667e641e28db5564c7529d8341ac91ea2f7704f9fb5d3fab2047ab1ca85a79241ac0ae3bd3378af6c054192c001d561aa\" width=\"300\"></td>\n",
              "      <td>{'status': '', 'content': {'uri': 'gs://bigframes_blob_test/image_blur_transformed_verbose/k9-guard-dog-paw-balm.png', 'version': None, 'authorizer': 'bigframes-dev.us.bigframes-default-connection', 'details': None}}</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fk9-guard-dog-hot-spot-spray.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492702954473&X-Goog-Signature=9ace4dd33a4cf252509332d5b8bbb0a0d34b1ab347e0e0dfcd6e4f453282586ef22e3abb535b200ffa7ae069f2dcc261b8d7fe92c1aa26245c59e38b422d3746ad492714fe7ca334c4dc85ba6c41e758ae0e4ebc546e6900a09074b81ee3a2b41955b7722addf60affa91a79a4c5c050ab72e33f57317d372bd1d3d9743978afe5f8c9cab26bb699c1e51440c63409938f83b96e349e47662ec8a946d255f11785407b09277b2d160c2dc03f5e758d04fdf50f3377544a5e2db05d09dc24cbe833a067cd68d4122aa8fbbe44c0c36b964739c6b38f376ec8146d180351e325829c536fb6f564e39c57e0cf9fe5f6162a9e77125976a8890de2fc11ac7b6c35f3\" width=\"300\"></td>\n",
              "      <td>bob</td>\n",
              "      <td>image/png</td>\n",
              "      <td>1182951</td>\n",
              "      <td>2025-03-20 17:45:02+00:00</td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_blur_transformed%2Fk9-guard-dog-hot-spot-spray.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761328612546638&X-Goog-Signature=8c08f8aab826067289a0ecbee6d28db95f91be43239c7f21cc7b9287f6791faca56697bab765947c2c113463684778739a917677e9f5c2d12e2c20f5e704de33969c346982992cd3323d7847bdba29d430cd5de894000c175538fa796c003ea4f16ead597d468e0c55ed378854ad8c489e9be8b1c68160ae4c763ebf9f1e5302da8c4dc0349fe16b4c5c09f0c68361ccc1d1c4c181d25ac391ef36e8283552a6f23df47ff8f7659908d7e0609b1e33657077262e1df9f3300138221aa1e871b3b2dff75dcdd2115c5a6e1c745da6dfb70e15856b4bb68606f5ccad76c0f306a4952af4a3fcceab6a3196188c3494d19c2a6dcd93db61e45a86a2b83c0b409fb3\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_resize_transformed%2Fk9-guard-dog-hot-spot-spray.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761328972859177&X-Goog-Signature=944b916a254535a97e94baed74a0a975662d60d2918c0ec21637aeec4ef5ea295ba99790e8b6feae10ae3e8d45222acc24ee6ed4b83507a2f4fae92e02d071e4914bce93870e83045006245cd07c48cc4de8ea2f25b4292d9a63a649fc11722dca1c959efe193f33e58904b5a01e521d9ba504b5ff9b486f5918cfbd84bbddf48bfba33f4963c1bcc7c435aaa6f0d349a3c390292a3371a5188c80fef32508605dae8fece0d1bd7d9ae696fb4682d25a8126021dfaa18daf5432773072eb293b0eddf114e7ea2447fdf061b53316bcc1d162ebe241ab467dd34f8afe1098afdaa06ab2e3c7b66e4bd2478e7feaa10e0e2fbdeb2a8e38a4a1abaf67159d97b690\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_normalize_transformed%2Fk9-guard-dog-hot-spot-spray.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761329288621983&X-Goog-Signature=20e455956981667bcb2f3f1118cb0d2a3fa493456c0b4c72aec88c6537d1252104985aa7f1e84b565b6ac4ad0f26624e4d2435da4030283f3dfb2459e43842137451073e438e7228b0bc0887960b64fc3597649820940cd8be44bd35adf9bae888442ce38d767274e44e2aaf3c5e70c8f305d2b058838d72de8bd30279e242dba2547e28864c176a42a574829b7340c4f6e05068bd002541249ce274f5f229250551a347ccbb7710c2416948e6231bac67936355dfea977052ec4e128bc7c606e9317af359574e046197fd72bf60c7e962f070710653dcfd0fbdb48e298050a29562b5a7cb4d479674c0d5e205184cca1905bf70e4ac7c39844082e9c5627bee\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_blur_resize_transformed%2Fk9-guard-dog-hot-spot-spray.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761329599373801&X-Goog-Signature=3cbe604a3ece1e837be0e704360e0d561a4d6cd3df5716820d3956aba14c2d5e222a5e87518c9a6797c0666175bbeadd2c1dcfc76a0028ed4a0dd79981f74fd175e00b38b244d27b7d406ed3926dc433e67d90cce24121339be9ae3ccaaf97710bb3483359fc6b4a28f50fdf5c10d3f25159c458061b0e31dad44e2d0e6206f03040cac21ec564e33d15796d3b50a67758258355cc0de201cd84ba758ca9ef623eddd26611ad57335511b844310fe60b1201e6051f5514267a6bdaa5caf8d7f32cd8789ec4bbad052a35bd9e87aab370053645844bc09f791806b6bc566c64d95a9cb738a9411d8cb78a625f9537c44e9fca9573b3e9e021b70d57d3bbc6724e\" width=\"300\"></td>\n",
              "      <td>{'status': '', 'content': {'uri': 'gs://bigframes_blob_test/image_blur_transformed_verbose/k9-guard-dog-hot-spot-spray.png', 'version': None, 'authorizer': 'bigframes-dev.us.bigframes-default-connection', 'details': None}}</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Ffluffy-buns-chinchilla-food-variety-pack.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492694988945&X-Goog-Signature=402a8e36e59cef5a392b383147d7f61b5cde31a6b30f3ece3698a1fb262f5dda282c735601fa5d259e04ecbcc4d9044f8457d760a244719d480e8f522456ebf1abf4997c062ceb884d0bb335bbd9bfdc21708df31043009daa8858ad7f67996511bf0663fe6f9e5551091977997ef391d982899423d1834d48fac332f903578902eb6794cc8fb3ac8f4f383849bce090be39443a21a669e0066520dcd14e22bd2c2963343ff6839d51e0b4cfaa0dcba0d17c562d5ee0e2c8c92e6ebf198487884f8854b93cd85c9070a0782fd6e614652cfbbcf2c71057a52822f9a14d196b879c42444bdbec09dade2b104ff829733a2671c09d43a4379c77c4362282f9469c\" width=\"300\"></td>\n",
              "      <td>bob</td>\n",
              "      <td>image/png</td>\n",
              "      <td>1520884</td>\n",
              "      <td>2025-03-20 17:44:55+00:00</td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_blur_transformed%2Ffluffy-buns-chinchilla-food-variety-pack.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761328609067500&X-Goog-Signature=d9406f7d68d95dc6c0191d575eef2dab94066831bfa225e3bcf66c51438a89dfe7da3ab76fdbf700d5b378869b2ae6800b932c6e227582ba37a5e4a046aac8b4ed78cb3d111ff15104b5e9211eab22b727e7d77f0bcc0460449cdcdd6355aa844b27c4f20bf43f85406a86480b3088d6d5286d7cdbf1ec418f34fbf3db1cea33a9e38dca00c1c17425468ab574b5e90f6eb469b277d9131ba24988bf3e6511b057b0ad8b91a30f06d7d360ed56a2b806e92d3f0c72a535853fba1510ab251a1e5e61be404ac61454cdc897bcae293f9bd716f5d7e96c21ec7e7f3e83da69099059c891e6fd7be31914887ee980861bc60418fd9078303b023a60ec40a8a3c5ca\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_resize_transformed%2Ffluffy-buns-chinchilla-food-variety-pack.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761328977756549&X-Goog-Signature=17d62f6fe38f8d83a5b7f4ef0b4d7f4751459618df70a97453d23dbd136d7ac6a299bfb74f3a850997671f51569fc9009242b21ea2dc93ee4b28ea4c785f171f85646e27aa2d9125869e0750b33a068cece4dd1b0c260da52369501c73a9cece48e02e82f3d0c835348b65f0191d60c5aa7f43d42bdffea2175a132775824b7e80d4c1a34c7ee5a66928e809c6b86e692b6661bfcda778a9d7d6282d6324c44df711b49a77da8817cd2ea4572f85697fceba94b25b91ed30173e589853a0f3a5fdf241a4f2a45945ea28191725ed45affdd8b137c81aafaf61b1b442c070ec1f092476c5061fa0056aa6854d76338aa2d576d00b6394073f0891e350d55e47d6\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_normalize_transformed%2Ffluffy-buns-chinchilla-food-variety-pack.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761329291268473&X-Goog-Signature=589d8815a9a51f8a5c7ef15715e6bde00f2755e3e007ad60050c6c9933211fe5598f0070583a792173b12131f05ea7af20a282a81e3bb7b3a7be457bc0cfea10f7ba04a510a9b8956ba84ceb013c6a37ceb626567a1bee9e282f70ece85e44a525b474bb1f5d5f2cd69a706368f44c715678d05d418c57d1575aa701c1460c44f361fac98a0e0a004541cc842fcf2f08c54b1900f3c68689015a00ac23f83385913ceb56100fad64b79bc99f4ac4f10cfa4f7daeeb1c4acf2d493d72a602e0216253ff8f756299a3532c913d08fbe61573a6504ba83219c2deb38923d2b09f4112209f807ce0f1da11f5fb6e7d93b44459b2e5024d0de9a10a8a4b4e049a83cc\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_blur_resize_transformed%2Ffluffy-buns-chinchilla-food-variety-pack.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761329597530166&X-Goog-Signature=37f1e05cfb8e4d3cdb0fcea609cff3ad60506d46d3c20d6d211e23cc2b8ce5f59288f6afe503e0a03a1db37d0a082bdbc9d2f95d964bfa079cc9cf175dabeee907b3bad0f1ede86568607c59ee777ccbff7ca083600d25464ab81f67c861986f63cfa498529cba9448fd1bbdbffe6033a205dd6911dae41013533748adfb4a42306bc0105e3f75d303d8b0c60973df6a3297ad71c320b48115776df823ca3835d163ddf785c7e845f1a60aad08a87c1212830c103842bc691a01e9f9d1d7ef8769fa3d70ca58f166ee60830758bce7c6bc6c2e588c3b59b53b5696103bd984fa819bd120f4eae57aa63e4b00746735814fd04690a514969d89d27ed482fa1081\" width=\"300\"></td>\n",
              "      <td>{'status': '', 'content': {'uri': 'gs://bigframes_blob_test/image_blur_transformed_verbose/fluffy-buns-chinchilla-food-variety-pack.png', 'version': None, 'authorizer': 'bigframes-dev.us.bigframes-default-connection', 'details': None}}</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fpurrfect-perch-cat-scratcher.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492719670724&X-Goog-Signature=305a28a8e79af299b4631aba67372e1eb7ccd730b63df2cb3b484597faf42c90c7cee2d9082bb277a6dce102d9b5e17dc8bf8c3757847e24c8c7473a1c9a7b8e2642ac844365889106cff5490d21cef1a95462188eef0a95343947754f1ff7a4841d1f6c762218dfe6f19c6b09656706e22e968a59c0c6fe4638803a1ad73e37257ceb0050748f6489377566fe206f269edba3254d0cf12f51af58b7a4637f35b32f6bc6bc0d4e496462fb6e34f2287edcc56f9f6cb3c9845f603f5d411abf168f7c1569a2394b4c56d512b747f79a216b4dfd37d5fe7c399c16552b77a58bba329e69a1bc42a05cbc9b8e35d4db8ce3d6f647b35c6e462e5207de6cf5f35133\" width=\"300\"></td>\n",
              "      <td>alice</td>\n",
              "      <td>image/png</td>\n",
              "      <td>1235401</td>\n",
              "      <td>2025-03-20 17:45:19+00:00</td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_blur_transformed%2Fpurrfect-perch-cat-scratcher.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761328612503741&X-Goog-Signature=dda0cb26d6a0c56dd54f6cb7c5f80e0ebdcf2baf5925748a5f06e2090187002bd68155a8415b156d3a317df7daa3324ad35e567e5a2143804da2a21f486b59643cc09be57523de2d7fdc800e73cf6df8ef5a515ec3fd18b87656b9f82aec4e7c50bc658dee1d7bee91414abc18fb5a8644395cf5069d84dee71fee258cdbd89dc24dab8470035d3e82c77a61b802bc48d8b4fa3f25739e7c23a7ba8c5ba32cfa3cf8afb48f6094f7c7388f713705bc43bebbcd2f1a8a70255b1ac8cf4ecafae7c29b8b5c5059d2033b234b17b3126aa09c87760e86a65cc98a487c8bcfceab0149fc20c8e2e14dcaf65c0907457b6622ca4ec08abdfe6dea759d3fdac17d0d0e\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_resize_transformed%2Fpurrfect-perch-cat-scratcher.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761328975344887&X-Goog-Signature=53b22f09f3ec2438cf38305aefd851e75a2fd60a83bbc0a4c884789c31f870f9ac51da98e3c989ad8b8ee8900c0fb4afefc320a26e72745f36f309ff512e5a1492d112e21251ef90a4db1e70d681d0eecb4bf09b0ae63cda30250155a2a36bfa47f50e4c17f71185eba07a49829287c384712ffa0b8256a3a5c464d5c4dae9a6cfe7578d27ea775e1b112460f79c42b8ec6dcf3053f92aa5a093147d1602b620279eb0ee41cd3b52e992c6ef8b96c074323cf959191836e97fbe1381afa86058cc213db6643ef450a2150c2cab259a7ad197f692e7bcf0a88bb5cf17783fd529bb051bea18e9ebabcb92d72723c8e9d411038d27138ad4c9b9549c84a12caf83\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_normalize_transformed%2Fpurrfect-perch-cat-scratcher.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761329290813232&X-Goog-Signature=7ee2a2b2b7389b4bfcc1a00c1e211526913bf1d9acf0bf50f1922cc8c9e572652138a720269a8e5e2abee5f65640311157a5721b2c84dead2338602e820546eb260421e628751894285abe8a447a7173a2c212094b9fdfc19001be6a1ea074727b1540a55d7869817df0d40adca7cb1845a839d59ccb604c022fe88270e665c0a8811d0addaafc24e5930bc7786de57b7496b16740300a653f2d09254d08ccfcf9f14fa4a11041bbad85dd7067e1039c723a487cf5653891538a08e8809c5970228131f41a0d2295fd3bdbcd93e46e4ff93c0cb55d531fbd2603f461c143ebecedbe88d2db6ee05d5fbb0ef43ef9e72ec3d26e147ff9f0ad620ff358737caaf1\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_blur_resize_transformed%2Fpurrfect-perch-cat-scratcher.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761329595960123&X-Goog-Signature=a08701f0c216432d05f62a5b5a2e29e47609071f4da3dd5a0686cbbe41e07af86b0cdd3a834deabda0154d1282ab375aef68aa6c084671127d3e2222f8cc720bd358b13d97d9afe517a56fd8adea4c1542823e98dffc573c431698096d791c1c42fadc5ec6887b78b6f9652bdb01b494f614b6795295fb4157b37264cbb5be9cdf798391fda5b775fb655051ea5536defa82f08be4bc54367dbc0490d06d81faf44e6b83cbebfcb2d9f81c4da9909ed509a99f9414afb5c823c36aef5fc5cdb2b229fc56e592bbfa3e5d86bced8d427427b325281c8c188db24e7349de77bcae87eceab8d814f82624266289d3eb79dd7979ba3ee22b16e579a5ae312b854842\" width=\"300\"></td>\n",
              "      <td>{'status': '', 'content': {'uri': 'gs://bigframes_blob_test/image_blur_transformed_verbose/purrfect-perch-cat-scratcher.png', 'version': None, 'authorizer': 'bigframes-dev.us.bigframes-default-connection', 'details': None}}</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fchirpy-seed-deluxe-bird-food.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492687196980&X-Goog-Signature=1dd8471397e99f228827628b7dfaa8cf68da8dec9b3d7c85224c674b9c090d94ce80a3850f411f77b2ecc8dcd4419380e2c3e8a5012a2c39affeb1e4a39aa9bd541acad972a806f8cdfc05fd426e56a7490c618c50de7f2de50c5e9280b6b2c44e3a199b3548a4b5c4010a76e45466ca5d5beaf8816a601d7868fdf90e330493e58ad2e2e730992db99a8eebd81c1f8af1348faa19cf847b9a9a3e2be012badbb3ee4296ab11f408f409f97a895588f8848d9579b3a7009ad34eb6c16713bbab2d427e482463583e610aa04cb3d5bcfbf18479880421b02fd900f018ec16b7b065a78dd900370981c67be1eea01a71c1d27092f041d8fead5f93cbfa7272d359\" width=\"300\"></td>\n",
              "      <td>bob</td>\n",
              "      <td>image/png</td>\n",
              "      <td>1591923</td>\n",
              "      <td>2025-03-20 17:44:47+00:00</td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_blur_transformed%2Fchirpy-seed-deluxe-bird-food.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761328610387873&X-Goog-Signature=abf0f8205292935c162464f21311534dab4f22cc6183493a9523a61412c0c983abff8a9c2a9a0269f901d1241a5fd36256429dee7a7af7fe197af935ca7da579bb253c5a7afc8b4a2b0781a776b7f3b299bb202fef12d3dcf51387da79c17bb4671658a51725b1859527dd5709d63de887aaa54b71511bff4f4065eb47755cf94b5f6104f3aa47db6ea0401a12e69aaba5b4c4f72aa37fe9770e8fac39bd57b18057a1a1cac7f5a8aa4b71babac3be3fe15dc48723315937d873adb6610ccecd13d724bf31bae54f924d98f8d9d22209bd82d8a0165e4d81cdc7562f8da2669176b589572a0a63de92bdc4d29f58706a858f5729cd956a25ee0470ca88b14cac\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_resize_transformed%2Fchirpy-seed-deluxe-bird-food.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761328971959868&X-Goog-Signature=dbc0aa34d2b41483b00d3c085a6d3c841d68ae791e422cd06d645e1aecd550d68cc95fe72ac216b938d963dad33d1e2753853b953804753d49ebc5a521f1188e278a2da3828e1dc039a71ed71d5c562e087b2a5670da33b173314ba4262f3fe918577554b6c6366ba64ab97a29dfa20f17c5a66338c8f063b8bc6e07f47da98cc07eaaf13404722a3c0fa356faa63d40a7bcf1f89a181ec13f289caf7c9ddaab82d84399ca45ce63f2a5a560bba9938c061cf7582e2a15dca0c78d9173c30b2514a8c3638311b328244bf3e210bd73fc43017411ac2bccc907bfcbe814cec680f5fd8204d3e95d3cf8cd60d72cbe90357c1215bdfb4c5a3f23d67ea43dd888e9\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_normalize_transformed%2Fchirpy-seed-deluxe-bird-food.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761329290985890&X-Goog-Signature=ccc922ef235017353e765cb8bdbf05aed8b4ad4fed0dbb0ad602e868d6c21f0de8dddd80679f692fd6d4c16e56e249ff6e5335e8886b219c76a7eff7169de8725e97a6cb6f8c510578f1c1ed61bf9f389506c6e43037559ca44c579b929002279b14bee20f9315c0684e43369afaea81beeae73d581b648ab14545f5b9de2c8782b7f5aeecc3fde294a7fe9ab24697ad8f45e16bb5bf558a30121d2a04376f56b188bc4bcb7dc5175d74088a614e10bbd26f89548e5b48a0d3a311eb3c21406921d1365cf57a79808637728e93f422e04c57397ce36a14c920a9821a1c3256ceef3e2d9846fc0f97028f32055f85bd56adf0e8844598bf08c607f38c90cc16d3\" width=\"300\"></td>\n",
              "      <td><img src=\"https://storage.googleapis.com/bigframes_blob_test/image_blur_resize_transformed%2Fchirpy-seed-deluxe-bird-food.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T181917Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1761329596741238&X-Goog-Signature=7bfd1914d5c7160217912cfa77b108b9a6239aed71ecd29b2916c216ea622dcff2f7317880281cd79a5cfd2702e8eb01e9f526a794cf483c565fef53f6a6ef856923ce0de977a4f7d3328d3a78bf560ed57f337c1dd959b804a2271046ddba4026299d28ff50f1712746d9b37e74cbcd02a7612780877ac0a470e8c2f39fe93bbfc8f2b28941be829f98fadb0da44cf90a760c6a7332343c88ac54c32d370761d84bd38a222ba9313acfd1cf766ad52bee9c592af4a8168766cd6477bc14ba575d817ce5f1ae14e6f92650df7f30c97a7b7477cca4c47e2ad800a51c13a662f7c2707885c9ab4d59791d42f36aa0e7f2eec3148ddc62a50dfbda4429517f4250\" width=\"300\"></td>\n",
              "      <td>{'status': '', 'content': {'uri': 'gs://bigframes_blob_test/image_blur_transformed_verbose/chirpy-seed-deluxe-bird-food.png', 'version': None, 'authorizer': 'bigframes-dev.us.bigframes-default-connection', 'details': None}}</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>5 rows × 10 columns</p>\n",
              "</div>[5 rows x 10 columns in total]"
            ],
            "text/plain": [
              "                                               image author content_type  \\\n",
              "0  {'uri': 'gs://cloud-samples-data/bigquery/tuto...  alice    image/png   \n",
              "1  {'uri': 'gs://cloud-samples-data/bigquery/tuto...    bob    image/png   \n",
              "2  {'uri': 'gs://cloud-samples-data/bigquery/tuto...    bob    image/png   \n",
              "3  {'uri': 'gs://cloud-samples-data/bigquery/tuto...  alice    image/png   \n",
              "4  {'uri': 'gs://cloud-samples-data/bigquery/tuto...    bob    image/png   \n",
              "\n",
              "      size                    updated  \\\n",
              "0  1591240  2025-03-20 17:45:04+00:00   \n",
              "1  1182951  2025-03-20 17:45:02+00:00   \n",
              "2  1520884  2025-03-20 17:44:55+00:00   \n",
              "3  1235401  2025-03-20 17:45:19+00:00   \n",
              "4  1591923  2025-03-20 17:44:47+00:00   \n",
              "\n",
              "                                             blurred  \\\n",
              "0  {'uri': 'gs://bigframes_blob_test/image_blur_t...   \n",
              "1  {'uri': 'gs://bigframes_blob_test/image_blur_t...   \n",
              "2  {'uri': 'gs://bigframes_blob_test/image_blur_t...   \n",
              "3  {'uri': 'gs://bigframes_blob_test/image_blur_t...   \n",
              "4  {'uri': 'gs://bigframes_blob_test/image_blur_t...   \n",
              "\n",
              "                                             resized  \\\n",
              "0  {'uri': 'gs://bigframes_blob_test/image_resize...   \n",
              "1  {'uri': 'gs://bigframes_blob_test/image_resize...   \n",
              "2  {'uri': 'gs://bigframes_blob_test/image_resize...   \n",
              "3  {'uri': 'gs://bigframes_blob_test/image_resize...   \n",
              "4  {'uri': 'gs://bigframes_blob_test/image_resize...   \n",
              "\n",
              "                                          normalized  \\\n",
              "0  {'uri': 'gs://bigframes_blob_test/image_normal...   \n",
              "1  {'uri': 'gs://bigframes_blob_test/image_normal...   \n",
              "2  {'uri': 'gs://bigframes_blob_test/image_normal...   \n",
              "3  {'uri': 'gs://bigframes_blob_test/image_normal...   \n",
              "4  {'uri': 'gs://bigframes_blob_test/image_normal...   \n",
              "\n",
              "                                        blur_resized  \\\n",
              "0  {'uri': 'gs://bigframes_blob_test/image_blur_r...   \n",
              "1  {'uri': 'gs://bigframes_blob_test/image_blur_r...   \n",
              "2  {'uri': 'gs://bigframes_blob_test/image_blur_r...   \n",
              "3  {'uri': 'gs://bigframes_blob_test/image_blur_r...   \n",
              "4  {'uri': 'gs://bigframes_blob_test/image_blur_r...   \n",
              "\n",
              "                                     blurred_verbose  \n",
              "0  {'status': '', 'content': {'uri': 'gs://bigfra...  \n",
              "1  {'status': '', 'content': {'uri': 'gs://bigfra...  \n",
              "2  {'status': '', 'content': {'uri': 'gs://bigfra...  \n",
              "3  {'status': '', 'content': {'uri': 'gs://bigfra...  \n",
              "4  {'status': '', 'content': {'uri': 'gs://bigfra...  \n",
              "\n",
              "[5 rows x 10 columns]"
            ]
          },
          "execution_count": 11,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "df_image"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Euk5saeVVdTP"
      },
      "source": [
        "### 4. Use LLM models to ask questions and generate embeddings on images"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 12,
      "metadata": {
        "id": "mRUGfcaFVW-3"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/log_adapter.py:182: FutureWarning: Since upgrading the default model can cause unintended breakages, the\n",
            "default model will be removed in BigFrames 3.0. Please supply an\n",
            "explicit model to avoid this message.\n",
            "  return method(*args, **kwargs)\n"
          ]
        }
      ],
      "source": [
        "from bigframes.ml import llm\n",
        "gemini = llm.GeminiTextGenerator()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 13,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 657
        },
        "id": "DNFP7CbjWdR9",
        "outputId": "3f90a062-0abc-4bce-f53c-db57b06a14b9"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>ml_generate_text_llm_result</th>\n",
              "      <th>image</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>The item is a tin of K9 Guard dog paw balm.</td>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fk9-guard-dog-paw-balm.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T182008Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492703986347&X-Goog-Signature=c7399e6e6e1ae65fe5341548d2d6837defeb7701818025ede8aa6abb1a52f050f735bab3d6790ed58e7b7c6ed850330baf8dcd47c79a3dfa367ed4d7af2a877bba4f9a50973aa8fdc3ca3ab67f48cd28f0f6a764c6cb5b750b3d5c55f7d1d69d788a29860e61629ef9f174743bb3f6c37d5fa4884a7a81c20ef6a8d2f38481f2e27a68d86e5d04f9f385375e79002ffdb350395d3f1d792c637029fc484fdd968fcd28d9aa2c2d746c0de73ba91475607da2ad2fcc3ccbdc7ed97a868e3b54cb92630a5c1ff44ada40c85f126d8e4d6da653bbc42f9ba59feb7329ed46e66d2fe410dea4ec594cf05c3fbb70f7e4a5c4d0d42a60aea81a2b88b2e13ebbaf8ef2\" width=\"300\"></td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>The item is K9 Guard Dog Hot Spot Spray.</td>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fk9-guard-dog-hot-spot-spray.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T182008Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492702954473&X-Goog-Signature=81adbf38fa5f98bb23323caa09ece42f454d3328abeab17914f2159a5b5e6723236d27376a4bf453f59f7a12cb7c1c97ff0ced98617b78d0c51497a1fe88fbc9332a1ac120ed000c8a03590e0405f51f28353e10164df445ca132875cf0f78b39ce171c182f0a5ebc5ec43b2d072371fe67e5b2ea0440e628f6474d78c3f27a21554ee2f5c2019615fd5191c4c149f2f42c0b747cb30ad813312a5c6cccc8009a11e23e322298797ff5125db27ec2ff216b292ceed75ee43c101bffc550f7f4a7a8057034fed77527a5f6125d9e61539fae7fb816ae04e7ec8abf1fc80e2d794407c8bf89e0c3e8d722844e35ae7a5e717e850cb65befc74ee40ced7e541dbd2\" width=\"300\"></td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>2 rows × 2 columns</p>\n",
              "</div>[2 rows x 2 columns in total]"
            ],
            "text/plain": [
              "                   ml_generate_text_llm_result  \\\n",
              "0  The item is a tin of K9 Guard dog paw balm.   \n",
              "1     The item is K9 Guard Dog Hot Spot Spray.   \n",
              "\n",
              "                                               image  \n",
              "0  {'uri': 'gs://cloud-samples-data/bigquery/tuto...  \n",
              "1  {'uri': 'gs://cloud-samples-data/bigquery/tuto...  \n",
              "\n",
              "[2 rows x 2 columns]"
            ]
          },
          "execution_count": 13,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "# Ask the same question on the images\n",
        "df_image = df_image.head(2)\n",
        "answer = gemini.predict(df_image, prompt=[\"what item is it?\", df_image[\"image\"]])\n",
        "answer[[\"ml_generate_text_llm_result\", \"image\"]]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 14,
      "metadata": {
        "id": "IG3J3HsKhyBY"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        }
      ],
      "source": [
        "# Ask different questions\n",
        "df_image[\"question\"] = [\"what item is it?\", \"what color is the picture?\"]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 15,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 657
        },
        "id": "qKOb765IiVuD",
        "outputId": "731bafad-ea29-463f-c8c1-cb7acfd70e5d"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>ml_generate_text_llm_result</th>\n",
              "      <th>image</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>The item is a tin of K9Guard Dog Paw Balm.</td>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fk9-guard-dog-paw-balm.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T182054Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492703986347&X-Goog-Signature=ace6ac472a007445ecd1a6b0e76283139f406917cd16719b5e44e835da19f3509d6b8205ae415c44253fc330bfc05b8145bd6d7ca1ad920b036d3b77304be9a71dfae37aa5e350fcef58359d26bcd1c959f864f8c3f596fbee8181cc91fce97f0a985cbefa82ae5fbfc66cd60e242034eb7f836ee550ea81396b31aa652992ade7c2e95c1274cc93528b3244d99345ce892b78935e12e27586ee417cacec3f566832b35aa05e030863098a28671a8a5be90d28d416df08b1febd9b1aa6e1e684ba64a323747dd7256fe138647b2c81b24c97ad5a39991df3cea967585ecfe2c3725c23d7689c7ab539e370cab4dfbf0804b295a5899b7b0d2b4e729849e1cb04\" width=\"300\"></td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>The bottle is mostly white, with a light blue accents. The background is a light gray. There are also black and green elements on the bottle's label.</td>\n",
              "      <td><img src=\"https://storage.googleapis.com/cloud-samples-data/bigquery%2Ftutorials%2Fcymbal-pets%2Fimages%2Fk9-guard-dog-hot-spot-spray.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=bqcx-1084210331973-pcbl%40gcp-sa-bigquery-condel.iam.gserviceaccount.com%2F20251024%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251024T182054Z&X-Goog-Expires=21600&X-Goog-SignedHeaders=host&generation=1742492702954473&X-Goog-Signature=8af6344fec8176634dca0405781c93ce8708d5e9268bf81b089f4072b510fcaa3da995f170c579375044f48abd13a133eec80d0b0ac49b13b69b3ede096e22cf06f4708ea50b9a8047f011a7c76233c175db9d31333af86bec77a8ceca31c12f446f0f0ddf6643dc4634533363b0bf88c72f9393f8f1287dccb2353d7f0cf877cfdc6e3e197e3c1d3d1cfde8f2cfff50613f7bbf024bf89dd1c75890b15745427cc7e8ae9d6166ab071006e7ec8ff72f760f9299e07ef06239b104a791e80a7658c9be67fe309ff5ac7442b8925e44045ae198f33da00c344d10d522d64935b06d750f981d2b514baf86bfecc45fc81c34f69533d963f11ab5fdad64c1dc207d\" width=\"300\"></td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>2 rows × 2 columns</p>\n",
              "</div>[2 rows x 2 columns in total]"
            ],
            "text/plain": [
              "                         ml_generate_text_llm_result  \\\n",
              "0         The item is a tin of K9Guard Dog Paw Balm.   \n",
              "1  The bottle is mostly white, with a light blue ...   \n",
              "\n",
              "                                               image  \n",
              "0  {'uri': 'gs://cloud-samples-data/bigquery/tuto...  \n",
              "1  {'uri': 'gs://cloud-samples-data/bigquery/tuto...  \n",
              "\n",
              "[2 rows x 2 columns]"
            ]
          },
          "execution_count": 15,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "answer_alt = gemini.predict(df_image, prompt=[df_image[\"question\"], df_image[\"image\"]])\n",
        "answer_alt[[\"ml_generate_text_llm_result\", \"image\"]]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 16,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 300
        },
        "id": "KATVv2CO5RT1",
        "outputId": "6ec01f27-70b6-4f69-c545-e5e3c879480c"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/log_adapter.py:182: FutureWarning: Since upgrading the default model can cause unintended breakages, the\n",
            "default model will be removed in BigFrames 3.0. Please supply an\n",
            "explicit model to avoid this message.\n",
            "  return method(*args, **kwargs)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>ml_generate_embedding_result</th>\n",
              "      <th>ml_generate_embedding_status</th>\n",
              "      <th>ml_generate_embedding_start_sec</th>\n",
              "      <th>ml_generate_embedding_end_sec</th>\n",
              "      <th>content</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>[ 0.00638842  0.01666344  0.00451782 ... -0.02...</td>\n",
              "      <td></td>\n",
              "      <td>&lt;NA&gt;</td>\n",
              "      <td>&lt;NA&gt;</td>\n",
              "      <td>{\"access_urls\":{\"expiry_time\":\"2025-10-25T00:2...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>[ 0.00973689  0.02148374  0.00244311 ...  0.00...</td>\n",
              "      <td></td>\n",
              "      <td>&lt;NA&gt;</td>\n",
              "      <td>&lt;NA&gt;</td>\n",
              "      <td>{\"access_urls\":{\"expiry_time\":\"2025-10-25T00:2...</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>2 rows × 5 columns</p>\n",
              "</div>[2 rows x 5 columns in total]"
            ],
            "text/plain": [
              "                        ml_generate_embedding_result  \\\n",
              "0  [ 0.00638842  0.01666344  0.00451782 ... -0.02...   \n",
              "1  [ 0.00973689  0.02148374  0.00244311 ...  0.00...   \n",
              "\n",
              "  ml_generate_embedding_status  ml_generate_embedding_start_sec  \\\n",
              "0                                                          <NA>   \n",
              "1                                                          <NA>   \n",
              "\n",
              "   ml_generate_embedding_end_sec  \\\n",
              "0                           <NA>   \n",
              "1                           <NA>   \n",
              "\n",
              "                                             content  \n",
              "0  {\"access_urls\":{\"expiry_time\":\"2025-10-25T00:2...  \n",
              "1  {\"access_urls\":{\"expiry_time\":\"2025-10-25T00:2...  \n",
              "\n",
              "[2 rows x 5 columns]"
            ]
          },
          "execution_count": 16,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "# Generate embeddings.\n",
        "embed_model = llm.MultimodalEmbeddingGenerator()\n",
        "embeddings = embed_model.predict(df_image[\"image\"])\n",
        "embeddings"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "iRUi8AjG7cIf"
      },
      "source": [
        "### 5. PDF chunking function"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 17,
      "metadata": {
        "id": "oDDuYtUm5Yiy"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        }
      ],
      "source": [
        "df_pdf = bpd.from_glob_path(\"gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/documents/*\", name=\"pdf\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 18,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "7jLpMYaj7nj8",
        "outputId": "06d5456f-580f-4693-adff-2605104b056c"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/log_adapter.py:182: FunctionAxisOnePreviewWarning: Blob Functions use bigframes DataFrame Managed function with axis=1 senario, which is a preview feature.\n",
            "  return method(*args, **kwargs)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:239: UserWarning: The `json_extract_string_array` is deprecated and will be removed in a\n",
            "future version. Use `json_value_array` instead.\n",
            "  warnings.warn(bfe.format_message(msg), category=UserWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:239: UserWarning: The `json_extract_string_array` is deprecated and will be removed in a\n",
            "future version. Use `json_value_array` instead.\n",
            "  warnings.warn(bfe.format_message(msg), category=UserWarning)\n"
          ]
        }
      ],
      "source": [
        "df_pdf[\"chunked\"] = df_pdf[\"pdf\"].blob.pdf_chunk(engine=\"pypdf\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 19,
      "metadata": {},
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/core/log_adapter.py:182: FunctionAxisOnePreviewWarning: Blob Functions use bigframes DataFrame Managed function with axis=1 senario, which is a preview feature.\n",
            "  return method(*args, **kwargs)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/bigquery/_operations/json.py:239: UserWarning: The `json_extract_string_array` is deprecated and will be removed in a\n",
            "future version. Use `json_value_array` instead.\n",
            "  warnings.warn(bfe.format_message(msg), category=UserWarning)\n"
          ]
        },
        {
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>chunked_verbose</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>{'status': '', 'content': array([\"CritterCuisi...</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>1 rows × 1 columns</p>\n",
              "</div>[1 rows x 1 columns in total]"
            ],
            "text/plain": [
              "                                     chunked_verbose\n",
              "0  {'status': '', 'content': array([\"CritterCuisi...\n",
              "\n",
              "[1 rows x 1 columns]"
            ]
          },
          "execution_count": 19,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "df_pdf[\"chunked_verbose\"] = df_pdf[\"pdf\"].blob.pdf_chunk(engine=\"pypdf\", verbose=True)\n",
        "df_pdf[[\"chunked_verbose\"]]"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 20,
      "metadata": {
        "id": "kaPvJATN7zlw"
      },
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        },
        {
          "data": {
            "text/plain": [
              "0    CritterCuisine Pro 5000 - Automatic Pet Feeder...\n",
              "0    on a level, stable surface to prevent tipping....\n",
              "0    included)\\nto maintain the schedule during pow...\n",
              "0    digits for Meal 1 will flash.\\n\u0000. Use the UP/D...\n",
              "0    paperclip) for 5\\nseconds. This will reset all...\n",
              "0    unit with a damp cloth. Do not immerse the bas...\n",
              "0    continues,\\ncontact customer support.\\nE2: Foo...\n",
              "Name: chunked, dtype: string"
            ]
          },
          "execution_count": 20,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "chunked = df_pdf[\"chunked\"].explode()\n",
        "chunked"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### 6. Audio transcribe function"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 21,
      "metadata": {},
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        }
      ],
      "source": [
        "audio_gcs_path = \"gs://bigframes_blob_test/audio/*\"\n",
        "df = bpd.from_glob_path(audio_gcs_path, name=\"audio\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 22,
      "metadata": {},
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        },
        {
          "data": {
            "text/plain": [
              "0    Now, as all books, not primarily intended as p...\n",
              "Name: transcribed_content, dtype: string"
            ]
          },
          "execution_count": 22,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "transcribed_series = df['audio'].blob.audio_transcribe(model_name=\"gemini-2.0-flash-001\", verbose=False)\n",
        "transcribed_series"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 23,
      "metadata": {},
      "outputs": [
        {
          "name": "stderr",
          "output_type": "stream",
          "text": [
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n",
            "/usr/local/google/home/shuowei/src/github.com/googleapis/python-bigquery-dataframes/bigframes/dtypes.py:959: JSONDtypeWarning: JSON columns will be represented as pandas.ArrowDtype(pyarrow.json_())\n",
            "instead of using `db_dtypes` in the future when available in pandas\n",
            "(https://github.com/pandas-dev/pandas/issues/60958) and pyarrow.\n",
            "  warnings.warn(msg, bigframes.exceptions.JSONDtypeWarning)\n"
          ]
        },
        {
          "data": {
            "text/plain": [
              "0    {'status': '', 'content': 'Now, as all books, ...\n",
              "Name: transcription_results, dtype: struct<status: string, content: string>[pyarrow]"
            ]
          },
          "execution_count": 23,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "transcribed_series_verbose = df['audio'].blob.audio_transcribe(model_name=\"gemini-2.0-flash-001\", verbose=True)\n",
        "transcribed_series_verbose"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "venv",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.10.18"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
