alisaman commited on
Commit
b49bad7
·
verified ·
1 Parent(s): 5fcb37e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pip install -q -U google-generativeai
2
+ #pip install ipython
3
+ #pip install pillow
4
+ #PIP INSTALL STREAMLIT
5
+ import streamlit as st
6
+ from PIL import Image
7
+ import google.generativeai as genai
8
+
9
+ api = st.text_input('put your api')
10
+
11
+ API = api
12
+
13
+ genai.configure(api_key=API)
14
+
15
+ models = st.selectbox('seletc your model' , ['gemini-pro-vision','gemini-pro'])
16
+ model = genai.GenerativeModel(models)
17
+
18
+ if models == "gemini-pro-vision":
19
+ imageupload = st.file_uploader('upload your image')
20
+ if imageupload:
21
+ pr = st.text_input('Your Prompt here' , value='Write a prompt for me to create an image like this')
22
+ img = Image.open(imageupload)
23
+ response = model.generate_content(['Write a prompt for me to create an image like this' , img])
24
+ st.subheader('Your Image 👇')
25
+ st.image(img)
26
+ st.subheader('Your Prompt to Have Image Like This ☝️️')
27
+ st.write(response.text)
28
+
29
+ elif models == "gemini-pro":
30
+ inp = st.text_area('write your prompt')
31
+ bt = st.button('Lets Go')
32
+ if inp != "" and bt:
33
+ response = model.generate_content(inp)
34
+ st.write(response.text)
35
+
36
+