LOVEBHATTI commited on
Commit
dc4b4cf
1 Parent(s): 3f3cfbe

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import google.generativeai as genai
3
+ from PIL import Image
4
+
5
+ genai.configure(api_key="AIzaSyBZQmot8_8bDxuGiffJ06woJCzH140Erc4")
6
+
7
+ def get_response(inputt, image):
8
+ model = genai.GenerativeModel('gemini-pro-vision')
9
+ if inputt != "":
10
+ response = model.generate_content((inputt, image))
11
+ else:
12
+ response = model.generate_content(image)
13
+ return response.text
14
+
15
+ st.header("My project")
16
+ inputt = st.text_input("input prompt", key='input')
17
+ uploaded_file = st.file_uploader("Choose you file", type=["jpg", "jpeg", "png"])
18
+ image =''
19
+ if uploaded_file is not None:
20
+ image = Image.open(uploaded_file)
21
+ st.image(image, caption='uploaded_image', use_column_width= True)
22
+
23
+ submit = st.button('Ask')
24
+ if submit:
25
+ response = get_response(inputt, image)
26
+ st.write(response)