Harnessing Google’s Gemini Pro and Gemini Pro Vision AI Models in Python

Jillani Soft Tech
3 min readDec 16, 2023

--

Exploring the Realms of Textual and Visual AI with Google’s Latest Offerings

Google Gemini

Hello Towards Data Science Community!

I’m thrilled to share my recent explorations with Google Deep Mind’s latest AI models: Gemini Pro and Gemini Pro Vision. These models have opened up new avenues in AI, adept at handling both textual and visual data. Here’s a glimpse into my journey, complete with Python code snippets and insights.

Introducing Gemini Pro and Gemini Pro Vision

Gemini Pro is Google’s state-of-the-art model designed for a variety of text-based tasks, while Gemini Pro Vision extends these capabilities to the visual domain. These models excel in understanding and generating content, whether it’s text, images, or videos.

Setting Up the Environment

# Importing essential libraries
import os
from dotenv import load_dotenv
import google.generativeai as genai

I began by setting up the environment, importing necessary libraries, and configuring the Google Generative AI library with my API key.

Delving into Gemini Pro

# Initialize Gemini Pro model
model = genai.GenerativeModel('gemini-pro')

With Gemini Pro initialized, I experimented with generating content based on textual prompts. For example:

response = model.generate_content('What is AI?')
print(response.text)

This snippet showcases the model’s ability to generate insightful responses to queries about AI.

Exploring Gemini Pro Vision

# Load an image and initialize Gemini Pro Vision model
import PIL.Image
img = PIL.Image.open('input_img.png')
vision_model = genai.GenerativeModel('gemini-pro-vision')

Gemini Pro Vision’s real prowess is in interpreting and generating content from images. Here’s how I leveraged it:

response = vision_model.generate_content(img)
print(response.text)

This code processes an image and outputs the model’s interpretation, highlighting its multimodal capabilities.

Sharing My Notebook and Inviting Collaboration

I’ve documented my entire journey in a Jupyter Notebook, which is available on my GitHub repository. You can find it here.

I invite you all to explore, fork, and contribute to this project. Let’s dive deeper into the potential of these groundbreaking AI models together!

Conclusion

Exploring Gemini Pro and Gemini Pro Vision has been a fascinating journey into the evolving landscape of AI. These models showcase the incredible advancements in dealing with both text and images, offering endless possibilities for future applications.

Stay tuned for more updates, and don’t hesitate to reach out with questions or ideas for collaboration!

Stay Connected and Explore More with Me! 🌟

Hello, Data Enthusiasts and Tech Innovators!

If you’re finding value in my content and are curious about the latest advancements in AI and data science, I invite you to join my professional network. Let’s connect and grow together in this exciting field! 🚀

🔗 Linkedin: Connect with me on LinkedIn for insightful discussions and updates. Find me as Muhammad Ghulam Jillani of Jillani SoftTech. Let’s expand our professional horizons together! LinkedIn Profile

👨‍💻 GitHub: For a deep dive into my projects and code repositories, follow me on GitHub under Jillani SoftTech. Explore and contribute to the evolving world of open-source! GitHub Profile

📊 Kaggle: Join me on Kaggle, where I share datasets and participate in competitions. Look for Jillani SoftTech and let’s tackle data challenges together! Kaggle Profile

✍️ Medium and Towards Data Science: For thought-provoking articles and in-depth analysis, follow me on Medium and Towards Data Science at Jillani SoftTech. Let’s engage in meaningful conversations around data and technology. Medium Profile

Your support and engagement mean the world to me. Let’s collaborate, share knowledge, and push the boundaries of what’s possible in the realm of data science and AI! 💡🌐

#DataScience #AI #MachineLearning #Networking #ProfessionalGrowth #TechCommunity #GoogleDeepMind #GeminiPro #Python #JupyterNotebook #TechInnovation

--

--

Jillani Soft Tech
Jillani Soft Tech

Written by Jillani Soft Tech

Senior Data Scientist & ML Expert | Top 100 Kaggle Master | Lead Mentor in KaggleX BIPOC | Google Developer Group Contributor | Accredited Industry Professional

No responses yet