Monday, September 30, 2024
Can AI Watch YouTube for You? Automating Insights with Gemini & Google Apps Script
Sunday, March 31, 2024
Smart replacing images in Google Slides with Gemini Pro API and Vertex AI
Surely, you have also experienced having a presentation in which you needed to replace old content with new. Replacing text is very simple because you just need to use the Replace function, and you can either do it in the Google Slides user interface.
The problem arises when you need to replace one image with another, for example, if your corporate logo is updated to a new graphic design or if one of your favorite cloud services updates its icons (Gmail, blink blink ;-) It's still somewhat bearable with one presentation, but what do you do when, like me, you have thousands of Google Slides files on your Google Drive?
Fortunately, there are large language models and, specifically, multimodal models that allow input prompts to include images in addition to text. Specifically, with Gemini Pro, you can have up to 16 such images as input. And then the old saying applies that one picture is worth a thousand words :)
I used Gemini Pro for exactly this use case in the Vertex AI service with integration into Google Apps Script, which could connect to my presentation, go through all the slides, and if there was an image containing the old logo, it replaced it with the new logo. I will show you how you can replicate such a procedure yourself, and all you need for it is just a Google Cloud account."
1. Create a new Google Apps Script project https://script.new/
2) Go to Project settings -> and click the checkbox Show "appsscript.json" manifest file in editor
3) Copy the manifest.json below
4) Prepare a Google Cloud project and if you don't have one, create one here: https://console.cloud.google.com/projectcreate
Then enable the Vertex AI API https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com
The Gemini Pro Vision API takes as input data that consists of parts (parts as an array), where each item can be either text or binary data (either embedded or embedded via a URL link)
https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini
Google Cloud credits are provided for this project
#GeminiSprint