Spaces:
Sleeping
Sleeping
updating requirements.txt and fixing integration of gemini vision model in NLP section in app.py app,py
Browse files- app.py +41 -12
- requirements.txt +2 -0
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
|
2 |
import pandas as pd
|
3 |
import warnings
|
4 |
-
import streamlit as
|
5 |
from classification import ClassificationModels
|
6 |
from regression import RegressionModels
|
7 |
warnings.filterwarnings("ignore")
|
@@ -15,20 +15,29 @@ from dotenv import load_dotenv
|
|
15 |
|
16 |
|
17 |
load_dotenv() # take environment variables from .env.
|
18 |
-
|
19 |
-
|
20 |
os.getenv("GOOGLE_API_KEY")
|
21 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
22 |
|
|
|
|
|
|
|
23 |
|
24 |
## Function to load OpenAI model and get respones
|
25 |
-
|
26 |
-
chat = model.start_chat(history=[])
|
27 |
|
28 |
def get_gemini_response(question):
|
29 |
response =chat.send_message(question,stream=True)
|
30 |
return response
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
def gemini_model():
|
33 |
##initialize our streamlit app
|
34 |
# st.set_page_config(page_title="Q&A Demo")
|
@@ -139,16 +148,31 @@ def regressor():
|
|
139 |
st.write(f"R-squared: {r2}")
|
140 |
|
141 |
def NLP():
|
142 |
-
|
143 |
|
144 |
-
with
|
145 |
st.title("Chat with Gemini Pro")
|
146 |
gemini_model()
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
with Bert:
|
150 |
-
st.title("
|
151 |
-
|
152 |
|
153 |
|
154 |
def Image():
|
@@ -167,6 +191,10 @@ def LLMs():
|
|
167 |
st.title("About Page")
|
168 |
st.write("This is the About Page")
|
169 |
|
|
|
|
|
|
|
|
|
170 |
def resume():
|
171 |
st.title("Contact Page")
|
172 |
st.write("You can reach us at example@example.com")
|
@@ -174,9 +202,10 @@ def resume():
|
|
174 |
|
175 |
# Main function to run the app
|
176 |
def main():
|
|
|
177 |
st.sidebar.title("Deep Learning/ Data Science/ AI Models")
|
178 |
# page_options = ["Classification", "Regressor", "NLP", "Image", "Voice", "Video", "LLMs"]
|
179 |
-
page_options = ["
|
180 |
choice = st.sidebar.radio("Select", page_options)
|
181 |
|
182 |
if choice == "Classification":
|
@@ -490,8 +519,8 @@ def main():
|
|
490 |
if choice == "Voice":
|
491 |
Voice()
|
492 |
|
493 |
-
if choice == "
|
494 |
-
|
495 |
|
496 |
if choice == "LLMs":
|
497 |
LLMs()
|
|
|
1 |
|
2 |
import pandas as pd
|
3 |
import warnings
|
4 |
+
import streamlit as st
|
5 |
from classification import ClassificationModels
|
6 |
from regression import RegressionModels
|
7 |
warnings.filterwarnings("ignore")
|
|
|
15 |
|
16 |
|
17 |
load_dotenv() # take environment variables from .env.
|
|
|
|
|
18 |
os.getenv("GOOGLE_API_KEY")
|
19 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
20 |
|
21 |
+
## Function to load OpenAI model and get respones
|
22 |
+
model_chat = genai.GenerativeModel('gemini-pro')
|
23 |
+
chat = model_chat.start_chat(history=[])
|
24 |
|
25 |
## Function to load OpenAI model and get respones
|
26 |
+
model_vision = genai.GenerativeModel('gemini-pro-vision')
|
|
|
27 |
|
28 |
def get_gemini_response(question):
|
29 |
response =chat.send_message(question,stream=True)
|
30 |
return response
|
31 |
|
32 |
+
## Function to load OpenAI model and get respones
|
33 |
+
|
34 |
+
def get_gemini_response_vision(input,image):
|
35 |
+
if input!="":
|
36 |
+
response = model_vision.generate_content([input,image])
|
37 |
+
else:
|
38 |
+
response = model_vision.generate_content(image)
|
39 |
+
return response.text
|
40 |
+
|
41 |
def gemini_model():
|
42 |
##initialize our streamlit app
|
43 |
# st.set_page_config(page_title="Q&A Demo")
|
|
|
148 |
st.write(f"R-squared: {r2}")
|
149 |
|
150 |
def NLP():
|
151 |
+
Gemini_Chat,Gemini_Vision, Bert, = st.tabs(['Gemini-Chat','Gemini-Vision','Bert'])
|
152 |
|
153 |
+
with Gemini_Chat:
|
154 |
st.title("Chat with Gemini Pro")
|
155 |
gemini_model()
|
156 |
|
157 |
+
with Gemini_Vision:
|
158 |
+
#initialize our streamlit app
|
159 |
+
#st.set_page_config(page_title="Gemini Image Demo")
|
160 |
+
st.header("Gemini Application")
|
161 |
+
input=st.text_input("Input Prompt: ",key="input")
|
162 |
+
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
163 |
+
image=""
|
164 |
+
if uploaded_file is not None:
|
165 |
+
image = Image.open(uploaded_file)
|
166 |
+
st.image(image, caption="Uploaded Image.", use_column_width=True)
|
167 |
+
submit=st.button("Tell me about the image")
|
168 |
+
## If ask button is clicked
|
169 |
+
if submit:
|
170 |
+
response=get_gemini_response_vision(input,image)
|
171 |
+
st.subheader("The Response is")
|
172 |
+
st.write(response)
|
173 |
|
174 |
with Bert:
|
175 |
+
st.title(" Bert model will available soon")
|
|
|
176 |
|
177 |
|
178 |
def Image():
|
|
|
191 |
st.title("About Page")
|
192 |
st.write("This is the About Page")
|
193 |
|
194 |
+
def AI():
|
195 |
+
st.title("About Page")
|
196 |
+
st.write("This is the About AI")
|
197 |
+
|
198 |
def resume():
|
199 |
st.title("Contact Page")
|
200 |
st.write("You can reach us at example@example.com")
|
|
|
202 |
|
203 |
# Main function to run the app
|
204 |
def main():
|
205 |
+
|
206 |
st.sidebar.title("Deep Learning/ Data Science/ AI Models")
|
207 |
# page_options = ["Classification", "Regressor", "NLP", "Image", "Voice", "Video", "LLMs"]
|
208 |
+
page_options = ["NLP","AI","Classification", "Regressor","Deep Learning"]
|
209 |
choice = st.sidebar.radio("Select", page_options)
|
210 |
|
211 |
if choice == "Classification":
|
|
|
519 |
if choice == "Voice":
|
520 |
Voice()
|
521 |
|
522 |
+
if choice == "AI":
|
523 |
+
AI()
|
524 |
|
525 |
if choice == "LLMs":
|
526 |
LLMs()
|
requirements.txt
CHANGED
@@ -4,3 +4,5 @@ scikit_learn==1.4.1.post1
|
|
4 |
streamlit==1.32.0
|
5 |
transformers==4.39.2
|
6 |
xgboost==2.0.3
|
|
|
|
|
|
4 |
streamlit==1.32.0
|
5 |
transformers==4.39.2
|
6 |
xgboost==2.0.3
|
7 |
+
google.generativeai
|
8 |
+
python-dotenv
|