This project is a Streamlit-based application that allows users to upload images and ask questions about them using the Gemini AI model. The application leverages generative AI to provide insightful responses based on the uploaded images and user queries.
This code uses the following libraries:
streamlit
: for building the user interface.google.generativeai
: for generating responses using the Gemini model.python-dotenv
: for managing environment variables.Pillow
: for handling image uploads and processing.We welcome contributions to enhance the Gemini PicAnalyzer! Here’s how you can get involved:
git clone https://github.com/AlexKalll/Gemini-Vision-App.git
Follow these steps to set up and run the project:
Clone the repository:
git clone https://github.com/AlexKalll/Gemini-Vision-App.git
Create a virtual environment:
python3 -m venv my_env source my_env/bin/activate # For Windows .\my_env\Scripts\activate
Install dependencies:
pip install -r requirements.txt
Run the Streamlit server:
streamlit run main.py
Access the application in your browser at http://localhost:8501.
Start analyzing images with the assistant!
Acces the Source Code
repository/ ├── main.py # The code and UI integrated together live here ├── requirements.txt # The Python packages needed to run locally ├── Demo.mp4 # Demo of the application ├── README.md # Documentation for the project ├── .gitignore # Files to ignore in the repository
Here’s a brief overview of the main components of the code in main.py
:
import os import streamlit as st import google.generativeai as genai from PIL import Image from dotenv import load_dotenv load_dotenv() my_api_key = os.getenv("GOOGLE_API_KEY") genai.configure(api_key=my_api_key) model = genai.GenerativeModel('gemini-1.5-flash') def get_gemini_response(user_quest, image): response = model.generate_content([user_quest, image]) return response.text st.set_page_config(page_title='GeminiVision App', page_icon='🤖') st.title("Gemini PicAnalyzer Application ") file = st.file_uploader('Choose an image...', type=['png', 'jpg', 'webp']) if file is not None: img = Image.open(file) st.image(img, width=200) st.subheader("Ask the model about the image") with st.form(key='input', clear_on_submit=True): user_quest = st.text_input("Enter Your question about an image you uploaded.", placeholder='Type here...') btn = st.form_submit_button() if btn and user_quest: response = get_gemini_response(user_quest, img) st.subheader("Answer: ") st.write(response) else: st.markdown('<div style="height: 150px;"></div>', unsafe_allow_html=True) st.markdown('---') st.success("Made By Kaletsidik ©2024")
Feel free to reach out for any inquiries or feedback:
Kaletsidik Ayalew
alexkalalw@gmail.com
There are no models linked
There are no models linked
There are no datasets linked
There are no datasets linked